From 4626b5c2f0fc2b5c7f040389d36beaf4eeaf20b2 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 27 Sep 2019 09:34:07 +0200 Subject: [PATCH] Fix bug trying to use encode method on byte object Traceback (most recent call last): File "/tmp/s1ap_reiniger.py", line 242, in handle_pcap(sys.argv[1], sys.argv[2]) File "/tmp/s1ap_reiniger.py", line 213, in handle_pcap pkt = handle_sctp_pkt(pkt) File "/tmp/s1ap_reiniger.py", line 192, in handle_sctp_pkt success = handle_sctp_chunk(chunk) File "/tmp/s1ap_reiniger.py", line 166, in handle_sctp_chunk handle_s1ap(s1ap()) File "/tmp/s1ap_reiniger.py", line 152, in handle_s1ap find_and_handle_s1ap_nas_pdu(msg[1]['value'], dl = False) File "/tmp/s1ap_reiniger.py", line 103, in find_and_handle_s1ap_nas_pdu pdu = handle_nas_pdu(ie['value'][1], dl) File "/tmp/s1ap_reiniger.py", line 30, in handle_nas_pdu log.debug("Processing %s NAS PDU: %s" % ("Downlink" if dl else "Uplink", pdu.encode('hex'))) AttributeError: 'bytes' object has no attribute 'encode' --- s1ap_reiniger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s1ap_reiniger.py b/s1ap_reiniger.py index 89c3d20..1c21f26 100755 --- a/s1ap_reiniger.py +++ b/s1ap_reiniger.py @@ -27,7 +27,7 @@ from pycrate_asn1dir import S1AP from pycrate_mobile import NAS def handle_nas_pdu(pdu, dl, regen = False): - log.debug("Processing %s NAS PDU: %s" % ("Downlink" if dl else "Uplink", pdu.encode('hex'))) + log.debug("Processing %s NAS PDU: %s" % ("Downlink" if dl else "Uplink", pdu.hex())) (msg, code) = NAS.parse_NASLTE_MT(pdu) if dl else NAS.parse_NASLTE_MO(pdu) if code: log.error("Failed to parse NAS payload") @@ -54,7 +54,7 @@ def handle_s1ap_imsi(imsi): return '\x29\x26\x24' + '\x00' * 5 def handle_s1ap_tmsi(tmsi): - log.info("Cleaning TMSI: %s" % tmsi.encode('hex')) + log.info("Cleaning TMSI: %s" % tmsi.hex()) return tmsi # NOTE: for now, keep TMSI unchanged def handle_s1ap_imeisv(imeisv):