Speeding up scapy packets sending

Sending packets with scapy I’m currently doing some code based on scapy. This code reads data from a possibly huge file and send a packet for each line in the file using the contained information. So the code contains a simple loop and uses sendp because the frame must be sent at layer 2. def run(self): filedesc = open(self.filename, 'r') # loop on read line for line in filedesc: # Build and send packet sendp(pkt, iface = self.iface, verbose = verbose) # Inter packet treatment Doing that the performance are a bit deceptive. For 18 packets, we’ve got: ...

17 avril 2014 · 3 min · Regit

Using Scapy lfilter

Scapy BPF filtering is not working when some exotic interface are used. This includes Virtualbox interface such as vboxnet. For example, the following code will not work if the interface is a virtualbox interface: build_filter = "src host %s and src port 21" sniff(iface=iface, prn=callback, filter=build_filter) To fix this, you can use the lfilter option. The filtering is now done inside Scapy. This is powerful but less efficient. The code can be modified like this: ...

7 juin 2012 · 1 min · Regit