1

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???

SamG101
  • 488
  • 1
  • 7
  • 18

2 Answers2

1

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).

Cukic0d
  • 5,111
  • 2
  • 19
  • 48
0

It is a python str , containing the interface name.

Linux: use the command in the console: ip link for the names

Examples for the value would be iface = "eth0" or iface = "wlan0"

See docs: https://scapy.readthedocs.io/en/latest/usage.html#sniffing

Luc
  • 156
  • 3
  • But a python string doesnt have an "is_invalid" attribute – SamG101 Nov 15 '19 at 09:09
  • windows see: https://stackoverflow.com/questions/49065489/scapy-sniff-doesnt-accept-the-iface-strings?rq=1 – Luc Nov 15 '19 at 09:12
  • Are you sure it needs an "is_invalid" attribute? Can you try the strings above – Luc Nov 15 '19 at 09:15
  • I guess you are using windows, and I cannot really help you with that, mabye try it like here (see how he is using it): https://stackoverflow.com/questions/45734269/scapy-3-way-handshake – Luc Nov 15 '19 at 09:28