-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (20 loc) · 751 Bytes
/
Copy pathmain.py
File metadata and controls
30 lines (20 loc) · 751 Bytes
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
import os
import zlib
def encode_block(block):
return bytes(byte ^ 0xAB for byte in block)
def encode_file(input_file, output_file):
with open(input_file, 'rb') as f_in:
exe_data = f_in.read()
compressed_data = zlib.compress(exe_data)
block_size = 512
encoded_data = bytearray()
for i in range(0, len(compressed_data), block_size):
block = compressed_data[i:i + block_size]
encoded_data.extend(encode_block(block))
with open(output_file, 'wb') as f_out:
f_out.write(encoded_data)
print(f"Đã mã hóa file EXE và lưu vào {output_file}")
if __name__ == "__main__":
input_exe = 'test7v1.exe'
output_txt = 'encoded_file.bin'
encode_file(input_exe, output_txt)