Advanced Python obfuscation tool with memory, binary, and machine code protection
Project description
Python Multi-Level Obfuscator
A sophisticated Python code obfuscation tool featuring a modern liquid glass GUI and three levels of protection: memory-level, binary-level, and machine code-level obfuscation.
🚀 Features
Multi-Level Protection
Memory-Level Obfuscation
- Dynamic code loading and execution
- Runtime memory encryption/decryption
- Anti-debugging techniques
- Code injection obfuscation
- Variable and function name randomization
- String literal encryption
- Control flow flattening
- Dead code insertion
Binary-Level Obfuscation
- PyInstaller integration for executable creation
- Binary packing and encryption
- Resource protection
- Anti-tampering mechanisms
- Signature verification
- Integrity checking
- Debug detection
- UPX compression support
Machine Code-Level Obfuscation
- C extension compilation
- CPU instruction obfuscation
- Control flow flattening
- Assembly wrapper generation
- Opcode-level junk insertion
- Anti-debugging assembly
Modern Liquid Glass GUI
- Glass morphism effects with transparency
- Rounded corners and smooth animations
- Gradient backgrounds with blur effects
- Responsive design for all screen sizes
- Real-time progress tracking
- Configuration management
- Batch processing support
Advanced Features
- Code validation and analysis
- Configuration profiles
- Comprehensive reporting
- Backup and recovery
- Multi-platform support
📦 Installation
Prerequisites
- Python 3.7 or higher
- pip (Python package manager)
Install Dependencies
cd code/obfuscator
pip install -r requirements.txt
Optional Dependencies
# For executable compression (Linux)
sudo apt install upx-ucl
# For Windows executable creation
pip install pywin32
# For macOS specific features
pip install pyobjc
🎯 Quick Start
GUI Mode
python run.py gui
# or
python main.py
Command Line Mode
# Obfuscate a file
python run.py obfuscate input.py -o output/
# Validate a file
python run.py validate input.py
# Run demo
python run.py demo
python run.py demo --quick
📋 Usage Examples
1. Basic Obfuscation
from main import ObfuscationEngine, ObfuscationConfig
from utils.validation_utils import CodeValidator
# Load configuration
config = ObfuscationConfig()
# Create engine
engine = ObfuscationEngine(config)
# Obfuscate file
results = engine.obfuscate_file('my_script.py', 'output_dir')
2. Custom Configuration
# Modify configuration
config.set("memory_level", "rename_variables", True)
config.set("binary_level", "compress_output", True)
config.set("machine_level", "enabled", False)
# Save configuration
config.save_config()
3. Code Validation
from utils.validation_utils import CodeValidator
validator = CodeValidator()
report = validator.generate_validation_report(source_code)
# Check if suitable for obfuscation
suitable, reason = validator.is_suitable_for_obfuscation(report)
print(f"Suitable: {suitable}, Reason: {reason}")
🔧 Configuration
Configuration File Structure
{
"obfuscation": {
"levels": {
"memory": {
"enabled": true,
"rename_variables": true,
"encrypt_strings": true,
"add_dead_code": true,
"flatten_control_flow": true
},
"binary": {
"enabled": true,
"use_pyinstaller": true,
"compress_output": true,
"add_upx": false
},
"machine": {
"enabled": false,
"create_c_extension": false,
"opcode_obfuscation": true
}
}
}
}
Configuration Profiles
The obfuscator supports multiple configuration profiles:
- Basic: Simple obfuscation for development
- Standard: Balanced protection for production
- Advanced: Maximum protection for sensitive code
🎨 GUI Components
Main Interface
- File Selection Panel: Browse and select Python files
- Obfuscation Level Selector: Choose protection levels
- Configuration Panel: Adjust settings
- Progress Monitor: Real-time obfuscation progress
- Output Viewer: View results and logs
Settings Tabs
- Memory Settings: Configure memory-level obfuscation
- Binary Settings: Configure binary-level obfuscation
- Machine Settings: Configure machine-level obfuscation
- Advanced Options: Additional configuration
🛡️ Security Features
Anti-Debugging
- PEB BeingDebugged flag detection
- Windows API debugging checks
- Timing-based detection
- Memory protection analysis
Anti-Tampering
- Digital signature verification
- Resource integrity checking
- Runtime validation
- Checksum verification
Code Protection
- String encryption
- Variable name randomization
- Control flow obfuscation
- Dead code injection
📊 Performance
Obfuscation Levels Comparison
| Level | Protection | Performance Impact | Use Case |
|---|---|---|---|
| Memory | Medium | Low | Development, internal tools |
| Binary | High | Medium | Production applications |
| Machine | Maximum | High | Security-critical code |
Supported File Sizes
- Memory-level: Up to 10MB
- Binary-level: Up to 100MB
- Machine-level: Up to 5MB
🔍 Validation
The obfuscator includes comprehensive code validation:
Syntax Validation
- Python syntax checking
- AST parsing validation
- Error reporting
Security Analysis
- Suspicious pattern detection
- Secret/hardcoded credential detection
- Malicious code identification
Complexity Analysis
- Function count
- Class count
- Variable count
- Line count
- Dependency analysis
🐛 Troubleshooting
Common Issues
Import Errors
# Install missing dependencies
pip install -r requirements.txt
GUI Not Displaying
# Set display environment (Linux)
export DISPLAY=:0
# Or use command line mode
python run.py obfuscate input.py
PyInstaller Errors
# Install PyInstaller
pip install pyinstaller
# Update PyInstaller
pip install --upgrade pyinstaller
Debug Mode
# Run with debug output
python run.py --debug obfuscate input.py
📈 Advanced Usage
Batch Processing
import os
from pathlib import Path
# Process multiple files
input_dir = Path("input_files")
output_dir = Path("output_files")
for py_file in input_dir.glob("*.py"):
results = engine.obfuscate_file(str(py_file), str(output_dir))
print(f"Processed {py_file.name}: {'Success' if results['success'] else 'Failed'}")
Custom Obfuscation Pipeline
from obfuscators.memory_obfuscator import MemoryObfuscator
from obfuscators.binary_obfuscator import BinaryObfuscator
from obfuscators.machine_obfuscator import MachineCodeObfuscator
# Custom pipeline
memory_obf = MemoryObfuscator()
binary_obf = BinaryObfuscator()
machine_obf = MachineCodeObfuscator()
# Step 1: Memory obfuscation
protected_code = memory_obf.create_protected_module(source_code)
# Step 2: Create temporary file
temp_file = "temp_protected.py"
with open(temp_file, 'w') as f:
f.write(protected_code)
# Step 3: Binary obfuscation
binary_obf.create_protected_executable(temp_file, "protected_app")
# Step 4: Machine obfuscation (optional)
machine_obf.create_comprehensive_protection(protected_code, "protected_extension")
🔗 API Reference
Main Classes
ObfuscationEngine
class ObfuscationEngine:
def __init__(self, config: ObfuscationConfig)
def obfuscate_file(self, input_file: str, output_dir: str) -> Dict[str, str]
def set_progress_callback(self, callback)
def set_status_callback(self, callback)
MemoryObfuscator
class MemoryObfuscator:
def __init__(self)
def obfuscate_source(self, source_code: str) -> str
def create_protected_module(self, source_code: str) -> str
def generate_execution_wrapper(self, code: str) -> str
BinaryObfuscator
class BinaryObfuscator:
def __init__(self, output_dir: str = "obfuscated_binary")
def create_protected_executable(self, script_path: str, output_name: str) -> bool
def build_with_pyinstaller(self, script_path: str, output_name: str) -> bool
MachineCodeObfuscator
class MachineCodeObfuscator:
def __init__(self)
def create_comprehensive_protection(self, python_code: str, output_name: str) -> bool
def generate_c_extension(self, python_code: str) -> str
🤝 Contributing
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Development Setup
# Clone repository
git clone <repository-url>
cd code/obfuscator
# Install development dependencies
pip install -r requirements.txt
pip install pytest black flake8
# Run tests
python -m pytest
# Format code
black .
flake8 .
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
Documentation
Getting Help
🔄 Changelog
Version 1.0.0
- Initial release
- Memory-level obfuscation
- Binary-level obfuscation
- Machine-level obfuscation
- Liquid glass GUI
- Command-line interface
- Code validation
- Configuration management
🙏 Acknowledgments
- Python community for excellent tools and libraries
- PyInstaller team for binary packaging
- tkinter for cross-platform GUI
- All contributors and testers
Note: This tool is designed for legitimate code protection purposes. Users are responsible for ensuring compliance with applicable laws and regulations in their jurisdiction.
Project details
Release history Release notifications | RSS feed
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 minimax_python_obfuscator-1.0.4.tar.gz.
File metadata
- Download URL: minimax_python_obfuscator-1.0.4.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a56d973650ad4f8f6eb07629dcb246f0ccbec0ee2d5a51a2240b0c4402b76fd
|
|
| MD5 |
b831510138997fceb8528e01d0149071
|
|
| BLAKE2b-256 |
300771a1f860714572c739428ff7d441ab054d844fa3166cb929b86155ac43e2
|
File details
Details for the file minimax_python_obfuscator-1.0.4-py3-none-any.whl.
File metadata
- Download URL: minimax_python_obfuscator-1.0.4-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8822fa8bd6e4bae76443bec3b9075a609b0a8813c34108cc8799fd1b30b4a89b
|
|
| MD5 |
417c6693ffbf3c3293650aaf53785814
|
|
| BLAKE2b-256 |
deb440fef934faa0a076e4228d4d52b88e84e7ceeafabdedbfb9496e4fad84fa
|