This Python tool allows you to obfuscate Python scripts by renaming variables and functions into randomized or meaningless names, adding a layer of complexity and protection for intellectual property. The tool can also reverse the obfuscation process using a saved mapping.
- Obfuscation: Changes the variable and function names to obscure symbols.
- Deobfuscation: Restores the obfuscated code to its original form using the saved mapping..
- Configurable via Command Line: Choose between obfuscation or deobfuscation directly from the command line.
-
Clone this repository to your local machine:
git clone <repo-url> cd python-obfuscator
-
Create a virtual environment and activate it:
- On Windows:
python -m venv venv venv\Scripts\activate
- On macOS/Linux:
python3 -m venv venv source venv/bin/activate
- On Windows:
-
Install the necessary dependencies:
pip install astunparse
You can obfuscate and deobfuscate Python files using this tool.
-
Run the following command to obfuscate a Python file:
python obfuscator.py obfuscate <your-python-file.py>
-
After obfuscation, the tool will print the obfuscated code to the console. It will also save a
mapping.jsonfile that stores the mapping between the original and obfuscated variable/function names.
-
To deobfuscate the script, use the command:
python obfuscator.py deobfuscate <your-obfuscated-file.py>
-
The tool will use the
mapping.jsonfile to restore the original names.
def greet():
message = "Hello, world!"
print(message)
greet() python obfuscator.py obfuscate script.py python obfuscator.py deobfuscate obfuscated_script.pyThis project is open-source and available under the MIT License.