Metadata-Version: 2.4
Name: PyProtect-v3
Version: 3.3.0
Summary: Python script obfuscation library with AES-256-GCM encryption and C extension acceleration
Author-email: NguyenNgocNam <c.nam020213@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/PyProtect/PyProtect
Project-URL: Repository, https://github.com/PyProtect/PyProtect
Keywords: obfuscation,security,cryptography,anti-debug,protection
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Security :: Cryptography
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: C
Classifier: Operating System :: OS Independent
Classifier: Environment :: Console
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: setuptools>=42.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Provides-Extra: build
Requires-Dist: wheel>=0.27.0; extra == "build"
Requires-Dist: build>=0.7.0; extra == "build"

# 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

```bash
pip install pyprotect-v3
```

### Obfuscate a Script

```bash
# 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

```python
from pyprotect import Obfuscator

obf = Obfuscator()
obf.encrypt_file("my_script.py")
```

### Run an Obfuscated Script

```bash
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

```python
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
