From 809560c469f4bba1e7706d2c5611d2777a95a97f Mon Sep 17 00:00:00 2001 From: David Kaufmann Date: Sat, 2 Jan 2016 23:12:14 +0100 Subject: [PATCH] update decode_ipid.py --- exercise2/task2/decode_ipid.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/exercise2/task2/decode_ipid.py b/exercise2/task2/decode_ipid.py index 4a98650..a112da9 100755 --- a/exercise2/task2/decode_ipid.py +++ b/exercise2/task2/decode_ipid.py @@ -6,6 +6,7 @@ logging.getLogger("scapy.runtime").setLevel(logging.ERROR) from scapy.all import * logging.getLogger("scapy.runtime").setLevel(logging.WARN) from pprint import pprint +import os # disable payload parsing (saves two seconds runtime^^) IP.payload_guess = [] @@ -21,11 +22,22 @@ for p in PcapReader('large_flow.pcap'): bin = "{0:016b}".format(id) upper = int(bin[0:8], 2) lower = int(bin[8:16], 2) - print ("Upper: %s, Lower: %s" % (bin[0:8], bin[8:16])) + print ("Upper: %s (%d), Lower: %s (%d)" % (bin[0:8], upper, bin[8:16], lower)) print ("Full: %s" % (bin)) bytes.append(upper) bytes.append(lower) +try: + os.unlink('stream_encrypted') +except Exception as e: + # ignore if file is missing + pass with open('stream_encrypted', 'a+') as encfile: encfile.write(bytes) +try: + os.unlink('stream_decrypted') +except Exception as e: + # ignore if file is missing + pass +os.system('openssl enc -d -rc4 -nosalt -k nSa123 -in stream_encrypted -out stream_decrypted') -- 2.43.0