Reputation: 49
i am trying to use Scapy to divide a SCTP packet,but i can only divive a packet into different layers. how can i divide SCTP into different chunks? for example,using show() in Scapy, i know there are 2 chunks in SCTP,but i dnt know how to get these two chunks. two chunks in SCTP packet
Is there any ways to divide chunks in the same layer? or can i store the information from show() into an array? Thanks^^
Upvotes: 0
Views: 1469
Reputation: 7009
You should be able to traverse the chunks the same way you traverse the layers.
With a method like:
def expand(pkt):
payload = []
for p in pkt.payload:
payload+=expand(p)
return [pkt.name, payload]
print(expand(pkt))
print(pkt.payload.payload.payload.name)
I get, for an SCTP package:
['Ethernet', ['IP', ['SCTP', ['SCTPChunkSACK', []]]]]
SCTPChunkSACK
edit: For the content:
>>> print(pkt[SCTP][1])
b'\x03\x00\x00\x10\x7f\x8cD\x18\x00\x01\xa0\x00\x00\x00\x00\x00'
>>> print(pkt[SCTP][1].show())
###[ SCTPChunkSACK ]###
type = sack
flags = 0x0
len = 16
cumul_tsn_ack= 0x7f8c4418
a_rwnd = 106496
n_gap_ack = 0
n_dup_tsn = 0
gap_ack_list= []
dup_tsn_list= []
So you already have your (nested) list of chunks at pkt[SCTP][1:].
Upvotes: 1