Skip to content

Instantly share code, notes, and snippets.

@mpurzynski
Created March 21, 2019 01:57
Show Gist options
  • Save mpurzynski/a83e8624457149cb0d79440e81b420e3 to your computer and use it in GitHub Desktop.
Save mpurzynski/a83e8624457149cb0d79440e81b420e3 to your computer and use it in GitHub Desktop.
lookup mac addresses in the oui database
ouifilename = "oui.txt"
with open(ouifilename) as ouifile:
macassignments = {}
for i in ouifile.readlines()[0::]:
i = i.strip()
if "(hex)" in i:
fields = i.split("\t")
macprefix = fields[0][0:8].replace("-", ":").lower()
entity = fields[2]
macassignments[macprefix] = entity
with open("lmacs.csv") as macs:
pmacs = macs.read().splitlines()
for mac in pmacs:
cmac = mac[0:8].lower()
if cmac in macassignments:
print("{0} {1}".format(mac, macassignments[cmac]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment