Catch exceptions while decoding the packet
If any exceptions are found while decoding the packet, remove it from the output trace to ensure no information leaks. In my real-world traces, I e.g. got the following exception terminating the program: CHOICE._from_per: S1AP-PDU, unknown extension index 699866529169900427952657872967740904512772918212192949539462653507496501180206847298869570851487786014667431700603926958879953036143148400114887836583469249625472224706264417515341607478659710751184333540332091231808038155414952989252906034887075176400074366401692584783210687966823902077240699797242085375 Traceback (most recent call last): File "./s1ap_reiniger.py", line 245, in <module> handle_pcap(sys.argv[1], sys.argv[2]) File "./s1ap_reiniger.py", line 215, in handle_pcap pkt = handle_sctp_pkt(pkt, i) File "./s1ap_reiniger.py", line 193, in handle_sctp_pkt success = handle_sctp_chunk(chunk, pkt_number) File "./s1ap_reiniger.py", line 167, in handle_sctp_chunk handle_s1ap(s1ap(), pkt_number) File "./s1ap_reiniger.py", line 122, in handle_s1ap log.info("Processing S1AP message '%s:%s' (Packet %d)" % (msg[0], msg[1]['value'][0], pkt_number)) TypeError: byte indices must be integers or slices, not str
This commit is contained in:
parent
a45e8b354c
commit
f0206b949b
|
@ -164,7 +164,11 @@ def handle_sctp_chunk(chunk, pkt_number):
|
|||
log.error("Malformed packet, skipping...")
|
||||
return False
|
||||
|
||||
handle_s1ap(s1ap(), pkt_number)
|
||||
try:
|
||||
handle_s1ap(s1ap(), pkt_number)
|
||||
except:
|
||||
log.error("Failed to decode S1AP payload (Packet %d)", (pkt_number))
|
||||
return False
|
||||
|
||||
# Encapsulate the new payload
|
||||
# TODO: reset checksum fields
|
||||
|
|
Loading…
Reference in New Issue