winpcap拦截数据包

Home / Hackintosh MrLee 2016-4-8 4638

详细说明:在windows下,利用winpcap拦截数据包,并且获得拦截数据包的时间戳-In the windows, the use winpcap packet intercept and get the timestamp of the packet intercept
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉): winpcap .......\Debug .......\.....\vc60.idb .......\.....\vc60.pdb .......\.....\winpcap.exe .......\.....\winpcap.ilk .......\.....\winpcap.obj .......\.....\winpcap.pch .......\.....\winpcap.pdb .......\winpcap.c .......\winpcap.dsp .......\winpcap.dsw .......\winpcap.ncb .......\winpcap.opt .......\winpcap.plg
下载地址:winpcap
 

实例

获得网卡接口。在普通的SOCKET编程中,对双网卡编程是不行的。当主机为双网卡时,本程序可分别获得两张网卡各自的描述结构及地址,然后可以对它们分别进行操作。返回的alldevs队列首部为逻辑网卡,一般不对它进行什么操作。[2] 获得网卡接口
#include "pcap.h"
void main()
{
    pcap_if_t *alldevs;
    /*struct pcap_if_t{
    pcap_if_t *next;
    char *name;
    char *description;
    pcap_addr *addresses;
    U_int falgs;
    }
    */
    pcap_if_t *d;
    int i=0;
    char errbuf[PCAP_ERRBUF_SIZE];
    /* Retrieve the device list */
    if (pcap_findalldevs(&alldevs, errbuf) == -1)//返回网卡列表,alldevs指向表头
    {
        fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
        exit(1);
    }
    /* Print the list */
    for(d=alldevs;d;d=d->next)
    {
        printf("%d. %s", ++i, d->name);
        if (d->description)
        printf(" (%s)\n", d->description);
        else printf(" (No description available)\n");
    }
    if(i==0)
    {
        printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
        return;
    }
    /* We don't need any more the device list. Free it */
    pcap_freealldevs(alldevs);
}

562c11dfa9ec8a133b04adb9f403918fa0ecc049

本文链接:https://www.it72.com/8976.htm

推荐阅读
最新回复 (0)
返回