From f2f243c77f3ee75840f108e0996ebfd10e98c9fd Mon Sep 17 00:00:00 2001 From: Adam Karpierz Date: Mon, 5 Mar 2018 01:09:33 +0100 Subject: [PATCH] Fix a backward compatibility bug in open_pcap (on Windows) Now scapy 2.4.x correctly works also if iface is of a different type than NetworkInterface (e.g. string). --- scapy/arch/windows/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scapy/arch/windows/__init__.py b/scapy/arch/windows/__init__.py index 44a2a1538..c12561323 100755 --- a/scapy/arch/windows/__init__.py +++ b/scapy/arch/windows/__init__.py @@ -544,7 +544,6 @@ class NetworkInterface(object): """Returns True if the interface is in monitor mode. Only available with Npcap.""" try: - self._check_npcap_requirement() return self.mode() == "monitor" except Scapy_Exception: return False @@ -853,9 +852,12 @@ def show_interfaces(resolve_mac=True): _orig_open_pcap = pcapdnet.open_pcap def open_pcap(iface, *args, **kargs): - if iface.ismonitor(): + iface_pcap_name = pcapname(iface) + if not isinstance(iface, NetworkInterface) and iface_pcap_name is not None: + iface = IFACES.dev_from_name(iface) + if isinstance(iface, NetworkInterface) and iface.ismonitor(): kargs["monitor"] = True - return _orig_open_pcap(pcapname(iface), *args, **kargs) + return _orig_open_pcap(iface_pcap_name, *args, **kargs) pcapdnet.open_pcap = open_pcap get_if_raw_hwaddr = pcapdnet.get_if_raw_hwaddr = lambda iface, *args, **kargs: (