Skip to content

Commit

Permalink
Bug fix for decoding error: most likely because of non UTF-8 characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrimana committed Oct 12, 2021
1 parent 4d7e722 commit 32bce07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions network_traffic/post-processing/extract_from_tshark.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ def extract_other_pkt(layers, frame_num, include_http_body=False):


def extract_from_tshark(full_path, data, is_decrypted, include_http_body=False):
with open(full_path, "r") as jf:
with open(full_path, "rb") as jf:
# Since certain json 'keys' appear multiple times in our data, we have to make them
# unique first (we can't use regular json.load() or we lose some data points). From:
# https://stackoverflow.com/questions/29321677/python-json-parser-allow-duplicate-keys
decoder = json.JSONDecoder(object_pairs_hook=parse_object_pairs)
pcap_data = decoder.decode(jf.read())
pcap_data = decoder.decode(jf.read().decode(errors='ignore'))

for packet in pcap_data:
layers = packet[json_keys.source][json_keys.layers]
Expand Down

0 comments on commit 32bce07

Please sign in to comment.