]> git.somenet.org - pub/jan/netsec2.git/blob - exercise2/task1/somedecode.py
GITOLITE.txt
[pub/jan/netsec2.git] / exercise2 / task1 / somedecode.py
1 #!/usr/bin/env python
2
3 import csv
4 import binascii
5
6 def somedecode(filename):
7   with open(filename, 'rb') as csvfile:
8     spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
9     header = None
10     bits = ""
11     
12     for row in spamreader:
13       if header is None:
14         header = row
15         continue
16       
17       if row[2] == '114.176.157.191' and row[10] == '5950':
18         bits += "0"
19       if row[2] == '114.176.157.191' and row[10] == '5960':
20         bits += "1"
21
22     bits = bits[:-(len(bits)%8)]
23     print binascii.unhexlify('%x' % int(bits, 2))
24
25 if __name__ == "__main__":
26         somedecode("flow_114.176.157.191_221.72.61.209.csv")
27