Advanced Python Code Protection System with AES-256-GCM encryption and AST obfuscation
Project description
PyObfuscator - Advanced Python Code Protection System
A comprehensive Python code obfuscation and encryption system designed for Linux environments. Provides military-grade protection against reverse engineering, code analysis, and unauthorized access through multiple layers of security.
๐ก๏ธ Security Features
- AES-256-GCM Encryption - Military-grade encryption for maximum security
- AST-Based Obfuscation - Advanced Abstract Syntax Tree manipulation
- Anti-Tampering Protection - Runtime integrity checks and modification detection
- Anti-Debugging - Detects and prevents debugging attempts
- Variable & Function Renaming - Systematic identifier obfuscation
- String Obfuscation - Advanced string encoding and hiding
- Dead Code Injection - Confuses static analysis tools
- Bytecode Protection - Low-level bytecode manipulation
๐ Quick Start
Installation
# Clone the repository
git clone https://github.com/MohamedQM/PyObfuscator.git
cd PyObfuscator
# Install dependencies (simple method)
python3 install.py
# Or install manually
pip3 install cryptography psutil
Basic Usage
# Obfuscate a Python file
python3 main.py your_script.py
# Maximum security protection
python3 main.py your_script.py --max-security
# Create importable library
python3 main.py your_script.py --library
Programmatic Usage
from pyobfuscator import obfuscate_code, obfuscate_file
# Obfuscate code directly
code = """
def hello():
print("Hello World!")
hello()
"""
protected_code = obfuscate_code(code, max_security=True)
# Obfuscate a file
success = obfuscate_file("input.py", "output.py")
๐ Project Structure
PyObfuscator/
โโโ pyobfuscator/ # Core library
โ โโโ __init__.py # Main API interface
โ โโโ core.py # Core obfuscation engine
โ โโโ obfuscator.py # AST manipulation
โ โโโ encryption.py # AES-256-GCM encryption
โ โโโ anti_tamper.py # Anti-tampering protection
โ โโโ utils.py # Utility functions
โโโ examples/ # Usage examples
โ โโโ sample_code.py # Sample code for testing
โ โโโ usage_example.py # Integration examples
โโโ main.py # CLI interface
โโโ install.py # Simple installer
โโโ test_basic.py # Basic functionality tests
โโโ README.md # This file
๐ Protection Levels
Basic Protection
- Variable and function renaming
- String encoding and obfuscation
- Basic dead code injection
- Simple control flow changes
Advanced Protection
- AES-256-GCM encryption with PBKDF2
- Advanced AST transformations
- Metadata removal
- Enhanced anti-debugging
Maximum Security
- All protection features enabled
- Real-time tampering detection
- Environment analysis
- Process monitoring
- Bytecode encryption
๐งช Testing
# Run basic functionality tests
python3 test_basic.py
# Test with sample code
python3 main.py examples/sample_code.py
python3 examples/sample_code_obfuscated.py
๐ป System Requirements
- OS: Linux (Ubuntu 18.04+ recommended)
- Python: 3.7+ (tested on 3.8-3.11)
- RAM: 512MB minimum
- Dependencies:
cryptography,psutil
๐ CLI Options
python3 main.py [INPUT_FILE] [OPTIONS]
Options:
-o, --output FILE Output file path
--max-security Enable maximum protection
--custom-key KEY Use custom encryption key
--library Create importable library
--no-anti-debug Disable anti-debugging
--preserve-names Keep original function names
๐ง Advanced Configuration
Custom Encryption Key
from pyobfuscator.encryption import AdvancedEncryption
encryptor = AdvancedEncryption()
key = encryptor.generate_key("your_custom_password")
obfuscated = obfuscate_code(source, encryption_key=key)
Selective Protection
from pyobfuscator.core import PyObfuscatorCore
obfuscator = PyObfuscatorCore()
obfuscator.config.rename_variables = True
obfuscator.config.encrypt_strings = True
obfuscator.config.add_fake_code = False
result = obfuscator.obfuscate(source_code)
โ ๏ธ Important Notes
- Linux Only: This tool is optimized for Linux environments
- Backup Your Code: Always keep original source code backups
- Test Thoroughly: Test obfuscated code before deployment
- GitHub Safe: No sensitive data included - safe for public repositories
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Links
- Repository: https://github.com/MohamedQM/PyObfuscator
- Issues: https://github.com/MohamedQM/PyObfuscator/issues
- Documentation: See
README_SIMPLE.mdfor Arabic documentation
Developed with โค๏ธ for the Python security community
Last Updated: August 2024
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyobfuscator_gmaq-1.0.0.tar.gz.
File metadata
- Download URL: pyobfuscator_gmaq-1.0.0.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bbeff8f7324ef869207d1def2b2e35eae7ef2f74119ef4367712eff7b91d73b
|
|
| MD5 |
e69f1fc0d26d3f54c1e3a460994809c3
|
|
| BLAKE2b-256 |
ccefedaedf5b1a82da9dd46367deba5e241ad9702b8e67786d830b2585cfed0a
|
File details
Details for the file pyobfuscator_gmaq-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pyobfuscator_gmaq-1.0.0-py3-none-any.whl
- Upload date:
- Size: 34.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41dd4b5ba77c8355d2bc5bea98bb5fc657d01a85328a743ea4f09fbcdd7c773d
|
|
| MD5 |
0ff01efec823fd612d5f3d796694a898
|
|
| BLAKE2b-256 |
13066301f14e1aef394938ec4d0b06d995dfbcdbd1313b0c82dfa32c5eb00db8
|