Solved

Script to resolve MAC address to Vendor list

Posted on 2004-04-29
4
4,042 Views
Last Modified: 2010-08-05
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
Comment
Question by:amitubale
  • 2
4 Comments
 
LVL 7

Expert Comment

by:fim32
ID: 10952166
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
 
LVL 10

Accepted Solution

by:
Mercantilum earned 50 total points
ID: 10958146
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
 
LVL 1

Author Comment

by:amitubale
ID: 10962502
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
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10962536
My pleasure :)
Interesting file Mac / vendors.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now