Trouble using scapy + macOS 13.4
Brief description
I'm having trouble working with scapy on macOS. I can't get it to return data after the srp()
A similar report was opened at https://github.com/secdev/scapy/issues/3762 but unfortunately @summerlinryan did not complete the troubleshooting requested.
I've tried to execute it both with and without libpcap support enabled via conf.use_pcap (see example program below)—the results are the same. I also tried to monitor the traffic leaving my interface(s) with Wireshark to see if something obvious jumped out, but on the test machine available to me, there was too much traffic to spot anything "by eye" and I didn't know quite what to specify as a filter to capture anything useful.
Scapy version
2.5.0
I did the initial test with a fresh virtualenv, only installing scapy via the standard pip install scapy. After that, I attempted to update via pip install --upgrade git+https://github.com/secdev/scapy.git which gave me 2.5.0.dev106
Python version
3.11.4
Operating system
macOS 13.4 (22F66)
How to reproduce
Here's a small test script as an example of a non-working program on my system:
#!/usr/bin/env python3
import logging
logging.getLogger("scapy").setLevel(logging.CRITICAL)
from scapy.all import ARP, Ether, srp, conf
#conf.use_pcap = True
IFACE = 'en0'
LOCALNET = '192.168.20.0/24'
def discover_devices(interface, ip_range):
arp_request = ARP(pdst=ip_range)
ether_broadcast = Ether(dst="ff:ff:ff:ff:ff:ff")
packet = ether_broadcast/arp_request
result = srp(packet,
monitor=False, #set to True when using libpcap
timeout=1,
iface=interface,
verbose=0)[0]
devices = []
for sent, received in result:
devices.append({'ip': received.psrc, 'mac': received.hwsrc})
print("Discovered devices:")
for device in devices:
print(device['ip'], device['mac'])
discover_devices(IFACE, LOCALNET)
Result
Script hangs indefinitely until halted with ⌃c
Expected result
something