diff --git a/scapy/arch/windows/__init__.py b/scapy/arch/windows/__init__.py index c6b345a01991b89b58d0dd94f5250e9dfcbda8ad..5968fc2f76f0a30c8777ed7e2bf44009ceae0ea7 100755 --- a/scapy/arch/windows/__init__.py +++ b/scapy/arch/windows/__init__.py @@ -6,11 +6,13 @@ """ Customizations needed to support Microsoft Windows. """ + import os,re,sys,socket,time, itertools import subprocess as sp from glob import glob import tempfile +#import scapy.data from scapy.config import conf, ConfClass from scapy.error import Scapy_Exception, log_loading, log_runtime, warning from scapy.utils import atol, itom, inet_aton, inet_ntoa, PcapReader @@ -259,6 +261,9 @@ class WinProgPath(ConfClass): ) self.cscript = win_find_exe("cscript", installsubdir="System32", env="SystemRoot") + if self.wireshark != "wireshark": + manu_path = load_manuf(os.path.sep.join(self.wireshark.split(os.path.sep)[:-1])+os.path.sep+"manuf") + scapy.data.MANUFDB = conf.manufdb = MANUFDB = manu_path conf.prog = WinProgPath() if conf.prog.powershell == "powershell": diff --git a/scapy/data.py b/scapy/data.py index 5a46311957afe11df02e8d0d090308766e32c0dd..14cb15e3847b0c8c5ce58c434c6795c1755bc30f 100644 --- a/scapy/data.py +++ b/scapy/data.py @@ -147,7 +147,8 @@ class ManufDA(DADict): if oui in self: return ":".join([self[oui][0]]+ mac.split(":")[3:]) return mac - + def __repr__(self): + return "\n".join(["<%s %s, %s>" % (i[0], i[1][0], i[1][1]) for i in self.__dict__.items()]) @@ -165,12 +166,12 @@ def load_manuf(filename): lng=shrt else: lng = l[i+2:] - manufdb[oui] = shrt,lng + manufdb[oui] = shrt, lng except Exception,e: log_loading.warning("Couldn't parse one line from [%s] [%r] (%s)" % (filename, l, e)) except IOError: #log_loading.warning("Couldn't open [%s] file" % filename) - pass + return "" return manufdb @@ -179,6 +180,7 @@ if WINDOWS: ETHER_TYPES=load_ethertypes("ethertypes") IP_PROTOS=load_protocols(os.environ["SystemRoot"]+"\system32\drivers\etc\protocol") TCP_SERVICES,UDP_SERVICES=load_services(os.environ["SystemRoot"] + "\system32\drivers\etc\services") + # Default value, will be updated by arch.windows MANUFDB = load_manuf(os.environ["ProgramFiles"] + "\\wireshark\\manuf") else: IP_PROTOS=load_protocols("/etc/protocols") diff --git a/test/regression.uts b/test/regression.uts index bd13bbefe2dedc8940d2c4a31081785df9b32697..f8bf0b1767ef062f7aab07bb0193db2d6537b5c4 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -650,6 +650,17 @@ send_and_sniff(IP(dst="secdev.org")/ICMP()) send_and_sniff(IP(dst="secdev.org")/ICMP(), flt="icmp") send_and_sniff(Ether()/IP(dst="secdev.org")/ICMP()) +############ +############ ++ ManuFDB tests + += __repr__ + +conf.manufdb + += check _resolve_MAC + +assert conf.manufdb._resolve_MAC("00:00:63") == "HP" ############ ############