在树莓派4b中使用nexmon的功能包抓取csi数据,raspberry pi os 内核版本5.10(2021 年末发行的那版)
见https://github.com/seemoo-lab/nexmon
https://github.com/seemoo-lab/nexmon_csi
若空间不足:
需扩展分区
sudo rasp-config
找到enpend
python版本用2.7,切换版本方式:
先将python的链接删了
sudo rm /usr/bin/python
将python2.7软链接上去
sudo ln -s /usr/bin/python2.7 /usr/bin/python
如果没有安装
# 安装python(指向python2)
sudo apt-get install python-dev
# 安装python3
sudo apt-get install python3-dev
具体步骤
sudo su
apt-get update
内核
不要急着upgrade,先查看内核版本,upgrade后版本可能太高无法使用,
uname -r
相关
sudo dpkg --get-selections | grep linux #查看已安装的内核
sudo apt remove linux-image-x.xx.x-xx-generic #删除新内核
sudo apt install linux-image-x.xx.x-xx-generic #安装原内核
sudo apt-get install kernel-devel
sudo apt install raspberrypi-kernel-headers
看一下lib/modules/内核下有无build文件夹
sudo apt-get update && sudo apt-get install --reinstall raspberrypi-bootloader raspberrypi-kernel
sudo apt-get install raspberrypi-kernel-headers
reboot
apt:
sudo apt install raspberrypi-kernel-headers git libgmp3-dev gawk qpdf bison flex make autoconf libtool texinfo
sudo apt install tcpdump
git clone https://github.com/seemoo-lab/nexmon.git
cd nexmon
检查系统是否缺少所需固件
#Check if
#/usr/lib/arm-linux-gnueabihf/libisl.so.10
#exists, if not, compile it from source:
cd buildtools/isl-0.10
./configure
make
make install
ln -s /usr/local/lib/libisl.so /usr/lib/arm-linux-gnueabihf/libisl.so.10
#Check if
#/usr/lib/arm-linux-gnueabihf/libmpfr.so.4
#exists, if not, compile it from source:
cd buildtools/mpfr-3.1.4
autoreconf -f -i
./configure
make
make install
ln -s /usr/local/lib/libmpfr.so /usr/lib/arm-linux-gnueabihf/libmpfr.so.4
在nexmon下:
cd /home/pi/nexmon
source setup_env.sh
make
cd patches/bcm43455c0/7_45_189/nexmon/
编译补丁
make
make backup-firmware
make install-firmware
cd /home/pi/nexmon
cd utilities/nexutil/
make && make install
#apt-get remove wpasupplicant做了断网。可以不做
#关闭省电模式
iw dev wlan0 set power_save off
nexutil -m0
安装mcp
https://github.com/seemoo-lab/nexmon_csi/issues/241
cd /home/pi/nexmon/patches/bcm43455c0/7_45_189/
git clone https://github.com/seemoo-lab/nexmon_csi.git
cd nexmon_csi
setStatus "Installing makecsiparams"
cd utils/makecsiparams
make
ln -s $PWD/makecsiparams /usr/local/bin/mcp
USE
mcp -C 1 -N 1 -c 36/80(其中36/80分别为你要捕获的WiFi的频道和想要采集的带宽) mac地址
确保接口已启动:
ifconfig wlan0 up
使用 nexutil 和生成的参数配置提取器(-v后为mcp生成的参数 ):
nexutil -Iwlan0 -s500 -b -l34 -vm+IBEQGIAgAAESIzRFWqu6q7qrsAAAAAAAAAAAAAAAAAAA==
启用监控模式:
iw phy `iw dev wlan0 info | gawk '/wiphy/ {printf "phy" $2}'` interface add mon0 type monitor
ifconfig mon0 up
60是数据包数量
tcpdump -i wlan0 dst port 5500 -vv -w test.pcap -c 60
重启开机注意需要:
cd /home/pi/nexmon
source setup_env.sh
cd /home/pi/nexmon/patches/bcm43455c0/7_45_189/nexmon_csi
make install-firmware
后续安装:
对于csikit
需要python版本3.8加
安装指令
pip install csikit
使用命令
csikit [OPTIONS] file[.pcap/.dat/.csv/.csi]
csikit log.all_csi.6.7.6.dat
csikit --graph --graph_type all_subcarriers log.all_csi.6.7.6.dat
csikit --csv log.all_csi.6.7.6.dat
对于picsi
sudo apt install python3-pip
# install pip for python3
pip3 install picsi
# install picsi
source ~/.profile
# update $PATH
picsi install
# install nexmon_csi
使用命令
picsi enable # enable nexmon_csi
picsi up # Collect CSI on 36/80
picsi up 149/80 # Collect CSI on 149/80
picsi down # Stop CSI collection
picsi disable # Restore original WiFi
picsi status # See status
picsi --help # See the help page