Differences between revisions 2 and 3
Revision 2 as of 2019-09-18 09:03:36
Size: 1632
Editor: asbesto
Comment:
Revision 3 as of 2019-09-18 09:15:15
Size: 3071
Editor: asbesto
Comment:
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
$1 == "BSS" {
    MAC = $2
    wifi[MAC]["enc"] = "Open"

#!/usr/bin/env awk -f

$1 ~ /^BSS/ {
    if($2 !~ /Load:/) { #< Escape "BBS Load:" line
        gsub("(\\(.*|:)", "", $2)
        MAC = toupper($2)
        wifi[MAC]["enc"] = "OPEN"
        wifi[MAC]["WPS"] = "no"
        wifi[MAC]["wpa1"] = ""
        wifi[MAC]["wpa2"] = ""
        wifi[MAC]["wep"] = ""
    }
Line 15: Line 25:
    # Workaround spaces in SSID
    FS=":" #< Changing field separator on ":", it should be
           # forbidded sign for SSID name
    $0=$0
    sub(" ", "", $2) #< remove first whitespace
Line 16: Line 31:
    FS=" "
    $0=$0
Line 17: Line 34:
$1 == "freq:" {
    wifi[MAC]["freq"] = $NF
$1 == "capability:" {
    for(i=2; i<=NF; i++) {
        if($i ~ /0x[0-9]{4}/) {
            gsub("(\\(|\\))", "", $i)
            if (and(strtonum($i), 0x10))
                wifi[MAC]["wep"] = "WEP"
        }
    }
}
$1 == "WPA:" {
    wifi[MAC]["wpa1"] = "WPA1"
}
$1 == "RSN:" {
    wifi[MAC]["wpa2"] = "WPA2"
}
$1 == "WPS:" {
    wifi[MAC]["WPS"] = "yes"
}
$1 == "DS" {
    wifi[MAC]["Ch"] = $5
Line 21: Line 56:
    wifi[MAC]["sig"] = $2 " " $3     match($2, /-([0-9]{2})\.00/, m)
    wifi[MAC]["Sig"] = m[1]
Line 23: Line 59:
$1 == "WPA:" {
    wifi[MAC]["enc"] = "WPA"
}
$1 == "WEP:" {
    wifi[MAC]["enc"] = "WEP"
$1 == "TSF:" {
    gsub("(\\(|d|,)", "", $4)
    match($5, /([0-9]{2}):([0-9]{2}):/, m)
    day = $4
    hour = m[1]
    min = m[2]
    wifi[MAC]["TSF"] = day"d"hour"h"min"m"
Line 30: Line 68:
    printf "%s, %s, %s, %s\n","SSID","Encryption","Signal","Frequency"
Line 33: Line 69:
        printf "%s, %s, %s, %s\n",wifi[w]["SSID"],wifi[w]["enc"],wifi[w]["sig"],wifi[w]["freq"]         if (wifi[w]["wep"]) {
            if (wifi[w]["wpa1"] || wifi[w]["wpa2"])
                wifi[w]["enc"] = wifi[w]["wpa1"]wifi[w]["wpa2"]
            else
                wifi[w]["enc"] = "WEP"
        }
        printf "%s:%s:%s:%s:%s:%s:%s\n", w, wifi[w]["SSID"], wifi[w]["enc"], \
               wifi[w]["WPS"], wifi[w]["Ch"], wifi[w]["Sig"], wifi[w]["TSF"]
Line 36: Line 79:
Line 37: Line 81:
Line 41: Line 86:
root@rover:/home/asbesto# iw wlan0 scan | awk -f scan.awk
SSID, Encryption, Signal, Frequency
Linkem2.4GHz_51F02C, Open, -76.00 dBm, 2462
mynetworch23, Open, -83.00 dBm, 5300
Vodafone-WiFi, Open, -77.00 dBm, 5180
Telecom-61991747, WPA, -84.00 dBm, 5520
Vodafone-WiFi, Open, -75.00 dBm, 2467
Home, WPA, -70.00 dBm, 2412
Vodafone-WiFi, Open, -57.00 dBm, 2442
Wiremore, Open, -28.00 dBm, 2437
FASTWEB-D67AA9(2.4ghz), WPA, -68.00 dBm, 2412
Vodafone-A46124408, Open, -77.00 dBm, 2467
VodafoneMontedoro, Open, -77.00 dBm, 5180
Telecom-61991747, WPA, -74.00 dBm, 2462
VodafoneMontedoro, Open, -58.00 dBm, 2442
tvccSiracusa, Open, -77.00 dBm, 5200
FASTWEB-D67AA9(5ghz), Open, -67.00 dBm, 5500

root@rover:/home/asbesto# iw wlan0 scan | awk -f parsa.awk
1C497B51F02D:Linkem2.4GHz_51F02C:WPA2:yes:11:76:12d23h25m
E48F34776815:Vodafone-A46124408:WPA2:yes:12:70:1d07h59m
A491B178032E:FASTWEB-78032E:WPA2:yes:1:82:0d11h45m
121331D67AA8:WOW FI - FASTWEB:WPA2:no:1:52:27d15h05m
5CE28C90FA0E:Infostrada-90FA0D:WPA1WPA2:yes::86:6d10h53m
64700239143D:Home:WPA1WPA2:yes:1:67:5d18h35m
BA9E639DB4E7:Wiremore:WPA2:no:6:27:0d01h35m
101331D67AA9:FASTWEB-D67AA9(2.4ghz):WPA2:yes:1:51:27d15h05m
30918F9DAD43:Telecom-61991747:WPA1WPA2:yes:11:76:40d15h04m
04F0211B577E:tvccSiracusa:WPA2:no::78:119d10h29m
E48F34564F0C:VodafoneMontedoro:WPA2:yes:7:58:1d03h07m
4C5E0C61E196:mynetworch23:WPA2:no::82:119d10h31m
121331D67AB1:FASTWEB-D67AA9(5ghz):WPA2:yes::66:28d04h46m
E48F34564F0E:Vodafone-WiFi:OPEN:no:7:58:1d03h07m
A691B178032D:WOW FI - FASTWEB:WPA2:no:1:72:0d11h45m
628F34776816:Vodafone-WiFi:OPEN:no:12:70:1d07h59m
root@rover:/home/asbesto#

Perche' BASH VINCE, DIOPORCO

Scan delle reti wifi presenti

iw wlan0 scan e un colpo di grep diocane:

Andiamo di awk

$1 ~ /^BSS/ {
    if($2 !~ /Load:/) { #< Escape "BBS Load:" line
        gsub("(\\(.*|:)", "", $2)
        MAC = toupper($2)
        wifi[MAC]["enc"] = "OPEN"
        wifi[MAC]["WPS"] = "no"
        wifi[MAC]["wpa1"] = ""
        wifi[MAC]["wpa2"] = ""
        wifi[MAC]["wep"] = ""
    }
}
$1 == "SSID:" {
    # Workaround spaces in SSID
    FS=":" #< Changing field separator on ":", it should be
           #  forbidded sign for SSID name
    $0=$0
    sub(" ", "", $2) #< remove first whitespace
    wifi[MAC]["SSID"] = $2
    FS=" "
    $0=$0
}
$1 == "capability:" {
    for(i=2; i<=NF; i++) {
        if($i ~ /0x[0-9]{4}/) {
            gsub("(\\(|\\))", "", $i)
            if (and(strtonum($i), 0x10)) 
                wifi[MAC]["wep"] = "WEP"
        }
    }
}
$1 == "WPA:" {
    wifi[MAC]["wpa1"] = "WPA1"
}
$1 == "RSN:" {
    wifi[MAC]["wpa2"] = "WPA2"
}
$1 == "WPS:" {
    wifi[MAC]["WPS"] = "yes"
}
$1 == "DS" {
    wifi[MAC]["Ch"] = $5
}
$1 == "signal:" {
    match($2, /-([0-9]{2})\.00/, m)
    wifi[MAC]["Sig"] = m[1]
}
$1 == "TSF:" {
    gsub("(\\(|d|,)", "", $4)
    match($5, /([0-9]{2}):([0-9]{2}):/, m)
    day = $4
    hour = m[1]
    min = m[2]
    wifi[MAC]["TSF"] = day"d"hour"h"min"m"
}
END {
    for (w in wifi) {
        if (wifi[w]["wep"]) {
            if (wifi[w]["wpa1"] || wifi[w]["wpa2"])
                wifi[w]["enc"] = wifi[w]["wpa1"]wifi[w]["wpa2"]
            else
                wifi[w]["enc"] = "WEP"
        }
        printf "%s:%s:%s:%s:%s:%s:%s\n", w, wifi[w]["SSID"], wifi[w]["enc"], \
               wifi[w]["WPS"], wifi[w]["Ch"], wifi[w]["Sig"], wifi[w]["TSF"]
    }
}

il risultato soddisfa:

root@rover:/home/asbesto# iw wlan0 scan | awk -f parsa.awk
1C497B51F02D:Linkem2.4GHz_51F02C:WPA2:yes:11:76:12d23h25m
E48F34776815:Vodafone-A46124408:WPA2:yes:12:70:1d07h59m
A491B178032E:FASTWEB-78032E:WPA2:yes:1:82:0d11h45m
121331D67AA8:WOW FI - FASTWEB:WPA2:no:1:52:27d15h05m
5CE28C90FA0E:Infostrada-90FA0D:WPA1WPA2:yes::86:6d10h53m
64700239143D:Home:WPA1WPA2:yes:1:67:5d18h35m
BA9E639DB4E7:Wiremore:WPA2:no:6:27:0d01h35m
101331D67AA9:FASTWEB-D67AA9(2.4ghz):WPA2:yes:1:51:27d15h05m
30918F9DAD43:Telecom-61991747:WPA1WPA2:yes:11:76:40d15h04m
04F0211B577E:tvccSiracusa:WPA2:no::78:119d10h29m
E48F34564F0C:VodafoneMontedoro:WPA2:yes:7:58:1d03h07m
4C5E0C61E196:mynetworch23:WPA2:no::82:119d10h31m
121331D67AB1:FASTWEB-D67AA9(5ghz):WPA2:yes::66:28d04h46m
E48F34564F0E:Vodafone-WiFi:OPEN:no:7:58:1d03h07m
A691B178032D:WOW FI - FASTWEB:WPA2:no:1:72:0d11h45m
628F34776816:Vodafone-WiFi:OPEN:no:12:70:1d07h59m
root@rover:/home/asbesto#

Estrazione degli ESSID

Verifica con db esistente

files /etc/network/interface.ESSID bello e pronto

Mi connetto

service networking start, non serve altro porcodio

vaffanculo

MyConnectionManager (last edited 2020-03-01 11:21:33 by asbesto)