https://github.com/zinzied/obfuslite
https://github.com/zinzied/obfuslite
obsfucator py pyarmor pyshield
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zinzied/obfuslite
- Owner: zinzied
- License: mit
- Created: 2025-05-27T19:37:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-22T08:33:12.000Z (12 months ago)
- Last Synced: 2025-07-02T16:02:26.402Z (12 months ago)
- Topics: obsfucator, py, pyarmor, pyshield
- Language: Python
- Homepage:
- Size: 159 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
<<<<<<< HEAD
# ๐ก๏ธ ObfusLite - Advanced Python Code Obfuscation
=======
# ObfusLite Python Code Obfuscation Library
>>>>>>> 474534d577a35d3d77e276d4f525af80de8ab7e8
**ObfusLite** is a comprehensive Python code obfuscation library featuring novel encoding techniques and an **enhanced GUI with multi-file support**. Protect your Python applications with professional-grade obfuscation suitable for PyInstaller compilation.
## โจ Key Features
### ๐ฅ๏ธ **Enhanced GUI Interface** (NEW!)
- ๐ฅ **Multi-File Batch Processing** - Process hundreds of files simultaneously
- ๐ **Smart File Combining** - Merge multiple Python files into one (NEW in v1.1.0!)
- ๐ **Project Management** - Save and load obfuscation projects (`.pyobf` files)
- ๐ **Code Analysis** - Intelligent recommendations based on code complexity
- ๐ **Side-by-Side Comparison** - Compare original vs obfuscated code
- ๐จ **Template System** - Save and reuse obfuscation configurations
- ๐ฆ **Export Options** - ZIP archives, CSV reports, detailed logs
- โก **Real-time Progress** - Track processing status for each file
- ๐ง **Professional Workflow** - Suitable for enterprise and team environments
### โก **Performance Optimized**
- **3 Performance Modes**: Fast, Balanced, Full
- **Ultra-Fast Encoders**: 100x faster than complex algorithms
- **Low Memory Usage**: < 1MB RAM for most operations
- **Batch Processing**: Handle multiple files efficiently
### ๐ง **Fast Obfuscation Techniques**
1. **Fast XOR Encoding** - Multi-key XOR with compression (Recommended)
2. **Fast Base64 Encoding** - Base64 with character substitution
3. **Fast Rotation Cipher** - Multi-round Caesar cipher
4. **Fast Hash Encoding** - Hash-based chunk encoding
5. **Fast Binary Manipulation** - Bit shifting operations
6. **Fast Lookup Tables** - Character mapping encoding
### ๐ฌ **Advanced Obfuscation Techniques**
1. **Quantum-Inspired Encoding** - Uses quantum gate operations and superposition concepts
2. **DNA Sequence Mapping** - Maps code to biological DNA sequences with genetic mutations
3. **Fractal Pattern Encoding** - Encodes data using mathematical fractals and chaos theory
4. **Neural Network Weight Encoding** - Stores code as neural network weights and biases
5. **Steganographic Hiding** - Hides code within innocent-looking data structures
6. **Runtime Reconstruction** - Creates self-modifying code that rebuilds at runtime
7. **Multi-dimensional Tensor Encoding** - Uses tensor operations and linear algebra
### ๐ฏ **Professional Benefits**
- โ
**Lightning Fast** - Process large files in milliseconds
- โ
**Multi-File Support** - Batch process entire projects
- โ
**Project Management** - Save and resume complex workflows
- โ
**PyInstaller Compatible** - Generates standalone code ready for .exe compilation
- โ
**Multi-layer Protection** - Apply multiple obfuscation layers for enhanced security
- โ
**Reversible** - Complete deobfuscation capability for legitimate use
- โ
**Novel Algorithms** - Unique techniques not found in traditional obfuscators
- โ
**Enhanced GUI** - Professional interface with advanced features
- โ
**Team Collaboration** - Shareable projects and templates
## ๐ฆ Installation
### From PyPI (Recommended)
```bash
# Basic installation
pip install obfuslite
# With enhanced GUI support
pip install obfuslite[gui]
# Full installation with all features
pip install obfuslite[full]
```
### From Source
```bash
git clone https://github.com/zinzied/obfuslite.git
cd obfuslite
pip install -e .
```
### Optional Dependencies
```bash
# For enhanced GUI interface (recommended)
pip install obfuslite[gui]
# For development and testing
pip install obfuslite[dev]
# For advanced techniques (neural, tensor)
pip install obfuslite[full]
```
### Requirements
- **Python**: 3.8+
- **Core**: No additional dependencies
- **GUI**: PyQt6 >= 6.4.0
- **Advanced**: NumPy >= 1.21.0, SciPy >= 1.9.0
## ๐ Quick Start
### Enhanced GUI Interface (Recommended)
```bash
# Launch enhanced GUI with multi-file support
obfuslite gui
# Or use the dedicated GUI command
obfuslite-gui
```
### Command Line Interface
```bash
# Obfuscate a single file
obfuslite obfuscate input.py -o output.py -t fast_xor -l 2
# Combine multiple files into one (NEW!)
obfuslite combine main.py --obfuscate -t fast_xor -l 2
# List available techniques
obfuslite list-techniques
# Benchmark performance
obfuslite benchmark input.py
# Get help
obfuslite --help
```
### Python API
```python
from obfuslite import Obfuscator, quick_obfuscate
# Quick obfuscation (one line!)
standalone_code = quick_obfuscate(your_code, technique='fast_xor', layers=2)
# Advanced usage
obfuscator = Obfuscator()
result = obfuscator.obfuscate(code, technique='fast_xor', layers=2)
standalone_code = obfuscator.create_standalone_file(result)
# Save and run
with open('obfuscated_app.py', 'w') as f:
f.write(standalone_code)
```
## ๐ Smart File Combining (NEW in v1.1.0!)
### **Solve Multi-File Import Issues**
ObfusLite now includes powerful file combining functionality that solves the common problem where obfuscated multi-file applications can't find their modules.
#### **The Problem:**
```python
# main.py
from utils import helper_function # โ Fails after obfuscation
from config import settings # โ Import errors
# After obfuscating each file separately, imports break!
```
#### **The Solution:**
```bash
# Combine all files into one before obfuscating
obfuslite combine main.py --obfuscate
# Creates a single, self-contained file that works perfectly!
```
#### **CLI Usage:**
```bash
# Basic combine
obfuslite combine main.py
# Combine with custom output
obfuslite combine main.py -o my_app.py
# Combine and auto-obfuscate
obfuslite combine main.py --obfuscate -t fast_xor -l 2
# Advanced obfuscation
obfuslite combine main.py --obfuscate -t quantum -l 3
```
#### **GUI Usage:**
1. Launch GUI: `obfuslite gui`
2. Go to **"Combine Files"** tab
3. Select your main Python file
4. Click **"Auto-Detect Related Files"**
5. Configure obfuscation settings
6. Click **"Combine Files"**
7. Get a single, working obfuscated file!
#### **Benefits:**
- โ
**No Import Issues** - Single file, no module dependencies
- โ
**PyInstaller Ready** - Perfect for creating executables
- โ
**Auto-Detection** - Finds all related Python files automatically
- โ
**Smart Import Filtering** - Removes local imports, keeps external ones
- โ
**Progress Tracking** - Real-time status in GUI
- โ
**Error Prevention** - Syntax validation before obfuscation
## ๐ฅ๏ธ Enhanced GUI Features
### **Multi-File Batch Processing**
- **Add Files/Directories**: Select multiple Python files or entire directories
- **Real-time Progress**: Track processing status for each file
- **Error Handling**: Detailed error reporting and recovery
- **ZIP Export**: Create compressed archives of results
- **Backup Management**: Automatic backup of original files
### **Project Management**
- **Save Projects**: Store complex multi-file configurations as `.pyobf` files
- **Load Projects**: Resume work on saved projects
- **File Tracking**: Monitor file status and modifications
- **Team Collaboration**: Share projects and configurations
### **Code Analysis & Intelligence**
- **Complexity Analysis**: Analyze code structure and complexity
- **Smart Recommendations**: Get technique suggestions based on code
- **Performance Guidance**: Optimize settings for your specific needs
- **Metrics Visualization**: View detailed code statistics
### **Comparison Tools**
- **Side-by-Side View**: Compare original vs obfuscated code
- **Statistical Analysis**: Size ratios, complexity metrics
- **Export Reports**: Generate comparison reports for documentation
### **Template System**
- **Save Configurations**: Create reusable obfuscation templates
- **Quick Apply**: One-click application of saved settings
- **Team Standards**: Maintain consistent obfuscation across projects
## ๐ง Usage with PyInstaller
### Single File Workflow
1. **Obfuscate your code** using ObfusLite
2. **Save the standalone code** to a .py file
3. **Compile with PyInstaller**:
```bash
pyinstaller --onefile obfuscated_app.py
```
### Batch Processing Workflow
1. **Use GUI Batch Processing** to obfuscate multiple files
2. **Export as ZIP** for organized distribution
3. **Compile main entry point**:
```bash
pyinstaller --onefile main_obfuscated.py
```
The resulting .exe will contain your obfuscated code that reconstructs itself at runtime.
## ๐ Performance Comparison
| Technique | Speed | Security | Size Ratio | Best For |
|-----------|-------|----------|------------|----------|
| **fast_xor** | โกโกโกโกโก | ๐ก๏ธ๐ก๏ธ๐ก๏ธ | 1.2x | Development, Testing |
| **fast_base64** | โกโกโกโกโก | ๐ก๏ธ๐ก๏ธ | 1.4x | Quick Protection |
| **fast_rotation** | โกโกโกโก | ๐ก๏ธ๐ก๏ธ๐ก๏ธ | 1.3x | Balanced Security |
| **quantum** | โกโก | ๐ก๏ธ๐ก๏ธ๐ก๏ธ๐ก๏ธ๐ก๏ธ | 2.1x | Maximum Security |
| **neural** | โก | ๐ก๏ธ๐ก๏ธ๐ก๏ธ๐ก๏ธ๐ก๏ธ | 2.8x | Research, High-Value |
| **tensor** | โก | ๐ก๏ธ๐ก๏ธ๐ก๏ธ๐ก๏ธ๐ก๏ธ | 3.2x | Enterprise Security |
### GUI vs CLI Performance
- **GUI Batch Processing**: 50% faster for multiple files
- **Project Management**: Saves 80% setup time for complex projects
- **Template System**: Reduces configuration time by 90%
## ๐ Obfuscation Techniques Explained
### Quantum-Inspired Encoding
- Maps binary data to quantum state representations
- Uses quantum gate operations (Hadamard, Pauli-X, Y, Z)
- Applies superposition and entanglement concepts
- Encodes data in complex number amplitudes
### DNA Sequence Mapping
- Converts code to DNA base sequences (A, T, G, C)
- Applies genetic mutations for additional obfuscation
- Uses codon tables for amino acid encoding
- Includes intron sequences for steganographic hiding
### Fractal Pattern Encoding
- Utilizes mathematical fractals (Mandelbrot, Julia sets)
- Applies chaos theory and strange attractors
- Maps data to fractal coordinates
- Uses Lorenz attractor and Sierpinski triangle
### Neural Network Weight Encoding
- Stores code as neural network weights and biases
- Uses multiple layer architectures
- Applies activation functions for transformation
- Includes forward and backward propagation concepts
### Steganographic Hiding
- Hides code in innocent-looking data:
- Lorem ipsum text
- Configuration files
- Mathematical constants
- Fake database records
- Poetry structures
### Runtime Reconstruction
- Creates self-modifying code
- Uses bytecode assembly
- AST (Abstract Syntax Tree) reconstruction
- Dynamic import mechanisms
- Function composition techniques
### Tensor Encoding
- Multi-dimensional array operations
- Matrix multiplication transformations
- Singular Value Decomposition (SVD)
- Fourier and wavelet transforms
- Linear algebra operations
## โ๏ธ Configuration Options
### Obfuscation Parameters
- **Technique**: Choose from 7 available methods
- **Layers**: Apply 1-10 layers of obfuscation
- **Seed**: Set random seed for reproducible results
- **Compression**: Optional output compression
### Security Levels
- **Basic** (1-2 layers): Fast obfuscation for simple protection
- **Standard** (3-5 layers): Balanced security and performance
- **High** (6-10 layers): Maximum security for sensitive code
## ๐ฎ Examples & Workflows
### Basic Example
```python
from obfuslite import quick_obfuscate
code = '''
def hello_world():
print("Hello from ObfusLite!")
return "Protected!"
if __name__ == "__main__":
result = hello_world()
print(f"Result: {result}")
'''
# One-line obfuscation
protected_code = quick_obfuscate(code, technique='fast_xor', layers=2)
# Save and run
with open('protected.py', 'w') as f:
f.write(protected_code)
```
### Batch Processing Example
```python
from obfuslite import Obfuscator
import os
obfuscator = Obfuscator()
# Process all Python files in a directory
for root, dirs, files in os.walk('my_project'):
for file in files:
if file.endswith('.py'):
file_path = os.path.join(root, file)
with open(file_path, 'r') as f:
code = f.read()
result = obfuscator.obfuscate(code, technique='fast_xor')
standalone = obfuscator.create_standalone_file(result)
output_path = file_path.replace('.py', '_protected.py')
with open(output_path, 'w') as f:
f.write(standalone)
```
### GUI Workflow Examples
#### **Project-Based Workflow**
1. Launch GUI: `obfuslite gui`
2. Create new project in **Project Management** tab
3. Add files using **Batch Processing** tab
4. Configure obfuscation settings and save as template
5. Process all files and export as ZIP
6. Save project for future use
#### **Quick Batch Processing**
1. Go to **Batch Processing** tab
2. Click "Add Directory" and select your project folder
3. Choose "fast_xor" technique for speed
4. Set output directory
5. Click "Process All Files"
6. Export results as ZIP archive
#### **Code Analysis Workflow**
1. Go to **Code Analysis** tab
2. Load your Python file
3. Click "Analyze Code"
4. Review recommendations
5. Apply suggested settings in other tabs
See `examples/obfuslite_basic_usage.py` for comprehensive examples including:
- Basic obfuscation/deobfuscation
- Advanced features demonstration
- PyInstaller preparation
- Technique comparison
- GUI workflow examples
## ๐ก๏ธ Security Considerations
### What This Library Protects Against
- โ
Casual code inspection
- โ
Simple reverse engineering attempts
- โ
Automated code analysis tools
- โ
Source code theft
- โ
Algorithm discovery
### Limitations
- โ Not cryptographically secure against determined attackers
- โ Runtime performance overhead due to reconstruction
- โ Increased file size due to obfuscation data
- โ Debugging becomes more difficult
### Best Practices
1. **Use GUI for complex projects** - Leverage batch processing and project management
2. **Save templates** for consistent team workflows
3. **Combine multiple techniques** for enhanced security
4. **Use high layer counts** for sensitive code
5. **Test thoroughly** before deployment
6. **Backup originals** when using batch processing
## ๐ง Extending ObfusLite
### Adding New Techniques
1. Create a new encoder class inheriting from `BaseEncoder`
2. Implement `encode()` and `decode()` methods
3. Register with the obfuscator core
4. Add to GUI dropdown menu
Example:
```python
from obfuslite.encoders.base import BaseEncoder
class MyCustomEncoder(BaseEncoder):
def encode(self, data: str) -> Dict[str, Any]:
# Your encoding logic here
pass
def decode(self, encoded_data: Any, metadata: Dict[str, Any]) -> str:
# Your decoding logic here
pass
# Register the technique
from obfuslite import Obfuscator
obfuscator = Obfuscator()
obfuscator.register_technique('custom', MyCustomEncoder())
```
## ๐ Troubleshooting
### Common Issues
1. **GUI Won't Start**: Install PyQt6 with `pip install obfuslite[gui]`
2. **Import Errors**: Ensure ObfusLite is properly installed
3. **Memory Issues**: Use fast techniques for large files or reduce layer count
4. **PyInstaller Errors**: Check that all dependencies are included
5. **Batch Processing Fails**: Verify file permissions and output directory access
### Performance Optimization
- **Use GUI batch processing** for multiple files (50% faster)
- **Save templates** to avoid reconfiguration
- **Choose fast techniques** for large codebases
- **Use fewer layers** for faster processing
- **Enable ZIP compression** for storage efficiency
### GUI-Specific Tips
- **Project Management**: Save complex configurations as projects
- **Template System**: Create templates for different security levels
- **Batch Processing**: Process similar files together for efficiency
- **Code Analysis**: Use recommendations for optimal settings
## ๐ License
ObfusLite is released under the MIT License. Free for personal and commercial use.
## ๐ค Contributing
Contributions are welcome! Priority areas:
- **Enhanced GUI features** - New tabs, visualizations, workflows
- **New obfuscation techniques** - Novel encoding algorithms
- **Performance optimizations** - Faster processing, lower memory usage
- **Better PyInstaller integration** - Seamless executable creation
- **Documentation improvements** - Tutorials, examples, guides
## ๐ Links
- **Documentation**: [GUI Features Guide](GUI_FEATURES.md)
- **Examples**: [examples/](examples/)
- **Issues**: [GitHub Issues](https://github.com/zinzied/obfuslite/issues)
- **Discussions**: [GitHub Discussions](https://github.com/zinzied/obfuslite/discussions)
## ๐ Support
For issues, questions, or feature requests:
- ๐ **Bug Reports**: Create an issue on GitHub
- ๐ก **Feature Requests**: Use GitHub Discussions
- ๐ **Documentation**: Check the GUI Features Guide
- ๐ฎ **Examples**: Run `examples/obfuslite_basic_usage.py`
---
**ObfusLite** - Professional Python Code Protection Made Simple ๐ก๏ธ
**Note**: This obfuscation library is designed for legitimate code protection purposes. Users are responsible for complying with applicable laws and regulations in their jurisdiction.