Advertisement
opexxx

iwmap.sh

May 1st, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.33 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #
  4. # ----------------------------------------------------------------------------
  5. # "THE BEER-WARE LICENSE" (Revision 42):
  6. # guelfoweb@gmail.com wrote this file. As long as you retain this notice you
  7. # can do whatever you want with this stuff. If we meet some day, and you think
  8. # this stuff is worth it, you can buy me a beer in return Gianni 'guelfoweb' Amato
  9. # ----------------------------------------------------------------------------
  10. #
  11.  
  12. #-------------------#
  13. WLAN="wlan0"        # <- Interface type
  14. LOGFILE="iwmap.log" # <- Logfile name
  15. SLEEP=10        # <- Delay in seconds
  16. SU="sudo"       # <- Super User
  17. #-------------------#
  18.  
  19. TS=`date --utc --date now +%s`
  20. LOGTMP=".iwmap_$TS.tmp"
  21. FUCK="/dev/null"
  22.  
  23. start(){
  24.     SCAN=`$SU iwlist $WLAN scanning 2> $FUCK | egrep 'Channel|Address|ESSID|Encryption|Group Cipher' | sed -e 's/Cell [0-9]* - Address: //g' \
  25.                         -e 's/Channel://g' \
  26.                         -e 's/Frequency://g' \
  27.                         -e 's/GHz//g' \
  28.                         -e 's/(Channel [0-9]*)//g' \
  29.                         -e 's/Encryption key://g' \
  30.                         -e 's/ESSID://g' \
  31.                         -e 's/Group Cipher : //g' \
  32.                         -e 's/^ *//g'`
  33.  
  34.     for i in $SCAN;
  35.     do
  36.         echo -n $i | sed '/^\([0-9A-Z][0-9A-Z]:\)\{5\}[0-9A-Z][0-9A-Z]$/{x;p;x;}' >> $LOGTMP; echo -n "," >> $LOGTMP
  37.     done
  38.  
  39.     if [ ! -f $LOGFILE ]; then > $LOGFILE; fi
  40.    
  41.     tail -n +2 $LOGTMP 2> $FUCK | sed 's/,$//g'| while read LINE;
  42.         do {
  43.             if [ ! "$LINE" = "" ]; then
  44.                 ESSID=`echo "$LINE" | cut -d\" -f2 | sed 's/,/ /g'`
  45.                 MACADDR=`echo $LINE | cut -d\, -f1`
  46.                 CHANNEL=`echo $LINE | cut -d\, -f2`
  47.                 FREQ=`echo $LINE | cut -d\, -f3`
  48.                 KEY=`echo $LINE | cut -d\, -f4`
  49.                 ESSID=`echo $LINE | awk -F  "\"" '{print $2}' | sed 's/,/ /g'`
  50.                 ENC=`echo "$LINE" | awk -F  "\"" '{print $3}' | awk -F  "," '{print $2}'`
  51.                 if [ "$ENC" = "" ]; then ENC="----"; fi
  52.                 FOUND="$MACADDR,$CHANNEL,$FREQ,$KEY,$ENC,$ESSID"
  53.                 DUPLICATE=`echo $FOUND | cut -d\, -f2,4,5,6`
  54.                 GREPLINE=`cut -d\, -f2,4,5,6 $LOGFILE | grep "$DUPLICATE"`
  55.                 if [ -z "$GREPLINE" ]; then
  56.                     echo -e "$MACADDR \t $CHANNEL \t $FREQ \t $KEY \t $ENC \t $ESSID"
  57.                     echo $FOUND >> $LOGFILE
  58.                 fi
  59.             fi
  60.             }
  61.         done
  62.  
  63.     rm $LOGTMP 2> $FUCK
  64. }
  65.  
  66. RES="BEGIN"
  67. echo -e "MACADDRESS \t\t CH \t FREQ \t KEY \t ENCR \t ESSID"
  68. echo -e "---------- \t\t -- \t ---- \t --- \t ---- \t -----"
  69. while [ $RES != "END" ]; do
  70.     start
  71.     sleep $SLEEP
  72. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement