- name
SKILL.md
The skill file stays in the publisher's repository.
Paste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add index-login/MobileRE-Skill --skill vmp-analysis -a cursor -yPaste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add index-login/MobileRE-Skill --skill vmp-analysis -a claude-code -yPaste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add index-login/MobileRE-Skill --skill vmp-analysis -a codex -yPaste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add index-login/MobileRE-Skill --skill vmp-analysis -a grok -ySend the copied message in a Grok Bot chat. The Bot fetches this SKILL.md from GitHub and adds it to the skills all your Bots share.
Install this skill: https://github.com/index-login/MobileRE-Skill/tree/HEAD/.kilo/skill/vmp-analysisFrom the publisher
目标:把一段自定义字节码变成可读指令清单,并说清编码模型。
核心约束:每条 handler 自定义 pc 推进与操作数布局,静态猜格式命中率接近 0。 必须先拿到动态 trace,再用它反推编码。
路径基准:项目根。工具在 tools/。
# 1) 确认工具可用
python3 tools/vmp.py --help
python3 tools/vmp.py profile list # 看有没有现成模型可复用
# 2) SO 已脱壳且能反汇编
python3 tools/so.py info <so> # 看 broken_sections / dynsym_defined
先查 profile list:已解出的壳有现成模型,命中就不用从零建模。
三个可观测特征(references/native-analysis.md ›「3.5.2」第一步):
JNI_OnLoad 的典型形态:
rt = FUN_xxx(); // 分配运行时
FUN_yyy(rt, vm); // 存 JavaVM
FUN_zzz(rt, &tbl1, &tbl2, bytecode, &selector, 0); // 启动解释器
return FUN_vvv(rt);
python3 tools/ptr_table.py <so> --scan --only-code --classify vm
输出里标 handler 表候选(项数非 2^n) 的那张。不要假设 256 项 ——
壳普遍只放实际用到的项数,其后紧跟 continuation 表。
交叉验证项数:
memcpy(dst, table, N) 的 N打开解释器主循环,对着反汇编填下表(这是 vmp.py trace 需要的):
python3 tools/vmp.py profile new <壳名>
生成骨架后按每个字段的 _comment 填。先填 [engine] 组:
opcodes 先全填 op_<hex> 占位,条目数 = handler_count(多填会把 continuation 表误当 opcode)。
再填 [engine] 的 operand_layout(opcode → 操作数宽度):
不填会用内置默认值(只对某个已解出的壳成立) → disasm 的 operand 列会系统性错,
而 verify 仍然通过(它只校验 opcode 链),表现为"长度对、语义错"。
取法:逐 handler 反编译,看它从 body 里读几个字节、按什么宽度。
# 简单壳:不需要 setup
python3 tools/vmp.py trace <so> -p <profile> --sel 0 --out trace.json
# 脱壳镜像 / 复杂壳:用 setup 脚本挂环境
cp tools/emu_setup_template.py <包名>/tools/setup_<name>.py
python3 tools/vmp.py trace <so> -p <profile> --setup <包名>/tools/setup_<name>.py --out trace.json
setup 脚本先不加第 5 步,跑一遍看 [!] unstubbed 日志再逐个补桩 —— 不要预猜。
常见报错:
python3 tools/vmp.py verify <so> -p <profile> --trace trace.json
命中率必须 > 95%。低于此值按未命中样例定位:
python3 tools/vmp.py disasm <so> -p <profile> --trace trace.json --vm <key>
python3 tools/vmp.py disasm <so> -p <profile> --trace trace.json --list-vms # 先看有哪些 VM
输出五列:pc / op / name / operand / raw。有 trace 时长度准确;无 trace 退化按
static_insn_len 推测,输出会标注。
opcodes 里的 op_<hex> 占位要逐个换成真名:
# 看某个 handler 的指令模型(需先跑 Ghidra 脚本 so_vm_model_handlers.java)
python3 tools/vmp.py model --op 0x39
python3 tools/vmp.py model --stats
对着 handler 的反编译结果判断语义,改 profile 的 opcodes,再跑 disasm 确认可读性提升。
这一步是增量的:先命名高频 opcode(disasm 末尾的频次表按降序),低频的留着占位。
<包名>/tools/vm_profiles/<name>.json(编码模型,样本事实;vmp.py 自动发现)trace.json(动态执行路径)disasm --json 可落盘)REPORT.md:VM 数量、各 VM 业务、编码公式、opcode 语义表通用工具(tools/,任何壳可用)
Ghidra 脚本(tools/ghidra/,索引见 tools/ghidra/README.md)
样本专用工具(<包名>/tools/,换壳需重写或改 profile)
分界线:能按 ELF 结构 / 通用算法判定的 → tools/;
需要样本的入口地址、加密区间、VM 编码常量的 → <包名>/tools/。
so-function-recovery 的分工是上下游,不是替代:那边步骤 5.7 判定为 VM 壳后转到这里;这里解完字节码,
回到那边继续按台账读函数。两边共用的只有 ptr_table.py / probe_layout.py / setup_*.py。
references/native-analysis.md ›「3.5.2 字节码 VM 逆向(VMP 型壳)」references/so-function-recovery.md ›「换壳工作流(0 → 1)」so-emulateso-function-recovery字节码 VM / VMP 壳逆向的执行流水线:从"确认是 VM"到"反汇编出可读指令"的 8 步固定流程。用 profile 描述编码模型(换壳只换 JSON),用动态 trace 反推 opcode 编码,用命中率 > 95% 验收。当目标是"业务方法在 .text 里找不到、JNI_OnLoad 只启动解释器"、或已有 opcode 表但不知道指令怎么解时使用。SO 层深挖的单步能力,入口仍在
---name: vmp-analysisdescription: 字节码 VM / VMP 壳逆向的执行流水线:从"确认是 VM"到"反汇编出可读指令"的 8 步固定流程。用 profile 描述编码模型(换壳只换 JSON),用动态 trace 反推 opcode 编码,用命中率 >…---# .kilo/skill/vmp-analysis/SKILL.mdOverview
字节码 VM / VMP 壳逆向的执行流水线:从"确认是 VM"到"反汇编出可读指令"的 8 步固定流程。用 profile 描述编码模型(换壳只换 JSON),用动态 trace 反推 opcode 编码,用命中率 > 95% 验收。当目标是"业务方法在 .text 里找不到、JNI_OnLoad 只启动解释器"、或已有 opcode 表但不知道指令怎么解时使用。SO 层深挖的单步能力,入口仍在 frida-mobile-security。
FAQ
Download .kilo/skill/vmp-analysis/SKILL.md from the publisher, or copy the path and open the repository. PlugMCP lists the skill and does not host the file.
The publisher keeps it at https://github.com/index-login/MobileRE-Skill.
Claude, Cursor, Codex, and Grok Build can read a SKILL.md you add from the publisher's repository. Grok Bot installs it when you send the skill's GitHub folder link in a chat.