我希望我的树莓每X分钟重新启动一次,将我的wifi加密狗网卡置于监视模式,然后重新启动嗅探脚本。同时,我需要通过以太网进行互联网连接。我从raspi-config启用了可预测的接口,并且USB加密狗开始被命名为wlx ????????????哪里????????????是mac地址。 问题是,当我使用aircrack-ng将usb软件狗置于监视模式时,eth0中的inet addr消失了,并且我不再有Internet连接了。
我的第一次尝试是像这样设置crontab
@reboot sudo shutdown -r +X
@reboot sudo ifconfig wlan1 up
@reboot sudo airmon-ng start wlan1
@reboot sudo python myScript.py
成功了。
pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.87 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::4033:ce91:f9f7:c6c6 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:26:91:26 txqueuelen 1000 (Ethernet)
RX packets 164 bytes 17133 (16.7 KiB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 196 bytes 33373 (32.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:73:c4:73 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan1mon: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
unspec 00-C0-CA-97-F0-1D-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
RX packets 6 bytes 832 (832.0 B)
RX errors 0 dropped 6 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
但是随后树莓开始给无线网卡起不同的名称(wlan1表示内置无线卡,wlan0表示外部USB加密狗)。我的python脚本总是用wlan1mon嗅探,所以我不希望有此更改。
因此,我从raspi-config
启用了可预测的接口,并且USB加密狗开始命名为wlx????????????
,其中????????????
是mac地址。
看来一切正常,但是当我将crontab更改为
@reboot sudo shutdown -r +X
@reboot sudo ifconfig wlx???????????? up
@reboot sudo airmon-ng start wlx????????????
@reboot sudo python myScript.py
如果我键入命令iwconfig
wlx ????????????正确设置为wlan1mon,因为该接口名称太长,但我再也没有通过以太网的互联网连接,而ifconfig给我这个:
pi@raspberrypi:~ $ ifconfig
enxb827eb269126: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::4033:ce91:f9f7:c6c6 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:26:91:26 txqueuelen 1000 (Ethernet)
RX packets 164 bytes 17133 (16.7 KiB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 196 bytes 33373 (32.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0和wlan1mon不再存在,并且缺少以太网接口字段inet。
iwconfig
而是给我这个:
pi@raspberrypi:~ $ iwconfig
enxb827eb269126 no wireless extensions
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point:Not-Associated
Retry short limit:27 RTS thr:off Fragment thr:off
Power Management:on
wlan1mon IEEE 802.11 Mode:Monitor Tx-Power=20dBm
Retry short long limit:2 RTS thr:off Fragment thr:off
Power Management:off
lo no wireless extensions