Python script obfuscation library with AES-256-GCM encryption and C extension acceleration
Project description
pyprotect-v3
A production-ready Python script obfuscation library with AES-256-GCM encryption, multi-platform C extension acceleration, and graceful pure-Python fallback.
Features
- AES-256-GCM Encryption — Industry-standard authenticated encryption
- C Extension Acceleration — Native code for decryption, anti-debug, and execution
- Multi-Platform — Windows, macOS, Linux with platform-specific anti-debug
- Pure Python Fallback — Graceful degradation if C extension fails to build
- Import Hook Support — Protect entire packages with transparent decryption
- CLI Tool — Simple command-line interface for obfuscating scripts
- PyPI Ready — Upload to PyPI with
pip install pyprotect-v3
Quick Start
Install
pip install pyprotect-v3
Obfuscate a Script
# Encrypt a single file
python -m pyprotect encrypt my_script.py -o dist/
# Encrypt an entire package
python -m pyprotect encrypt-dir mypackage/ -o dist/
# Build C extension only
python -m pyprotect build-engine
Programmatic Usage
from pyprotect import Obfuscator
obf = Obfuscator()
obf.encrypt_file("my_script.py")
Run an Obfuscated Script
python my_script_protected.py
The script will automatically:
- Try to load the C extension for native decryption
- Fall back to pure Python if C extension unavailable
- Decrypt and execute the original code
Protect a Package with Import Hook
from pyprotect.hooks import install_hook
hook = install_hook(key=b"your-32-byte-key-here!!!!!!")
import my_protected_module
Architecture
pyprotect-v3/
├── pyprotect/
│ ├── __init__.py # Package init, version info
│ ├── __main__.py # CLI: python -m pyprotect
│ ├── obfuscator.py # Main obfuscation tool
│ ├── engine.c # Cross-platform C extension
│ ├── engine.py # Pure Python fallback engine
│ ├── crypto.py # AES-GCM encryption (ctypes + pure Python)
│ ├── anti_debug.py # Anti-debug checks (Python fallback)
│ └── hooks.py # Import hook for multi-module protection
├── setup.py # PyPI-ready setup
├── pyproject.toml # Build configuration
└── README.md # This file
Anti-Debug Features
| Platform | Techniques |
|---|---|
| Linux | /proc/self/status TracerPid, ptrace(PTRACE_TRACEME) |
| Windows | IsDebuggerPresent(), CheckRemoteDebuggerPresent(), NtQueryInformationProcess() |
| macOS | ptrace(PT_DENY_ATTACH), sysctl KERN_PROC |
C Extension Fallback
If the C extension fails to build (no C compiler, missing OpenSSL, etc.), pyprotect-v3 automatically uses a pure Python fallback that:
- Uses
ctypesto call OpenSSL for AES-GCM decryption if available - Falls back to a built-in pure Python AES-256-GCM implementation
- Performs anti-debug checks via
os,sys, andctypes
License
MIT
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 Distributions
Built Distributions
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 pyprotect_v3-3.3.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pyprotect_v3-3.3.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 105.6 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cff674c61304ff66b572a9e0ffbd47bf6caf475297e952744143d9975e7a8d1
|
|
| MD5 |
49bf1afdb9e1e80af7717115a66dff90
|
|
| BLAKE2b-256 |
fdd86d2520d225422cfb25d716d963e45901feb24c0b38eb9a9afda5569d8a48
|
File details
Details for the file pyprotect_v3-3.3.1-cp312-cp312-manylinux_2_38_x86_64.whl.
File metadata
- Download URL: pyprotect_v3-3.3.1-cp312-cp312-manylinux_2_38_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.38+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
615b71cd6892139489e85f7808d72e5b9639164664079a0020523da293c6a224
|
|
| MD5 |
2d603425cf753a8f41528d2dde9de007
|
|
| BLAKE2b-256 |
b1afab7f95a96902f3c9fe64d4c754a8b9215f5e79a14a4ea4683cf4c088273b
|