Created
March 21, 2019 01:57
-
-
Save mpurzynski/a83e8624457149cb0d79440e81b420e3 to your computer and use it in GitHub Desktop.
lookup mac addresses in the oui database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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