diff options
Diffstat (limited to 'usr/bin/autowifi_dryrun')
-rwxr-xr-x | usr/bin/autowifi_dryrun | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/usr/bin/autowifi_dryrun b/usr/bin/autowifi_dryrun new file mode 100755 index 00000000..1795269a --- /dev/null +++ b/usr/bin/autowifi_dryrun @@ -0,0 +1,52 @@ +#!/bin/sh +# ENV: +# the root directory (e.g. root=$PWD/../../ if run from here ) +root=${root:-/} +wifi=${wifi:-wlan0} + +test "${1:-}" = 'quiet' && exec 2>&- + +# for iwlist_scan +. $root/usr/lib/autowifi/lib/iwlist + +# . $ROOT/usr/lib/autowifi/lib/ + +# for check_internet and check_gateway +# . /usr/lib/autowifi/lib/network + +crack_wifi(){ + #SSID MAC CHANNEL ENCRYPTION WPA WPA2 + 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 + ALL_RET=1 + for hack in $(find $root/usr/lib/autowifi/plugins -type f | sort -n); do + printf "%s" "Trying $(basename $hack) against $1 : " >&2 + key=$($hack "$@"); + ret=$? + if [ $ret -eq 0 ];then + echo "success!" >&2 + echo $1:$2:$encr:$key + ALL_RET=0 + else + echo "fail ..." >&2 + fi + done + return $ALL_RET +} +loop_over_networks(){ + . /tmp/${wifi}.scan + echo "SSID:MAC:CHANNEL:ENCRYPTION:key" + for i in `seq 1 $WIFI_COUNT`; do + eval crack_wifi \"\${ESSID_${i}}\" \${MAC_${i}} \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} + done +} + +iwlist_scan > /tmp/${wifi}.scan +loop_over_networks |