Production-grade AST deobfuscator and anti-analysis neutralization engine.
Reverse hostile anti-bot challenge scripts, unflatten state-machine control flow, inline operation proxies, harvest isolated string banks, and neutralize anti-tamper logic with zero semantic drift.
- Executive Summary
- Key Capabilities
- Performance Benchmarks
- Defense Matrix & Target Coverage
- Architecture Pipeline
- Installation & Requirements
- Usage
- Deobfuscation Mechanics & Transformations
- 1. Control-Flow Unflattening
- 2. Proxy Function & Dictionary Inlining
- 3. Isolated String-Bank Harvester
- 4. Fixpoint Constant Folding
- 5. Anti-Tamper & Tripwire Neutralization
- 6. Comma Sequence Splitting
- 7. Logical Guard Unwrapping
- 8. Multi-Hop Constant & Alias Propagation
- 9. Literal & Character Normalization
- 10. Statement Ternary Unrolling
- 11. Yoda Condition Normalization
- 12. Compound Declaration Splitting
- Machine-Readable JSON Audit Report
- Verification & Testing Matrix
- License
Enterprise anti-bot challenge scripts (Akamai Bot Manager, Cloudflare Turnstile, DataDome, Shape Security, Kasada, and ThreatMetrix) protect telemetry collectors, canvas/sensor probes, and behavioral fingerprinting behind layered obfuscation. These defenses use switch-case dispatch loops, dynamic function wrappers, encrypted string arrays, and anti-tamper tripwires to prevent inspection.
disarm is a multi-pass Abstract Syntax Tree (AST) transformer and sandboxed dynamic analysis engine built for security teams, reverse engineers, and automated CI/CD threat intelligence pipelines. It decomposes hostile scripts into clean, auditable, and syntactically normalized modern JavaScript without breaking runtime semantics.
- Zero Semantic Drift Guarantee: Every transform preserves exact JavaScript execution semantics. Differential oracle suites execute raw and deobfuscated payloads side-by-side in isolated V8 contexts to verify zero behavioral divergence.
- State-Machine Control-Flow Unflattening: Reconstructs linear control flow from scrambled while-switch loops and state arrays. Preserves complex loops, conditionals, and switch fallthrough logic.
- Isolated Sandbox String Harvester: Executes string bank decoders inside a hardened, isolated Node.js
vmcontext with simulated browser environments (window,navigator,document,crypto,screen). Harvests and inlines decrypted strings at compile time. - Two-Phase Fixpoint Optimization: Runs iterative constant folding, proxy inlining, and dead-code elimination passes to a mathematical fixpoint.
- Anti-Analysis & Tripwire Disarming: Automatically disables debugger traps (
debugger;,Function("debugger")()), infinite recursion loops, and single-call anti-tamper wrappers without modifying legitimate business logic. - CI/CD & Headless Automation Ready: Supports Unix stdin/stdout streaming (
curl -s <url> | disarm -), automatic V8 memory auto-scaling for multi-megabyte payloads, and structured JSON telemetry reports for automated SIEM ingestion.
Engine performance measured on a real-world 2.44 MB production target bundle (new-test.js, 640,859 AST nodes) across all 32 pipeline stages:
| Metric | Measurement | Technical Context |
|---|---|---|
| Input Payload Size | 2.44 MB (2,554,357 bytes) | Enterprise anti-bot challenge bundle |
| AST Node Volume | 640,859 input nodes | Parsed via Babel parser (script mode) |
| Transformations Applied | 106,896 AST modifications | Zero manual patching required |
| Total Pipeline Runtime | 50.1 seconds | Parse (290 ms) + 32 Passes (49.7 s) + Print (170 ms) |
| Fixpoint Convergence | 2 rounds | Sub-expression loop elimination |
| Heap Memory Overhead | Auto-scaled to 4096 MB | Seamless execution in containerized CI environments |
| Target System | Key Obfuscation Vectors | Disarm Deobfuscation Mechanism |
|---|---|---|
| Akamai Bot Manager | Sensor data telemetry, heavy array rotation, switch dispatchers | Dynamic string harvesting, loop unflattening, constant folding |
| Cloudflare Turnstile | /challenge-platform/ orchestrator, opaque predicates, dispatch loops |
State-machine reconstruction, proxy inlining, dead branch culling |
| DataDome | Rotated AST transforms, wrapper chains, dynamic eval | Multi-hop proxy inlining, decoder sandbox isolation |
| Kasada | Virtual machine bytecodes, comma sequence chaining, hex literals | Comma sequence splitting, hex normalization, constant folding |
| ThreatMetrix (TMX) | Instance string decoders, radix encodings, guarded calls | Class-based bank harvesting, radix conversion folding |
| obfuscator.io / Custom | Self-defending controllers, dead code injection, hex names | Controller neutralization, identifier re-scoping, dead code sweep |
Hostile JavaScript Input
│
▼
[ Babel AST Parser ]
(Script mode, error recovery)
│
┌─────────────────────────────────────┴─────────────────────────────────────┐
│ │
│ Phase 1: Fingerprint & Sequence Pre-processing │
│ ├── 01. detect-techniques Fingerprint obfuscation techniques │
│ ├── 02. split-sequences Unwrap comma operators into statements │
│ ├── 03. split-declarations Split compound variable declarations │
│ ├── 04. fuse-literals Fuse split strings & arithmetic trees │
│ ├── 05. strip-debug-traps Purge debugger statements & trap ctors │
│ └── 06. strip-self-defending Neutralize single-call anti-tamper │
│ │
│ Phase 2: Structural Unravelling │
│ ├── 07. inline-proxies Inline wrapper functions & dictionaries │
│ ├── 08. unflatten-control-flow Reconstruct linear code from switches │
│ ├── 09. unwrap-logical-guards Convert && and || chains to if-blocks │
│ └── 10. unwrap-ternaries Convert statement ternaries to if/else │
│ │
│ Phase 3: String Decryption & Constant Evaluation │
│ ├── 11. decode-string-banks Sandbox-harvest & inline string banks │
│ ├── 12. simplify-tricks Fold coercion tricks (![], !0, void 0) │
│ ├── 13. normalize-conditions Flip inverted Yoda comparisons │
│ ├── 14. fold-number-tostring Fold Number(n).toString(radix) │
│ ├── 15. fold-unescape Fold unescape, atob, btoa, URI codecs │
│ ├── 16. fold-constants Pure binary/unary/logical fixpoint loop │
│ └── 17. propagate-constants Propagate constant values & aliases │
│ │
│ Phase 4: Secondary Fixpoint Pass │
│ ├── 18. strip-debug-traps Purge traps exposed by folded strings │
│ ├── 19. strip-self-defending Re-evaluate exposed tamper controllers │
│ ├── 20. inline-proxies Inline remaining secondary proxies │
│ ├── 21. unflatten-control-flow Unflatten remaining nested dispatchers │
│ ├── 22. unwrap-logical-guards Unwrap newly exposed logical guards │
│ ├── 23. unwrap-ternaries Unwrap newly exposed statement ternaries│
│ ├── 24. fuse-literals Re-fuse secondary split strings │
│ ├── 25. fold-constants Fold newly exposed constant expressions │
│ └── 26. propagate-constants Collapse secondary alias references │
│ │
│ Phase 5: Normalization & Final Polish │
│ ├── 27. normalize-conditions Final sweep on inverted comparisons │
│ ├── 28. normalize-literals Convert 0x1f4 -> 500 and unescape chars │
│ ├── 29. normalize-member Rewrite a["prop"] -> a.prop │
│ ├── 30. remove-dead-code Drop literal branches & unreachable code│
│ ├── 31. rename-identifiers Scope-aware renaming of junk tokens │
│ └── 32. cleanup Prune empty statements & pure literals │
│ │
└─────────────────────────────────────┬─────────────────────────────────────┘
│
▼
[ Babel AST Code Generator ]
│
▼
Clean JavaScript + Audit Report
- Node.js >= 18.0.0 (LTS recommended)
- Memory: Minimum 2 GB RAM (automatically expands to 4 GB for payloads >= 2.5 MB)
# Clone the repository
git clone https://github.com/cipherwire/disarm.git
cd disarm
# Install dependencies (strictly Babel AST parser/traverse/generator)
npm ci
# Run verification suite (all 45 tests)
npm test# Deobfuscate file to default output directory (output/<basename>.clean.js)
node src/cli.js target.js
# Custom output destination and JSON audit log
node src/cli.js challenge.js -o dist/clean.js --report dist/audit.json
# Stdin to stdout streaming (useful for curl / pipeline integrations)
curl -s "https://example.com/sensor.js" | node src/cli.js - > sensor.clean.js
# Telemetry inspection mode: extract detected fingerprinting probes & API targets
node src/cli.js inspect challenge.js
# Annotate disarmed anti-tamper logic with explanatory comments
node src/cli.js challenge.js --annotateIntegrate disarm directly into automated ingestion, vulnerability scanning, and threat intelligence pipelines:
name: Security Analysis Pipeline
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
analyze-payloads:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install disarm
run: |
git clone https://github.com/cipherwire/disarm.git /opt/disarm
cd /opt/disarm && npm ci
- name: Fetch and Deobfuscate Target Payload
run: |
curl -sSL "https://cdn.example.com/telemetry.js" > /tmp/payload.js
node /opt/disarm/src/cli.js /tmp/payload.js \
-o /tmp/payload.clean.js \
--report /tmp/payload.report.json \
--inspect
- name: Upload Clean Artifact & Telemetry Report
uses: actions/upload-artifact@v4
with:
name: deobfuscated-telemetry
path: |
/tmp/payload.clean.js
/tmp/payload.report.jsonConsume disarm as an ES module within security tooling:
import { deobfuscate, inspectTelemetry } from './src/index.js';
const obfuscatedSource = `
var _0xseq = "2|0|1".split("|"), _0xidx = 0;
while (true) {
switch (_0xseq[_0xidx++]) {
case "0": var b = 20; continue;
case "1": return a + b;
case "2": var a = 10; continue;
}
break;
}
`;
// Execute full 32-pass deobfuscation
const { code, report, ast } = deobfuscate(obfuscatedSource, {
sandbox: true, // Enable sandboxed string-bank harvester (default: true)
telemetry: true, // Calculate AST complexity reduction metrics (default: true)
annotate: false, // Insert explanatory comments above disarmed traps (default: false)
});
console.log(code);
// Output:
// var a = 10;
// var b = 20;
// return a + b;
console.log(`Changes made: ${report.totalChanges()}`);
// Output: Changes made: 4
// Extract browser probes and telemetry endpoints
const inspection = inspectTelemetry(ast);
console.log(inspection.endpoints);Transforms scrambled state-machine loops back into sequential execution blocks while strictly preserving switch fallthrough semantics:
// Before
var seq = "2|0|1".split("|"), idx = 0;
while (true) {
switch (seq[idx++]) {
case "0": b(); continue;
case "1": c(); continue;
case "2": a(); continue;
}
break;
}
// After disarm
a();
b();
c();Inlines single-return wrapper functions and object dictionary dispatchers, with automatic argument purity checking to prevent side-effect duplication:
// Before
var dict = {
"add": function(a, b) { return a + b; },
"key": "token"
};
var total = dict.add(10, 20);
var header = dict.key;
// After disarm
var total = 30;
var header = "token";Executes encrypted string banks inside a hardened Node.js vm context with simulated browser environments. Probes discovered decoders with literal arguments, substitutes decrypted strings directly into the AST, and strips dead bank arrays.
Evaluates constant binary, unary, and logical operations iteratively. Automatically skips pre-folded negative constants (-Infinity, -0) to reach fixpoint in 2 rounds:
// Before
var offset = (0x10 * 4 + 2) ^ 0;
var negInf = -1 / 0;
var encoded = atob("YW50aV9ib3Q=");
// After disarm
var offset = 66;
var negInf = -Infinity;
var encoded = "anti_bot";Detects beautification tripwires (Function("debugger")(), debugger;, prototype length checks) and neutralizes them to undefined or no-op stubs without breaking surrounding business logic:
// Before
function calculate() {
var a = checkState() ? Function("debugger")() : 42;
return a;
}
// After disarm
function calculate() {
var a = checkState() ? undefined : 42;
return a;
}Splits dense comma-separated expressions in variable initializers, expression statements, and return statements into sequential lines:
// Before
(a = 1, b = 2, dispatch(a + b));
return x = 10, y = 20, x + y;
// After disarm
a = 1;
b = 2;
dispatch(a + b);
x = 10;
y = 20;
return x + y;Translates short-circuit logical expressions (&& and ||) used to obscure conditional execution into structured if blocks:
// Before
isReady && initialize();
!isBlocked || abort();
// After disarm
if (isReady) {
initialize();
}
if (isBlocked) {
abort();
}Propagates constant strings and single-assignment aliases through variable chains directly to call sites:
// Before
var base = "https://telemetry.target.api";
var r1 = base;
var r2 = r1;
fetch(r2);
// After disarm
fetch("https://telemetry.target.api");Normalizes obscure hexadecimal numbers and escaped unicode/hex strings back to clean decimals and unescaped UTF-8 characters:
// Before
var port = 0x1bb;
var message = "\x73\x65\x6e\x73\x6f\x72\x5f\x6f\x6b";
// After disarm
var port = 443;
var message = "sensor_ok";Converts statement-level ternary expressions into structured if/else and else if blocks:
// Before
isReady ? (initialize(), start()) : (retryCount++, wait());
// After disarm
if (isReady) {
initialize();
start();
} else {
retryCount++;
wait();
}Inverts backwards comparisons to place variables on the left and literals on the right:
// Before
if ("hidden" === document.visibilityState && 403 === response.status)
// After disarm
if (document.visibilityState === "hidden" && response.status === 403)Breaks multi-declarator variable statements into distinct statements:
// Before
var a = init(), b = configure(), c = start();
// After disarm
var a = init();
var b = configure();
var c = start();Every run produces an auditable JSON report recording pass counts, notes, technique detections, and complexity metrics:
{
"tool": "disarm",
"generatedAt": "2026-11-03T04:00:00.000Z",
"totalChanges": 106896,
"telemetry": {
"initial": {
"cyclomatic": 16257,
"nodeCount": 640859,
"totalIdentifiers": 235574,
"opaqueRatio": 75
},
"final": {
"cyclomatic": 16722,
"nodeCount": 668482,
"totalIdentifiers": 237077,
"opaqueRatio": 75
},
"readabilityScore": 48
},
"passes": [
{
"name": "split-sequences",
"changes": 16859,
"notes": ["unwrapped 16859 comma sequence expression(s)"]
},
{
"name": "split-declarations",
"changes": 5772,
"notes": ["split 5772 compound variable declaration(s)"]
},
{
"name": "inline-proxies",
"changes": 1090,
"notes": ["inlined 1090 proxy function/object call(s)"]
},
{
"name": "decode-string-banks",
"changes": 47,
"notes": ["found 1 decoder function(s)"]
},
{
"name": "normalize-literals",
"changes": 73148,
"notes": ["normalized 73148 hexadecimal or escaped literal(s)"]
}
],
"meta": {
"techniques": [
{ "name": "coercion-trick", "count": 577 },
{ "name": "string-array-literal", "count": 170 },
{ "name": "guarded-decoder-call", "count": 37 },
{ "name": "function-ctor-call", "count": 10 }
],
"inspection": {
"endpoints": [
"https://telemetry.target.api/v1/sensor"
],
"summary": {
"hasAutomationCheck": true,
"hasCanvasFingerprint": true
}
}
}
}The test suite runs across Linux and Windows on Node.js 18.x, 20.x, and 22.x:
# Run all 45 automated tests
npm test
# Run individual verification suites
npm run test:verify # 20 core transformation unit tests
npm run test:oracle # 5 semantic differential oracle tests
npm run test:probe # 10 empirical regression audit probes
npm run test:behavior # 13 round-trip behavior gauntlet tests
# Benchmark pipeline execution on a target file
npm run profile <path-to-target.js>-
Core Verification Suite (
tools/verify.js- 20 checks):- Control-flow unflattening state recovery
- Proxy function wrapper inlining
- Object dictionary operation inlining
- Negative arithmetic constant folding
- Coercion trick simplification (
!0,!1,[][[]] + "") - Member normalization on reserved words (
obj.default,obj.catch) - Trap stripping and anti-tamper neutralization
- Comma sequence expression splitting
- Logical guard unwrapping into structured
ifstatements - Multi-hop constant and alias chain propagation
- Hexadecimal and Unicode string literal normalization
- End-to-end modern challenge reconstruction
- Statement ternary unrolling
- Yoda condition normalization
- Compound declaration splitting
- Split string and arithmetic tree fusion
- Structural complexity telemetry scoring
- Browser fingerprint and telemetry inspection
- Explanatory comment annotations
- Stdin pipe ingestion and direct stdout streaming
-
Semantic Differential Oracle (
tools/oracle.js- 5 checks):- Arithmetic and split string evaluation invariance
- State machine control flow execution invariance
- Proxy call and dictionary resolution invariance
- Conditional guards and branch execution invariance
- Mangled iterative Fibonacci algorithm invariance
-
Audit Regression Probes (
tools/audit-probe.js- 10 checks):- B1: Impure argument multi-use duplication prevention
- B2: Multi-argument evaluation order preservation
- B3: Stale alias value protection on reassigned targets
- B4: Nested loop break/continue bail in switch unflattening
- B5: Empty
var;statement prevention on declarator removal - B6: Deep arithmetic chain climbing fixpoint convergence
- B7: Object property shorthand preservation on substitution
- B8: Rest (
...args) and default parameter (b = 10) preservation - B9: Intentional switch fallthrough preservation
- B10: Business function preservation containing inline debugger checks
-
Obfuscator Behavior Gauntlet (
test/behavior.js- 13 checks):- 10 fixture round-trips against
javascript-obfuscatorpresets (controlflow, hexnames, maxhard, minified, stringarray) - Real-world ThreatMetrix dynamic script hidden string recovery
- Real-world
obfuscator.ioexecution safety - Maxhard gauntlet technique manifest fingerprinting
- 10 fixture round-trips against