Skip to main content

VMP — Virtual Machine Protection for Python. Code obfuscator with register-based VM opcodes, hidden imports, anti-debug, and more.

Project description

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

pip install vmp-protector

Build (obfuscate) a file

vmp build input.py
vmp build input.py -o output.py --level 4

Use in code

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

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 importsgetuid() 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

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

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

vmp_protector-1.0.0.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

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

vmp_protector-1.0.0-py3-none-any.whl (43.8 kB view details)

Uploaded Python 3

File details

Details for the file vmp_protector-1.0.0.tar.gz.

File metadata

  • Download URL: vmp_protector-1.0.0.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for vmp_protector-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d84296f254e848ead36afd47eec9754fb90697f213f29d8c381448166f077b52
MD5 8b3a31035a986135ae74267d1f7c1884
BLAKE2b-256 98f52db1babc7b5f11696a5ca49db29809c65bd16547747f63854871fe25e4a8

See more details on using hashes here.

File details

Details for the file vmp_protector-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: vmp_protector-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 43.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for vmp_protector-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71cf1670820caf83727648953cce4043acc11fd9402cf83ed54f48673ace4184
MD5 3252103b6d9a5c159a8bb459816c3c52
BLAKE2b-256 7909d1e59c39bc7e5ffc6d13e2998e773678f0a5d5b412ad43d4b08fd063ef4f

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