Skip to content Skip to sidebar Skip to footer

Filter Http Get Requests Packets Using Scapy

I am trying to filter HTTP Get request packets using scapy by using the Raw information of the packet for deciding which packet is a Get request and which isn't but I didn't find a

Solution 1:

This warn is for scapy source code(packet.py), not for python compiler:

warning("Calling str(pkt) on Python 3 makes no sense!")

Then, base on source, the bytes function return an analysable byte array with no warning fire:

...
if six.PY2:
    def__str__(self):
        # type: () -> strreturn self.build()
else:
    def__str__(self):
        # type: () -> str
        warning("Calling str(pkt) on Python 3 makes no sense!")
        returnstr(self.build())

def__bytes__(self):
    # type: () -> bytesreturn self.build()
...

Instead of using str(packet) its better use bytes(packet)

For convert byte array to string:

packetstr = "".join(map(chr, bytes(packet)))

Solution 2:

You can try something along the lines of:

if packet.haslayer(Raw):
   data = str(packet.getlayer(Raw))

Post a Comment for "Filter Http Get Requests Packets Using Scapy"