-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathana
More file actions
executable file
·35 lines (28 loc) · 749 Bytes
/
ana
File metadata and controls
executable file
·35 lines (28 loc) · 749 Bytes
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
#!/usr/bin/perl
# don't show incomplete rows
# show manufacturer of device based off of MAC (OUI)
my $ARP = "/usr/sbin/arp";
my $filename = "/b/data/oui.bdb" ;
my %h;
use strict;
use BerkeleyDB;
tie %h, "BerkeleyDB::Hash",
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
print map { s/((\w+:\w+:\w+):\w+:\w+:\w+) /$1 . " (" . mac($2) . ") "/e if !/(ff:){5}/; $_ } grep { !/\(incomplete\)/ } `$ARP -na`;
sub mac
{
my $mac = shift;
$mac =~ s/:(.):/:0$1:/g;
$mac =~ s/:(.)$/:0$1/g;
$mac =~ s/^(.):/0$1:/g;
$mac =~ s/\W//g;
$mac = lc($mac);
$mac = $h{$mac};
$mac =~ s/^(.*?)\n.*$/$1/s;
$mac =~ s/,? inc\.?$//i;
$mac =~ s/^\s*//;
$mac =~ s/\s*$//;
return $mac || "?";
}