summaryrefslogtreecommitdiffstats
path: root/usr/bin/autowifi_dryrun
blob: c98671066daefb56980a5d95470d88ee05f74000 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh 
# ENV:
# the root directory (e.g. root=$PWD/../../ if run from here )
cd $(dirname $(readlink -f $0))
test  "${1:-}" = 'quiet' && exec 2>&-

interface=${interface:-wlan0}
root=${root:-../../}
crackdir=$root/usr/lib/autowifi/plugins
wifi_keys=$root/etc/autowifi/wifi_keys
wifi_log=$root/var/log/autowifi.log

# exists() run_hooks()
. $root/usr/lib/autowifi/lib/core

# start_wpa_supplicant()
. $root/usr/lib/autowifi/lib/wpa_supplicant

crack_wifi(){
    #SSID MAC FREQ ENCRYPTION 

    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
}
wifi_init(){
    wpa_supplicant_is_usable || start_wpa_supplicant /tmp/autowifi.wpa_supplicant
    wifi_scan > /tmp/${interface}.scan
    . /tmp/${interface}.scan
}
loop_over_networks(){
    wifi_init

    echo "SSID:MAC:FREQ:ENCRYPTION:key"
    for i in `seq 1 $WIFI_COUNT`; do
        eval crack_wifi \"\${ESSID_${i}}\" \${MAC_${i}} \${FREQ_${i}} \${ENCRYPTION_${i}} 
    done
}

loop_over_networks