Metadata-Version: 2.4
Name: vmp-protector
Version: 1.0.0
Summary: VMP — Virtual Machine Protection for Python. Code obfuscator with register-based VM opcodes, hidden imports, anti-debug, and more.
Author: VMP Security
License: MIT
Keywords: obfuscation,protection,vm,anti-debug,code-protection,pyarmor-alternative
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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: Topic :: Security
Classifier: Topic :: Software Development :: Compilers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file
Dynamic: requires-python

# VMP — Virtual Machine Protection for Python

**pip install vmp-protector**

Code protector similar to pyarmor, but fully dependent on the PyPI package — no standalone runtime folders.

## Quick Start

### Install
```bash
pip install vmp-protector
```

### Build (obfuscate) a file
```bash
vmp build input.py
vmp build input.py -o output.py --level 4
```

### Use in code
```python
import vmp
from vmp import *

# Register opcodes
mov(r1, 42)
add(r1, r2)
cmp(r1, 10)
jne(label("skip"))

# Hidden imports — no module name in source
tk = getuid("0x00004823F5", "0x000384F7")  # -> tkinter
os_mod = getuid("0x0000112233", "0x0000445566")  # -> os

# Generate UIDs for any module
from vmp.getuid import generate_uids, register_uid
uids = generate_uids("my_module")
register_uid(uids, "my_module")

# String vault
vault = StringVault(secret="key")
vault.set("api", "sk-123")
vault.get("api")

# Anti-debug decorator
@anti_debug
def my_func():
    return 42

# License system
key = generate_license(secret="my-secret", user="alice", days=30)
check_license(key, secret="my-secret")  # True

# Runtime shield
s = shield(anti_debug=True, anti_vm=True)

# Code protection decorator
@protect(level=3)
def secret_algo():
    return "hidden"

# JIT obfuscation
@jit_obfuscate
def another():
    pass

# Integrity seal
@seal_code
def sealed():
    return 1
verify_seal(sealed)  # True

# Environment check
report = check_environment()
```

## Protection Levels (vmp build)

| Level | Features |
|-------|----------|
| 1 | String encryption + variable renaming |
| 2 | + Control flow flattening + dead code injection |
| 3 | + Opaque predicates + anti-debug + watermark |
| 4 | Maximum — all of the above + extra junk code |

## How It Works

Unlike pyarmor which creates a `dist/` folder with a standalone runtime, VMP:

1. **Obfuscates** your `.py` file in-place
2. **Adds** `import vmp._runtime as _vmp_rt` at the top
3. **Encrypts** all string literals → decrypted at runtime via `_vmp_rt.ds()`
4. **Resolves** `getuid()` calls at runtime via `_vmp_rt.gui()`
5. **Requires** `pip install vmp-protector` to run the protected file

No extra folders. No standalone runtime. Just the obfuscated `.py` + the PyPI package.

## CLI Commands

```bash
vmp build input.py                    # Build with default level 3
vmp build input.py -o out.py -l 4     # Maximum protection
vmp build input.py --fingerprint me   # Custom watermark
vmp info                              # Show VMP info
vmp uid numpy                         # Generate UIDs for numpy
vmp check                             # Check for VM/sandbox
vmp check -v                          # Verbose environment report
```

## All Features

1. **Register-based VM** — 16 general-purpose registers + PC/SP/FLAGS, 28 opcodes
2. **Hidden imports** — `getuid()` resolves modules by hex UID, no name in source
3. **String encryption** — XOR + zlib + base64, per-file key
4. **Anti-debug** — IsDebuggerPresent, TracerPid, timing checks, background monitor
5. **Anti-tamper** — File checksum verification, continuous monitoring
6. **Control flow obfuscation** — Flattening, dead code, opaque predicates
7. **String vault** — Secure key-value string storage with encryption
8. **License system** — HMAC-signed license keys with expiry
9. **Code integrity** — Seal functions, detect in-memory patching
10. **JIT obfuscation** — Runtime wrapper generation with randomized names
11. **Stealth imports** — Hide module names from `sys.modules`
12. **Anti-VM/sandbox** — MAC prefix checks, process detection, DMI data
13. **Watermarking** — Zero-width character fingerprints in source
14. **Runtime shield** — One-call activation of multiple protections

## PyPI Upload

```bash
pip install build twine
python -m build
twine upload dist/*
```
