Merge pull request #1198 from karpierz/fix_bug_in_open_pcap_on_windows

Fix a backward compatibility bug in open_pcap (on Windows)
This commit is contained in:
Guillaume Valadon 2018-03-06 22:03:57 +01:00 committed by GitHub
commit faeeef0026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -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: (