Linux 802.11 CSI Tool

参考

dhalperi.github.io/linux-80211n-csitool/installation.html

blog.csdn.net/qq_20604671/article/details/53996239


下面介绍工具的安装,其实写这个工具的作者已经描述得很详细,但是还是会出一些问题。安装过程中穿插一些小提示,有些可以不去管它,按照步骤一步步输入命令就行,下面我列出我觉得必要的步骤,大家一步步照着输到终端就行。

[plain]  view plain  copy
  1. 1. Prerequisites  
  2.   
  3. sudo apt-get install gcc make linux-headers-$(uname -r) git-core  
  4.   
  5. 2. Build and Install the Modified Wireless Driver  
  6.   
  7. CSITOOL_KERNEL_TAG=csitool-$(uname -r | cut -d . -f 1-2)  
  8.   
  9. git clone https://github.com/dhalperi/linux-80211n-csitool.git  
  10.   
  11. cd linux-80211n-csitool  
  12.   
  13. git checkout ${CSITOOL_KERNEL_TAG}  
  14.   
  15. make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireless/iwlwifi modules  
  16.   
  17. sudo make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireless/iwlwifi INSTALL_MOD_DIR=updates modules_install  
  18.   
  19. sudo depmod  
  20.   
  21. cd ..  
  22.   
  23. 3. Install the Modified Firmware  
  24.   
  25. git clone https://github.com/dhalperi/linux-80211n-csitool-supplementary.git  
  26.   
  27. for file in /lib/firmware/iwlwifi-5000-*.ucode; do sudo mv $file $file.orig; done  
  28.   
  29. sudo cp linux-80211n-csitool-supplementary/firmware/iwlwifi-5000-2.ucode.sigcomm2010 /lib/firmware/  
  30.   
  31. sudo ln -s iwlwifi-5000-2.ucode.sigcomm2010 /lib/firmware/iwlwifi-5000-2.ucode  
  32.   
  33. 4. Build the Userspace Logging Tool  
  34.   
  35. make -C linux-80211n-csitool-supplementary/netlink  
      
这时,安装工作结束了。如果你是按照网上的安装教程一步步执行每条命令,最后会看到你的WiFi图标下会显示设备未托管,并且连不上网,不要慌张,因为需要手动配置网络。如果不想用命令行配置,安装时不使用任何Tip就行。但是建议手动配置,功能更强大,我也会提供相应配置脚本。现在就可以讲如何使用该工具,如果是AP模式,就很简单,运行下面的脚本就行。这种情况需要一个没有设置密码的路由器,当然路由器要支持802.11n协议。参数只有一个,那就是路由器WiFi名。
[plain]  view plain  copy
  1. #!/bin/bash  
  2. modprobe -r iwldvm iwlwifi mac80211  
  3. if [ "$#" -ne 1 ]; then  
  4.     echo "Usage: wifi_connect <SSID>!"  
  5.     exit 0  
  6. else  
  7.     id=$1  
  8. fi  
  9. ifconfig wlan0 up 2>/dev/null 1>/dev/null  
  10. while [ $? -ne 0 ]  
  11. do  
  12.   modprobe iwlwifi connector_log=0x1   
  13.   sleep 1  
  14.   ifconfig wlan0 up 2>/dev/null 1>/dev/null  
  15. done  
  16.   
  17. iw dev wlan0 connect $id && \  
  18. dhclient wlan0 && \  
  19. echo "success!"  
连接上ap后,输入iwconfig命令查看连接状态。确保无误后运行log_to_file记录CSI,然后在另一个终端输入ping命令,如下:

sudo ping 192.168.1.1 -i 0.05

ping后面接的是网关地址,i后面的参数是ping时间间隔,单位是秒。间隔小于0.2s需要root权限。

除了ap模式,CSI Tool还提供monitor模式的用法。监听模式不需要路由器,但是至少需要2台安装Intel 5300网卡的电脑,它比ap模式更加稳定,可以发送指定数量的包,可以设置发送包之间的间隔,以及信道和带宽。
下面便是monitor模式的设置:

