$ show KnifeXRage/Godot-Secure
Godot-Secure is a set of Python scripts that automatically modify the Godot Engine source code to integrate enhanced encryption (AES-256 or Camellia-256) with a unique security token system. The scripts generate random magic headers, a 32-byte security token embedded in the engine binary, and optionally apply advanced key derivation formulas or scramble the GDScript tokenizer buffer to prevent decompilation. The tool is designed to be run once before compiling a custom Godot engine build, making each build cryptographically unique and resistant to generic decryption tools. The codebase demonstrates solid engineering with declarative modification definitions, backup creation, and detailed logging, though it is tightly coupled to the Godot source structure.
The LLM identified 3 files worth highlighting for reuse:
The `build_random_key_derivation()` function generates a random C++ expression for key derivation using a set of base operations (XOR, ADD, OR, AND, bit rotations) and chaining. It produces unique, non-trivial formulas that are injected into the Godot source to obfuscate the encryption key. This function is self-contained, uses only the `secrets` module, and can be extracted for any code obfuscation or key derivation generation task.
The `apply_buffer_scramble()` function implements a GDScript tokenizer buffer scrambler. It parses the Godot tokenizer header to determine the number of tokens, generates a random permutation of token IDs, injects write/read lookup tables into the source file, and modifies the token write/read streams. This function is self-contained, handles backup creation, and demonstrates a reusable pattern for scrambling any token-based serialization format.
The `setup_modifications()` and `apply_modifications()` functions define a declarative modification system using a list of dictionaries with operations (replace_line, replace_block, insert_after, append, create_file). This pattern allows for clear, maintainable source code patching and could be extracted as a generic source patching framework for other projects.