William Robinet | 30 Nov 18:40

Patch for Scapy on amd64 (Gentoo Linux)

Hi,

Here is what I needed to change in Scapy in order to get the
traceroute(), sniff(), ... functions to work on my Gentoo Linux amd64 machine:

--- scapy-1.0.2.9beta.py        2005-11-19 09:48:54.000000000 +0100
+++ scapy-1.0.2.9beta_patched.py        2005-11-30 18:21:48.000000000
+0100
@@ -1806,7 +1806,7 @@

         # XXX. Argl! We need to give the kernel a pointer on the BPF,
         # python object header seems to be 20 bytes
-        bpfh = struct.pack("HI", nb, id(bpf)+20)  
+        bpfh = struct.pack("LL", nb, id(bpf)+36)  
         s.setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, bpfh)

     def set_promisc(s,iff,val=1):

The problem was:
>>> traceroute("www.google.com")
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "scapy-1.0.2.9beta.py", line 8773, in traceroute
    timeout=timeout, filter=filter, **kargs)
  File "scapy-1.0.2.9beta.py", line 7872, in sr
    s = conf.L3socket(filter=filter, iface=iface)
  File "scapy-1.0.2.9beta.py", line 7267, in __init__
    attach_filter(self.ins, filter)
  File "scapy-1.0.2.9beta.py", line 1810, in attach_filter
    s.setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, bpfh)
  File "<string>", line 1, in setsockopt
error: (22, 'Invalid argument')
>>>

Hope it helps,
William

--

-- 
GPG Key ID: 74C7A949


Gmane