-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbjhv.py
47 lines (31 loc) · 1.16 KB
/
bjhv.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
47
# # import zlib
# # with open('logfile.txt', 'rb') as file:
# # compressed_data = file.read()
# # decompressed_data = zlib.decompress(compressed_data)
# # print(decompressed_data.decode('utf-8', errors='ignore'))
# import gzip
# with open('logfile.txt', 'rb') as file:
# compressed_data = file.read()
# try:
# with gzip.GzipFile(fileobj=compressed_data) as f:
# decompressed_data = f.read()
# print(decompressed_data.decode('utf-8', errors='ignore'))
# except Exception as e:
# print(f"Decompression error: {e}")
import base64
with open('logfile.txt', 'r') as file:
encoded_data = file.read()
decoded_data = base64.b64decode(encoded_data)
# Now try decompressing it with zlib or gzip
try:
decompressed_data = zlib.decompress(decoded_data)
print(decompressed_data.decode('utf-8', errors='ignore'))
except zlib.error:
print("Not zlib compressed, trying gzip...")
import gzip
try:
with gzip.GzipFile(fileobj=decoded_data) as f:
decompressed_data = f.read()
print(decompressed_data.decode('utf-8', errors='ignore'))
except Exception as e:
print(f"Decompression error: {e}")