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/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 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/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(+) (limited to 'usr/bin/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 90a584de..3c3444df 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -54,28 +54,37 @@ iwlist_scan(){ done; echo WIFI_COUNT=$count) } crack_wifi(){ - if $6;then + if [ -n "$6" ];then encr=psk2 - elif $5; then + elif [ -n "$5" ]; then encr=psk - elif [ $4 == on ]; then + elif [ "$4" == on ]; then encr=wep fi for hack in $(find /usr/lib/autowifi/ -type f); do key=$($hack $@); - if ! [ $key -eq 1 ];then + ret=$? + if [ $ret -eq 0 ];then connect_wifi $3 $1 $encr $key - break + sleep 20 + if check_gateway; then + (cat /etc/autowifi/wifi_keys; echo "$1|$2|$key" ) | sort | uniq >> /etc/autowifi/wifi_keys + echo "yay internet" + return 0 + fi fi done } +check_gateway(){ + ping -c 1 -w 5 $(ip route | awk '/default/{print $3}') +} check_internet(){ wget -O- --spider http://google.de/index.html } loop_over_networks(){ . /tmp/${wifi}.scan for i in `seq 1 $WIFI_COUNT`; do - crack_wifi \${ESSID_${i}} \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} + eval crack_wifi \${ESSID_${i}} \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} done } -- cgit v1.2.3 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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 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 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 143 insertions(+), 54 deletions(-) mode change 100755 => 100644 usr/bin/autowifi (limited to 'usr/bin/autowifi') 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 -- 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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/autowifi') 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 + fi + done + done + +} #scan_all(){ # for i in `seq 1 $WIFI_COUNT`; do @@ -155,11 +170,11 @@ elif [ -n "$1" ]; then connect_to_network_by_ssid "$1" else echo looping network now - check_internet || loop_over_networks + check_internet || loop_cracks_over_networks while sleep 60; do if ! check_internet; then - loop_over_networks + loop_cracks_over_networks fi done fi -- cgit v1.2.3 From 410ddbd1f77e2f65de6e6b6c86daf031e296028d Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 26 Jun 2013 13:26:15 +0200 Subject: fix multiple wifi_init --- usr/bin/autowifi | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'usr/bin/autowifi') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index d9337cf4..1969e650 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -63,7 +63,6 @@ find_count_of_ssid(){ connect_to_network_by_ssid(){ - wifi_init find_count_of_ssid "$1" | (while read i do loop_over_cracks "$i" && exit 0 @@ -76,7 +75,6 @@ connect_to_network_by_ssid(){ } connect_with_pw(){ - wifi_init find_count_of_ssid "$1" | (while read i do KEY="$2" @@ -92,8 +90,8 @@ wifi_init(){ . /tmp/${interface}.scan } loop_over_networks(){ - wifi_init + wifi_init for i in `seq 1 $WIFI_COUNT`; do loop_over_cracks "$i" if [ $? -eq 0 ]; then @@ -144,9 +142,7 @@ loop_over_cracks(){ # exit 0 #} - - - +wifi_init if [ -n "$2" ]; then echo connecting to $1 with pw $2 connect_with_pw "$1" "$2" -- cgit v1.2.3 From 1d591aa1f4af30f41f2d44656d5b86e73048cffd Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 30 Jun 2013 14:17:57 +0200 Subject: less timeout --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin/autowifi') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 6fb64f95..5d9cad16 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -172,7 +172,7 @@ else echo looping network now check_internet || loop_cracks_over_networks - while sleep 60; do + while sleep 10; do if ! check_internet; then loop_cracks_over_networks fi -- cgit v1.2.3 From 7823e04b4b3f83f1efcc60f11892714b208db96c Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 27 Sep 2013 01:00:45 +0200 Subject: implement painmode --- usr/bin/autowifi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'usr/bin/autowifi') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 07786d67..7efcee62 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -4,9 +4,10 @@ cd $(dirname $(readlink -f $0)) interface=${interface:-wlan0} root=${root:-../../} -crackdir=$root/usr/lib/autowifi/plugins +crackdir= $root/usr/lib/autowifi/plugins wifi_keys=$root/etc/autowifi/wifi_keys wifi_log=$root/var/log/autowifi.log +painmode=${painmode:-} # exists() run_hooks() . $root/usr/lib/autowifi/lib/core @@ -104,7 +105,7 @@ 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}})" + KEY="$(eval root=$root painmode=$painmode \$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 -- cgit v1.2.3 From 9e6f266a64ed9d37105b8f17c97e11dd79349d9b Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 27 Sep 2013 01:01:34 +0200 Subject: fixed stupid bug --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin/autowifi') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 7efcee62..673a7a0a 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -4,7 +4,7 @@ cd $(dirname $(readlink -f $0)) interface=${interface:-wlan0} root=${root:-../../} -crackdir= $root/usr/lib/autowifi/plugins +crackdir=$root/usr/lib/autowifi/plugins wifi_keys=$root/etc/autowifi/wifi_keys wifi_log=$root/var/log/autowifi.log painmode=${painmode:-} -- cgit v1.2.3 From 39d6a2fb1ee0f714e893f8247c19651a583a3ba7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 27 Sep 2013 01:50:07 +0200 Subject: fixed autowifi_dryrun & fixed painmode --- usr/bin/autowifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/bin/autowifi') diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 673a7a0a..6b9a090c 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -170,7 +170,7 @@ else check_internet || loop_cracks_over_networks while sleep 10; do - if ! check_internet; then + if ! check_gateway; then loop_cracks_over_networks fi done -- cgit v1.2.3