Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用c+将外部WiFi卡设置为监控模式+;在Mac OS上_C++_Macos_Network Programming_Libpcap - Fatal编程技术网

C++ 使用c+将外部WiFi卡设置为监控模式+;在Mac OS上

C++ 使用c+将外部WiFi卡设置为监控模式+;在Mac OS上,c++,macos,network-programming,libpcap,C++,Macos,Network Programming,Libpcap,我正在运行MacOSCatalina,我有一个无线ALFA网卡(支持监控模式)。我当前可以使用以下代码将标准Mac OS的驱动程序设置为监视器模式: int main(int argc, char **argv) { char errbuf[PCAP_ERRBUF_SIZE]; char dev[] = "en0"; pcap_t *handler=pcap_create(dev, errbuf); if (handler == NULL

我正在运行MacOSCatalina,我有一个无线ALFA网卡(支持监控模式)。我当前可以使用以下代码将标准Mac OS的驱动程序设置为监视器模式:

 int main(int argc, char **argv)
{
    char errbuf[PCAP_ERRBUF_SIZE];
    char dev[] = "en0";
    pcap_t *handler=pcap_create(dev, errbuf);
 
    if (handler == NULL){
        printf("unable to put in monitor mode\n");
        return -1;
    }
    if(pcap_set_rfmon(handler, 1) == 0){
        printf("monitor mode enabled\n");
    }
    pcap_set_snaplen(handler, 2048);
    pcap_set_promisc(handler, 0);
    pcap_set_timeout(handler, 10000);
    int status = pcap_activate(handler);
    
    return 0;
}
这利用了模块
pcap plus
,该模块使用
libpcap
,导入为
\include

正如我所说,当我在电脑附带的普通WiFi卡上使用它时,它会将其置于监控模式。当我在我的ALFA网卡上使用它时,它处于
“en7”
状态,它甚至打印出
启用的监控模式(我的成功消息)。但是,卡上的监视器模式未启用。我总是以root权限运行代码,所以我已经知道不是这样。另外,我不知道这对你来说是否重要,但我已经能够使用它来嗅探我网络上的数据包

这些是我能想到的唯一原因/解决方案。我可能没有想到真正的解决办法,如果有人知道,请告诉我

  • 司机不支持。也许它可以被过度利用
  • 正如我前面提到的,找到一种方法来超越某些功能,并强制它进入监视模式
  • 使代码直接与USB设备交互,并告诉它进入监控模式
  • (3可能是唯一有效的方法,但是,我不知道如何实现这一点)