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:
- Make sure the wireless interface hardware supports packet injection in monitor mode.
- 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
Now open a raw socket to this monitor mode interface.
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.