· 8 years ago · May 22, 2018, 07:30 AM
1#!/bin/bash
2# WiFi Hunter
3# ===========
4#
5# Scans for unprotected Access Points in your neighborhood and alerts you
6# when it finds something good for you :)
7# -- ideamonk at gmail.com
8
9export MPLAYER_VERBOSE=0
10
11refreshReport()
12{
13 ap_list=`iwlist wlan0 scanning | grep ESSID`
14 ap_count=`iwlist wlan0 scanning | grep ESSID | wc -l`
15 hole_list=`iwlist wlan0 scanning | grep -e 'Encryption key:off' -B 6 | grep 'ESSID'`
16 hole_count=`iwlist wlan0 scanning | grep 'Encryption key:off' | wc -l`
17}
18
19showReport()
20{
21 echo "Total $ap_count APs "
22 echo "APs - " $ap_list | sed -e s/ESSID://
23 echo $hole_count " Unprotected APs"
24 if [ $hole_count -gt 0 ] ; then
25 echo "Unprotected ones -- " $hole_list | sed -e s/ESSID://
26 fi
27 echo "------------------------------------------------------------------"
28}
29
30refreshReport
31showReport
32
33echo
34echo "Scanning now ... "
35
36oldcount=0
37
38while [ 1 -eq 1 ] ; do
39 refreshReport
40 if [ $ap_count != $oldcount ] ; then
41 oldcount=$ap_count
42 if [ $hole_count -gt 0 ] ; then
43 mplayer '/usr/share/sounds/ubuntu/stereo/system-ready.ogg' -quiet -msglevel all=-1 >&/dev/null
44 # Yay I can haz stderr redirection too, complete silence :D >& FTW
45 # &> redirection works only with bash though
46 echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
47 echo " --== FOUND SOMETHING ==--"
48 fi
49 showReport
50 echo
51 echo "Scanning for more..."
52 fi
53done