我正在尝试在后台运行airodump
..我编写了以下来自/etc/rc.local
的脚本:
#!/bin/bash
/usr/local/sbin/airmon-ng check kill >> /tmp/airmon-kill 2>&1
sleep 2
/usr/local/sbin/airmon-ng start wlan0 > /tmp/airmon-start 2>&1
sleep 2
/usr/local/sbin/airodump-ng wlan0mon --manufacturer --uptime --wps --output-format csv --write-interval 5 --write log > /tmp/airmon-dump 2>&1&
当我从终端以root身份运行这些命令时,它们可以正常工作。当我从rc.local
运行它时,我遇到了各种各样的问题..
首先是kill脚本..这个似乎工作正常,因为输出是:
Killing these processes:
PID Name
2294 dhcpcd
接下来是启动脚本...这就是我自己在终端上运行时遇到的错误:
PHY Interface Driver Chipset
phy0 mon.wlan0 rt2800usb Ralink Technology, Corp. RT5370
phy0 wlan0 rt2800usb Ralink Technology, Corp. RT5370
Error setting channel: command failed: Device or resource busy (-16)
Error -16 likely means your card was set back to station mode by something.
Removing non-monitor mon.wlan0 interface...
WARNING: unable to start monitor mode, please run "airmon-ng check kill"
为什么行为如此不同?两者都以root身份运行(我检查过)并且都从bash运行。为什么不同的行为?
答案 0 :(得分:0)
而不是将其放在rc.local
中,在我看来,它可能在网络实际开始之前运行,编辑/etc/network/interfaces
。在wlan0
的定义(或任何无线接口的名称)中,添加post-up
命令:
iface wlan0 inet dhcp
...
post-up /path/to/your/bash/script.sh
这将在wlan0
界面实际联机后运行您的脚本。