-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel_21.py
47 lines (40 loc) · 1.13 KB
/
level_21.py
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
import zlib, bz2
def uncompress():
with open("./file/level_21/package.pack", "rb") as file:
data = file.read()
while True:
if data.startswith(b'x\x9c'):
data = zlib.decompress(data)
elif data.startswith(b'BZh'):
data = bz2.decompress(data)
elif data.endswith(b'\x9cx'):
data = data[::-1]
else:
break
print(data.decode()[::-1])
def solve():
"""
add logging
:return:
"""
result = ""
with open("./file/level_21/package.pack", "rb") as file:
data = file.read()
while True:
if data.startswith(b'x\x9c'):
data = zlib.decompress(data)
result += ' '
elif data.startswith(b'BZh'):
data = bz2.decompress(data)
result += '#'
elif data.endswith(b'\x9cx'):
data = data[::-1]
result += '\n'
else:
break
print(result)
if __name__ == '__main__':
uncompress()
# look at your logs
solve()
# copper