diff options
-rw-r--r-- | etc/autowifi/wifi_keys | 2 | ||||
-rwxr-xr-x | usr/bin/autowifi | 21 | ||||
-rwxr-xr-x | usr/lib/autowifi/00profile | 9 | ||||
-rwxr-xr-x | usr/lib/autowifi/01open | 5 |
4 files changed, 31 insertions, 6 deletions
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 |