.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::MAC::Vendor 3pm" .TH Net::MAC::Vendor 3pm "2014-10-08" "perl v5.20.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::MAC::Vendor \- look up the vendor for a MAC .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::MAC::Vendor; \& \& my $mac = "00:0d:93:29:f6:c2"; \& \& my $array = Net::MAC::Vendor::lookup( $mac ); .Ve .PP You can also run this as a script with as many arguments as you like. The module realizes it is a script, looks up the information for each \s-1MAC,\s0 and outputs it. .PP .Vb 1 \& perl Net/MAC/Vendor.pm 00:0d:93:29:f6:c2 00:0d:93:29:f6:c5 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Institute of Electrical and Electronics Engineers (\s-1IEEE\s0) assigns an Organizational Unique Identifier (\s-1OUI\s0) to manufacturers of network interfaces. Each interface has a Media Access Control (\s-1MAC\s0) address of six bytes. The first three bytes are the \s-1OUI.\s0 .PP This module allows you to take a \s-1MAC\s0 address and turn it into the \s-1OUI\s0 and vendor information. You can, for instance, scan a network, collect \s-1MAC\s0 addresses, and turn those addresses into vendors. With vendor information, you can often guess at what what you are looking at (e.g. an Apple product). .PP You can use this as a module as its individual functions, or call it as a script with a list of \s-1MAC\s0 addresses as arguments. The module can figure it out. .PP This module tries to persistently cache with DBM::Deep the \s-1OUI\s0 information so it can avoid using the network. If it cannot load DBM::Deep, it uses a normal hash (which is lost when the process finishes). You can preload this cache with the \f(CW\*(C`load_cache()\*(C'\fR function. So far, the module looks in the current working directory for a file named mac_oui.db to find the cache. I need to come up with a way to let the user set that location. .SS "Functions" .IX Subsection "Functions" .ie n .IP "run( @macs )" 4 .el .IP "run( \f(CW@macs\fR )" 4 .IX Item "run( @macs )" If I call this module as a script, this class method automatically runs. It takes the \s-1MAC\s0 addresses and prints the registered vendor information for each address. I can pass it a list of \s-1MAC\s0 addresses and \fIrun()\fR processes each one of them. It prints out what it discovers. .Sp This method does try to use a cache of \s-1OUI\s0 to cut down on the times it has to access the network. If the cache is fully loaded (perhaps using \f(CW\*(C`load_cache\*(C'\fR), it may not even use the network at all. .IP "lookup( \s-1MAC \s0)" 4 .IX Item "lookup( MAC )" Given the \s-1MAC\s0 address, return an anonymous array with the vendor information. The first element is the vendor name, and the remaining elements are the address lines. Different records may have different numbers of lines, although the first two should be consistent. .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formats for \s-1MAC.\s0 .IP "normalize_mac( \s-1MAC \s0)" 4 .IX Item "normalize_mac( MAC )" Takes a \s-1MAC\s0 address and turns it into the form I need to send to the \s-1IEEE\s0 lookup, which is the first six bytes in hex separated by hyphens. For instance, 00:0d:93:29:f6:c2 turns into 00\-0D\-93. .Sp The input string can be a separated by colons or hyphens. They can omit leading 0's (which might make things look odd). We only need the first three bytes .Sp .Vb 1 \& 00:0d:93:29:f6:c2 # usual form \& \& 00\-0d\-93\-29\-f6\-c2 # with hyphens \& \& 00:0d:93 # first three bytes \& \& 0:d:93 # missing leading zero \& \& :d:93 # missing all leading zeros .Ve .IP "fetch_oui( \s-1MAC \s0)" 4 .IX Item "fetch_oui( MAC )" Looks up the \s-1OUI\s0 information on the \s-1IEEE\s0 website, or uses a cached version of it. Pass it the result of \f(CW\*(C`normalize_mac()\*(C'\fR and you should be fine. .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formants for \&\s-1MAC.\s0 .Sp To avoid multiple calls on the network, use \f(CW\*(C`load_cache\*(C'\fR to preload the entire \s-1OUI\s0 space into an in-memory cache. This can take a long time over a slow network, though; the file is about 60,000 lines. .IP "fetch_oui_from_ieee( \s-1MAC \s0)" 4 .IX Item "fetch_oui_from_ieee( MAC )" Looks up the \s-1OUI\s0 information on the \s-1IEEE\s0 website. Pass it the result of \f(CW\*(C`normalize_mac()\*(C'\fR and you should be fine. .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formants for \&\s-1MAC.\s0 .IP "fetch_oui_from_cache( \s-1MAC \s0)" 4 .IX Item "fetch_oui_from_cache( MAC )" Looks up the \s-1OUI\s0 information in the cached \s-1OUI\s0 information (see \&\f(CW\*(C`load_cache\*(C'\fR). .Sp The \f(CW\*(C`normalize_mac()\*(C'\fR function explains the possible formats for \&\s-1MAC.\s0 .Sp To avoid multiple calls on the network, use \f(CW\*(C`load_cache\*(C'\fR to preload the entire \s-1OUI\s0 space into an in-memory cache. .Sp If it doesn't find the \s-1MAC\s0 in the cache, it returns nothing. .IP "extract_oui_from_html( \s-1HTML, OUI \s0)" 4 .IX Item "extract_oui_from_html( HTML, OUI )" Gets rid of the \s-1HTML\s0 around the \s-1OUI\s0 information. It may still be ugly. The \s-1HTML\s0 is the search results page of the \s-1IEEE\s0 ouisearch lookup. .Sp Returns false if it could not extract the information. This could mean unexpected input or a change in format. .IP "parse_oui( \s-1STRING \s0)" 4 .IX Item "parse_oui( STRING )" Takes a string that looks like this: .Sp .Vb 5 \& 00\-03\-93 (hex) Apple Computer, Inc. \& 000393 (base 16) Apple Computer, Inc. \& 20650 Valley Green Dr. \& Cupertino CA 95014 \& UNITED STATES .Ve .Sp and turns it into an array of lines. It discards the first line, strips the leading information from the second line, and strips the leading whitespace from all of the lines. .Sp With no arguments, it returns an empty anonymous array. .IP "load_cache( [ \s-1SOURCE \s0] )" 4 .IX Item "load_cache( [ SOURCE ] )" Downloads the current list of all OUIs, parses it with \f(CW\*(C`parse_oui()\*(C'\fR, and stores it in \f(CW$Cached\fR anonymous hash keyed by the OUIs (i.e. 00\-0D\-93). The \f(CW\*(C`fetch_oui()\*(C'\fR will use this cache if it exists. .Sp By default, this uses \f(CW\*(C`http://standards.ieee.org/regauth/oui/oui.txt\*(C'\fR, but given an argument, it tries to use that. To load from a local file, use the \f(CW\*(C`file://\*(C'\fR scheme. .Sp If \f(CW\*(C`load_cache\*(C'\fR cannot load the data, it issues a warning and returns nothing. .Sp This previously used DBM::Deep if it was installed, but that was much too slow. Instead, if you want persistence, you can play with \&\f(CW$Net::MAC::Vendor::Cached\fR yourself. .SH "SEE ALSO" .IX Header "SEE ALSO" Net::MacMap .SH "SOURCE AVAILABILITY" .IX Header "SOURCE AVAILABILITY" The source is in Github: .PP .Vb 1 \& git://github.com/briandfoy/net\-mac\-vendor.git .Ve .SH "AUTHOR" .IX Header "AUTHOR" brian d foy \f(CW\*(C`\*(C'\fR .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (c) 2004\-2014 brian d foy. All rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.