]> git.somenet.org - pub/jan/netsec2.git/blob - exercise1/task2/somedecode.py
Ex2-1 report done.
[pub/jan/netsec2.git] / exercise1 / task2 / 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] == '192.168.67.81':
18         bits += "{0:06b}".format(int(row[7]))
19
20     print binascii.unhexlify('%x' % int(bits, 2))
21
22 if __name__ == "__main__":
23         somedecode("transmission.csv")
24