From 631986deaf81a4641578d1d878f66d2e1a622396 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 13:24:52 +0200 Subject: new profiles & autowifi --- usr/bin/autowifi | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'usr/bin/autowifi') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 90a584de..3c3444df 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -54,28 +54,37 @@ iwlist_scan(){ done; echo WIFI_COUNT=$count) } crack_wifi(){ - if $6;then + if [ -n "$6" ];then encr=psk2 - elif $5; then + elif [ -n "$5" ]; then encr=psk - elif [ $4 == on ]; then + elif [ "$4" == on ]; then encr=wep fi for hack in $(find /usr/lib/autowifi/ -type f); do key=$($hack $@); - if ! [ $key -eq 1 ];then + ret=$? + if [ $ret -eq 0 ];then connect_wifi $3 $1 $encr $key - break + sleep 20 + if check_gateway; then + (cat /etc/autowifi/wifi_keys; echo "$1|$2|$key" ) | sort | uniq >> /etc/autowifi/wifi_keys + echo "yay internet" + return 0 + fi fi done } +check_gateway(){ + ping -c 1 -w 5 $(ip route | awk '/default/{print $3}') +} check_internet(){ wget -O- --spider http://google.de/index.html } loop_over_networks(){ . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do - crack_wifi \${ESSID_${i}} \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} + eval crack_wifi \${ESSID_${i}} \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} done } -- cgit v1.2.3