50 lines
1.3 KiB
Text
50 lines
1.3 KiB
Text
|
#!/usr/bin/perl
|
||
|
|
||
|
use warnings;
|
||
|
use strict;
|
||
|
use Text::CSV;
|
||
|
|
||
|
binmode STDIN, ':utf8';
|
||
|
|
||
|
my ($lineno, $entry, $registry, $mac, $vendor, $address);
|
||
|
|
||
|
my $csv = Text::CSV->new({
|
||
|
allow_loose_quotes => 1,
|
||
|
auto_diag => 1,
|
||
|
binary => 1,
|
||
|
eol => $/
|
||
|
});
|
||
|
|
||
|
open OUI, ">:encoding(utf8)", "ieee-oui.txt" || die "Could not open ieee-oui.txt for writing";
|
||
|
open DAT, ">:encoding(utf8)", "ethercodes.dat" || die "Could not open ethercodes.dat for writing";
|
||
|
open AIR, ">:encoding(utf8)", "aircrack-oui.txt" || die "Could not open oui.txt for writing";
|
||
|
|
||
|
$csv->bind_columns (\$registry, \$mac, \$vendor, \$address);
|
||
|
|
||
|
while ($csv->getline(*STDIN)) {
|
||
|
$lineno++;
|
||
|
next if ($mac eq 'Assignment');
|
||
|
$entry++;
|
||
|
print OUI "$mac\t$vendor\n";
|
||
|
|
||
|
# skip >24-bit vendors for aircrack-ng and arpwatch
|
||
|
next if (length($mac) ne 6);
|
||
|
|
||
|
printf AIR "%s-%s-%s (hex)\t\t%s\n", substr($mac,0,2), substr($mac,2,2), substr($mac,4,2), $vendor;
|
||
|
|
||
|
# arpwatch doesn't want a leading 0
|
||
|
$mac = lc($mac);
|
||
|
print DAT substr($mac,0,1) unless substr($mac,0,1) eq '0';
|
||
|
print DAT substr($mac,1,1), ':';
|
||
|
print DAT substr($mac,2,1) unless substr($mac,2,1) eq '0';
|
||
|
print DAT substr($mac,3,1), ':';
|
||
|
print DAT substr($mac,4,1) unless substr($mac,4,1) eq '0';
|
||
|
print DAT substr($mac,5,1);
|
||
|
print DAT "\t$vendor\n";
|
||
|
}
|
||
|
|
||
|
close OUI;
|
||
|
close DAT;
|
||
|
close AIR;
|
||
|
print STDERR "$entry entries\n";
|