Agrentuml/apka-P
GitHub: Agrentuml/apka-P
当 GraphQL Introspection 被禁用时,从 Android APK 中逆向提取完整 GraphQL schema 的离线分析工具。
Stars: 2 | Forks: 0
```
█████╗ ██████╗ ██╗ ██╗ █████╗ ██████╗
██╔══██╗██╔══██╗██║ ██╔╝██╔══██╗ ██╔══██╗
███████║██████╔╝█████╔╝ ███████║█████╗██████╔╝
██╔══██║██╔═══╝ ██╔═██╗ ██╔══██║╚════╝██╔═══╝
██║ ██║██║ ██║ ██╗██║ ██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
```
# apka-P · APK API
**当 Introspection 被禁用时,从 Android APK 中提取 GraphQL schema。**
[](https://python.org)
[](LICENSE)
[](https://bugcrowd.com/Agrentuml)
## 这是什么?
当你在对包含 GraphQL 的应用进行 Bug Bounty 测试时,你首先尝试的通常是 Introspection。而他们首先做的通常是禁用它。
**apka-P** 通过直接从 Android APK 文件中提取完整的 GraphQL schema 来解决这个问题——不需要任何 Introspection 请求,也完全不需要与服务端进行交互。
它能够读取应用自身已知的信息:应用可以发起的每一个 query、mutation 和 subscription,包括参数名称、类型以及 GraphQL endpoint URL。
## 演示
```
Queries: 142
Mutations: 89
Subscriptions: 3
Endpoint: https://api.example.com/graphql
```
它会打开一个本地的交互式 HTML 浏览器——支持按操作名称、参数和响应字段进行搜索。
## 工作原理
apka-P 按顺序运行多种提取策略,并合并所有结果:
| 策略 | 作用 | 依赖 |
|----------|-------------|----------|
| **Assets (.graphql)** | 查找 APK 内部的原始 `.graphql` 文件 | nothing |
| **Assets (schema.json)** | 查找打包的 Introspection JSON 文件 | nothing |
| **DEX string pool** | 直接从二进制 DEX 文件中读取 GraphQL 字符串——即使经过 ProGuard 混淆也有效 | nothing |
| **React Native** | 从 JS bundle (`index.android.bundle`) 中提取操作 | nothing |
| **Apollo Kotlin (smali)** | 解析反编译后的 smali 代码,查找 `OPERATION_DOCUMENT` 字符串 | apktool |
| **String grep** | 兜底方案——扫描所有 smali 代码以查找 GraphQL 模式 | apktool |
## 安装
```
git clone https://github.com/Agrentuml/apka-P
cd apka-P
pip install -e .
```
可选但建议安装——安装 `apktool` 以启用基于 smali 的提取策略:
```
# macOS
brew install apktool
# Linux
sudo apt install apktool
```
## 使用方法
```
# Basic
apka-p target.apk
# Verbose — 查看触发了哪些策略及其原因
apka-p target.apk -v
# 自定义输出目录
apka-p target.apk -o ~/bug-bounty/results/
# 跳过 HTML(仅 JSON)
apka-p target.apk --no-html
# Version
apka-p --version
```
输出目录为 `./apkap_output/标签:Android安全, API安全, APK分析, Bug Bounty, GraphQL, JSON输出, Python, Schema提取, 云安全监控, 云资产清单, 众测, 动态分析, 可自定义解析器, 多模态安全, 安全测试, 攻击性安全, 无后门, 白帽黑客, 目录枚举, 移动安全, 移动应用安全, 网络安全, 逆向工具, 逆向工程, 隐私保护, 静态分析