forked from samtap/fang-hacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iwlist.awk
executable file
·46 lines (37 loc) · 1011 Bytes
/
iwlist.awk
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
#!/bin/sh
awk '
BEGIN { OFS = "\t"; }
/\<Cell/ {
# Print previous AP
if (wpa) {
security = "WPA"
} else if (wep) {
security = "WEP"
} else {
security = "None"
}
if (essid) print essid, address, security, quality;
# Reset security flags.
wep = 0; wpa = 0;
address = $5
}
/\<ESSID:/ {
essid = substr($0, index($0, ":") + 1);
essid = substr(essid, 2, length(essid) - 2) # discard quotes
}
/\<Quality/ {
split($1, q, "[:=]"); # q[1] -> "Quality", q[2] -> value
split(q[2], qvalues, "/");
if (qvalues[2]) {
quality = int(qvalues[1] / qvalues[2] * 100); # we have both parts, divide
} else {
quality = qvalues[1]; # we have only one part, use it as-is
}
}
/\<Encryption key:(o|O)n/ { wep = 1 }
/\<IE:.*WPA.*/ { wpa = 1 }
END {
# Print last AP
if (wpa) { security = "WPA" } else { if (wep) { security = "WEP" } else { security = "None" }}
if (essid) print essid, address, security, quality;
}'