diff options
author | makefu <github@syntax-fehler.de> | 2013-05-29 20:39:27 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-05-29 20:39:27 +0200 |
commit | 7d8f7c4c3c7f592191bf61fbddeb3996c58dcba3 (patch) | |
tree | 97cf6156d5a09f500cdd5922258841970babd69f | |
parent | d0e92e7aa1ece7bbccedafbb1730b80c76424f07 (diff) |
add autowifi_dryrun
usage: root=../../ ./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 |