# Dsl Vm Reverse

Reverse JavaScript-based custom DSL/VM interpreters, non-standard WASM-like runtimes...

- Repository: https://github.com/zhaoxuya520/reverse-skill (43923 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-09-22
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add zhaoxuya520/reverse-skill --skill dsl-vm-reverse -g -a claude-code -y`
Codex: `npx skills add zhaoxuya520/reverse-skill --skill dsl-vm-reverse -g -a codex -y`
Cursor: `npx skills add zhaoxuya520/reverse-skill --skill dsl-vm-reverse -g -a cursor -y`
Gemini CLI: `npx skills add zhaoxuya520/reverse-skill --skill dsl-vm-reverse -g -a gemini-cli -y`

## Description

Reverse JavaScript-based custom DSL/VM interpreters, non-standard WASM-like runtimes, and risk-control engines. Use when analyzing IIFE or switch-based opcode dispatchers, extracting instruction tables, recovering bytecode semantics, capturing VM state at runtime, or reconstructing execution flow.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 🔄 DSL 自定义虚拟机逆向（DSL VM Reverse Engineering）

## ACTION REQUIRED（读完后立刻执行）

1. `NOW`: 确认当前任务是自定义 JS opcode VM / 风控引擎，不是标准 WASM 或普通 webpack
2. `NOW`: `case-init` 直到 `scope.md` 就绪；离线样本用 `offline` / `lab`
3. `ACT`: 从「3. 通用逆向工作流」Phase 1 做文件分类，不要停在目录

> 用于逆向基于 JavaScript 实现的自定义 WASM 虚拟机/风控引擎

---

## 目录

- [1. 适用范围](#1-适用范围)
- [2. DSL VM 识别特征](#2-dsl-vm-识别特征)
- [3. 通用逆向工作流](#3-通用逆向工作流)
- [4. Opcode 提取与分类](#4-opcode-提取与分类)
- [5. 运行时捕获方案](#5-运行时捕获方案)
- [6. 常见状态码](#6-常见状态码)
- [7. Skill 自检清单](#7-skill-自检清单)

---

## 1. 适用范围

当目标文件符合以下 **任意特征** 时使用本 skill：

| # | 特征 | 说明 |
|---|------|------|
| 1 | IIFE 开头 + 大量单字母变量名 | `!function(){var U=void 0,y=parseInt,E0=Function,...}` |
| 2 | 包含 `DG()` 或类似函数含 switch-case 循环 | 解释器主循环，`d[7]&31` 解码 opcode |
| 3 | 大文件（500KB+）但零字节占比 < 1% | 非标准 WASM，纯 JS |
| 4 | 包含 `C[number]` 常量表引用 | `C[9][xxx]` 函数表/字符串表 |
| 5 | 单行压缩代码 | 583KB 单行，混淆变量名 |

### 排除规则

| 条件 | 非本 skill | 转至 |
|------|-----------|------|
| 文件以 `\x00asm` 开头 | 标准 WASM 二进制 | `reverse-engineering/languages.md` |
| 文件以 `Uint8Array([0,97,115,109])` 含 WASM 魔术字 | WASM 嵌入式 | 提取 .wasm 后转 IDA/Ghidra |
| 标准 Webpack 打包（`function(e,t,n){...}`） | 普通 JS | `js-reverse/` |
| 零字节占比 > 20% | WASM 二进制 | `reverse-engineering/languages.md` |

---

## 2. DSL VM 识别特征

### 代码特征

```javascript
// 特征 1: IIFE 入口，单字母变量映射数字常量
!function(){
    var U=void 0, y=parseInt, E0=Function, AN=Uint8Array;
    var E=15, l=10, m=12, x=16, S=13, $=11;
    // 数字常量映射为变量名，替代原始数字
    ...
}

// 特征 2: 解释器主循环 DG()
function DG(C, d, ...) {
    var d = [];  // 数组模拟 WASM stack/locals
    for (d[7] = x; d[7] !== U;) {
        var aE = d[7] & 31;         // 低 5 位 = opcode
        var O = d[7] >> 5 & 31;      // 高 5 位 = sub-operation
        switch (aE) {
            case 0: /* ... */ d[7] = 612; break;
            case 1: /* ... */
            // ... N 个 case
        }
    }
}

// 特征 3: 常量表 C[9] 存储函数索引和字符串
// C[9][0] = ["pc"]      → 函数参数描述
// C[9][667] = "string"  → 字符串常量
// C[9][x] = number      → 函数索引

The rest: https://github.com/zhaoxuya520/reverse-skill/blob/HEAD/skills/reverse-engineering/dsl-vm-reverse/SKILL.md
