|
|
 |
 |
|
|
 |
|
sniffer技术原理及应用(1)
|
|
|
|
编辑:华夏媒体 作者:未知 来源:网络 时间:2006-07-29 总浏览量:1538 |
|
文字大小:[ 大 中 小 ]
文字颜色: 双击滚屏/单击停止 |
|
[上一页] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [下一页]
|
}
/* Init packet structure */ memset(&ArpPacket, 0, sizeof(TArpPacket));
/* Build ARP Request packet */ BuildARPPacket(&ArpPacket, magicpack, wParams.srcMAC, ARP_OP_REQUEST,
wParams.srcMAC, wParams.srcIPAdd, mactarget, iptarget,wParams.ar_hw);
/* Init ARP Request packet */ PacketInitPacket(lpPacketRequest, &ArpPacket, sizeof(ArpPacket)); /* Set number of ARP Request packets to send */ if(PacketSetNumWrites(lpAdapter, 1) == FALSE) { msgStatus = "Warning : unable to send more than one packet in a single write.."; SHOWSTAT(msgStatus); } /* Set hardware filter to directed mode */ if(PacketSetHwFilter(lpAdapter, NDIS_PACKET_TYPE_DIRECTED) == FALSE) { msgStatus ="Warning: unable to set directed mode.."; SHOWSTAT(msgStatus); } /* Set a 512K buffer in the driver */ if(PacketSetBuff(lpAdapter, 512000) == FALSE) { msgStatus = "Error: unable to set the kernel buffer.."; SHOWSTAT(msgStatus); PacketFreePacket(lpPacketRequest); return(EXIT_FAILURE); } /* Set a 1 second read timeout */ if(PacketSetReadTimeout(lpAdapter, -1) == FALSE) { msgStatus = "Warning: unable to set the read tiemout.."; SHOWSTAT(msgStatus); } /* Allocate PACKET structure for ARP Reply packet */ if((lpPacketReply = PacketAllocatePacket()) == NULL) { msgStatus = "Error: failed to allocate the LPPACKET structure.."; SHOWSTAT(msgStatus); PacketFreePacket(lpPacketRequest); return(EXIT_FAILURE); } /* Init ARP Reply packet */ PacketInitPacket(lpPacketReply, (char*)buffer, 256000); /* Allocate memory for remote MAC address */ timestamp = GetTickCount();
/* Main capture loop */ for(;;) { if(numPacks < wParams.numPacks) { /* Send packet */ if(PacketSendPacket(lpAdapter, lpPacketRequest, TRUE) == FALSE) { msgStatus ="Error : unable to send the packets.."; SHOWSTAT(msgStatus); PacketFreePacket(lpPacketRequest);
|
|
[上一页] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [下一页]
|
|
|
打印 收藏 关闭 至顶部 |
|
 |
|