jd-opensource/arkdecompiler

GitHub: jd-opensource/arkdecompiler

针对 HarmonyOS NEXT 的反编译器,能够将 Panda 字节码文件(.abc)还原为可读的 ArkTS 源代码并输出 AST 结构。

Stars: 161 | Forks: 22

# arkdecompiler arkdecompiler 是 HarmonyOS NEXT 的反编译器 (纯血鸿蒙反编译器),它以 Panda Binary File 作为输入,解析 Panda Bytecode,然后将其翻译为 Panda IR。获得 IR 后,我们可以进行各种分析。基于 IR,我们逆向构建原生 ArkTS AST 树,然后遍历 AST 树并将其翻译为原生 ArkTS 源代码。 - [2025 Black Hat, USA](https://www.blackhat.com/us-25/arsenal/schedule/index.html#decompiler-for-harmonyos-next-45569) - [2026 Black Hat, ASIA](https://blackhat.com/asia-26/arsenal/schedule/index.html) # 日程安排 - ✅ 支持所有指令 - ⏳ 覆盖官方编译器和 test262 中充足的边缘情况 # 安装说明 ## 测试平台 Ubuntu 22.04 未来我们将适配其他开发平台(如 Windows、macOS)并添加 GUI。 ## 准备环境 ``` ./prepare.sh(It will create the root directory **harmonyos**) ``` ## 在 `harmonyos` 中克隆 `arkdecompiler` ``` cd harmonyos && git clone https://github.com/jd-opensource/arkdecompiler.git ``` - 目录结构 ``` ➜ harmonyos ls ark.py arkcompiler arkdecompiler build developtools docs foundation kernel out prebuilts prebuilts_download.sh third_party ``` ## 向 arkcompiler 和 third_party 应用补丁 根据 `patches` 向 `arkcompiler/runtime_core`、`arkcompiler/ets_frontend` 和 `third_party/protobuf` 应用补丁。 # 使用方法 ## 构建反编译主程序 `xabc` ``` ./build.sh ``` ## 准备源代码文件 创建 `demo.ts`(参考 `tests` 目录) ## 编译 && 反编译 ./run.sh(它将调用 `genlogs.sh`) ### 详细说明 - 编译结果为:**demo.abc**(由 `genlogs.sh` 生成) - 反编译结果为:**arkdemo.ts** # 演示 ## 将字节码反编译为 arkTS ![demo](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/5e747624a2182124.png) ## AST ``` { "type": "Program", "statements": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "v254", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "right": { "type": "Identifier", "name": "undefined", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "c", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "right": { "type": "Identifier", "name": "v254", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "v0", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "right": { "type": "NumberLiteral", "value": 1, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "v254", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "right": { "type": "BinaryExpression", "operator": "+", "left": { "type": "NumberLiteral", "value": 1, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "right": { "type": "Identifier", "name": "v0", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "c", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "right": { "type": "Identifier", "name": "v254", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "v254", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "right": { "type": "Identifier", "name": "undefined", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, { "type": "ReturnStatement", "argument": { "type": "Identifier", "name": "undefined", "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } }, "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } } ], "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 1 } } } ```
标签:ArkTS, AST 抽象语法树, Black Hat, HarmonyOS NEXT, Multi-Agent, Panda Binary, Panda IR, 二进制发布, 云安全监控, 云资产清单, 京东科技, 代码分析, 凭证管理, 反编译器, 字节码翻译, 开源工具, 方舟字节码, 源码恢复, 目录枚举, 移动安全, 编译原理, 网络安全, 自动化payload嵌入, 逆向工程, 隐私保护, 静态分析, 鸿蒙开发