Skip to content
Skillpedia
Security48k · #4016

dsl-vm-reverse

Lets your agent analyze systems using JavaScript to create custom languages. It identifies how the code works internally and extracts important information.

What it does

This tool helps understand complex JavaScript code that has been disguised to protect information. It analyzes the code to figure out how it works internally, acting like a translator for difficult code.

When to use it

  • ✓When a website uses an internal system to check if you are not a robot.
  • ✓To understand how a custom JavaScript code executes its instructions.
  • ✓When trying to recover the logic of an obfuscated JavaScript program.

Example of what to ask your AI

“Analyze this JavaScript code and tell me what it does:”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/reverse-engineering/dsl-vm-reverse/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/reverse-engineering/dsl-vm-reverse/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool looks for specific patterns in JavaScript code, like 'switch' structures or self-executing functions, which are common in protection systems. It then tries to extract the instructions and understand the logic behind them.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add sickn33/agentic-awesome-skills --skill dsl-vm-reverse

Or download just the file:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/reverse-engineering/dsl-vm-reverse/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

🔄 DSL 自定义虚拟机逆向(DSL VM Reverse Engineering)

When to Use

  • A protected web asset runs a custom bytecode VM (risk-control/captcha engines).
  • Recovering opcode semantics from a JS interpreter loop.

目录


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 识别特征

代码特征

// 特征 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      → 函数索引

// 特征 4: W(C[index], null, ...) 调用模式
// W = Function.prototype.call.bind(call)
// 所有内置函数通过 C[index] 索引调用

// 特征 5: 指令编码格式
// d[7] = opcode(bit 0-4) | subop(bit 5-9) | operand(bit 10+)

Opcode 编码格式

每条指令编码为 32 位整数:

bit 0-4:   opcode (0-N)
bit 5-9:   sub-operation (0-31)
bit 10-31: operand/立即数

解码:
  aE = d[7] & 31        → opcode
  O  = d[7] >> 5 & 31   → sub-operation
  d[other] = d[7] >> 10  → operand

3. 通用逆向工作流

Phase 1: 文件分类(5 分钟)

# 检查是否为 DSL VM
python3 << 'EOF'
with open('target.js', 'rb') as f:
    head = f.read(100)

# 1. 检查 WASM 魔术字
if head[:4] == b'\x00asm':
    print("标准 WASM 二进制")
    exit()

# 2. 检查零字节占比
data = open('target.js', 'rb').read()
zero_pct = data.count(b'\x00') / len(data) * 100
print(f"零字节占比: {zero_pct:.1f}%")

if zero_pct > 20:
    print("WASM 二进制")
elif head[:2] == b'!f':
    # 检查单字母变量模式
    if b'var U=void 0' in head or b'U=void 0,y=parseInt' in head:
        print("→ DSL VM!")
    else:
        print("普通 JS IIFE")
EOF

Phase 2: 变量映射表提取(10 分钟)

import re

with open('target.js', 'r', errors='replace') as f:
    s = f.read()

# 提取开头 2000 字符的 var X=数字 映射
mappings = re.findall(r'var\s+(\w+)\s*=\s*(\d+)', s[:2000])
print('常量映射:')
for name, val in mappings:
    print(f"  {name:4s} = {val:3d} (0x{int(val):02x})")

Phase 3: Opcode 提取与分类(15 分钟)

# 1. 提取所有 case
all_cases = re.findall(r'case\s+(\d+):', s)
unique = sorted(set(int(c) for c in all_cases))

print(f"总 case: {len(all_cases)} 个")
print(f"唯一 opcode: {len(unique)} 个: {unique}")

# 2. 分类每个 opcode
for op in unique:
    idx = s.find(f'case {op}:')
    snippet = s[idx:idx+200]
    if 'd[7]=' in snippet:
        op_type = 'BRANCH'
    elif 'return' in snippet:
        op_type = 'RETURN'
    elif 'W(C[' in snippet:
        op_type = 'CALL'
    elif 'new' in snippet:
        op_type = 'ALLOC'
    elif 'try' in snippet or 'catch' in snippet:
        op_type = 'EXCEPTION'
    else:
        op_type = 'ARITH/STORE'
    print(f"  opcode {op:2d}: {op_type}")

Phase 4: 常量表分析(30 分钟)

const_refs = re.findall(r'C\[9\]\[(\d+)\]', s)
unique_refs = sorted(set(int(x) for x in const_refs))

print(f"C[9] 引用: {len(unique_refs)} 个索引")
print(f"范围: {min(unique_refs)} - {max(unique_refs)}")

# 对每个引用分析上下文
for ref in unique_refs[:20]:
    idx = s.find(f'C[9][{ref}]')
    ctx = s[max(0,idx-50):idx+80]
    clean = ''.join(c if c.isprintable() else ' ' for c in ctx)
    print(f"  C[9][{ref}] → {clean}")

Phase 5: 导出函数追踪(1-2 小时)

导出函数(如 getToken)通过以下路径定位:

1. 找 AWSCInner.register() 或类似注册调用
2. 确定注册的模块和工厂函数
3. 找工厂函数返回的对象 → 导出函数定义位置

…
FAQ

What is a 'DSL VM'?

It's a custom language 'interpreter', like a small program within another program that understands a specific set of commands (bytecode) to perform tasks, often for security.

What are 'opcodes'?

They are 'operation codes', the basic commands that the 'virtual machine' (the interpreter) understands and executes. Think of them as the words in a very small and specific vocabulary.

Why is JavaScript code disguised?

Usually to make it difficult for others to copy the technology, understand business secrets, or create cheats in games and security systems.

Details

Original description by the author

Reverse JavaScript-based custom DSL/VM interpreters and risk-control engines: identify IIFE/switch-based opcode dispatch, extract opcode tables, and capture runtime semantics.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#4016
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills