Last active
February 4, 2024 20:51
-
-
Save kvba0000/ec5a35a73a7f2780c2cc5f43d4f9440c to your computer and use it in GitHub Desktop.
Bitflip script written in Python with chunk reading function. Mainly used to de-anti-decompile Gamemaker fangames like MTO (Mysterytale Online).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import fstat | |
from time import sleep | |
filename = "data.win" | |
new_filename = f"new_{filename}" | |
chunk_size = 1024 | |
# Main progress | |
wf = open(new_filename, "wb") | |
with open(filename, "rb") as f: | |
file_stats = fstat(f.fileno()) | |
file_size = file_stats.st_size | |
c = 0 | |
while True: | |
chunk = f.read(chunk_size) | |
if not chunk: | |
break | |
c += chunk_size | |
print(f"Bitflipping {filename}... {c}/{file_size}") | |
binary = "".join(f"{byte:08b}" for byte in chunk) | |
n_binary = "".join(map(lambda b: '0' if b == '1' else '1', [*binary])) | |
new_binary = bytes(int(n_binary[i:i+8], 2) for i in range(0, len(n_binary), 8)) | |
wf.write(new_binary) | |
sleep(0.01) | |
f.close() | |
print(f"Bitflip done. Output saved to {new_filename}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment