Shell脚本:
我正在路由器上进行一些测试,为此使用mdk3和reaver实用程序。
这是两个命令:
[cmd1] echo y|reaver -i wlan2mon -b 00:FF:EE:CC:DS:B6 -vv -l 230
[cmd2] sudo mdk3 wlan2mon a -a 00:FF:EE:CC:DS:B6
目标:
我正在尝试创建一个将在[cmd1]中运行2分钟的shell脚本,然后它将ctrl + c信号发送到[cmd1],以便它将保存reaver session 。
然后cmd2将运行2分钟,此后此操作也将停止。
这两个将循环。
以下是我编写的示例脚本,您可以在其中添加计时器吗?
#!/bin/bash
while :; do echo
echo "running mdk for 2 minutes";
timeout 120 sudo mdk3 wlan2mon a -a 00:FF:EE:CC:DS:B6;
echo "mdk finished";
echo "starting reaver for 2 minutes ";
#here timeout won't work, as ctrl+c can only save the state.
//add code here to run reaver utility for two minutes and send ctrl+c to it
echo y|reaver -i wlan2mon -b 00:FF:EE:CC:DS:B6 -vv;
echo "reaver ran for two minutes";
done
最佳答案
我对reaver
程序不熟悉,但是我认为以下方法应该有效,
# Run reaver as a background process (add &)
echo y|reaver -i wlan2mon -b 00:FF:EE:CC:DS:B6 -vv &
# Save the process id.
reaverpid=$!
# Sleep 2 minutes
sleep 120
# Send SIGINT, which is what ctrl-c normally does.
kill -SIGINT $reaverpid