Community编程与开发github.com

yaklang/vm-and-bytecode-reverse

定制虚拟机与字节码逆向工程手册。适用于CTF挑战或受保护软件中实现自定义虚拟机、专有字节码、调度循环或迷宫类挑战的场景。

vm-and-bytecode-reverse 是什么?

此技能提供了一个全面的逆向工程工作手册,专门用于应对自定义虚拟机(VM)及其专有字节码的挑战。常见于CTF竞赛、软件保护或代码混淆场景,其中程序逻辑通过自定义指令集和调度循环执行。技能核心价值在于系统化地指导分析者理解VM架构、捕获并解析字节码指令、逆向调度逻辑以及处理迷宫式代码路径。支持主流逆向平台如Ghidra、IDA Pro、Binary Ninja和Radare2,并提供了从基础反汇编到动态调试的完整工作流程。通过该技能,用户能够高效地提取VM指令集、识别关键分发机制并最终还原出原始程序逻辑。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yaklang/hack-skills/tree/main/skills/vm-and-bytecode-reverse

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

vm-and-bytecode-reverse 是做什么的?

定制虚拟机与字节码逆向工程手册。适用于CTF挑战或受保护软件中实现自定义虚拟机、专有字节码、调度循环或迷宫类挑战的场景。

概述

本技能提供一套系统化的方法论,用于逆向分析自定义虚拟机(VM)及其专有字节码。当面临通过自定义虚拟化层执行逻辑的二进制文件时,此技能将指导你完成从架构识别到字节码恢复的完整流程。

适用场景

  • CTF挑战中包含自定义VM和字节码
  • 受保护软件使用基于虚拟化的混淆
  • 需要理解自定义调度循环和指令分发
  • 从内存或二进制文件中提取并解码字节码
  • 迷宫或密码类挑战,其中逻辑在VM内部执行

支持平台

  • Ghidra:用于静态分析和脚本处理
  • IDA Pro:利用微码API或自定义处理器模块
  • Binary Ninja:通过IL提升或Python脚本
  • Radare2:命令行分析与调试
  • Unicorn / QEMU:动态执行和跟踪字节码

工作流程

  1. 识别VM架构

    • 定位调度循环(dispatch loop)
    • 识别指令处理函数或跳转表
    • 收集寄存器、栈和内存访问模式
  2. 提取字节码

    • 从.data、.rdata或堆分配中定位字节码
    • 分析初始化例程以确定编码方案
    • 处理加密或压缩的字节码
  3. 推断指令集

    • 根据调度器逻辑映射操作码到行为
    • 识别常见指令模式(MOV、ADD、JMP等)
    • 处理不变特性和操作数编码
  4. 构建反汇编器

    • 编写Python脚本或Ghidra头文件
    • 将字节码解码为可读指令
    • 测试并迭代直到所有指令覆盖
  5. 动态调试

    • 使用断点跟踪指令执行
    • 记录寄存器状态变化
    • 验证静态分析结果

常见模式

  • 基于switch的调度:主循环通过switch语句分发操作码
  • 直接线程化:指令处理器作为函数指针数组
  • 间接线程化:使用跳转到下一条指令地址
  • 操作码折叠:同一VM指令多个编码
  • 重叠指令:字节码不同部分依赖上下文

工具建议

  • Ghidra + GhidraByteCode 插件
  • IDA Pro + vmaware 或 REIL 提升
  • Python + capstone / keystone 用于原型开发
  • Frida 用于运行时追踪和hook

参考链接

示例

# 简单VM反汇编器示例
opcodes = {
    0x01: "MOV",
    0x02: "ADD",
    0x03: "SUB",
    0x10: "JMP",
    0x11: "JZ",
}

def disassemble(bytecode):
    i = 0
    while i < len(bytecode):
        op = bytecode[i]
        if op in opcodes:
            print(f"{i:04x}: {opcodes[op]}")
            i += 1
        else:
            print(f"{i:04x}: ??? ({op:#x})")
            i += 1

贡献

欢迎提交改进和新发现模式。请提交拉取请求并在GitHub上讨论。

许可证

MIT

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

yaklang/401-403-bypass-techniques

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

yaklang/active-directory-acl-abuse

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

yaklang/active-directory-certificate-services

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

yaklang/active-directory-kerberos-attacks

Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets, delegation abuse, or pass-the-ticket attacks.

yaklang/ai-ml-security

AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing, data privacy attacks (membership inference, model inversion), and autonomous agent security risks.

yaklang/android-pentesting-tricks

Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent redirection, root detection bypass, tapjacking, and backup extraction during authorized mobile security assessments.

yaklang/anti-debugging-techniques

Anti-debugging detection and bypass playbook. Use when reversing protected binaries that detect debuggers via ptrace, PEB flags, timing checks, or signal/exception handlers on Linux and Windows.

yaklang/api-auth-and-jwt-abuse

API authentication and JWT abuse playbook. Use when testing bearer tokens, API keys, claim trust, header spoofing, rate limits, and API auth boundary weaknesses.

yaklang/api-authorization-and-bola

API authorization and BOLA testing playbook. Use when APIs expose object identifiers, nested resources, hidden writable fields, or weak function-level authorization.

yaklang/api-recon-and-docs

API reconnaissance and documentation review playbook. Use when discovering endpoints, schemas, versions, OpenAPI specs, hidden docs, and surface area for API testing.

yaklang/api-sec

Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.

yaklang/arbitrary-write-to-rce

Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.

yaklang/authbypass-authentication-flaws

Authentication bypass testing playbook. Use when assessing login flows, password reset logic, account recovery, MFA bypass, token predictability, brute-force resistance, and session boundary flaws.

yaklang/auth-sec

Entry P1 category router for authentication and authorization. Use when testing login flows, sessions, object authorization, JWT, OAuth, CORS, CSRF, and enterprise SSO weaknesses before any deeper auth topic skill.

yaklang/binary-protection-bypass

Binary protection bypass playbook. Use when identifying and bypassing ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, CET, and MTE protections in ELF binaries to enable exploitation.

yaklang/browser-exploitation-v8

Browser and V8 exploitation playbook. Use when exploiting JavaScript engine vulnerabilities including JIT type confusion, incorrect bounds elimination, and V8 sandbox bypass to achieve renderer RCE and sandbox escape in Chrome/Chromium.

yaklang/business-logic-vuln

Entry P1 category router for business logic testing. Use when workflow abuse, race conditions, pricing flaws, or multi-step state attacks matter more than parser-level input injection.

yaklang/business-logic-vulnerabilities

Business logic vulnerability playbook. Use when reasoning about workflows, race conditions, price manipulation, coupon abuse, state machines, and multi-step authorization gaps.

yaklang/classical-cipher-analysis

Classical cipher analysis playbook. Use when encountering substitution ciphers, Vigenere, transposition, XOR, or encoded text in CTF challenges that requires frequency analysis, Kasiski examination, or known-plaintext cryptanalysis.

yaklang/clickjacking

Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.

相关技能