From 7d8f7c4c3c7f592191bf61fbddeb3996c58dcba3 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 29 May 2013 20:39:27 +0200 Subject: add autowifi_dryrun usage: root=../../ ./autowifi_dryrun --- usr/bin/autowifi_dryrun | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 usr/bin/autowifi_dryrun (limited to 'usr') 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 -- cgit v1.2.3