backporting @rubfi #638 PR vendorlist

This commit is contained in:
tobozo 2017-10-14 10:02:59 +02:00
parent 81df4f1c52
commit 4b7ef2bc70
4 changed files with 24068 additions and 22892 deletions

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,8 @@
<a href="https://github.com/SamuelKlit" target="_blank">@SamuelKlit</a> (Samuel KS)<br />
<a href="https://github.com/schinfo" target="_blank">@schinfo</a> (Helmut)<br />
<a href="https://github.com/ajnavarro" target="_blank">@ajnavarro</a> (Antonio Navarro Perez)<br />
<a href="https://github.com/rubfi" target="_blank">rubfi</a><br />
<br />
Also special thanks to <a href="https://github.com/deantonious" target="_blank">@deantonious</a> for the help with the webdesign!<br />
<br />

23983
esp8266_deauther/oui.h Normal file

File diff suppressed because it is too large Load Diff

81
utils/update_manuf.py Normal file
View File

@ -0,0 +1,81 @@
#/usr/bin/env python
"""This scripts downloads the last OUI manufaturer file from the Whireshark
project and converts it to esp8266_deauther format"""
import argparse
from urllib.request import urlopen
WS_MANUF_FILE_URL = "https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf"
def parse_options():
"""Parses command line options"""
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="Output file name (e.g oui.h)")
parser.add_argument("-u", "--url", help="Wireshark oui/manuf file url")
opt = parser.parse_args()
return opt
def generate_oui_h(url, filename):
"""Generates the vendors/oui file"""
if url:
data = urlopen(url)
else:
data = urlopen(WS_MANUF_FILE_URL)
out = """#ifndef oui_h
#define oui_h
/*
Based on Wireshark manufacturer database
source: https://www.wireshark.org/tools/oui-lookup.html
Wireshark is released under the GNU General Public License version 2
*/
const static uint8_t data_vendors[] PROGMEM = {///*
"""
for line in data:
line = line.decode()
# Skipping empty lines and comments
if line.startswith('#') or line.startswith('\n'):
continue
mac, short_desc, *rest = line.strip().split('\t')
# Limiting short_desc to 8 chars
short_desc = short_desc[0:8]
# Convert to ascii
short_desc = short_desc.encode("ascii", "ignore").decode()
mac_octects = len(mac.split(':'))
if mac_octects == 6:
continue
else:
# Convert to esp8266_deauther format
short_desc = short_desc.ljust(8, '\0')
hex_sdesc = ", 0x".join("{:02x}".format(ord(c)) for c in short_desc)
(oc1, oc2, oc3) = mac.split(':')
out = out + (" 0x{}, 0x{}, 0x{}, 0x{},\n".format(oc1.upper(), oc2.upper(), oc3.upper(),
hex_sdesc.upper().replace('X', 'x')))
out = out[:-2] # Removing last comma
out = out + "\n};\n#endif"
# Saving to file
if filename:
with open(filename, 'w') as out_file:
out_file.write("%s" % out)
else:
print(out)
if __name__ == "__main__":
options = parse_options()
generate_oui_h(options.url, options.output)