Wifiweasel

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(iwscan bash)
Line 44: Line 44:
 
close scan;
 
close scan;
 
</pre>
 
</pre>
 
 
produces output in the form of
 
produces output in the form of
 
"essid"  channel  signal_strength  encryption_status
 
"essid"  channel  signal_strength  encryption_status
Line 53: Line 52:
 
====iwscan bash====
 
====iwscan bash====
 
<pre>  
 
<pre>  
iwlist eth0 scanning | awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr/{ print $4 }' | sort -k4 -k3nr
+
#!/bin/sh
 +
#
 +
# Blind simple stupid OpenAP finder/connector
  
</pre>
+
#
output=
+
# grab a list of line seperated open AP's
 +
for AP in $(iwlist eth0 scanning | awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr/{ print $4 }' | sort -k4 -k3nr |grep off |awk ' iwlist eth0 scanning | awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr/{ print $4 }' | sort -k4 -k3nr |grep off |awk '{print $1}'{print $1}'); do
  
"SSIDNAME" 2.412 46/94 off <br>
+
ifconfig eth0 essid $AP
"NextName" 2.412 29/94 on  <br>
+
udhcpc eth0
"guess?" 2.462 4/94 on    <br>
+
  
====precon====
 
$iwscan_output grep off
 
  
?compare signal?
+
#
 +
# is net on/working?
 +
#  w00t=yes  FAIL=no
  
ifconfig eth0 essid "essid"
 
udhcpc eth0
 
chknet 
 
 
====chknet====
 
<pre>
 
#!/bin/sh
 
 
HOSTTT="google.com"
 
HOSTTT="google.com"
 
for Hosts in $HOSTTT
 
for Hosts in $HOSTTT
Line 79: Line 73:
 
   count=$(ping -c 1 $HOSTTT | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
 
   count=$(ping -c 1 $HOSTTT | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
 
   if [ $count -eq 0 ]; then
 
   if [ $count -eq 0 ]; then
        export netstat=0
+
    # 100% failed
 +
    echo "FAIL"
 
   fi
 
   fi
 +
 
 
   if [ $count -eq 1 ]; then
 
   if [ $count -eq 1 ]; then
export netstat=1 ;
+
 
 +
echo "w00t"
 
   fi
 
   fi
while ($netstat=0)
 
do ./iwscan + the signal comparision crap then retry connecting ugh this isnt right is it
 
  
 
done
 
done
</pre>
 
outputs
 
 
FAIL or
 
w00t
 

Revision as of 01:59, 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

iwscan bash

 
#!/bin/sh
#
# Blind simple stupid OpenAP finder/connector

#
# grab a list of line seperated open AP's
for AP in $(iwlist eth0 scanning | awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr/{ print $4 }' | sort -k4 -k3nr |grep off |awk ' iwlist eth0 scanning | awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr/{ print $4 }' | sort -k4 -k3nr |grep off |awk '{print $1}'{print $1}'); do

	 ifconfig eth0 essid $AP
	 udhcpc eth0


#
# is net on/working?
#  w00t=yes   FAIL=no

HOSTTT="google.com"
for Hosts in $HOSTTT
do
  count=$(ping -c 1 $HOSTTT | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
  if [ $count -eq 0 ]; then
    # 100% failed
    echo "FAIL" 
  fi
  
  if [ $count -eq 1 ]; then
  
	echo "w00t"
  fi

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

iwscan bash

 
 iwlist eth0 scanning | awk -F '[ :=]+' '/(ESS|Freq|Qual)/{ printf $3" " } /Encr/{ print $4 }' | sort -k4 -k3nr

output=

"SSIDNAME" 2.412 46/94 off
"NextName" 2.412 29/94 on
"guess?" 2.462 4/94 on

precon

$iwscan_output grep off

?compare signal?

ifconfig eth0 essid "essid" udhcpc eth0 chknet

chknet

#!/bin/sh
HOSTTT="google.com"
for Hosts in $HOSTTT
do
  count=$(ping -c 1 $HOSTTT | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
  if [ $count -eq 0 ]; then
        export netstat=0 
  fi
  if [ $count -eq 1 ]; then
	export netstat=1 ;
  fi
while ($netstat=0)
do ./iwscan + the signal comparision crap then retry connecting ugh this isnt right is it

done

outputs

FAIL or w00t