[plain]  view plain  copy
  1. injection模式启用需要编译。需要下载安装下面的一些文件  
  2. 具体步骤如下:  
  3.   
  4. sudo apt-get install libpcap-dev  
  5.   
  6. git clone https://github.com/dhalperi/lorcon-old.git  
  7.   
  8. cd lorcon-old  
  9.   
  10. ./configure  
  11.   
  12. make  
  13.   
  14. sudo make install  
  15.   
  16. cd linux-80211n-csitool-supplementary/injection  
  17.   
  18. make  
  19.   
  20. 使用:  
  21.   
  22. 接收方:  
  23.   
  24. ./setup_monitor_csi.sh.sh 64 HT20  
  25.   
  26. sudo ../netlink/log_to_file log.dat  
  27.   
  28. 发送方:  
  29.   
  30. ./setup_injection.sh 64 HT20  
  31.   
  32. sudo echo 0x4101 |sudo tee /sys/kernel/debug/ieee80211/phy0/iwlwifi/iwldvm/debug/monitor_tx_rate  
  33.       
  34. sudo ./random_packets 1 100 1  

需要注意的是最后2行,0x4101是对发送速率的选择,需要根据自己的情况设置,每一位
的含义见下图。最后一行就 是发送方发包命令,有4个参数,第一个是包的数量,第二个
是包的长度,第三个是模式,默认1就行。最后一个是 发包间隔,单位us。



由于原来的setup_monitor_csi和setup_inject两个脚本运行会出现各种问题,所以需要修改一下,将代码替换到源文件就可以了。下面是两个脚本的代码:

setup_inject  
[plain]  view plain  copy
  1. #!/usr/bin/sudo /bin/bash  
  2. sudo modprobe -r iwldvm iwlwifi mac80211  
  3. modprobe -r iwlwifi mac80211 cfg80211  
  4. modprobe iwlwifi debug=0x40000  
  5. if [ "$#" -ne 2 ]; then  
  6.     echo "Going to use default settings!"  
  7.     chn=64  
  8.     bw=HT20  
  9. else  
  10.     chn=$1  
  11.     bw=$2  
  12. fi  
  13. ifconfig wlan0 2>/dev/null 1>/dev/null  
  14. while [ $? -ne 0 ]  
  15. do  
  16.             ifconfig wlan0 2>/dev/null 1>/dev/null  
  17. done  
  18. iw dev wlan0 interface add mon0 type monitor  
  19.   
  20. ifconfig wlan0 down  
  21. while [ $? -ne 0 ]  
  22. do  
  23.     ifconfig wlan0 down  
  24. done  
  25. ifconfig mon0 up  
  26. while [ $? -ne 0 ]  
  27. do  
  28.            ifconfig mon0 up  
  29. done  
  30.   
  31. iw mon0 set channel $chn $bw  

setup_monitor_csi

[plain]  view plain  copy
  1. #!/usr/bin/sudo /bin/bash  
  2. sudo modprobe -r iwldvm iwlwifi mac80211  
  3. modprobe -r iwlwifi mac80211 cfg80211  
  4. modprobe iwlwifi connector_log=0x1  
  5. if [ "$#" -ne 2 ]; then  
  6.     echo "Going to use default settings!"  
  7.     chn=64  
  8.     bw=HT20  
  9. else  
  10.     chn=$1  
  11.     bw=$2  
  12. fi  
  13.   
  14. iwconfig wlan0 mode monitor 2>/dev/null 1>/dev/null  
  15. while [ $? -ne 0 ]  
  16. do  
  17.     iwconfig wlan0 mode monitor 2>/dev/null 1>/dev/null  
  18. done  
  19.   
  20. ifconfig wlan0 up 2>/dev/null 1>/dev/null  
  21. while [ $? -ne 0 ]  
  22. do  
  23.   ifconfig wlan0 up 2>/dev/null 1>/dev/null  
  24. done  
  25.   
  26. iw wlan0 set channel $chn $bw   

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值