如何在Linux中使用RAW套接字发送802.11管理帧和数据帧 [英] How to send both 802.11 management frames and data frames using RAW sockets in linux

查看:122
本文介绍了如何在Linux中使用RAW套接字发送802.11管理帧和数据帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个应用程序,该应用程序将使用原始套接字从用户空间一起发送802.11管理帧和数据帧.我能够使用sendto()函数发送数据帧,但是我也需要发送管理帧,而我大多陷在其中.有什么可行的方法吗?

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?

推荐答案

要从无线接口发送管理,数据或任何类型的纯原始数据包,您必须执行以下操作:

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

  1. 确保无线接口硬件在监视模式下支持数据包注入.
  2. 将无线接口设置为监视模式.例如

sudo ifconfig wlan0关闭
sudo iwconfig wlan0模式监视器

sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode monitor

或者您也可以创建一个新的虚拟监视器界面.

Or you can also create a new virtual monitor interface.

sudo iw dev wlan0接口添加mon0类型监视器

sudo iw dev wlan0 interface add mon0 type monitor

  1. 现在打开一个原始套接字到此监视器模式界面.

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

最后,在构建用于管理和控制帧的无线802.11数据包时,在开始处构建并附加适当的radiotap标头.由于您基本上绕过了所有下层杠杆无线驱动程序(处理管理和控制框架),因此包括radiotap标头就成为您的工作.

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.

这篇关于如何在Linux中使用RAW套接字发送802.11管理帧和数据帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