|
|
 |
 |
|
|
 |
|
sniffer技术原理及应用(1)
|
|
|
|
编辑:华夏媒体 作者:未知 来源:网络 时间:2006-07-29 总浏览量:1528 |
|
文字大小:[ 大 中 小 ]
文字颜色: 双击滚屏/单击停止 |
|
[上一页] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [下一页]
|
OidData->Length = 6; if(PacketRequest(lpAdapter, FALSE, OidData) == FALSE) memcpy(ether_addr, 0, 6); else memcpy(ether_addr, OidData->Data, 6); free(OidData); } int GetARPReply(LPPACKET lpPacket, unsigned char *iptarget, unsigned char
*result) { unsigned short int ether_type; unsigned char ipsender[4]; unsigned int off=0; unsigned int tlen; struct bpf_hdr *hdr; char *pChar; char *buf;
buf = (char *)lpPacket->Buffer; hdr = (struct bpf_hdr *)(buf + off); tlen = hdr->bh_caplen; off += hdr->bh_hdrlen; pChar = (char*)(buf + off); off = Packet_WORDALIGN(off + tlen); memcpy(ðer_type, pChar + 12, 2); ether_type = ntohs(ether_type); if(ether_type == ETH_TYPE_ARP) { memcpy(ipsender, pChar + 28, 4); if((iptarget[0] == ipsender[0])&&(iptarget[1] == ipsender[1])&& (iptarget[2] == ipsender[2])&&(iptarget[3] == ipsender[3])) memcpy(result, pChar + 22, 6); else return(EXIT_FAILURE); } else return(EXIT_FAILURE); return(EXIT_SUCCESS); } int CheckPROMode(LPADAPTER lpAdapter, unsigned char *iptarget, unsigned char
*remotemac) {
LPPACKET lpPacketRequest; LPPACKET lpPacketReply; char buffer[256000];
TArpPacket ArpPacket; unsigned char magicpack[ETH_ADD_LEN]= {0xFF,0xFF,0xFF,0xFF,0xFF,0xFE}; unsigned char mactarget[ARP_ETH_ADD_SPACE];
DWORD timestamp = 0; int numPacks = 0; /* Init fields */ memset(mactarget, 0, 6); /* Allocate PACKET structure for ARP Request packet */ if((lpPacketRequest = PacketAllocatePacket()) == NULL) { msgStatus = "Error : failed to allocate the LPPACKET structure.."; SHOWSTAT(msgStatus); return(EXIT_FAILURE);
|
|
[上一页] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [下一页]
|
|
|
打印 收藏 关闭 至顶部 |
|
 |
|