Linux CSITool的Monitor Mode配置

Linux CSI Tool的Monitor Mode配置

参考文献: https://blog.csdn.net/James_Bond_slm/article/details/117432357?spm=1001.2014.3001.5506

Monitor模式配置

一、 在终端下执行以下代码:

cd ~
sudo apt-get install libpcap-dev
git clone https://github.com/dhalperi/lorcon-old.git
cd lorcon-old
./configure
make
sudo make install

二、发送端配置

发送端是最难配置的,中途出现很多错误,大多是来源于setup_inject.sh文件,所以需要改此文件。

  1. 编译发送代码
cd ~
cd linux-80211n-csitool-supplementary/injection/
make
  1. 修改setup_inject.sh文件
    首先,复制 linux-80211n-csitool-supplementary/injection/ 目录下的setup_inject.sh文件,并将副本命名为inject.sh, 打开副本将以下代码复制过去,替换原来的代码(此代码亲测好用,所以请不要犹豫,替换吧!):
#!/usr/bin/sudo /bin/bash
sudo service network-manager stop
WLAN_INTERFACE=$1
SLEEP_TIME=2
modprobe iwlwifi debug=0x40000
if [ "$#" -ne 3 ]; then
    echo "Going to use default settings!"
    chn=64
    bw=HT20
else
    chn=$2
    bw=$3
fi
sleep $SLEEP_TIME
ifconfig $WLAN_INTERFACE 2>/dev/null 1>/dev/null
while [ $? -ne 0 ]
do
    ifconfig $WLAN_INTERFACE 2>/dev/null 1>/dev/null
done
sleep $SLEEP_TIME
echo "Add monitor mon0....."
iw dev $WLAN_INTERFACE interface add mon0 type monitor
sleep $SLEEP_TIME
echo "Bringing $WLAN_INTERFACE down....."
ifconfig $WLAN_INTERFACE down
while [ $? -ne 0 ]
do
    ifconfig $WLAN_INTERFACE down
done
sleep $SLEEP_TIME
echo "Bringing mon0 up....."
ifconfig mon0 up
while [ $? -ne 0 ]
do
    ifconfig mon0 up
done
sleep $SLEEP_TIME
echo "Set channel $chn $bw....."
iw mon0 set channel $chn $bw
  1. 查看无线网卡接口名称,一般情况下为wlan0
iwconfig
  1. 执行脚本
sudo bash ./inject.sh wlan0 64 HT20  #将wlan0替换为3中显示的网卡接口名称
  1. 发送指令
echo 0x4101 | sudo tee `sudo find /sys -name monitor_tx_rate`  #0x4101可替换为自己需要的参数
cd ~
cd linux-80211n-csitool-supplementary/injection/
sudo ./random_packets 1000000000 100 1 1000

random_packets的参数解释:第一个参数是累计发包数量,第二个参数是包的大小,第三个参数1代表injection MAC,用1就可以了,最后一个参数代表每隔1000微秒发一次包,即一秒发1000个包,也就是说发包频率为1000Hz。

这样发送端就配置好了,可以继续配置接收端了。

三、接收端配置

  1. 编译接收代码
cd ~
cd linux-80211n-csitool-supplementary/netlink/
make
  1. 修改setup_monitor.sh文件
    首先,复制 linux-80211n-csitool-supplementary/injection/ 目录下的setup_monitor.sh文件,并将副本命名为monitor.sh, 打开副本将以下代码复制过去,替换原来的代码(此代码亲测好用,所以请不要犹豫,替换吧!):
#!/usr/bin/sudo /bin/bash
sudo modprobe -r iwlwifi mac80211
sudo modprobe iwlwifi connector_log=0x1

sudo service network-manager stop
SLEEP_TIME=2
WLAN_INTERFACE=$1
if [ "$#" -ne 3 ]; then
	echo "Going to use default settings!"
	chn=64
	bw=HT20
else
	chn=$2
	bw=$3
fi
echo "Bringing $WLAN_INTERFACE down......"
ifconfig $WLANINTERFACE down
while [ $? -ne 0 ]
do
	ifconfig $WLAN_INTERFACE down
done
sleep $SLEEP_TIME
echo "Set $WLAN_INTERFACE into monitor mode......"
iwconfig $WLAN_INTERFACE mode monitor
while [ $? -ne 0 ]
do
	iwconfig $WLAN_INTERFACE mode monitor
done
sleep $SLEEP_TIME
echo "Bringing $WLAN_INTERFACE up......"
ifconfig $WLAN_INTERFACE up
while [ $? -ne 0 ]
do
	ifconfig $WLAN_INTERFACE up
done
sleep $SLEEP_TIME
echo "Set channel $chn $bw..."
iw $WLAN_INTERFACE set channel $chn $bw
  1. 执行脚本
sudo bash ./monitor.sh wlan0 64 HT20
  1. 接收指令
cd ~
cd linux-80211n-csitool-supplementary/netlink/
sudo ./log_to_file your_file_name.dat  #your_file_name是保存数据的文件名,可根据自己的命名习惯更改。

配置完成!愉快地做实验收数据吧~
祝大家实验顺利,多发paper。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值