Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving Custom Protocol Packets With Scapy and NetFilter Queue

I am doing a project that involves shimming a packet with a custom layer containing some specific fields. I managed to do this using the guide here:

http://www.secdev.org/projects/scapy/doc/build_dissect.html

The guide is great on how to build and send packets with custom layers, but not so much on how to receive them.

I have a packet with the form:

IP()/CustomLayer()/ICMP()

And I am sending this packet to another host that will receive the packet using python's netfilter queue and scapy libraries.

My question is, how do I receive an incoming packet with custom layers in it and still have access to the fields? Trying to parse the packet with

IP(packet)

seems to not be working.. Any help is greatly appreciated!

like image 337
alec Avatar asked Feb 06 '26 21:02

alec


1 Answers

Have you tried to declare an empty packet first?

pkt = IP()/CustomLayer()/ICMP()

and then

pkt = IP(packet)

Look here and you may find the solution to your problem: Extract Scapy Custom layer

like image 89
rebrid Avatar answered Feb 09 '26 10:02

rebrid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!