Pradeep
Pradeep

Reputation: 639

Scapy: How to access RAW of a custom packet

I am trying to access the RAW data of this packet. I am not sure how to extract that and store it in a variable. I have tried using the getlayer method but it does not return the Raw payload.

>>> b.show2()
###[ LSP Object ]###
  \common_object_header\
   |###[ PCEP Common Object Header ]###
   |  oclass= LSP
   |  oType= 1L
   |  resflags=
   |  pflag=
   |  iflag=
   |  obLength= 20
  plspid= 0x1L
  flag= 0L
  Cflag=
  oflag= DOWN
  Aflag=
  Rflag=
  Sflag=
  Dflag= D
  \symbolic_path_name\
   |###[ symbolic_path_name_tlv ]###
   |  tlvType= SYMBOLIC-PATHNAME-TLV
   |  tlvLength= 5
   |  tlvValue= 'lsp12'
   |###[ Raw ]###
   |     load= '000' <---- How to access this field???
>>>

>>> b.symbolic_path_name.getlayer(Raw) <--- This does'nt return anything
>>>
>>>
>>> b.symbolic_path_name.getlayer(Raw).load
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'load'
>>>                                                                                                                                                                                    

Upvotes: 0

Views: 3894

Answers (1)

eephillip
eephillip

Reputation: 1328

So I think the Raw object is the last layer and that represents the payload. So you would access it directly

last = b.getlayer(Raw)
# Because Raw is last this works as well, e.g. No Padding
last2 = b.lastlayer()
print last.load
print last2.load

Upvotes: 1

Related Questions