30 lines
776 B
Awk
30 lines
776 B
Awk
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])
|
|
}
|