Created
September 11, 2022 01:32
-
-
Save iwalfy/c94ae0fcccc8370507e07633f81e1594 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
# | |
# Simple script to convert macOS saves of Geometry Dash to Windows | |
# | |
import sys | |
import base64 | |
import gzip | |
from Crypto.Cipher import AES | |
KEY = ( | |
b"\x69\x70\x75\x39\x54\x55\x76\x35\x34\x79\x76\x5d\x69\x73\x46\x4d" | |
b"\x68\x35\x40\x3b\x74\x2e\x35\x77\x33\x34\x45\x32\x52\x79\x40\x7b" | |
) | |
def xor(string: str, key: int) -> str: | |
return ("").join(chr(ord(char) ^ key) for char in string) | |
def encrypt_data(data: str) -> str: | |
gzipped = gzip.compress(data.encode()) | |
base64_encoded = base64.urlsafe_b64encode(gzipped) | |
return xor(base64_encoded.decode(), key=11) | |
def remove_pad(data: bytes) -> bytes: | |
last = data[-1] | |
if last < 16: | |
data = data[:-last] | |
return data | |
def mac_decrypt(data: bytes) -> str: | |
cipher = AES.new(KEY, AES.MODE_ECB) | |
return remove_pad(cipher.decrypt(data)).decode() | |
def main(): | |
if len(sys.argv) >= 3: | |
f = open(sys.argv[1], "rb") | |
macSave = f.read() | |
f.close() | |
macSaveDecrypt = mac_decrypt(macSave) | |
windowsSave = encrypt_data(macSaveDecrypt) | |
f = open(sys.argv[2], "w") | |
f.write(windowsSave) | |
f.close() | |
else: | |
print("Usage: ./gdMac2Win.py <inputFile> <outputFile>") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment