-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch21.py
More file actions
63 lines (45 loc) · 1.05 KB
/
ch21.py
File metadata and controls
63 lines (45 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import zlib
from pprint import pprint
import bz2
PACK = './ch21_files/package.pack'
if __name__ == '__main__':
f = open(PACK, 'rb')
data = f.read()
f.close()
ctr = 1
log = ''
while True:
ctr += 1
if data[:10].encode("hex")[:4] == '789c':
print data[:10].encode("hex")
data = zlib.decompress(data)
log += '1'
elif data[:3] == 'BZh':
print data[:10]
data = bz2.decompress(data)
log += '2'
elif data[-10:][::-1].encode("hex")[:4] == '789c':
data = data[::-1]
print data[:10].encode("hex")
data = zlib.decompress(data)
log += '3'
elif data[::-1][:3] == 'BZh':
data = data[::-1]
print data[:10]
data = bz2.decompress(data)
log += '4'
else:
print '\nBREAKING\n'
print data[::-1]
break
# print log
# print len(log)
# disp = log.split('1')
# pprint(disp)
# disp = log.split('2')
# pprint(disp)
log = log.replace('1', ' ')
disp = log.split('3')
pprint(disp)
# disp = log.split('4')
# pprint(disp)