Wifiweasel

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(/bin/sh)
(/bin/sh)
Line 74: Line 74:
 
## heh ping flood the noobs  
 
## heh ping flood the noobs  
 
#
 
#
Func.iwlist.open
+
Func_iwlist_open
 
########################## outputs the single highest signal open AP in quotes
 
########################## outputs the single highest signal open AP in quotes
Func_iwlist_open(){
+
Func_iwlist_open () {
 
iwlist $IFACE scanning \
 
iwlist $IFACE scanning \
 
| awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr { print $4 }' \
 
| awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr { print $4 }' \
 
|sort -k4 -k3nr \
 
|sort -k4 -k3nr \
 
|grep off \
 
|grep off \
|awk '{print $1}' }
+
|awk '{print $1}'
 +
}
 
########################## set wireless essid  
 
########################## set wireless essid  
Func_ifconfig_up(){
+
Func_ifconfig_up () {
iwconfig $IFACE essid $Func_iwlist_open }
+
iwconfig $IFACE essid Func_iwlist_open  
 +
}
 
########################## bring down interface for another try
 
########################## bring down interface for another try
Func_ifconfig_down(){
+
Func_ifconfig_down () {
 
killall udhcpc  
 
killall udhcpc  
ifconfig $IFACE down }
+
ifconfig $IFACE down
 +
}
 
########################## check connectivity
 
########################## check connectivity
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 30; $Func_chk_net fi  #W00T   
+
if [ $=0 ];then ERROR=0; echo Online! ;sleep 30; Func_chk_net ;
if [ $=1 ] ;then ERROR=1 ;echo FAILING; $Func_Main fi #FAIL-retry
+
fi  #W00T   
done }
+
if [ $=1 ] ; then ERROR=1 ;echo FAILING; Func_Main ;
 +
fi  
 +
}
  
### MAIN  ##BROKEN  
+
Func_MAIN () { while [ ERROR=1 ] ; do
Func_MAIN(){
+
Func_ifconfig_down ;
$Func.ifconfig.down
+
Func_ifconfig_up Func_iwlist_open;
$Func.ifconfig.up $Func_iwlist_open  
+
udhcpc $IFACE ;
udhcpc $IFACE  
+
Func_ch_net
$Func_ch_net    }
+
done;
 +
}
 +
 
 +
#### MAIN  ##BROKEN  
 +
Func.ifconfig.down ;
 +
Func.ifconfig.up $Func_iwlist_open ;
 +
udhcpc $IFACE ;
 +
Func_chk_net ;
 +
 
 +
#exit=0
 +
#fi
 +
echo Works you'll never see this line cause its an endless loop
 +
echo EOF go search teh web now!
  
done
 
</pre>
 
 
====the end====
 
====the end====
 
(a new story) wont exec i suck
 
(a new story) wont exec i suck

Revision as of 10:52, 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

/bin/sh

(Not Finished)

 
#!/bin/sh

   #####################
###########################
#/var/wifi/hacker/kd8ikt###
# OMG i'm programming now!#
###########################
###we.trekbeyond.org#######
  #####################
        #KISS#

######wireless interface
IFACE=eth0
#
####host to do ping test
HOST=myspace.com
#
## heh ping flood the noobs 
#
#  Func_iwlist_open
########################## outputs the single highest signal open AP in quotes
Func_iwlist_open () {
iwlist $IFACE scanning \
| awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr { print $4 }' \
|sort -k4 -k3nr \
|grep off \
|awk '{print $1}'	
}
########################## set wireless essid 
Func_ifconfig_up () {
iwconfig $IFACE essid Func_iwlist_open 
}
########################## bring down interface for another try
Func_ifconfig_down () {
killall udhcpc 
ifconfig $IFACE down	
}
########################## check connectivity
Func_chk_net ()	{
ping -w 2 -c 1 $HOST 
if [ $=0 ];then ERROR=0; echo Online! ;sleep 30; Func_chk_net ; 
fi  #W00T  
if [ $=1 ] ; then ERROR=1 ;echo FAILING; Func_Main ;
fi 
 }

Func_MAIN () { while [ ERROR=1 ] ; do
Func_ifconfig_down ;
Func_ifconfig_up Func_iwlist_open;
udhcpc $IFACE ;
Func_ch_net 
done; 
} 

#### MAIN  ##BROKEN 
Func.ifconfig.down ;
Func.ifconfig.up $Func_iwlist_open ; 
udhcpc $IFACE ; 
Func_chk_net ; 

#exit=0
#fi
echo Works you'll never see this line cause its an endless loop
echo EOF go search teh web now!

====the end====
(a new story) wont exec i suck

<pre>
Func_MAIN(){ while [ ERROR=1 ] ; do
$Func.ifconfig.down
$Func.ifconfig.up $Func_iwlist_open
udhcpc $IFACE
$Func_ch_net ;
break }
### MAIN  ##BROKEN
$Func.ifconfig.down
$Func.ifconfig.up $Func_iwlist_open
udhcpc $IFACE
$Func_ch_net

done
Personal tools

script to Auto connect to Open wirelss 81102 AP's

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

/bin/sh

(Not Finished)

 
#!/bin/sh

   #####################
###########################
#/var/wifi/hacker/kd8ikt###
# OMG i'm programming now!#
###########################
###we.trekbeyond.org#######
  #####################
        #KISS#

######wireless interface
IFACE=eth0
#
####host to do ping test
HOST=myspace.com
#
## heh ping flood the noobs 
#
#  Func_iwlist_open
########################## outputs the single highest signal open AP in quotes
Func_iwlist_open () {
iwlist $IFACE scanning \
| awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr { print $4 }' \
|sort -k4 -k3nr \
|grep off \
|awk '{print $1}'	
}
########################## set wireless essid 
Func_ifconfig_up () {
iwconfig $IFACE essid Func_iwlist_open 
}
########################## bring down interface for another try
Func_ifconfig_down () {
killall udhcpc 
ifconfig $IFACE down	
}
########################## check connectivity
Func_chk_net ()	{
ping -w 2 -c 1 $HOST 
if [ $=0 ];then ERROR=0; echo Online! ;sleep 30; Func_chk_net ; 
fi  #W00T  
if [ $=1 ] ; then ERROR=1 ;echo FAILING; Func_Main ;
fi 
 }

Func_MAIN () { while [ ERROR=1 ] ; do
Func_ifconfig_down ;
Func_ifconfig_up Func_iwlist_open;
udhcpc $IFACE ;
Func_ch_net 
done; 
} 

#### MAIN  ##BROKEN 
Func.ifconfig.down ;
Func.ifconfig.up $Func_iwlist_open ; 
udhcpc $IFACE ; 
Func_chk_net ; 

#exit=0
#fi
echo Works you'll never see this line cause its an endless loop
echo EOF go search teh web now!

====the end====
(a new story) wont exec i suck

<pre>
Func_MAIN(){ while [ ERROR=1 ] ; do
$Func.ifconfig.down
$Func.ifconfig.up $Func_iwlist_open
udhcpc $IFACE
$Func_ch_net ;
break }
### MAIN  ##BROKEN
$Func.ifconfig.down
$Func.ifconfig.up $Func_iwlist_open
udhcpc $IFACE
$Func_ch_net

done