[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4447
  • Last Modified:

Script to resolve MAC address to Vendor list

Hello, I have a list of 6000 mac address. I have downloaded the oui.txt file from IEEE of the vendors. I would like to run the 6000 mac address against the oui.txt. What would be th best way to go ?
I have tries to sort them and get the names of the Vendors. I would like to just get the counts/persentage of the vendor mac for a pie chart. The Mac addr are the wireless card used in our enterprise. To draw the pie chart I have a php script.

http://standards.ieee.org/regauth/oui/oui.txt it looks like this..
00-00-00   (hex)            XEROX CORPORATION
000000     (base 16)            XEROX CORPORATION
                        M/S 105-50C
                        800 PHILLIPS ROAD
                        WEBSTER NY 14580

00-00-01   (hex)            XEROX CORPORATION
000001     (base 16)            XEROX CORPORATION
                        ZEROX SYSTEMS INSTITUTE
                        M/S 105-50C 800 PHILLIPS ROAD
                        WEBSTER NY 14580
---------------------------------------------------------------------------------------
my mac addr .txt file looks like this..
00e098a32b78
00e098a32bd0
00e098a34b4c
00e098a34c4c
00e098a34c5a
00e098a35d68
00e098a36598
...
---------------------

Thanks in advance.
0
amitubale
Asked:
amitubale
  • 2
1 Solution
 
fim32Commented:
well, as you can see, the vendor string is the first 6 hex digits... so i would go through your mac list and organize them by the first 6 digits, and count those.  then it'll be a lot easier to compare them against the oui.txt list.

in fact, i'm sure you'll reduce yourself to a handful of vendors...
0
 
MercantilumCommented:
Maybe something like

use strict;

my %mac;

# get mac data
open F, "mac.txt" or die "mac.txt: $!";
while (<F>) { $mac{lc(substr($_,0,6))}++; }
close F;

my %oui;

# get oui data
open F, "oui.txt" or die "oui.txt: $!";
while (<F>)
{
  if (/^[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]/i)
  {
     chomp;
     @_ = split /[()]/;
     $_[0] =~ s/-//g;
     $_[2] =~ s/^[\t\s]+//;
     $oui{lc(substr($_[0], 0, 6))} = $_[2];
  }
}
close F;

# print list of mac sorted
for (sort { $mac{$a} <=> $mac{$b} } keys %mac)
{
   my $vendor = (exists $oui{$_} ? $oui{$_}:"???");
   print "Mac: $_ Vendor: $vendor Number: $mac{$_}\n";
}
0
 
amitubaleAuthor Commented:
Hello Mercantilum
Thank you for the soution, I hardly know any perl but I wrote 4 different scripts to do various functions on my mac address list. You solution is perfect for what I am trying to do. FYI the list of MAC are all the wireless users in our enterprise ..not i will dig out a php script to chart a nice pie chart on a web server.

Thank you.
Amit

I also found another one http://net.doit.wisc.edu/~plonka/mac2vendor/

0
 
MercantilumCommented:
My pleasure :)
Interesting file Mac / vendors.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now