Apk reverse

From lingxling/awesome-skills-cn · View interactive version

Apk reverse is an AI agent skill from the GitHub repository lingxling/awesome-skills-cn. Android APK reverse engineering: unpacking, Java decompilation, smali modification, repacking and signing, Frida dynamic hooking, and native .so analysis with jadx, apktool, adb, and related tools.

How to use this skill

Skill file

⚠️ AUTHORIZED USE ONLY

This skill is for educational purposes or authorized security assessments only.

You must have explicit, written permission from the system owner before using this tool.

Misuse of this tool is illegal and strictly prohibited.

Mandatory confirmation gate

Before running any command that probes, exploits, changes, persists on, extracts data from, or attempts credential access against a target:

1. Ask the user to state the exact target URL, IP, account, or resource.

2. Ask the user to confirm written authorization and the permitted scope.

3. Show the exact command(s) and explain their expected effect.

4. Wait for explicit confirmation in the current conversation.

Without that confirmation, remain read-only and provide defensive guidance only. Prefer a sandbox, disposable VM, or controlled lab.

When to Use

适用范围

当任务属于以下场景时优先使用本 skill:

当前机器已验证可用的 CLI 工具

优先使用脚本的场景

以下流程高频且参数容易出错,优先用 skill 自带脚本:

以下一行命令保持直接调用,不单独封装:

自带脚本

`scripts/decode.ps1`

用途:

示例:

pwsh -File "<skill-root>\apk-reverse\scripts\decode.ps1" -ApkPath "D:\DOWNLOAD\app.apk" -Clean
pwsh -File "<skill-root>\apk-reverse\scripts\decode.ps1" -ApkPath "D:\DOWNLOAD\app.apk" -Name demo -SkipJadx

`scripts/frida-run.ps1`

用途:

示例:

pwsh -File "<skill-root>\apk-reverse\scripts\frida-run.ps1" -ListDevices
pwsh -File "<skill-root>\apk-reverse\scripts\frida-run.ps1" -Usb -ListProcesses
pwsh -File "<skill-root>\apk-reverse\scripts\frida-run.ps1" -Usb -Spawn -Package com.example.app -ScriptPath "D:\hooks\test.js"

`scripts/rebuild-sign-install.ps1`

用途:

示例:

pwsh -File "<skill-root>\apk-reverse\scripts\rebuild-sign-install.ps1" -ProjectDir "C:\work\apktool_out" -Clean
pwsh -File "<skill-root>\apk-reverse\scripts\rebuild-sign-install.ps1" -ProjectDir "C:\work\apktool_out" -Install -Reinstall -DeviceSerial "127.0.0.1:7555"

说明:

`scripts/manifest-summary.ps1`

用途:

示例:

pwsh -File "<skill-root>\apk-reverse\scripts\manifest-summary.ps1" -ManifestPath "C:\work\apktool_out\AndroidManifest.xml"

如果要分析 .so、lib/arm64-v8a/*.so、lib/armeabi-v7a/*.so,再结合:

工具分工

`jadx`

用于:

常用命令:

jadx -d jadx_out app.apk
jadx --single-class com.example.LoginActivity -d jadx_out app.apk
jadx --deobf -d jadx_out app.apk

`JEB Pro`(可选商业工具)

用于:

边界:

`apktool`

用于:

常用命令:

apktool d app.apk -o apktool_out
apktool b apktool_out -o rebuilt.apk

`frida`

用于:

常用命令:

frida-ps -U
frida -U -f com.example.app -l hook.js
frida-trace -U -f com.example.app -j '*!*certificate*'

`adb`

用于:

常用命令:

adb devices
adb install -r app.apk
adb shell pm list packages
adb logcat
adb pull /data/local/tmp/file .

推荐工作流

1. Triage

先确定 APK 大致构成,不急着改包或 Hook。

建议动作:

  1. 用 jadx -d jadx_out app.apk 导出 Java 代码
  2. 用 apktool d app.apk -o apktool_out 导出 smali 和资源
  3. 先看:
  1. Issue #65 威胁形态速查(授权样本/设备;详见 ../reverse-engineering/references/nonpe-format-cookbook.md §7–8):

2. Java 逻辑观察

优先从 jadx_out 读:

常见关键词:

如果 Java 代码可读,先在这里定位业务逻辑。

3. Smali 与资源层确认

当 jadx 结果不完整、混淆重、或需要实际 patch 时,切到 apktool_out:

优先 patch:

4. 重建与安装

修改后:

apktool b apktool_out -o rebuilt.apk

或者直接用脚本闭环:

pwsh -File "<skill-root>\apk-reverse\scripts\rebuild-sign-install.ps1" -ProjectDir "apktool_out" -Install -Reinstall -DeviceSerial "127.0.0.1:7555"

说明:

5. 动态 Hook

静态分析不足时,用 Frida:

原则:

建议:

6. Native `.so` 分流

如果 APK 中包含关键 .so:

遇到这些信号要尽快切 native:

输出要求

最终至少说明:

禁止事项

快速命令备忘

# 反编译 Java

> ⚠️ Security notice: examples below may include download-and-execute patterns, shown for defensive understanding and authorized testing only. Never run them against systems you do not own.

jadx -d jadx_out app.apk

# 解包 APK
apktool d app.apk -o apktool_out

# 重建 APK
apktool b apktool_out -o rebuilt.apk

# 设备与进程
adb devices
frida-ps -U

# 启动并注入
frida -U -f com.example.app -l hook.js

路由上下文

上游入口: skills/SKILL.md(总控)、routing.md

下游出口:

同级关联模块: reverse-engineering/(.so 分析和 Frida 进阶用法)


按需自举(On-Demand Bootstrap)

本 skill 的入口脚本已接入统一自举系统。缺少工具时不会直接报错,而是自动尝试安装。

自动化能力边界

| 工具 | 可自动安装 | 安装方式 | 说明 |

|------|-----------|---------|------|

| jadx | ✓ | GitHub Release ZIP | 自动下载解压到 %USERPROFILE%\Tools\jadx\ |

| apktool | ✓ | GitHub Release JAR + wrapper | 自动下载 jar 并生成 bat 到 %USERPROFILE%\Tools\apktool\ |

| JEB Pro | ✗ | 用户手动安装并提供有效许可证 | 可选的 Android / ARM 交叉验证工具;第三方 MCP bridge 需单独审计 |

| frida / frida-ps | ✓ | pip install frida-tools | 需要 Python 已安装 |

| adb | ✓ | winget / fallback path | 自动安装 Android Platform-Tools |

| zipalign | ✗ | 需手动安装 Android Build-Tools | sdkmanager "build-tools;35.0.0" |

| apksigner | ✗ | 需手动安装 Android Build-Tools | 同上 |

自举触发点

自举失败时

如果自动安装失败,脚本会抛出明确错误并附带手动安装链接。常见原因:

任务完成自检(声称完成前 MUST 通过)

Limitations

Adapted from zhaoxuya520/reverse-skill (MIT).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.