How to send both 802.11 management frames and data

2019-06-04 03:26发布

问题:

I am trying to build an application that will send 802.11 management frames and data frames together from the userspace using raw sockets. I am being able to send data frames using the the sendto() function, but I need to send management frames as well, where I am mostly stuck. Is there any possible way of doing it?

回答1:

In order to send management, data or any type of pure raw packet from a wireless interface you have to do the following:

  1. Make sure the wireless interface hardware supports packet injection in monitor mode.
  2. Set the wireless interface in monitor mode. e.g.

sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode monitor

Or you can also create a new virtual monitor interface.

sudo iw dev wlan0 interface add mon0 type monitor

  1. Now open a raw socket to this monitor mode interface.

  2. Finally, Build and append at the beginning, the appropriate radiotap header while building your wireless 802.11 packet for management and control frames. Since you are basically bypassing all lower lever wireless drivers (which handles management and control frames), it becomes your job to include the radiotap header.