Search code examples
python-3.xscapyvariable-types

Scapy Sniff 'iface' attribute data type


Using scapy 2.4.3 (installed on pip using "pip install --pre scapy[complete]") with Python 3.7.2

Using the sniff function in scapy, what should the data type that goes into the iface parameter be? I used the scapy.all.show_interfaces() function to list the known interfaces, and this is the output:

INDEX  IFACE                                           IP               MAC
13     Realtek PCIe GBE Family Controller              169.254.142.162  HewlettP:47:07:dc
10     Microsoft Wi-Fi Direct Virtual Adapter          169.254.246.19   Azurewav:80:86:ff
7      Realtek RTL8723DE 802.11b/g/n PCIe Adapter      192.168.0.7      Azurewav:80:86:ff
-1     [Unknown] Adapter for loopback traffic capture  None             ff:ff:ff:ff:ff:ff

When I put "Realtek PCIe GBE Family Controller" into the sniff function, there is no "scapy.error.Scapy_Exception: Interface is invalid (no pcap match found) !" error, so I know that the interface is valid. However, I am receiving this error: AttributeError: 'str' object has no attribute 'is_invalid'. If I change the iface attribute to scapy.all.ifaces.dev_from_index(-1), then the error is OSError: exception: access violation reading 0x00000000000002A8. What does the iface data type have to be for it to be parsed correctly and work???


Solution

  • See https://stackoverflow.com/a/55093154/5459467 and https://stackoverflow.com/a/58793945/5459467.

    You will need to use the IFACES util to access the NetworkInterface object rather than its name.

    If that doesn't make the trick, make sure you have the latest version npcap installed, try with a different interface (probably not the -1 one).