netcrawl.tools.manuf package

Submodules

netcrawl.tools.manuf.manuf module

Parser library for Wireshark’s OUI database.

Converts MAC addresses into a manufacturer using Wireshark’s OUI database.

See README.md.

class netcrawl.tools.manuf.manuf.MacParser(manuf_name='/home/docs/checkouts/readthedocs.org/user_builds/netcrawl/checkouts/latest/netcrawl/tools/manuf/manuf', update=False)[source]

Bases: object

Class that contains a parser for Wireshark’s OUI database.

Optimized for quick lookup performance by reading the entire file into memory on initialization. Maps ranges of MAC addresses to manufacturers and comments (descriptions). Contains full support for netmasks and other strange things in the database.

See https://www.wireshark.org/tools/oui-lookup.html

Parameters:
  • manuf_name (str) – Location of the manuf database file. Defaults to “manuf” in the same directory.
  • update (bool) – Whether to update the manuf file automatically. Defaults to False.
Raises:

IOError – If manuf file could not be found.

MANUF_URL = 'https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf'
get_all(mac)[source]

Get a Vendor tuple containing (manuf, comment) from a MAC address.

Parameters:mac (str) – MAC address in standard format.
Returns:Vendor namedtuple containing (manuf, comment). Either or both may be None if not found.
Return type:Vendor
Raises:ValueError – If the MAC could not be parsed.
get_comment(mac)[source]

Returns comment from a MAC address.

Parameters:mac (str) – MAC address in standard format.
Returns:String containing comment, or None if not found.
Return type:string
Raises:ValueError – If the MAC could not be parsed.
get_manuf(mac)[source]

Returns manufacturer from a MAC address.

Parameters:mac (str) – MAC address in standard format.
Returns:String containing manufacturer, or None if not found.
Return type:string
Raises:ValueError – If the MAC could not be parsed.
refresh(manuf_name=None)[source]

Refresh/reload manuf database. Call this when manuf file is updated.

Parameters:manuf_name (str) – Location of the manuf data base file. Defaults to “manuf” in the same directory.
Raises:IOError – If manuf file could not be found.
search(mac, maximum=1)[source]

Search for multiple Vendor tuples possibly matching a MAC address.

Parameters:
  • mac (str) – MAC address in standard format.
  • maximum (int) – Maximum results to return. Defaults to 1.
Returns:

List of Vendor namedtuples containing (manuf, comment), with closest result first. May be empty if no results found.

Raises:

ValueError – If the MAC could not be parsed.

update(manuf_url=None, manuf_name=None, refresh=True)[source]

Update the Wireshark OUI database to the latest version.

Parameters:
  • manuf_url (str) – URL pointing to OUI database. Defaults to database located at code.wireshark.org.
  • manuf_name (str) – Location to store the new OUI database. Defaults to “manuf” in the same directory.
  • refresh (bool) – Refresh the database once updated. Defaults to True. Uses database stored at manuf_name.
Raises:

URLError – If the download fails

class netcrawl.tools.manuf.manuf.Vendor(manuf, comment)

Bases: tuple

comment

Alias for field number 1

manuf

Alias for field number 0

netcrawl.tools.manuf.manuf.main()[source]

Simple command line wrapping for MacParser.

Module contents