得到远程机器MAC地址源代码

2016-02-19 13:58 2 1 收藏

下面图老师小编要向大家介绍下得到远程机器MAC地址源代码,看起来复杂实则是简单的,掌握好技巧就OK,喜欢就赶紧收藏起来吧!

【 tulaoshi.com - 编程语言 】

#include
#include
#include
#include "iphlpapi.h"

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

#pragma comment ( lib, "ws2_32.lib" )
#pragma comment ( lib, "Iphlpapi.lib" )

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

void main( int argc, char ** argv )
{
int numberOfHost = 1;
struct hostent *remoteHostent;

//处理命令行参数
if ( argc == 3 )
numberOfHost = atoi( argv[2] );
if ( ( argc 3 ) || ( argc 2 ) )
{
printf( "RmtHost v0.2 - Get remote HostName /MacAddress" );
printf( "by ShotgunLabs ( Shotgun@xici.net )" );
printf( "Usage :RmtHost.exe [RemoteIP]" );
printf( "Example:RmtHost.exe 192.168.0.3" );
printf( "RmtHost.exe 192.168.0.3 255" );
exit( 0 );
}
//初始化SOCKET
WSADATA wsaData;
int iRet = WSAStartup(MAKEWORD(2,1), &wsaData);
if ( iRet != 0 )
{
printf( "WSAStartup Error:%d", GetLastError() );
exit( 0 );
}
int nRemoteAddr = inet_addr( argv[1] );
remoteHostent= (struct hostent*)malloc( sizeof(struct hostent ));
struct in_addr sa;
for ( int i = 0; i numberOfHost; i ++ )
{
//获取远程机器名
sa.s_addr = nRemoteAddr;
printf( "IpAddress : %s", inet_ntoa( sa ) );
remoteHostent = gethostbyaddr( (char*)&nRemoteAddr,4, AF_INET );
if ( remoteHostent )
printf( "HostName : %s",remoteHostent-h_name );
else
printf( "gethostbyaddr Error:%d",GetLastError() );
//发送ARP查询包获得远程MAC地址

unsigned char macAddress[6];
ULONG macAddLen = 6;
iRet=SendARP(nRemoteAddr, (unsigned long)NULL,(PULONG)&macAddress, &macAddLen);
if ( iRet == NO_ERROR )
{
printf( "MacAddress: " );
for( int i =0; i6; i++ )
{
printf( "%.2x", macAddress[i] );
if ( i5 ) printf( "-" );
}
printf( "" );
}
else
printf( "SendARP Error:%d", GetLastError());
nRemoteAddr = htonl( ntohl( nRemoteAddr ) + 1 );
}
}

来源:https://www.tulaoshi.com/n/20160219/1605868.html

延伸阅读
标签: PHP
  其实写这几篇代码的时间不过近三天而已,事前即没有经过详细思考和计划(可以说一点计划都没有)那天想起做个论坛试试,于是就做起来了,而我也是才接触了将近一个月时间的PHP,以前也没真正写过程序之类的东东,在写这段代码的两天半时间里,有好几次遇到困难,都想放弃,但是我还是写出来了,而且没想到居然能用,所以中间可能有很多...
标签: PHP
  主界面,也就是显示主题列表的这页。 //foxbbs.php 功能:显示论坛的主题 <HTML <HEAD <TITLE狐网论坛</TITLE <STYLE type=text/css P {FONT-FAMILY: normal; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt} DIV {FONT-FAMILY: normal; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt} </STYLE <LINK href="js/lfox.css&...
最后我们要做的工作,就是把每一页,或者你认为重要的关键的页面进行加密,就OK啦。怎样对网页的源代码进行加密就不用我多说了吧?网上到处都有,可以用工具,也可以自己写一个htm文件来转换。加密软件,我推荐“Batch HTML Encryptor”,去google找吧。还有转换加密网页的代码如下: 〈HTML〉〈HEAD〉〈TITLE〉网页加密解密〈/TITLE〉 ...
标签: Web开发
一般情况下都是设置body标签的onload监听window的load事件.但load事件是要在页面的元素全部加载完了才触发的,如果页面上图片较多或图片太大,就会导致初始化的代码未被执行的时候用户就做了其它操作了. Jquery库提供了一个非常方便好用的函数( $(selector).ready()),让我们可以在页面的dom加载完后就可以做相应的操作(当然,这还得看用户浏览器的...
标签: PHP
  info.inc.php主要做些判断和信息处理 <?php function update($reginfo) {      switch ($reginfo[4])       {      case ($reginfo[4]==1):        $reginfo[4]="男";    &...

经验教程

398

收藏

54
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部