Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scapy getlayer options

This is my code:

from scapy.all import *

packets = rdpcap('secret.pcap')

packet_join = []

for packet in packets:
    if packet.haslayer('TCP'):
        raw_data = packet.getlayer(Raw)
        packet_join.append(raw_data)

I only found the getlayer(Raw) from some googling.

My question is, is there a list of the layers I can use for getlayer somewhere? Or more detailed documentation on its use? I couldn't find much in the Scapy documentation.

I know you can also use things like getlayer(TCP)

like image 416
Proletariat Avatar asked Jul 16 '26 12:07

Proletariat


1 Answers

You can use any Scapy layer as attribute of .getlayer() and .haslayer(). You can list the loaded layers by using ls().

By the way, it's better to write TCP in x rather than x.haslayer(TCP) and x[Raw] rather than x.getlayer(Raw).

like image 70
Pierre Avatar answered Jul 21 '26 16:07

Pierre