-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathiwscan
executable file
·62 lines (57 loc) · 1.31 KB
/
iwscan
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
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
##
## List wireless access points in line-by-line format
## Copyright (c) 2013-2022 SATOH Fumiyasu @ OSSTech Corp., Japan
##
## License: GNU General Public License version 3
##
set -u
if [ X"`id |sed 's/).*//;s/.*(//'`" != X"root" ]; then
exec sudo -u root "$0" ${1+"$@"}
exit $?
fi
if [ "${1+set}" ]; then
if="$1"; shift
else
if=$(iwconfig 2>/dev/null|sed -n '/^[a-z][a-z0-9]* *IEEE 802\.11/ { s/ .*//; p; q; }')
fi
iwlist "$if" scan \
|sed 's/^\( *Cell\) \([0-9]*\) - /\1\t\2\n/;s/^ *\([^:=]*\)[:=] */\1\t/' \
|awk '
BEGIN {
FS = "\t"
}
info["Channel"] > 0 && ($1 == "Cell" || $1 == "") {
if (info["Encryption"] == "?") {
info["Encryption"] = "WEP?"
}
printf "%3d %-5s %-8s %-42s %s\n",
info["Channel"],
info["Quality"],
info["Mode"],
info["ESSID"],
info["Encryption"],
""
;
delete info
info["Encryption"] = "-"
}
{
info[$1] = $2
if ($1 == "Quality") {
sub(/ .*/, "", info[$1])
}
}
$1 == "Encryption key" && $2 == "on" {
info["Encryption"] = "?"
}
$1 == "IE" && $2 ~ /WPA/ {
enc = $2
sub(/^IEEE 802\.11i\//, "", enc)
sub(/ Version /, " v", enc)
info["Encryption"] = (info["Encryption"] == "?") ? "" : info["Encryption"] ","
info["Encryption"] = info["Encryption"] enc
}
' \
|sort -n \
;