diff --git a/docs/topics/localfiles_encrypt_decrypt.md b/docs/topics/localfiles_encrypt_decrypt.md index b3c7a3223..6ad3d6354 100644 --- a/docs/topics/localfiles_encrypt_decrypt.md +++ b/docs/topics/localfiles_encrypt_decrypt.md @@ -2,18 +2,24 @@ Although Geometry Dash's install path is usually inside the user's `steamapps/common` folder (if the game was bought from Steam) the game will actually store all relevant user data inside the `AppData/Local` directory, in which a new folder will be created under the name of `GeometryDash`. This folder contains all custom songs that the user has downloaded but it also contains 2 important files, which are *CCGameManager.dat* and *CCLocalLevels.dat*; the first one contains all the information regarding the player's in-game stats and preferences while the latter contains the data for the game's user created levels. +On Android, saves are placed under `/data/data/{package name}` (replace `{package name}` with package name of game). + On MacOS, saves are placed under `~/Library/Application Support/GeometryDash`, and use completely different encoding from Windows one. However when these files are written to the disk they are encrypted and have to be decrypted before they can be read or modified. Both files share the same process for decryption and encryption. +Windows and Android Geometry Dash can load plain XML save files, but MacOS Geometry Dash can't. + ## Decryption -### Windows +### Windows and Android -Local game files are decrypted in the following order: Apply XOR function with key `0xB` (`11`), then apply [B64 decoding](topics/encryption/base64), the resulting byte sequence will be a [gzip](https://zlib.net) compressed string which needs to be decompressed/inflated. +Local game files are decrypted in the following order: Apply XOR function with key `0xB` (`11`), then apply [B64 decoding](topics/encryption/base64), the resulting byte sequence will be a [gzip](https://en.wikipedia.org/wiki/Gzip) compressed string which needs to be decompressed/inflated. -Simple XOR function differs can be written like this: +If file size is not divisible by 4, last `file_size % 4` bytes are garbage. + +Simple XOR function can be written like this: @@ -48,7 +54,7 @@ def decrypt_data(data: str) -> str: ### MacOS On MacOS, decryption is quite simpler. Saves are encrypted with -[AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard), using `ECB` mode. +[AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard), using [ECB](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_codebook_.28ECB.29) mode with [PKCS#7](https://en.wikipedia.org/wiki/Padding_%28cryptography%29#PKCS.235_and_PKCS.237) padding. 256-bit key for encryption looks like this: @@ -56,6 +62,12 @@ On MacOS, decryption is quite simpler. Saves are encrypted with ### **Plain** +```plain +ipu9TUv54yv]isFMh5@;t.5w34E2Ry@{ +``` + +### **Hex** + ```plain 69 70 75 39 54 55 76 35 34 79 76 5d 69 73 46 4d 68 35 40 3b 74 2e 35 77 33 34 45 32 52 79 40 7b ``` @@ -97,9 +109,9 @@ def mac_decrypt(data: bytes) -> str: ## Encryption -### Windows +### Windows and Android -Encryption is done pretty much the same way but with opposite operations and order. So the sequence for encrypting can be defined as: [gzip](https://zlib.net) compress/deflate -> [Base64](topics/encryption/base64) encode -> XOR using `0xb` (`11`) as a key. +Encryption is done pretty much the same way but with opposite operations and order. So the sequence for encrypting can be defined as: [gzip](https://en.wikipedia.org/wiki/Gzip) compress/deflate → [Base64](topics/encryption/base64) encode → XOR using `0xb` (`11`) as a key. @@ -116,7 +128,7 @@ def encrypt_data(data: str) -> str: ### MacOS -Like on Windows, encryption and decrypion are almost the same: +Like on Windows and Android, encryption and decryption are almost the same: