scripts/scan.awk: add script to scan IPv6 link local

This commit is contained in:
Michele Guerini Rocco 2023-03-07 18:18:46 +01:00
parent 97292aa847
commit 85bf0db0a3
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

29
scripts/scan.awk Normal file
View 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])
}