Skip to main content

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:

  1. Try to load the C extension for native decryption
  2. Fall back to pure Python if C extension unavailable
  3. 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 ctypes to 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, and ctypes

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pyprotect_v3-3.3.1-cp312-cp312-win_amd64.whl (105.6 kB view details)

Uploaded CPython 3.12Windows x86-64

pyprotect_v3-3.3.1-cp312-cp312-manylinux_2_38_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

File details

Details for the file pyprotect_v3-3.3.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyprotect_v3-3.3.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3cff674c61304ff66b572a9e0ffbd47bf6caf475297e952744143d9975e7a8d1
MD5 49bf1afdb9e1e80af7717115a66dff90
BLAKE2b-256 fdd86d2520d225422cfb25d716d963e45901feb24c0b38eb9a9afda5569d8a48

See more details on using hashes here.

File details

Details for the file pyprotect_v3-3.3.1-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for pyprotect_v3-3.3.1-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 615b71cd6892139489e85f7808d72e5b9639164664079a0020523da293c6a224
MD5 2d603425cf753a8f41528d2dde9de007
BLAKE2b-256 b1afab7f95a96902f3c9fe64d4c754a8b9215f5e79a14a4ea4683cf4c088273b

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