Skip to main content

Advanced Python Code Protection System with AES-256-GCM encryption and AST obfuscation

Project description

PyObfuscator - Advanced Python Code Protection System

Python Version Platform License

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

  1. Linux Only: This tool is optimized for Linux environments
  2. Backup Your Code: Always keep original source code backups
  3. Test Thoroughly: Test obfuscated code before deployment
  4. GitHub Safe: No sensitive data included - safe for public repositories

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ”— Links


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

pyobfuscator_gmaq-2.0.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyobfuscator_gmaq-2.0.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file pyobfuscator_gmaq-2.0.0.tar.gz.

File metadata

  • Download URL: pyobfuscator_gmaq-2.0.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pyobfuscator_gmaq-2.0.0.tar.gz
Algorithm Hash digest
SHA256 52eba1b291f994addbbcc704d8b21f520483c8dbe6c40ea65b55cb37765ca0d1
MD5 2608490c9b014e47cec884fcf0e66ab6
BLAKE2b-256 9dcdf08b212f8e37e2d58e8bee532eca12dda38daf1c929ad8b58d7a1abe6267

See more details on using hashes here.

File details

Details for the file pyobfuscator_gmaq-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyobfuscator_gmaq-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3136f99f3a1b7f539d027f6d85670655c85ca6a852afe635468213f57b3628fc
MD5 5861d48be3b7497d859108e5121189f4
BLAKE2b-256 3c2ded40d0c6e513a44a13c30ecae72472c82d2ed89d5062064f2ed8d6543276

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page