Wifiweasel
From Openmoko
(→wifiweasel) |
(→wifiweasel) |
||
Line 53: | Line 53: | ||
[[category:GTA02 Hardware]] | [[category:GTA02 Hardware]] | ||
====wifiweasel==== | ====wifiweasel==== | ||
− | this | + | wifiweasel v1 |
+ | once run this script takes control of the wireless interface | ||
+ | detects and connects to strongest open wifi AP in the vicinity | ||
+ | and checks connectivity every X seconds if connection fails the | ||
+ | whole proccess repeats itself | ||
<pre> | <pre> | ||
#!/bin/sh | #!/bin/sh | ||
− | |||
##################### | ##################### | ||
########################### | ########################### | ||
Line 67: | Line 70: | ||
#KISS# | #KISS# | ||
− | ###### | + | # CONFIG |
+ | #######interface################ | ||
IFACE=eth0 | IFACE=eth0 | ||
# | # | ||
− | ####host | + | #####host |
HOST=myspace.com | HOST=myspace.com | ||
# | # | ||
− | ## heh ping flood the | + | ###heh#ping#flood#the#net#poison |
# | # | ||
− | # | + | #check connectivity every X sec |
− | ########################## | + | X=30 |
+ | # | ||
+ | # /CONFIG | ||
+ | ################################ | ||
+ | #### Scan Funk #### | ||
Func_iwlist_open () { | Func_iwlist_open () { | ||
iwlist $IFACE scanning \ | iwlist $IFACE scanning \ | ||
Line 84: | Line 92: | ||
|awk '{print $1}' | |awk '{print $1}' | ||
} | } | ||
− | ############ | + | #### iface up Funk ######## |
Func_ifconfig_up () { | Func_ifconfig_up () { | ||
iwconfig $IFACE essid Func_iwlist_open | iwconfig $IFACE essid Func_iwlist_open | ||
} | } | ||
− | ######### | + | #### iface down Funk ##### |
Func_ifconfig_down () { | Func_ifconfig_down () { | ||
killall udhcpc | killall udhcpc | ||
ifconfig $IFACE down | ifconfig $IFACE down | ||
} | } | ||
− | ######### | + | #### Conn Funk ##### |
Func_chk_net () { | Func_chk_net () { | ||
ping -w 2 -c 1 $HOST | ping -w 2 -c 1 $HOST | ||
− | if [ $=0 ];then ERROR=0; echo Online! ;sleep | + | if [ $=0 ];then ERROR=0; echo Online! ;sleep $X; Func_chk_net ; |
fi #W00T | fi #W00T | ||
if [ $=1 ] ; then ERROR=1 ;echo FAILING; Func_Main ; | if [ $=1 ] ; then ERROR=1 ;echo FAILING; Func_Main ; | ||
fi | fi | ||
} | } | ||
− | + | #### Main Funk ######### | |
Func_MAIN () { while [ ERROR=1 ] ; do | Func_MAIN () { while [ ERROR=1 ] ; do | ||
Func_ifconfig_down ; | Func_ifconfig_down ; | ||
Line 109: | Line 117: | ||
done; | done; | ||
} | } | ||
− | + | #### MAIN #### | |
− | #### MAIN | + | |
Func.ifconfig.down ; | Func.ifconfig.down ; | ||
Func.ifconfig.up $Func_iwlist_open ; | Func.ifconfig.up $Func_iwlist_open ; | ||
udhcpc $IFACE ; | udhcpc $IFACE ; | ||
Func_chk_net ; | Func_chk_net ; | ||
− | + | echo This is the end my only friend the end | |
− | This is the end my only friend the end | + | |
− | + | ||
Done; | Done; | ||
+ | #####################EOF############### | ||
</pre> | </pre> |
Revision as of 11:16, 22 July 2008
script to Auto connect to Open wirelss 81102 AP's
Contents |
TODO
- determine AP without encryption and sort by best signal
- using essid of best signal perform connect/udhcpc and chknet every so often
if net is down repeat
- put it all together
sandbox
iwscan perl
#!/usr/bin/perl # Tim Osburn - tim@osburn.com # # install perl $iwlist = "/sbin/iwlist eth0 scanning"; open scan, "$iwlist |"; while (<scan>) { if (/^\s+Cell (\S+) - Address: (\S+)/) { $CELL=$1; $ADDRESS=$2; # print "$1 $2"; $INLOOP=1; } if (/^\s+ESSID:(\S+)/) { $ESSID=$1; print " $1"; } if (/^\s+Frequency:\S+ \S+ \(Channel (\S+)\)/) { $CHAN=$1; print " $1"; } if (/^\s+Quality=\S+\s+Signal level=(\S+).*/) { $SIGNAL=$1; print " $1"; } if (/^\s+Encryption key:(\S+)/) { $ENCRYPTION=$1; print " $1\n"; } } close scan;
produces output in the form of "essid" channel signal_strength encryption_status
"ESSID_NAME1" 1 -82 on
"ESSID_NAME2" 1 -49 off
wifiweasel
wifiweasel v1 once run this script takes control of the wireless interface detects and connects to strongest open wifi AP in the vicinity and checks connectivity every X seconds if connection fails the whole proccess repeats itself
#!/bin/sh ##################### ########################### #/var/wifi/hacker/kd8ikt### # OMG i'm programming now!# ########################### ###we.trekbeyond.org####### ##################### #KISS# # CONFIG #######interface################ IFACE=eth0 # #####host HOST=myspace.com # ###heh#ping#flood#the#net#poison # #check connectivity every X sec X=30 # # /CONFIG ################################ #### Scan Funk #### Func_iwlist_open () { iwlist $IFACE scanning \ | awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr { print $4 }' \ |sort -k4 -k3nr \ |grep off \ |awk '{print $1}' } #### iface up Funk ######## Func_ifconfig_up () { iwconfig $IFACE essid Func_iwlist_open } #### iface down Funk ##### Func_ifconfig_down () { killall udhcpc ifconfig $IFACE down } #### Conn Funk ##### Func_chk_net () { ping -w 2 -c 1 $HOST if [ $=0 ];then ERROR=0; echo Online! ;sleep $X; Func_chk_net ; fi #W00T if [ $=1 ] ; then ERROR=1 ;echo FAILING; Func_Main ; fi } #### Main Funk ######### Func_MAIN () { while [ ERROR=1 ] ; do Func_ifconfig_down ; Func_ifconfig_up Func_iwlist_open; udhcpc $IFACE ; Func_ch_net done; } #### MAIN #### Func.ifconfig.down ; Func.ifconfig.up $Func_iwlist_open ; udhcpc $IFACE ; Func_chk_net ; echo This is the end my only friend the end Done; #####################EOF###############
to be implemented
instead of pinging net hosts which could quickly start dropping pkts we will ping the router via ip route show to 0/0