小编Nis*_*mar的帖子

无线嗅探使用pcap,MAC地址过滤器

我正在用C编写无线数据包嗅探器程序.我已经使用airmon-ng将我的无线接口设置为监控模式,现在我正在嗅探"mon0"接口.我正在使用linux(ubuntu 10.10).

我想将MAC地址设置为数据包的过滤器.我已经完成了如下所示,但它说"mon0没有分配IPV4地址"

 pcap_lookupnet(dev,&net,&mask,errbuf);
    printf("%s\n",errbuf);
    /* Open the session in promiscuous mode */
    handle = pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);
    if (handle == NULL) {
        printf("Couldn't open device %s: %s\n", dev, errbuf);
        return 2;
    }
    if(pcap_compile(handle,&fp,argv[0],0,net)==-1){
        fprintf(stderr,"Error calling pcap_compile\n");exit(1);}
    if(pcap_setfilter(handle,&fp) == -1){
        fprintf(stderr,"Error setting filter\n");exit(1);}
    /* The call pcap_loop() and pass our callback function */
    pcap_loop(handle, 10, my_callback, NULL);
Run Code Online (Sandbox Code Playgroud)

请帮帮我,我怎样才能设置过滤MAC地址?

wireless mode monitor capture pcap

0
推荐指数
1
解决办法
4259
查看次数

在C中实现ToLower功能

我在C中编写自己的ToLower(char*str)实现.但是我在函数中遇到了分段错误.我写的功能是:

void ToLower(char *str)
{
    while(*str != '\0')
    {
        if(*str >=65 && *str<=90)
        {
            // It fails in the below assignment
            *str = *str + 32;
        }
        str++;
    }

}
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
2
解决办法
6313
查看次数

标签 统计

c ×1

capture ×1

mode ×1

monitor ×1

pcap ×1

wireless ×1