scripts/scan.awk: add script to scan IPv6 link local
This commit is contained in:
parent
97292aa847
commit
85bf0db0a3
29
scripts/scan.awk
Normal file
29
scripts/scan.awk
Normal file
@ -0,0 +1,29 @@
|
||||
BEGIN {
|
||||
"nix build -f '<nixpkgs>' nmap --no-link --json | jq -r '.[0].outputs.out'"|getline nmap
|
||||
db = nmap"/share/nmap/nmap-mac-prefixes"
|
||||
while((getline line < db) > 0)
|
||||
{
|
||||
n = split(line, rec, " ");
|
||||
prefix = rec[1]
|
||||
vendors[prefix] = rec[2]
|
||||
for (i=3; i<n; i++)
|
||||
vendors[prefix] = vendors[prefix]" "rec[i]
|
||||
}
|
||||
FS=" |%"
|
||||
}
|
||||
|
||||
/ff:fe/ {
|
||||
eui64 = $4
|
||||
eui48 = eui64
|
||||
gsub(/ff:fe|fe80::/, "", eui48)
|
||||
gsub(":", "", eui48)
|
||||
mac = xor(strtonum("0x"eui48), lshift(1, 41))
|
||||
prefix = substr(sprintf("%X", mac), 0, 6)
|
||||
mac = sprintf("%012x", mac)
|
||||
prettymac = ""
|
||||
for (i=0; i<=6; i++)
|
||||
{ prettymac = prettymac substr(mac,2*i+1,2)
|
||||
if (i < 5) prettymac = prettymac":"
|
||||
}
|
||||
printf("%25s\t%s\t%s\n", eui64, prettymac, vendors[prefix])
|
||||
}
|
Loading…
Reference in New Issue
Block a user