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)
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)
.