kfix / SleepProxyServer

mDNS (Bonjour) Sleep Proxy Server (python 2 implementation) for Mac OSX "Wake on Demand"
BSD 2-Clause "Simplified" License
31 stars 9 forks source link

Exception in snifferthread when creating L2listen #6

Open jeremiahrex opened 5 years ago

jeremiahrex commented 5 years ago

After a registration is successfully confirmed, a sniffer thread is set up which creates a socket that listens for the appropriate ARP and TCP traffic. However something goes wrong when passing the compiled BPF filter code to setsockopt.

Exception in thread Thread-5: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/home/jerry/.local/lib/python2.7/site-packages/sleepproxy/sniff.py", line 18, in run self._sniff() File "/home/jerry/.local/lib/python2.7/site-packages/sleepproxy/sniff.py", line 24, in _sniff sock = conf.L2listen(type=ETH_P_ALL, filter=self._filterexp, iface=self._iface) File "/home/jerry/.local/lib/python2.7/site-packages/scapy/arch/linux.py", line 454, in __init__ attach_filter(self.ins, filter, iface) File "/home/jerry/.local/lib/python2.7/site-packages/scapy/arch/linux.py", line 141, in attach_filter sock.setsockopt(socket.SOL_SOCKET, SO_ATTACH_FILTER, bp) File "<string>", line 1, in setsockopt error: [Errno 22] Invalid argument

Running lubuntu 16.04.6 LTS on a Macmini G4.

I have confirmed that the BPF filters are being correctly generated in scapy. I suspect that it is a similar issue to https://github.com/secdev/scapy/issues/842.

kfix commented 5 years ago

which kernel package / version are you running?

jeremiahrex commented 5 years ago

These are the packages I've installed with pip: cffi (1.12.3) dnspython (1.16.0) gevent (1.4.0) greenlet (0.4.15) netifaces (0.10.9) pip (8.1.1) scapy (2.4.2) SleepProxyServer (0.1)

So after verifying everything up to the internals of scapy I tried following the "legacy" code path in scapy/common.py and behold, it worked properly. I got a different error later on though (AttributeError: who_has). So I think that is further evidence in the direction that SleepProxyServer is fine and it's scapy changes that are causing the issue. Looks like they changed how they were using the Python ctypes, perhaps > V2.

I also tried this with a virtual machine using the same distro/kernel version on a VirtualBox on my x86-64 machine. Still get the same error as in #5 and run into the same error later with who_has.