Sniffing wifi using libpcap in monitor mode

喜欢而已 提交于 2019-12-05 07:59:12

You don't need to set rfmon mode on mon0 - it's inherently in monitor mode. Just capture on it; that's what you did with Wireshark.

For various reasons having to do with

  1. libnl having multiple incompatible versions, so choosing the right version with which to build libpcap is, apparently, a pain for distribution builders;

  2. choosing a version different from the one used by an application that uses both libnl and libpcap causing horrible problems due to the aforementioned incompatibilities;

the libpcap rfmon mode code for Linux that works best for most devices, which uses libnl (essentially, it creates a new monN interface, duplicating what airmon-ng does, opens that interface for capturing, and deletes it when the capture is finished), is not enabled in many Linux distributions because libpcap is configured not to use libnl.

Therefore, it doesn't work well on Linux.

Writing code for libpcap to directly use netlink sockets, rather than go through libnl, is on my to-do list, but it is, unfortunately, behind a number of other issues on that list.

If you're trying to set a device in monitor mode using the pcap library in C, you can use the following commands (see pcap manpage):

SYNOPSIS

#include <pcap/pcap.h>

int pcap_can_set_rfmon(pcap_t *p);

DESCRIPTION

pcap_can_set_rfmon() checks whether monitor mode could be set on a capture handle when the handle is activated.


SYNOPSIS

#include <pcap/pcap.h>

int pcap_set_rfmon(pcap_t *p, int rfmon);

DESCRIPTION

pcap_set_rfmon() sets whether monitor mode should be set on a capture handle when the handle is activated. If rfmon is non-zero, monitor mode will be set, otherwise it will not be set.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!