]> git.somenet.org - pub/jan/netsec2.git/blob - exercise2/task2/parse_stream_data.py
GITOLITE.txt
[pub/jan/netsec2.git] / exercise2 / task2 / parse_stream_data.py
1 #!/usr/bin/python
2
3 from pprint import pprint
4
5 # field value 17 was UDP, but autocorr.py could not handle strings
6 # field value 1 was ICMP
7 # cat large_flow_02.dehexed.csv | cut -d, -f 5 | sed 's/"//g' | sed 's/17/0/' > bits
8 # looked almost like text, so inverted the bits^^
9 fullstr = "000110011001101111001010110110110101110111011011010001111111111100111010111101110100110010101010001010010101010110100111000110001111000100011100011100010100011010000111111001111011100100110001110100001111100000101101011001101111110110000111010000011001101100011101111011011110010000111101101101011110110110100110000011100101110101000100011000011111000001001110110000101000001100011001101011111001110011001111110111001000101111011010000110001010000110011111011000111000001011110000"
10
11 bytes = bytearray()
12
13 bytelist = [ fullstr[i:i+8] for i in range(0, len(fullstr), 8) ]
14
15 solution = ""
16
17 for bchar in bytelist:
18     b = int(bchar, 2)
19     bytes.append(b)
20
21 with open('stream_encrypted', 'wb') as outfile:
22     outfile.write(bytes)
23
24 # openssl enc -d -rc4 -nosalt -k nSa123 -in stream_encrypted