vm-obfuscator-pro
v4.3.2
Published
VM Obfuscator Pro — multi-layer VM-based JavaScript obfuscator with bytecode encryption, dynamic opcodes, per-function opcode remapping, jump-table hiding, self-modifying bytecode, multi-layer VM bootstrap, anti-debug, anti-tamper, and more. v4.0.2: named
Maintainers
Readme
VM Obfuscator Pro
Multi-layer VM-based JavaScript obfuscator. Compiles your JavaScript into encrypted bytecode executed by an embedded virtual machine — the original AST is destroyed, not merely renamed.
Zero dependencies. The parser is vendored; npm i vm-obfuscator-pro
installs in under a second and works standalone.
Install
npm i vm-obfuscator-proQuick start
const VMObfuscator = require('vm-obfuscator-pro');
const ob = new VMObfuscator({ preset: 'vm' });
const result = ob.obfuscate('function greet(name) { return "Hello, " + name + "!"; } console.log(greet("World"));');
console.log(result.code);CLI:
npx vmobf input.js -o output.js --preset vmCorrectness — verified, not claimed
Every release passes a differential test rig: 44 real-world-style programs
(closures, classes with extends/super, generators, async/await, spread
over Sets/Maps/generators, sparse arrays, labeled loops, tagged templates,
try/catch/finally, getters/setters, …) are run plain, then obfuscated under
each preset, and their stdout must match byte-for-byte. The rig also plants
canary strings to catch the worst failure mode — an obfuscator that quietly
ships your original source when it can't compile something.
This package never silently falls back to source. If your code uses
something the compiler can't handle, obfuscate() throws with the exact
construct and location. (You can opt into the old behavior with
fallbackToSource: true — the output then contains plaintext code and a
loud warning.)
Supported language surface
Classes (incl. extends, super(), statics, accessors), closures and
upvalue capture (including per-iteration let in loops), generators,
async/await, spread/rest everywhere (via the real Symbol.iterator
protocol), destructuring, default parameters, labeled break/continue,
tagged templates, optional chaining, ??, try/catch/finally, and more.
Not supported (fails loudly at build time): private class fields
(#x), class field initializers, for await...of, BigInt literals.
Performance
- Generated-code runtime: ~4× plain JavaScript on hot loops
(
preloadBytecode: true, the default, decrypts the program once at startup). SetpreloadBytecode: falseto keep lazy per-token decryption (anti-dump) at higher runtime cost — themaxpreset does this. - Build time: ~30 ms for typical files.
- Output size: ~28 KB runtime overhead + encrypted bytecode.
Presets
| Preset | Description |
|--------|-------------|
| vm-low | Lightweight. VM + encryption, fast, small. |
| vm | Balanced (recommended). All core layers, preload enabled. |
| max | Everything, including lazy AES per-token decryption, anti-dump, full anti-debug suite. Slowest runtime, strongest anti-analysis. |
| custom | Blank slate for individual flags. |
Layers (highlights)
- Bytecode compilation — JS → custom 99-opcode bytecode; no function bodies or string literals survive in the output.
- Per-build opcode shuffle + per-function second remapping + jump-table hiding + chunk permutation.
- Encoding — XOR-block + Feistel, AES-like S-box, or real AES-128-CBC (key material scattered, wiped after expansion).
- Self-modifying bytecode — position-dependent XOR reversed at runtime.
- Multi-layer VM — register-based bootstrap VM (VM1) decrypts for the stack VM (VM2), with a decoy VM (VM3) behind opaque predicates.
- Runtime hardening — early-captured globals (immune to later hooking), encrypted constant caches, optional stack encoding and 3-phase handler rotation.
- IR layer — MBA arithmetic, IR-level control-flow flattening with 4 decode shapes + state aliases + fake states, exception-based control flow, call-graph obfuscation, value encoding.
- Anti-debug / anti-tamper (opt-in per preset) — 7-vector DevTools detection, timing checks, integrity hashing (whitespace-immune), self-defending output, domain lock, code expiry/run locks.
Run npx vmobf --list-options for all 70+ options and --list-presets.
What this protects against
VM obfuscation raises reverse-engineering cost from minutes to days. It does not make code impossible to analyze — the decryptor ships with the program, so a determined expert with a debugger can always recover behavior. Use it to stop casual copying, tampering, and license bypass. For threats beyond that, no client-side protection (including commercial ones) is sufficient.
Testing
node test/gen-corpus.js # regenerate the corpus
node test/run.js # full differential matrix (must be 132/132)
node test/run.js --bench # build + runtime timingLicense
UNLICENSED — proprietary, closed-source. Distributed exclusively via npm.
Vendored acorn (MIT) in vendor/ with its license.
