[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AT0PQCPZA2MAN1ZTKZB55F":3,"skill-same:01M7AT0PQCPZA2MAN1ZTKZB55F":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7AT0PQCPZA2MAN1ZTKZB55F","re-wasm",null,"WASM 逆向：格式解析、wasm2wat、浏览器侧。触发词：WASM、wasm、WebAssembly、wat","dslsdzc\u002Frev-skills","dslsdzc","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F150430440?v=4","01M7ASEW5AKHWCFR1TXPAXQ237","DslsDZC","01M7ASEW5WJZ3GGBCCT12KHAQZ",243,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fre-wasm\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: re-wasm\ndescription: WASM 逆向：格式解析、wasm2wat、浏览器侧。触发词：WASM、wasm、WebAssembly、wat\ncapabilities: [web-assembly]\n---\n\n# WebAssembly 逆向（WABT \u002F wasmtime \u002F Chrome DevTools）\n\n## 何时使用 \u002F 何时不用\n\n- 用：.wasm 模块还原逻辑（网页前端加密\u002F校验、浏览器插件、游戏、恶意网页\u002F供应链 JS 加载的 wasm 载荷）\n- 用：`WebAssembly.instantiate` \u002F `WebAssembly.Module` \u002F `.wasm` fetch 出现的样本——wasm 与 JS 胶水一体分析\n- 不用：非 wasm（native 走 [[re-binary-core]]、.NET 走 [[re-dotnet]]、Java 走 [[re-java]]、纯 JS\u002F脚本走 [[re-script-deob]]）\n- 不用：wasm 模块本身可读性尚可、只需读逻辑——直接 `wasm2wat` 读 WAT 即可，无需完整流程\n- 注意：动态运行默认沙箱（[[re-analyze\u002Fplatform-tips]] 最高原则）；wasm 模块相对隔离，但宿主 JS 胶水会调 DOM\u002F网络等敏感 API——JS 侧先还原（[[re-script-deob]]）\n\n## 工具准备\n\n参考 [[re-analyze\u002Fplatform-tips]]——wasm 解析\u002F反编译为静态步骤，免沙箱；动态运行（wasmtime\u002Fwasm3\u002F浏览器加载）按最高原则进沙箱（至少断网）。\n\n### WABT（wasm2wat \u002F wasm-decompile \u002F wasm-objdump，解析与反编译主力）\n\n- Debian\u002FUbuntu: `apt install wabt`；Fedora: `dnf install wabt`；Arch: `pacman -S wabt`\n- macOS: `brew install wabt`；Windows: `choco install wabt` 或 GitHub `WebAssembly\u002Fwabt` release 的 bin 目录\n- 验证: `wasm2wat --version && wasm-decompile --version && wasm-objdump --version`\n\n### wasmtime（WASI CLI 运行时，--invoke 直调导出函数）\n\n- 官方安装器（全平台，装到 `~\u002F.wasmtime\u002Fbin`）: `curl https:\u002F\u002Fwasmtime.dev\u002Finstall.sh -sSf | bash`\n- Debian\u002FUbuntu: 无官方包——用官方安装脚本\u002F二进制（install.wasmtime.dev）或源码构建；Fedora: 官方仓库无 CLI 包——用官方安装脚本或第三方仓库（GetPageSpeed\u002FCOPR）；Arch: `pacman -S wasmtime`；macOS: `brew install wasmtime`；Windows: `winget install BytecodeAlliance.Wasmtime`\n- 验证: `wasmtime --version`\n\n### wasm3（轻量解释器，无 WASI 依赖也可跑，嵌入式\u002F快速验证场景）\n\n- Arch: 官方仓库无 wasm3——AUR（如 wasm3 包）或源码构建；macOS: `brew install wasm3`\n- Debian\u002FUbuntu\u002FFedora 无官方包 → GitHub `wasm3\u002Fwasm3` release 下载对应平台单文件二进制，或源码构建: `git clone --depth 1 https:\u002F\u002Fgithub.com\u002Fwasm3\u002Fwasm3 && cmake -B build -S wasm3 && cmake --build build`\n- 验证: `wasm3 --version`\n\n### Chrome DevTools（浏览器侧动态分析）\n\n- Chrome\u002FChromium: Debian\u002FUbuntu `apt install chromium`（Chrome 用官方 deb）；Fedora `dnf install chromium`；Arch `pacman -S chromium`；macOS `brew install --cask google-chrome`；Windows 官方安装器\n- 验证: 启动浏览器 `F12` 打开 DevTools → Sources 面板能展开 .wasm 文件\n- 本地起服务供浏览器加载: `python3 -m http.server 8000`\n\n### binaryen（wasm-opt 优化\u002F混淆还原，wasm-dis 反汇编）\n\n- Debian\u002FUbuntu: `apt install binaryen`；Fedora: `dnf install binaryen`；Arch: `pacman -S binaryen`\n- macOS: `brew install binaryen`；Windows: `choco install binaryen` 或 GitHub `WebAssembly\u002Fbinaryen` release\n- 验证: `wasm-opt --version`\n\n## 操作步骤\n\n按顺序执行，每步记录证据（路径 + sha256，见 [[re-triage]]）。\n\n1. **识别 wasm 模块**：\n   ```sh\n   file sample.wasm                          # \"WebAssembly (wasm) binary module version 0x1 (MVP)\"\n   xxd sample.wasm | head -1                 # 魔数 00 61 73 6D（\\0asm）+ 版本 01 00 00 00\n   ```\n   - 魔数 `\\0asm`（`00 61 73 6D`）+ 版本 `01 00 00 00` = 标准 wasm；不符 → 不是 wasm（可能加密\u002F混淆\u002F损坏，见坑 3）\n   - 常以内嵌形态出现，先还原成 .wasm 文件：`atob(...)` 的 base64 串、JS 里 `Uint8Array([0,97,115,109,...])` 数组字面量\n   - 从 JS 侧确认：`WebAssembly.instantiate` \u002F `WebAssembly.Module` \u002F `.wasm` fetch 出现即 wasm 载荷（JS 胶水走 [[re-script-deob]]）\n\n2. **section 解析（wasm-objdump \u002F wasm2wat）**：\n   ```sh\n   wasm-objdump -x sample.wasm        # 全部 section：Type\u002FImport\u002FFunction\u002FTable\u002FMemory\u002FGlobal\u002FExport\u002FCode\u002FData\n   wasm-objdump -h sample.wasm        # 只列 section 摘要\n   wasm2wat sample.wasm -o sample.wat # 二进制 → WAT 文本（有扩展指令时加 --enable-all）\n   wasm-objdump -d sample.wasm        # 反汇编全部函数体（WAT 风格指令）\n   ```\n   - 各 section 的逆向意义：Type（函数签名，辅助还原类型）、Import（**宿主 JS\u002FWASI 注入的函数——调用边界**）、Export（**JS 可调的对外函数名**）、Data（**字符串常量区**）、Code（指令体）\n   - 先读 Import + Export 建立调用面，再进 Code\n\n3. **反编译（wasm-decompile）**：\n   ```sh\n   wasm-decompile sample.wasm -o sample.c    # 类 C 伪码（可读性优先）\n   ```\n   - 与 WAT 对照：wasm-decompile 可读性好但丢部分类型\u002F边界信息；关键函数以 `wasm2wat` 产出的 WAT 为准精读\n   - 入口定位：`(export \"checkPassword\" ...)` → JS 侧 `instance.exports.checkPassword`；import 的函数 → 到 JS 胶水找实现（坑 2）\n   - 字符串：`wasm-objdump -s sample.wasm` dump 全部 section 原始内容（hex dump，含 Data 段；Data section 亦可从 `-x` 输出读）；WAT 里找 `(data (i32.const 偏移) \"字符串\")`，把代码里 `i32.const 偏移` 映射回字符串（坑 1）\n   - 函数多\u002F疑似混淆时先用 wasm-decompile 粗读，挑出目标函数再精读\n\n4. **浏览器侧（DevTools Sources \u002F JS 调用面）**：\n   - 打开样本页面（本地起服务），DevTools → Sources → 左侧展开 `.wasm` 文件：Chrome 自动给出反编译伪代码视图，可下断点、单步，Scope 面板看 wasm 局部变量，Call Stack 同时显示 JS↔wasm 帧\n   - 调用面：JS 侧 `WebAssembly.instantiate(bytes, importObject)` 的 `importObject` 定义了 wasm 的 import 实现；`instance.exports.xxx(...)` 是 wasm 对外函数——在 JS 调用点下断点，单步进入 wasm 帧观察入参\u002F返回值\n   - 无头环境：Chrome headless + DevTools Protocol（`--headless --remote-debugging-port=9222`），或 Node `WebAssembly.instantiate` 等价复现调用\n   - 动态改值：DevTools 在 wasm 伪代码视图里修改参数重放调用，黑盒对比输出\n\n5. **动态（wasmtime + 插桩\u002F黑盒差分）**：\n   ```sh\n   wasmtime run sample.wasm                                   # WASI 程序（需 _start 导出）\n   wasmtime run --invoke checkPassword sample.wasm '\"test\"'   # 直调导出函数（参数按 JSON 解析）\n   wasmtime run --dir . --env FLAG=xxx sample.wasm            # 显式授权 WASI 文件\u002F环境能力\n   wasm3 sample.wasm checkPassword test                       # 无 WASI 模块用 wasm3（参数原样）\n   ```\n   - 插桩：`wasm-objdump -d` 静态指令 + `--invoke` 黑盒差分——同一导出函数喂不同输入，观察输出变化定位分支\u002F校验逻辑\n   - WASI 系统调用：`strace -f wasmtime run sample.wasm`（坑 5，走 [[re-tracing]]）\n   - 需要 BigInt 参数或进 JS 侧跟踪时，写 node 胶水：\n     ```js\n     const { instance } = await WebAssembly.instantiate(bytes, imports);\n     console.log(instance.exports.f(1n, 2n));   \u002F\u002F i64 必须 BigInt（坑 4）\n     ```\n   - 一切动态执行默认沙箱（[[re-analyze\u002Fplatform-tips]] 最高原则）\n\n## 跨域联合\n\n- [[re-managed]]：网关工作流步骤①（识别运行时）②（反编译）固定调用本技能；wasm 宿主程序（JS\u002FNode）属托管代码域\n- [[re-script-deob]]：JS 胶水代码（instantiate\u002Fimport 对象\u002Ffetch wasm\u002Fatob 内嵌）先去混淆还原——imports 的实现基本都在 JS 侧，两技能必须联用\n- [[re-tracing]]：WASI 程序动态侧——`strace -f wasmtime run` 观察系统调用边界\n- [[re-emulation]]：可选——无合适运行时的 WASI 模块模拟执行（wasm 常经 Emscripten 编译，模拟前先按 WASI 映射理解宿主依赖）\n- [[re-firmware]]：嵌入式\u002F路由器 web 界面中的 wasm 模块\n- 底座 [[re-binary-core]]：初勘（[[re-triage]]）；wasm 与 native 混合样本\n- [[re-malware]]：恶意网页\u002F供应链 JS 加载 wasm 载荷的完整链路\n- [[re-deobfuscate]]：wasm 混淆（wasm-obfuscator 等）属混淆对抗，深层还原思路一致\n\n## 常见坑与陷阱\n\n- **字符串在 data 段不在代码里**：现象——wasm2wat\u002F反编译只见 `i32.const 偏移` 数字，grep 不到任何明文；原因——wasm 没有字符串类型，字符串常量存 Data 段、代码用内存地址引用；对策——`wasm-objdump -s sample.wasm` dump 全部 section 原始内容（hex dump，Data 段在其中；也可从 `-x` 输出读 Data section）（WAT 里看 `(data (i32.const 偏移) \"…\")`），把偏移映射回引用处\n- **imports 是 JS 边界不是库调用**：现象——wasm 文件里找不到关键校验\u002F解密逻辑；原因——wasm 的 import 由宿主 JS 注入（`WebAssembly.instantiate(bytes, { env: {...} })`），敏感逻辑在 JS 侧；对策——`wasm-objdump -x` 列出 Import section → 到 JS 胶水代码找对应实现（[[re-script-deob]]）——wasm 只证明\"调用了什么\"，不证明\"它做了什么\"\n- **wasm 混淆（wasm-obfuscator 等）先反混淆再分析**：现象——wasm2wat 输出大段控制流扁平化、死代码、`select` 噪音，字符串被切碎\u002F加密，函数名全抹；原因——混淆器做控制流平坦化 + 字符串加密 + 名称抹除；对策——binaryen 逐遍优化还原平坦化：`wasm-opt --flatten --simplify-locals --vacuum --dce -O3` 多轮迭代；字符串加密需定位解密逻辑（思路同 [[re-deobfuscate]]，注意解密函数可能是 import——回到坑 2）\n- **BigInt 调用约定**：现象——JS 调 wasm 导出函数报 `TypeError: Cannot convert a BigInt value to a number`，或 i64 参数静默截断；原因——i64 参数\u002F返回值在 JS↔wasm 边界只能走 BigInt（Number 仅 2^53 精度）；对策——JS 侧 `instance.exports.f(1n, 2n)` 传 BigInt；wasmtime `--invoke` 参数按 JSON 解析不支持 BigInt——需要时写 node 胶水；复刻算法用 Python int \u002F JS BigInt，别用 Number\n- **WASI 系统调用边界**：现象——wasmtime 跑 WASI 程序报 `unknown import: wasi_snapshot_preview1.…`，或浏览器与运行时行为不一致；原因——WASI 程序通过 import `wasi_snapshot_preview1` 拿文件\u002F时钟\u002F随机数\u002F网络能力，运行时未授权该能力即失败；浏览器里宿主 import 是 JS 而非 WASI，同一模块两端行为可以不同；对策——`wasm-objdump -x` 看 Import 段确认用到的 WASI 函数 → `wasmtime run --dir . --env K=v` 显式授权 → `strace -f wasmtime run` 观察实际系统调用（[[re-tracing]]）；结论标注运行环境（browser vs wasi）\n","# WebAssembly 逆向（WABT \u002F wasmtime \u002F Chrome DevTools）\n\n## 何时使用 \u002F 何时不用\n\n- 用：.wasm 模块还原逻辑（网页前端加密\u002F校验、浏览器插件、游戏、恶意网页\u002F供应链 JS 加载的 wasm 载荷）\n- 用：`WebAssembly.instantiate` \u002F `WebAssembly.Module` \u002F `.wasm` fetch 出现的样本——wasm 与 JS 胶水一体分析\n- 不用：非 wasm（native 走 [[re-binary-core]]、.NET 走 [[re-dotnet]]、Java 走 [[re-java]]、纯 JS\u002F脚本走 [[re-script-deob]]）\n- 不用：wasm 模块本身可读性尚可、只需读逻辑——直接 `wasm2wat` 读 WAT 即可，无需完整流程\n- 注意：动态运行默认沙箱（[[re-analyze\u002Fplatform-tips]] 最高原则）；wasm 模块相对隔离，但宿主 JS 胶水会调 DOM\u002F网络等敏感 API——JS 侧先还原（[[re-script-deob]]）\n\n## 工具准备\n\n参考 [[re-analyze\u002Fplatform-tips]]——wasm 解析\u002F反编译为静态步骤，免沙箱；动态运行（wasmtime\u002Fwasm3\u002F浏览器加载）按最高原则进沙箱（至少断网）。\n\n### WABT（wasm2wat \u002F wasm-decompile \u002F wasm-objdump，解析与反编译主力）\n\n- Debian\u002FUbuntu: `apt install wabt`；Fedora: `dnf install wabt`；Arch: `pacman -S wabt`\n- macOS: `brew install wabt`；Windows: `choco install wabt` 或 GitHub `WebAssembly\u002Fwabt` release 的 bin 目录\n- 验证: `wasm2wat --version && wasm-decompile --version && wasm-objdump --version`\n\n### wasmtime（WASI CLI 运行时，--invoke 直调导出函数）\n\n- 官方安装器（全平台，装到 `~\u002F.wasmtime\u002Fbin`）: `curl https:\u002F\u002Fwasmtime.dev\u002Finstall.sh -sSf | bash`\n- Debian\u002FUbuntu: 无官方包——用官方安装脚本\u002F二进制（install.wasmtime.dev）或源码构建；Fedora: 官方仓库无 CLI 包——用官方安装脚本或第三方仓库（GetPageSpeed\u002FCOPR）；Arch: `pacman -S wasmtime`；macOS: `brew install wasmtime`；Windows: `winget install BytecodeAlliance.Wasmtime`\n- 验证: `wasmtime --version`\n\n### wasm3（轻量解释器，无 WASI 依赖也可跑，嵌入式\u002F快速验证场景）\n\n- Arch: 官方仓库无 wasm3——AUR（如 wasm3 包）或源码构建；macOS: `brew install wasm3`\n- Debian\u002FUbuntu\u002FFedora 无官方包 → GitHub `wasm3\u002Fwasm3` release 下载对应平台单文件二进制，或源码构建: `git clone --depth 1 https:\u002F\u002Fgithub.com\u002Fwasm3\u002Fwasm3 && cmake -B build -S wasm3 && cmake --build build`\n- 验证: `wasm3 --version`\n\n### Chrome DevTools（浏览器侧动态分析）\n\n- Chrome\u002FChromium: Debian\u002FUbuntu `apt install chromium`（Chrome 用官方 deb）；Fedora `dnf install chromium`；Arch `pacman -S chromium`；macOS `brew install --cask google-chrome`；Windows 官方安装器\n- 验证: 启动浏览器 `F12` 打开 DevTools → Sources 面板能展开 .wasm 文件\n- 本地起服务供浏览器加载: `python3 -m http.server 8000`\n\n### binaryen（wasm-opt 优化\u002F混淆还原，wasm-dis 反汇编）\n\n- Debian\u002FUbuntu: `apt install binaryen`；Fedora: `dnf install binaryen`；Arch: `pacman -S binaryen`\n- macOS: `brew install binaryen`；Windows: `choco install binaryen` 或 GitHub `WebAssembly\u002Fbinaryen` release\n- 验证: `wasm-opt --version`\n\n## 操作步骤\n\n按顺序执行，每步记录证据（路径 + sha256，见 [[re-triage]]）。\n\n1. **识别 wasm 模块**：\n   ```sh\n   file sample.wasm                          # \"WebAssembly (wasm) binary module version 0x1 (MVP)\"\n   xxd sample.wasm | head -1                 # 魔数 00 61 73 6D（\\0asm）+ 版本 01 00 00 00\n   ```\n   - 魔数 `\\0asm`（`00 61 73 6D`）+ 版本 `01 00 00 00` = 标准 wasm；不符 → 不是 wasm（可能加密\u002F混淆\u002F损坏，见坑 3）\n   - 常以内嵌形态出现，先还原成 .wasm 文件：`atob(...)` 的 base64 串、JS 里 `Uint8Array([0,97,115,109,...])` 数组字面量\n   - 从 JS 侧确认：`WebAssembly.instantiate` \u002F `WebAssembly.Module` \u002F `.wasm` fetch 出现即 wasm 载荷（JS 胶水走 [[re-script-deob]]）\n\n2. **section 解析（wasm-objdump \u002F wasm2wat）**：\n   ```sh\n   wasm-objdump -x sample.wasm        # 全部 section：Type\u002FImport\u002FFunction\u002FTable\u002FMemory\u002FGlobal\u002FExport\u002FCode\u002FData\n   wasm-objdump -h sample.wasm        # 只列 section 摘要\n   wasm2wat sample.wasm -o sample.wat # 二进制 → WAT 文本（有扩展指令时加 --enable-all）\n   wasm-objdump -d sample.wasm        # 反汇编全部函数体（WAT 风格指令）\n   ```\n   - 各 section 的逆向意义：Type（函数签名，辅助还原类型）、Import（**宿主 JS\u002FWASI 注入的函数——调用边界**）、Export（**JS 可调的对外函数名**）、Data（**字符串常量区**）、Code（指令体）\n   - 先读 Import + Export 建立调用面，再进 Code\n\n3. **反编译（wasm-decompile）**：\n   ```sh\n   wasm-decompile sample.wasm -o sample.c    # 类 C 伪码（可读性优先）\n   ```\n   - 与 WAT 对照：wasm-decompile 可读性好但丢部分类型\u002F边界信息；关键函数以 `wasm2wat` 产出的 WAT 为准精读\n   - 入口定位：`(export \"checkPassword\" ...)` → JS 侧 `instance.exports.checkPassword`；import 的函数 → 到 JS 胶水找实现（坑 2）\n   - 字符串：`wasm-objdump -s sample.wasm` dump 全部 section 原始内容（hex dump，含 Data 段；Data section 亦可从 `-x` 输出读）；WAT 里找 `(data (i32.const 偏移) \"字符串\")`，把代码里 `i32.const 偏移` 映射回字符串（坑 1）\n   - 函数多\u002F疑似混淆时先用 wasm-decompile 粗读，挑出目标函数再精读\n\n4. **浏览器侧（DevTools Sources \u002F JS 调用面）**：\n   - 打开样本页面（本地起服务），DevTools → Sources → 左侧展开 `.wasm` 文件：Chrome 自动给出反编译伪代码视图，可下断点、单步，Scope 面板看 wasm 局部变量，Call Stack 同时显示 JS↔wasm 帧\n   - 调用面：JS 侧 `WebAssembly.instantiate(bytes, importObject)` 的 `importObject` 定义了 wasm 的 import 实现；`instance.exports.xxx(...)` 是 wasm 对外函数——在 JS 调用点下断点，单步进入 wasm 帧观察入参\u002F返回值\n   - 无头环境：Chrome headless + DevTools Protocol（`--headless --remote-debugging-port=9222`），或 Node `WebAssembly.instantiate` 等价复现调用\n   - 动态改值：DevTools 在 wasm 伪代码视图里修改参数重放调用，黑盒对比输出\n\n5. **动态（wasmtime + 插桩\u002F黑盒差分）**：\n   ```sh\n   wasmtime run sample.wasm                                   # WASI 程序（需 _start 导出）\n   wasmtime run --invoke checkPassword sample.wasm '\"test\"'   # 直调导出函数（参数按 JSON 解析）\n   wasmtime run --dir . --env FLAG=xxx sample.wasm            # 显式授权 WASI 文件\u002F环境能力\n   wasm3 sample.wasm checkPassword test                       # 无 WASI 模块用 wasm3（参数原样）\n   ```\n   - 插桩：`wasm-objdump -d` 静态指令 + `--invoke` 黑盒差分——同一导出函数喂不同输入，观察输出变化定位分支\u002F校验逻辑\n   - WASI 系统调用：`strace -f wasmtime run sample.wasm`（坑 5，走 [[re-tracing]]）\n   - 需要 BigInt 参数或进 JS 侧跟踪时，写 node 胶水：\n     ```js\n     const { instance } = await WebAssembly.instantiate(bytes, imports);\n     console.log(instance.exports.f(1n, 2n));   \u002F\u002F i64 必须 BigInt（坑 4）\n     ```\n   - 一切动态执行默认沙箱（[[re-analyze\u002Fplatform-tips]] 最高原则）\n\n## 跨域联合\n\n- [[re-managed]]：网关工作流步骤①（识别运行时）②（反编译）固定调用本技能；wasm 宿主程序（JS\u002FNode）属托管代码域\n- [[re-script-deob]]：JS 胶水代码（instantiate\u002Fimport 对象\u002Ffetch wasm\u002Fatob 内嵌）先去混淆还原——imports 的实现基本都在 JS 侧，两技能必须联用\n- [[re-tracing]]：WASI 程序动态侧——`strace -f wasmtime run` 观察系统调用边界\n- [[re-emulation]]：可选——无合适运行时的 WASI 模块模拟执行（wasm 常经 Emscripten 编译，模拟前先按 WASI 映射理解宿主依赖）\n- [[re-firmware]]：嵌入式\u002F路由器 web 界面中的 wasm 模块\n- 底座 [[re-binary-core]]：初勘（[[re-triage]]）；wasm 与 native 混合样本\n- [[re-malware]]：恶意网页\u002F供应链 JS 加载 wasm 载荷的完整链路\n- [[re-deobfuscate]]：wasm 混淆（wasm-obfuscator 等）属混淆对抗，深层还原思路一致\n\n## 常见坑与陷阱\n\n- **字符串在 data 段不在代码里**：现象——wasm2wat\u002F反编译只见 `i32.const 偏移` 数字，grep 不到任何明文；原因——wasm 没有字符串类型，字符串常量存 Data 段、代码用内存地址引用；对策——`wasm-objdump -s sample.wasm` dump 全部 section 原始内容（hex dump，Data 段在其中；也可从 `-x` 输出读 Data section）（WAT 里看 `(data (i32.const 偏移) \"…\")`），把偏移映射回引用处\n- **imports 是 JS 边界不是库调用**：现象——wasm 文件里找不到关键校验\u002F解密逻辑；原因——wasm 的 import 由宿主 JS 注入（`WebAssembly.instantiate(bytes, { env: {...} })`），敏感逻辑在 JS 侧；对策——`wasm-objdump -x` 列出 Import section → 到 JS 胶水代码找对应实现（[[re-script-deob]]）——wasm 只证明\"调用了什么\"，不证明\"它做了什么\"\n- **wasm 混淆（wasm-obfuscator 等）先反混淆再分析**：现象——wasm2wat 输出大段控制流扁平化、死代码、`select` 噪音，字符串被切碎\u002F加密，函数名全抹；原因——混淆器做控制流平坦化 + 字符串加密 + 名称抹除；对策——binaryen 逐遍优化还原平坦化：`wasm-opt --flatten --simplify-locals --vacuum --dce -O3` 多轮迭代；字符串加密需定位解密逻辑（思路同 [[re-deobfuscate]]，注意解密函数可能是 import——回到坑 2）\n- **BigInt 调用约定**：现象——JS 调 wasm 导出函数报 `TypeError: Cannot convert a BigInt value to a number`，或 i64 参数静默截断；原因——i64 参数\u002F返回值在 JS↔wasm 边界只能走 BigInt（Number 仅 2^53 精度）；对策——JS 侧 `instance.exports.f(1n, 2n)` 传 BigInt；wasmtime `--invoke` 参数按 JSON 解析不支持 BigInt——需要时写 node 胶水；复刻算法用 Python int \u002F JS BigInt，别用 Number\n- **WASI 系统调用边界**：现象——wasmtime 跑 WASI 程序报 `unknown import: wasi_snapshot_preview1.…`，或浏览器与运行时行为不一致；原因——WASI 程序通过 import `wasi_snapshot_preview1` 拿文件\u002F时钟\u002F随机数\u002F网络能力，运行时未授权该能力即失败；浏览器里宿主 import 是 JS 而非 WASI，同一模块两端行为可以不同；对策——`wasm-objdump -x` 看 Import 段确认用到的 WASI 函数 → `wasmtime run --dir . --env K=v` 显式授权 → `strace -f wasmtime run` 观察实际系统调用（[[re-tracing]]）；结论标注运行环境（browser vs wasi）\n",{"name":5,"description":7,"capabilities":24},[25],"web-assembly","main","1977504515d3f5fa8889da43974feb7a0f4eaab9",".claude\u002Fskills\u002Fre-wasm",43,"https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills","https:\u002F\u002Fgithub.com\u002Fdslsdzc","Building systems from scratch","2026-10-12 04:15:49",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add dslsdzc\u002Frev-skills --skill re-wasm",{"tool":40,"command":41},"bunx","bunx skills add dslsdzc\u002Frev-skills --skill re-wasm",{"tool":43,"command":44},"pnpm","pnpm dlx skills add dslsdzc\u002Frev-skills --skill re-wasm","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fre-wasm\u002FSKILL.md",true,[],[49,56,62,69,76,83],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7AT3SFGN6KTM2DBN8TCNC4K","no-tools","缺工具准备章节。missing tools section.","https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fno-tools\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7AT3PY0QVB4A4WGAZHY43WP","good-skill","https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fgood-skill\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7AT3NJ1PG8DR115AMJC1Q1C","gateway-skill","网关型技能，无工具准备章节。gateway skill.","https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fgateway-skill\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7AT3KCJGZV60PKJX244V8Z4","broken-link","含死链接与合法 references 链接。broken link.","https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fbroken-link\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7AT3HMVTA2MR66A5FMATVFQ","wrong-name","名字与目录不符。name mismatch.","https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fbad-name\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7AT3F4K5ES6N62092Y8TRNG","bad-frontmatter","https:\u002F\u002Fgithub.com\u002Fdslsdzc\u002Frev-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fbad-frontmatter\u002FSKILL.md",[],[]]