getmac.sh
#!/bin/sh
cat oui.txt|sed -e :a -e '$!N;s/\n\s/=/;ta' -e 'P;D' | sed 's/(hex)\+/=/g' | sed 's/,/ /g' | sed 's/^\s/,/' | awk -F '=' '{print($1","$3","$2","$NF)}' | sort | sed '1s/^/Brand,Vendor,MAC address,Country/' >_MAC.csv
getmac.py
# coding: utf-8
import csv
import string
import re
array=("alcatel",
"alps",
"amoi",
"apple",
"asus",
"Asustek",
"changhong",
"bird",
"Blackberry",
"Datang",
"dopod",
"ericsson",
"gionee",
"google",
"Haier",
"htc",
"Hisense",
"huawei",
"htc",
"INFOCUS",
"Konka",
"koobee",
"LG",
"lenovo",
"meizu",
"Motorola",
"Newman",
"NOKIA",
"OPPO",
"SONY",
"samsung",
"SHARP",
"philips",
"sonim",
"tcl",
"THL",
"Tianyu",
"veaka",
"VEB",
"vivo",
"xiaomi",
"yotaphone",
"yulong",
"zte corporation",
"mediatek",
"qualcomm",
"micromax",
"spice",
"Karbonn",
"Lava",
"Intex",
"Celkon"
"kyocera",
"Pantech",
"Palm",
"smartisan"
)
brand_count=len(array)
csvfile = open('____MAC.csv', 'wb')
writer=csv.writer(csvfile)
flag=0
def string_found(string1, string2):
if re.search(r"\b" + re.escape(string1) + r"\b", string2):
return 1
return -1
for line in open("_MAC.csv"):
brand,vendor,macaddress,country = line.split(",")
brand = brand.strip(' \t\r\n');
vendor = vendor.strip(' \t\r\n');
macaddress = macaddress.strip(' \t\r\n');
country = country.strip(' \t\r\n');
vendor1=vendor.upper();
for i in range(0,brand_count):
if (string_found(array[i].upper(),vendor1)!=-1):
writer.writerow([array[i].upper(),vendor,macaddress,country])
flag=1
break
if(flag==0):
writer.writerow([brand ,vendor ,macaddress,country])
flag=0
csvfile.close()
print "Total",len(array),"main vendors created in ____MAC.csv"