android-decompile-mcp 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.vi.md ADDED
@@ -0,0 +1,226 @@
1
+ # DexAndroid
2
+
3
+ [English](./README.md) · [简体中文](./README.zh-CN.md) · [繁體中文](./README.zh-TW.md) · [日本語](./README.ja.md) · [한국어](./README.ko.md) · [Español](./README.es.md) · [Français](./README.fr.md) · [Deutsch](./README.de.md) · [Português](./README.pt-BR.md) · [Русский](./README.ru.md) · [العربية](./README.ar.md) · [हिन्दी](./README.hi.md) · [Bahasa Indonesia](./README.id.md) · **Tiếng Việt** · [ไทย](./README.th.md) · [Italiano](./README.it.md) · [Türkçe](./README.tr.md)
4
+
5
+ > ⚠️ **Chỉ dùng cho học tập và giảng dạy.** Không dùng cho hành vi bất hợp pháp, crack trái phép, xâm phạm bản quyền hay vượt bảo vệ của bên thứ ba. Tuân thủ pháp luật địa phương và điều khoản ứng dụng. Người dùng chịu trách nhiệm nếu lạm dụng.
6
+
7
+ **MCP Server** giải nén Android + phân tích smali. Trong Cursor / Claude: quản lý thiết bị, phát hiện packer, unpack tĩnh / BlackDex / Frida, dex→smali, tìm chuỗi API.
8
+
9
+ Repo: [https://github.com/TimeCyber/DexAndroid](https://github.com/TimeCyber/DexAndroid)
10
+
11
+ ---
12
+
13
+ ## Tính năng
14
+
15
+ | Khả năng | Công cụ MCP | Ghi chú |
16
+ | --- | --- | --- |
17
+ | Devices | `list_devices` | Connected ADB devices |
18
+ | Packages | `list_packages` | Optional keyword filter |
19
+ | Packer detect | `detect_packer` | 360 / Tencent / Bangcle / ijiami / Alibaba, etc. |
20
+ | Pull APK | `pull_apk` | Installed app (+ splits) |
21
+ | Static unpack | `static_unpack` | Extract `classes*.dex` |
22
+ | No-Root unpack | `blackdex_prepare` / `blackdex_pull` | BlackDex memory dump |
23
+ | Root unpack | `frida_prepare` / `frida_unpack` | frida-server + frida-dexdump |
24
+ | Decompile | `dex_to_smali` | baksmali → smali |
25
+ | Analyze | `smali_list_classes` / `smali_read_class` / `smali_search` | List / read / regex |
26
+
27
+ ### Các phương pháp unpack
28
+
29
+ | Phương pháp | Root? | Khi nào |
30
+ | --- | --- | --- |
31
+ | Static | No | Unpacked apps or shell/resources only |
32
+ | BlackDex | No | Most protected apps |
33
+ | Frida | **Yes** | Strong packers / fuller dumps |
34
+
35
+ ---
36
+
37
+ ## Yêu cầu
38
+
39
+ - **Windows / macOS / Linux** (docs use Windows examples)
40
+ - **Node.js** ≥ 18
41
+ - **ADB** on PATH, or set `ADB_PATH`
42
+ - **Java 8+** (for baksmali via `dex_to_smali`)
43
+ - Optional: [BlackDex](https://github.com/CodingGay/BlackDex/releases); rooted device + `frida-server`; `pip install frida-tools frida-dexdump`
44
+
45
+ Place baksmali fat jar / frida-server / BlackDex under local `tools/` (large binaries are gitignored).
46
+
47
+ ---
48
+
49
+ ## Cài đặt & build
50
+
51
+ ```bash
52
+ git clone https://github.com/TimeCyber/DexAndroid.git
53
+ cd DexAndroid
54
+ npm install
55
+ npm run build
56
+ ```
57
+
58
+ Khởi động MCP (stdio):
59
+
60
+ ```bash
61
+ npm start
62
+ # node dist/index.js
63
+ ```
64
+
65
+ Chế độ dev:
66
+
67
+ ```bash
68
+ npm run dev
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Thiết lập Cursor (MCP)
74
+
75
+ Thêm vào `.cursor/mcp.json` (**đổi đường dẫn**):
76
+
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "dex-android-unpack": {
81
+ "command": "node",
82
+ "args": ["E:/DexAndroid/dist/index.js"],
83
+ "env": {
84
+ "ADB_PATH": "E:/Android/Sdk/platform-tools/adb.exe",
85
+ "DEX_OUT_DIR": "E:/DexAndroid/unpack-output"
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ Khởi động lại Cursor / tải lại MCP.
93
+
94
+ ---
95
+
96
+ ## Biến môi trường
97
+
98
+ | Biến | Ý nghĩa | Mặc định |
99
+ | --- | --- | --- |
100
+ | `ADB_PATH` | adb executable | `adb` |
101
+ | `DEX_OUT_DIR` | Default output dir | `<cwd>/unpack-output` |
102
+ | `BAKSMALI_JAR` | baksmali jar | auto-discover under `tools/` |
103
+
104
+ ---
105
+
106
+ ## Quy trình điển hình
107
+
108
+ ### 1. Unpack tĩnh (nhanh nhất)
109
+
110
+ 1. `list_devices` or prepare local `apkPath`.
111
+ 2. `detect_packer`.
112
+ 3. `static_unpack` → `classes*.dex`.
113
+ 4. `dex_to_smali` → smali folder.
114
+ 5. `smali_search` / `smali_read_class`.
115
+
116
+ **Note:** Protected apps often yield only the shell via static unpack—use BlackDex / Frida for business code.
117
+
118
+ ### 2. Không Root (BlackDex)
119
+
120
+ 1. `list_devices`.
121
+ 2. `blackdex_prepare` with `blackdexApkPath`.
122
+ 3. Unpack the target app in BlackDex UI.
123
+ 4. `blackdex_pull` with `targetPkg`.
124
+ 5. `dex_to_smali` then `smali_*`.
125
+
126
+ ### 3. Có Root (Frida)
127
+
128
+ 1. Rooted device (e.g. Magisk), `adb` ready.
129
+ 2. `frida_prepare` to push/start `tools/frida-server`.
130
+ 3. Matching `frida` / `frida-dexdump` locally (prefer 16.x).
131
+ 4. `frida_unpack` with `pkg`, prefer `spawn: true`, `deepSearch: true`.
132
+ 5. `dex_to_smali` on output, then analyze.
133
+
134
+ If Frida 17 attach fails, align tools to 16.x; some devices need temporary `setenforce 0`.
135
+
136
+ ### 4. Ví dụ smali
137
+
138
+ ```text
139
+ smali_list_classes smaliDir=.../smali keyword=login
140
+ smali_search smaliDir=.../smali pattern=https?://|/api/|publicClient/
141
+ smali_read_class smaliDir=.../smali className=com.example.api.ApiService
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Cấu trúc
147
+
148
+ ```text
149
+ DexAndroid/
150
+ ├── src/ # MCP server (TypeScript)
151
+ │ ├── index.ts
152
+ │ ├── adb.ts
153
+ │ ├── detect.ts
154
+ │ ├── smali.ts
155
+ │ └── unpack/
156
+ ├── dist/
157
+ ├── examples/ # Damai / Huaxi sample smali.zip + docs
158
+ ├── tools/ # baksmali / frida-server / BlackDex (local)
159
+ ├── unpack-output/ # local dumps (gitignored)
160
+ ├── package.json
161
+ └── README.md
162
+ ```
163
+
164
+ ---
165
+
166
+ ## Ví dụ decompile
167
+
168
+ Xem [`examples/`](./examples/) (smali dạng zip):
169
+
170
+ | Ví dụ | Đường dẫn | Nội dung |
171
+ | --- | --- | --- |
172
+ | Damai | [`examples/damai/`](./examples/damai/) | Frida smali.zip + API docs |
173
+ | Huaxi Maternity | [`examples/huaxi/`](./examples/huaxi/) | Static smali.zip (`info.cd120.two`) |
174
+
175
+ Sau khi giải nén, dùng `smali_*`.
176
+
177
+ ---
178
+
179
+ ## Bảng tra MCP
180
+
181
+ | Tool | Params |
182
+ | --- | --- |
183
+ | `detect_packer` | `apkPath` or `pkg`, optional `serial` |
184
+ | `pull_apk` | `pkg`, optional `outDir` / `serial` |
185
+ | `static_unpack` | `apkPath` or `pkg`, optional `outDir` |
186
+ | `blackdex_prepare` | `blackdexApkPath`, optional `serial` |
187
+ | `blackdex_pull` | `targetPkg`, optional `outDir` / `serial` |
188
+ | `frida_prepare` | optional `serial` / `serverLocalPath` |
189
+ | `frida_unpack` | `pkg`, optional `spawn` / `deepSearch` / `outDir` |
190
+ | `dex_to_smali` | `dexInput`, optional `outDir` |
191
+ | `smali_list_classes` | `smaliDir`, optional `keyword` |
192
+ | `smali_read_class` | `smaliDir`, `className` |
193
+ | `smali_search` | `smaliDir`, `pattern`, optional `flags` / `maxResults` |
194
+
195
+ ---
196
+
197
+ ## FAQ
198
+
199
+ **Q: Empty `list_devices`?**
200
+ Check USB debugging, `adb devices`, pass `serial` if multiple.
201
+
202
+ **Q: No business classes after static unpack?**
203
+ Likely packed—use BlackDex or Frida.
204
+
205
+ **Q: `dex_to_smali` failed?**
206
+ Install Java; put baksmali jar in `tools/` or set `BAKSMALI_JAR`.
207
+
208
+ **Q: Frida jailed / version mismatch?**
209
+ Keep `frida-server` and host `frida` major versions aligned; try 16.x.
210
+
211
+ **Q: Where is output?**
212
+ Default `unpack-output/` (or `DEX_OUT_DIR`). **Do not commit dumps.**
213
+
214
+ ---
215
+
216
+ ## Tuyên bố pháp lý
217
+
218
+ Dự án này **chỉ dành cho học tập, giảng dạy và nghiên cứu bảo mật được ủy quyền**. Nghiêm cấm dùng cho tội phạm/bất hợp pháp (truy cập trái phép, crack, đạo nhái, tấn công, xâm phạm IP). Tác giả không chịu trách nhiệm về lạm dụng. Việc sử dụng đồng nghĩa chấp nhận điều khoản.
219
+
220
+ > ⚠️ **Chỉ dùng cho học tập và giảng dạy.** Không dùng cho hành vi bất hợp pháp, crack trái phép, xâm phạm bản quyền hay vượt bảo vệ của bên thứ ba. Tuân thủ pháp luật địa phương và điều khoản ứng dụng. Người dùng chịu trách nhiệm nếu lạm dụng.
221
+
222
+ ---
223
+
224
+ ## License
225
+
226
+ MIT — see [`LICENSE`](./LICENSE).
@@ -0,0 +1,252 @@
1
+ # DexAndroid
2
+
3
+ [English](./README.md) · **简体中文** · [繁體中文](./README.zh-TW.md) · [日本語](./README.ja.md) · [한국어](./README.ko.md) · [Español](./README.es.md) · [Français](./README.fr.md) · [Deutsch](./README.de.md) · [Português](./README.pt-BR.md) · [Русский](./README.ru.md) · [العربية](./README.ar.md) · [हिन्दी](./README.hi.md) · [Bahasa Indonesia](./README.id.md) · [Tiếng Việt](./README.vi.md) · [ไทย](./README.th.md) · [Italiano](./README.it.md) · [Türkçe](./README.tr.md)
4
+
5
+ > ⚠️ **仅用于学习与教学目的。** 禁止用于任何违法犯罪、未授权破解、侵权或绕过他人防护的行为。使用者须遵守所在国家/地区法律法规与目标应用服务条款;因滥用造成的后果由使用者自行承担。
6
+
7
+ 安卓脱壳 + smali 分析 **MCP Server**。在 Cursor / Claude 等客户端中通过工具调用完成:设备管理、加固检测、静态/免 Root/Root 脱壳、dex→smali、接口字符串检索。
8
+
9
+ Repo: [https://github.com/TimeCyber/DexAndroid](https://github.com/TimeCyber/DexAndroid)
10
+
11
+ ---
12
+
13
+ ## 功能概览
14
+
15
+ | 能力 | MCP 工具 | 说明 |
16
+ | --- | --- | --- |
17
+ | 设备列表 | `list_devices` | ADB 已连接设备 |
18
+ | 包名列表 | `list_packages` | 可按关键字过滤 |
19
+ | 加固识别 | `detect_packer` | 360 / 腾讯 / 梆梆 / 爱加密 / 阿里聚安全等 |
20
+ | 拉 APK | `pull_apk` | 从设备拉取已安装应用(含 split) |
21
+ | 静态解包 | `static_unpack` | 解压 APK 提取 `classes*.dex` |
22
+ | 免 Root 脱壳 | `blackdex_prepare` / `blackdex_pull` | BlackDex 内存 dump 后拉取 |
23
+ | Root 脱壳 | `frida_prepare` / `frida_unpack` | 推送 frida-server + frida-dexdump |
24
+ | 反编译 | `dex_to_smali` | baksmali 转 smali |
25
+ | 分析 | `smali_list_classes` / `smali_read_class` / `smali_search` | 列类、读类、正则搜索 |
26
+ | 入口定位 | `find_app_entry` | MAIN/LAUNCHER + smali onCreate(只读) |
27
+ | 解码/重打包 | `apk_decode` / `apk_repack` | apktool 解码 + 重建签名 |
28
+
29
+ ### 三种脱壳方案对比
30
+
31
+ | 方案 | 是否需要 Root | 适用场景 |
32
+ | --- | --- | --- |
33
+ | 静态解包 | 否 | 未加固,或只要壳/资源 |
34
+ | BlackDex | 否 | 多数加固 App |
35
+ | Frida | **是** | 强加固 / 壳对抗,内存 dump 更完整 |
36
+
37
+ ---
38
+
39
+ ## 环境要求
40
+
41
+ - **Windows / macOS / Linux**(文档以 Windows 为例)
42
+ - **Node.js** ≥ 18
43
+ - **ADB**:加入 PATH,或设置 `ADB_PATH`
44
+ - **Java 8+**(`dex_to_smali` 调用 baksmali)
45
+ - 可选:[BlackDex](https://github.com/CodingGay/BlackDex/releases) APK;设备 Root + `frida-server`;本机 `pip install frida-tools frida-dexdump`
46
+
47
+ 将 baksmali fat jar / frida-server / BlackDex 放到本地 `tools/`(大文件默认不进 Git,见 `.gitignore`)。
48
+
49
+ ---
50
+
51
+ ## 安装(推荐)
52
+
53
+ 无需 clone,通过 npx 自动从 npm 下载并启动:
54
+
55
+ ```bash
56
+ npx -y android-decompile-mcp
57
+ ```
58
+
59
+ 或全局安装:
60
+
61
+ ```bash
62
+ npm i -g android-decompile-mcp
63
+ android-decompile-mcp
64
+ ```
65
+
66
+ ### 本地开发构建
67
+
68
+ ```bash
69
+ git clone https://github.com/TimeCyber/DexAndroid.git
70
+ cd DexAndroid
71
+ npm install
72
+ npm run build
73
+ npm start
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 接入 Cursor(MCP)
79
+
80
+ 在项目 `.cursor/mcp.json` 或 Cursor 全局 MCP 配置中增加:
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "android-decompile-mcp": {
86
+ "command": "npx",
87
+ "args": ["-y", "android-decompile-mcp"],
88
+ "env": {
89
+ "ADB_PATH": "adb",
90
+ "DEX_OUT_DIR": "./unpack-output"
91
+ }
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ 保存后重启 Cursor / 重载 MCP。例如:「列出设备并检测加固」「对本地 apk 做 static_unpack,再 dex_to_smali,搜索登录接口」。
98
+
99
+ ---
100
+
101
+ ## 环境变量
102
+
103
+ | 变量 | 说明 | 默认 |
104
+ | --- | --- | --- |
105
+ | `ADB_PATH` | adb 可执行文件 | `adb` |
106
+ | `DEX_OUT_DIR` | 脱壳/拉取默认输出目录 | `<cwd>/unpack-output` |
107
+ | `BAKSMALI_JAR` | baksmali 可执行 jar | 自动在 `tools/` 下查找 |
108
+
109
+ ---
110
+
111
+ ## 使用说明(典型流程)
112
+
113
+ ### 1. 静态解包(最快)
114
+
115
+ 1. `list_devices` 确认设备(若用 `pkg` 拉取)或准备本地 `apkPath`。
116
+ 2. `detect_packer` 看是否加固。
117
+ 3. `static_unpack` → 得到 `classes*.dex`。
118
+ 4. `dex_to_smali` → smali 目录。
119
+ 5. `smali_search` / `smali_read_class` 分析接口、字符串、加解密等。
120
+
121
+ **注意:** 加固 App 的静态 dex 往往只有壳,业务代码需 BlackDex / Frida。
122
+
123
+ ### 2. 免 Root(BlackDex)
124
+
125
+ 1. `list_devices`。
126
+ 2. `blackdex_prepare`,传入 `blackdexApkPath`。
127
+ 3. 在手机 BlackDex 界面选择目标应用并脱壳。
128
+ 4. `blackdex_pull`,传入 `targetPkg`。
129
+ 5. `dex_to_smali` → 再 `smali_*` 分析。
130
+
131
+ ### 3. Root(Frida)
132
+
133
+ 1. 设备已 Root(如 Magisk),`adb` 可用。
134
+ 2. `frida_prepare`:推送并启动 `tools/frida-server`。
135
+ 3. 本机已安装匹配版本的 `frida` / `frida-dexdump`(建议 16.x)。
136
+ 4. `frida_unpack`:传 `pkg`,建议 `spawn: true`、`deepSearch: true`。
137
+ 5. 对输出目录 `dex_to_smali` 后分析。
138
+
139
+ 若 Frida 17 附加失败,可降级到同一 16.x;部分机型需临时 `setenforce 0`。
140
+
141
+ ### 4. smali 分析示例
142
+
143
+ ```text
144
+ smali_list_classes smaliDir=.../smali keyword=login
145
+ smali_search smaliDir=.../smali pattern=https?://|/api/|publicClient/
146
+ smali_read_class smaliDir=.../smali className=com.example.api.ApiService
147
+ ```
148
+
149
+ ---
150
+
151
+ ## 目录结构
152
+
153
+ ```text
154
+ DexAndroid/
155
+ ├── src/ # MCP server (TypeScript)
156
+ │ ├── index.ts
157
+ │ ├── adb.ts
158
+ │ ├── detect.ts
159
+ │ ├── smali.ts
160
+ │ └── unpack/
161
+ ├── dist/
162
+ ├── examples/ # Damai / Huaxi sample smali.zip + docs
163
+ ├── skills/ # 规范 skill 源(改这里再 sync)
164
+ ├── .cursor/skills/ # Cursor
165
+ ├── .agents/skills/ # Codex
166
+ ├── .claude/skills/ # Claude Code
167
+ ├── tools/ # baksmali / frida-server / BlackDex (local)
168
+ ├── unpack-output/ # local dumps (gitignored)
169
+ ├── package.json
170
+ └── README.md
171
+ ```
172
+
173
+ ### Agent Skill(多客户端)
174
+
175
+ 脱壳后使用 **`android-api-smali-analysis`**,强制还原请求头 / Body / 加解密与密钥(smali / `.so` / 服务端下发),禁止只写 path。
176
+
177
+ | 客户端 | 路径 |
178
+ | --- | --- |
179
+ | 规范源 | [`skills/android-api-smali-analysis/SKILL.md`](./skills/android-api-smali-analysis/SKILL.md) |
180
+ | Cursor | [`.cursor/skills/`](./.cursor/skills/android-api-smali-analysis/) |
181
+ | Codex | [`.agents/skills/`](./.agents/skills/android-api-smali-analysis/) |
182
+ | Claude Code | [`.claude/skills/`](./.claude/skills/android-api-smali-analysis/)(可 `/android-api-smali-analysis`) |
183
+
184
+ 修改规范源后执行:`node tools/sync-skills.mjs`。详见 [`skills/README.md`](./skills/README.md)。
185
+
186
+ ---
187
+
188
+ ## 反编译示例
189
+
190
+ 仓库 [`examples/`](./examples/) 提供两套可下载示例(smali 为 zip):
191
+
192
+ | 示例 | 路径 | 内容 |
193
+ | --- | --- | --- |
194
+ | 大麦 | [`examples/damai/`](./examples/damai/) | Frida smali 压缩包 + API / 选座 / 登录文档 |
195
+ | 华西妇幼 | [`examples/huaxi/`](./examples/huaxi/) | 静态解包 smali 压缩包(`info.cd120.two`) |
196
+
197
+ 解压后即可对目录执行 `smali_list_classes` / `smali_search` / `smali_read_class`。
198
+
199
+ ---
200
+
201
+ ## MCP 工具参数速查
202
+
203
+ | Tool | Params |
204
+ | --- | --- |
205
+ | `detect_packer` | `apkPath` or `pkg`, optional `serial` |
206
+ | `pull_apk` | `pkg`, optional `outDir` / `serial` |
207
+ | `static_unpack` | `apkPath` or `pkg`, optional `outDir` |
208
+ | `blackdex_prepare` | `blackdexApkPath`, optional `serial` |
209
+ | `blackdex_pull` | `targetPkg`, optional `outDir` / `serial` |
210
+ | `frida_prepare` | optional `serial` / `serverLocalPath` |
211
+ | `frida_unpack` | `pkg`, optional `spawn` / `deepSearch` / `outDir` |
212
+ | `dex_to_smali` | `dexInput`, optional `outDir` |
213
+ | `smali_list_classes` | `smaliDir`, optional `keyword` |
214
+ | `smali_read_class` | `smaliDir`, `className` |
215
+ | `smali_search` | `smaliDir`, `pattern`, optional `flags` / `maxResults` |
216
+ | `find_app_entry` | `projectDir` / `manifestPath` / `apkPath`,可选 `smaliDir` |
217
+ | `apk_decode` | `apkPath`,可选 `outDir` |
218
+ | `apk_repack` | `projectDir`,可选 `outApk` / keystore 参数 |
219
+ | `smali_patch` | `mode` + `smaliPath`/`projectDir`;自备 `content` 或 `insert_verify_log` |
220
+
221
+ ---
222
+
223
+ ## 常见问题
224
+
225
+ **Q: `list_devices` 为空?**
226
+ 检查 USB 调试、`adb devices`、多设备时传 `serial`。
227
+
228
+ **Q: 静态解包后找不到业务类?**
229
+ 多半是加固壳,请改用 BlackDex 或 Frida。
230
+
231
+ **Q: `dex_to_smali` 失败?**
232
+ 确认已安装 Java,并在 `tools/` 放置 baksmali jar,或设置 `BAKSMALI_JAR`。
233
+
234
+ **Q: Frida 报 jailed / 版本不匹配?**
235
+ 保持 `frida-server` 与本机 `frida` 主版本一致;必要时用 16.x。
236
+
237
+ **Q: 输出目录在哪?**
238
+ 默认 `unpack-output/`(或 `DEX_OUT_DIR`)。**请勿提交到 Git**。
239
+
240
+ ---
241
+
242
+ ## 合规与免责声明
243
+
244
+ 本项目**仅用于学习、教学与已授权的安全研究**。严禁将本工具用于任何违法犯罪活动,包括但不限于未授权访问、破解、盗版、攻击他人系统或侵犯知识产权。作者与贡献者不对任何滥用行为负责。使用即表示你已阅读并同意上述条款。
245
+
246
+ > ⚠️ **仅用于学习与教学目的。** 禁止用于任何违法犯罪、未授权破解、侵权或绕过他人防护的行为。使用者须遵守所在国家/地区法律法规与目标应用服务条款;因滥用造成的后果由使用者自行承担。
247
+
248
+ ---
249
+
250
+ ## License
251
+
252
+ MIT,见仓库根目录 [`LICENSE`](./LICENSE)。
@@ -0,0 +1,226 @@
1
+ # DexAndroid
2
+
3
+ [English](./README.md) · [简体中文](./README.zh-CN.md) · **繁體中文** · [日本語](./README.ja.md) · [한국어](./README.ko.md) · [Español](./README.es.md) · [Français](./README.fr.md) · [Deutsch](./README.de.md) · [Português](./README.pt-BR.md) · [Русский](./README.ru.md) · [العربية](./README.ar.md) · [हिन्दी](./README.hi.md) · [Bahasa Indonesia](./README.id.md) · [Tiếng Việt](./README.vi.md) · [ไทย](./README.th.md) · [Italiano](./README.it.md) · [Türkçe](./README.tr.md)
4
+
5
+ > ⚠️ **僅供學習與教學用途。** 禁止用於任何違法犯罪、未授權破解、侵權或規避他人防護之行為。使用者須遵守當地法律與目標應用服務條款;濫用後果自負。
6
+
7
+ 安卓脫殼 + smali 分析 **MCP Server**。可在 Cursor / Claude 等客戶端透過工具呼叫完成:裝置管理、加固偵測、靜態/免 Root/Root 脫殼、dex→smali、介面字串檢索。
8
+
9
+ Repo: [https://github.com/TimeCyber/DexAndroid](https://github.com/TimeCyber/DexAndroid)
10
+
11
+ ---
12
+
13
+ ## 功能概覽
14
+
15
+ | 能力 | MCP 工具 | 說明 |
16
+ | --- | --- | --- |
17
+ | 设备列表 | `list_devices` | ADB 已连接设备 |
18
+ | 包名列表 | `list_packages` | 可按关键字过滤 |
19
+ | 加固识别 | `detect_packer` | 360 / 腾讯 / 梆梆 / 爱加密 / 阿里聚安全等 |
20
+ | 拉 APK | `pull_apk` | 从设备拉取已安装应用(含 split) |
21
+ | 静态解包 | `static_unpack` | 解压 APK 提取 `classes*.dex` |
22
+ | 免 Root 脱壳 | `blackdex_prepare` / `blackdex_pull` | BlackDex 内存 dump 后拉取 |
23
+ | Root 脱壳 | `frida_prepare` / `frida_unpack` | 推送 frida-server + frida-dexdump |
24
+ | 反编译 | `dex_to_smali` | baksmali 转 smali |
25
+ | 分析 | `smali_list_classes` / `smali_read_class` / `smali_search` | 列类、读类、正则搜索 |
26
+
27
+ ### 三種脫殼方案比較
28
+
29
+ | 方案 | 是否需要 Root | 適用場景 |
30
+ | --- | --- | --- |
31
+ | 静态解包 | 否 | 未加固,或只要壳/资源 |
32
+ | BlackDex | 否 | 多数加固 App |
33
+ | Frida | **是** | 强加固 / 壳对抗,内存 dump 更完整 |
34
+
35
+ ---
36
+
37
+ ## 環境需求
38
+
39
+ - **Windows / macOS / Linux**(文件以 Windows 為例)
40
+ - **Node.js** ≥ 18
41
+ - **ADB**:加入 PATH,或設定 `ADB_PATH`
42
+ - **Java 8+**(`dex_to_smali` 呼叫 baksmali)
43
+ - 可選:[BlackDex](https://github.com/CodingGay/BlackDex/releases);裝置 Root + `frida-server`;本機 `pip install frida-tools frida-dexdump`
44
+
45
+ 請將 baksmali fat jar / frida-server / BlackDex 放於本機 `tools/`(大型檔案預設不進 Git)。
46
+
47
+ ---
48
+
49
+ ## 安裝與建置
50
+
51
+ ```bash
52
+ git clone https://github.com/TimeCyber/DexAndroid.git
53
+ cd DexAndroid
54
+ npm install
55
+ npm run build
56
+ ```
57
+
58
+ 啟動 MCP(stdio):
59
+
60
+ ```bash
61
+ npm start
62
+ # node dist/index.js
63
+ ```
64
+
65
+ 開發模式:
66
+
67
+ ```bash
68
+ npm run dev
69
+ ```
70
+
71
+ ---
72
+
73
+ ## 接入 Cursor(MCP)
74
+
75
+ 於 `.cursor/mcp.json` 或全域 MCP 設定新增(**路徑請改為本機**):
76
+
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "dex-android-unpack": {
81
+ "command": "node",
82
+ "args": ["E:/DexAndroid/dist/index.js"],
83
+ "env": {
84
+ "ADB_PATH": "E:/Android/Sdk/platform-tools/adb.exe",
85
+ "DEX_OUT_DIR": "E:/DexAndroid/unpack-output"
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ 儲存後重啟 Cursor / 重載 MCP。
93
+
94
+ ---
95
+
96
+ ## 環境變數
97
+
98
+ | 變數 | 說明 | 預設 |
99
+ | --- | --- | --- |
100
+ | `ADB_PATH` | adb 可执行文件 | `adb` |
101
+ | `DEX_OUT_DIR` | 脱壳/拉取默认输出目录 | `<cwd>/unpack-output` |
102
+ | `BAKSMALI_JAR` | baksmali 可执行 jar | 自动在 `tools/` 下查找 |
103
+
104
+ ---
105
+
106
+ ## 使用說明(典型流程)
107
+
108
+ ### 1. 靜態解包(最快)
109
+
110
+ 1. `list_devices` 或準備本機 `apkPath`。
111
+ 2. `detect_packer`。
112
+ 3. `static_unpack` → `classes*.dex`。
113
+ 4. `dex_to_smali` → smali 目錄。
114
+ 5. `smali_search` / `smali_read_class`。
115
+
116
+ **注意:** 加固 App 靜態 dex 常只有殼,業務程式碼需 BlackDex / Frida。
117
+
118
+ ### 2. 免 Root(BlackDex)
119
+
120
+ 1. `list_devices`。
121
+ 2. `blackdex_prepare`(`blackdexApkPath`)。
122
+ 3. 於手機 BlackDex 介面選擇目標 App 並脫殼。
123
+ 4. `blackdex_pull`(`targetPkg`)。
124
+ 5. `dex_to_smali` 後再 `smali_*`。
125
+
126
+ ### 3. Root(Frida)
127
+
128
+ 1. 裝置已 Root,`adb` 可用。
129
+ 2. `frida_prepare` 推送並啟動 `frida-server`。
130
+ 3. 本機安裝相符版本 `frida` / `frida-dexdump`(建議 16.x)。
131
+ 4. `frida_unpack`(建議 `spawn: true`、`deepSearch: true`)。
132
+ 5. `dex_to_smali` 後分析。
133
+
134
+ 若 Frida 17 附加失敗,可對齊至 16.x;部分機型需暫時 `setenforce 0`。
135
+
136
+ ### 4. smali 分析範例
137
+
138
+ ```text
139
+ smali_list_classes smaliDir=.../smali keyword=login
140
+ smali_search smaliDir=.../smali pattern=https?://|/api/|publicClient/
141
+ smali_read_class smaliDir=.../smali className=com.example.api.ApiService
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 目錄結構
147
+
148
+ ```text
149
+ DexAndroid/
150
+ ├── src/ # MCP server (TypeScript)
151
+ │ ├── index.ts
152
+ │ ├── adb.ts
153
+ │ ├── detect.ts
154
+ │ ├── smali.ts
155
+ │ └── unpack/
156
+ ├── dist/
157
+ ├── examples/ # Damai / Huaxi sample smali.zip + docs
158
+ ├── tools/ # baksmali / frida-server / BlackDex (local)
159
+ ├── unpack-output/ # local dumps (gitignored)
160
+ ├── package.json
161
+ └── README.md
162
+ ```
163
+
164
+ ---
165
+
166
+ ## 反編譯範例
167
+
168
+ 見 [`examples/`](./examples/)(smali 以 zip 提供):
169
+
170
+ | 範例 | 路徑 | 內容 |
171
+ | --- | --- | --- |
172
+ | 大麥 | [`examples/damai/`](./examples/damai/) | Frida smali 壓縮包 + API 文件 |
173
+ | 華西婦幼 | [`examples/huaxi/`](./examples/huaxi/) | 靜態解包 smali 壓縮包(`info.cd120.two`) |
174
+
175
+ 解壓後即可執行 `smali_*` 工具。
176
+
177
+ ---
178
+
179
+ ## MCP 工具參數速查
180
+
181
+ | Tool | Params |
182
+ | --- | --- |
183
+ | `detect_packer` | `apkPath` or `pkg`, optional `serial` |
184
+ | `pull_apk` | `pkg`, optional `outDir` / `serial` |
185
+ | `static_unpack` | `apkPath` or `pkg`, optional `outDir` |
186
+ | `blackdex_prepare` | `blackdexApkPath`, optional `serial` |
187
+ | `blackdex_pull` | `targetPkg`, optional `outDir` / `serial` |
188
+ | `frida_prepare` | optional `serial` / `serverLocalPath` |
189
+ | `frida_unpack` | `pkg`, optional `spawn` / `deepSearch` / `outDir` |
190
+ | `dex_to_smali` | `dexInput`, optional `outDir` |
191
+ | `smali_list_classes` | `smaliDir`, optional `keyword` |
192
+ | `smali_read_class` | `smaliDir`, `className` |
193
+ | `smali_search` | `smaliDir`, `pattern`, optional `flags` / `maxResults` |
194
+
195
+ ---
196
+
197
+ ## 常見問題
198
+
199
+ **Q: `list_devices` 為空?**
200
+ 檢查 USB 偵錯、`adb devices`,多裝置時傳 `serial`。
201
+
202
+ **Q: 靜態解包後找不到業務類?**
203
+ 多半是加固殼,請改用 BlackDex 或 Frida。
204
+
205
+ **Q: `dex_to_smali` 失敗?**
206
+ 確認已安裝 Java,並放置 baksmali jar 或設定 `BAKSMALI_JAR`。
207
+
208
+ **Q: Frida jailed / 版本不符?**
209
+ 保持 `frida-server` 與本機 `frida` 主版本一致;必要時用 16.x。
210
+
211
+ **Q: 輸出目錄在哪?**
212
+ 預設 `unpack-output/`。**請勿提交至 Git**。
213
+
214
+ ---
215
+
216
+ ## 合規與免責聲明
217
+
218
+ 本專案**僅供學習、教學與已授權安全研究**。嚴禁用於任何違法犯罪行為,包括未授權存取、破解、盜版、攻擊系統或侵害智慧財產權。作者與貢獻者不對濫用負責。使用即表示同意上述條款。
219
+
220
+ > ⚠️ **僅供學習與教學用途。** 禁止用於任何違法犯罪、未授權破解、侵權或規避他人防護之行為。使用者須遵守當地法律與目標應用服務條款;濫用後果自負。
221
+
222
+ ---
223
+
224
+ ## License
225
+
226
+ MIT,見倉庫根目錄 [`LICENSE`](./LICENSE)。