IdeaMonk

thoughts, ideas, code and other things...

Thursday, April 15, 2010

Looking for low hanging fruits

Pissed of with no internet access since last 5 days I wrote this and roamed around in my neighborhood looking for some free access...

Sad part is I could harldy find any in good range... but was fun listening to beeps roaming around with my netbook and pausing to take a look.

#!/bin/bash
# WiFi Hunter
# ===========
#
# Scans for unprotected Access Points in your neighborhood and alerts you
# when it finds something good for you :)
# -- ideamonk at gmail.com

export MPLAYER_VERBOSE=0

refreshReport()
{
ap_list=`iwlist wlan0 scanning | grep ESSID`
ap_count=`iwlist wlan0 scanning | grep ESSID | wc -l`
hole_list=`iwlist wlan0 scanning | grep -e 'Encryption key:off' -B 6 | grep 'ESSID'`
hole_count=`iwlist wlan0 scanning | grep 'Encryption key:off' | wc -l`
}

showReport()
{
echo "Total $ap_count APs "
echo "APs - " $ap_list | sed -e s/ESSID://
echo $hole_count " Unprotected APs"
if [ $hole_count -gt 0 ] ; then
echo "Unprotected ones -- " $hole_list | sed -e s/ESSID://
fi
echo "------------------------------------------------------------------"
}

refreshReport
showReport

echo
echo "Scanning now ... "

oldcount=0

while [ 1 -eq 1 ] ; do
refreshReport
if [ $ap_count != $oldcount ] ; then
oldcount=$ap_count
if [ $hole_count -gt 0 ] ; then
mplayer '/usr/share/sounds/ubuntu/stereo/system-ready.ogg' -quiet -msglevel all=-1 >&/dev/null
# Yay I can haz stderr redirection too, complete silence :D >& FTW
# &> redirection works only with bash though
echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
echo " --== FOUND SOMETHING ==--"
fi
showReport
echo
echo "Scanning for more..."
fi
done

and a small quality function in my bashrc to help me walk in right direction -

# Quality hunter -- to be used along wifi hunter :D
quality()
{

while [ 1 -eq 1 ] ; do
iwlist wlan0 scanning | grep -A 6 $1 | grep Quality;
done
}



usage $ quality 'APNAME'

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home