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。** [![Python](https://img.shields.io/badge/python-3.10%2B-blue?style=flat-square)](https://python.org) [![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE) [![Author](https://img.shields.io/badge/author-Agrentuml-purple?style=flat-square)](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//`: ``` apkap_output/target/ ├── schema.html ← open this in browser └── schema.json ← raw data, import into Burp/InQL ``` ## 输出 HTML 报告是一个独立的交互式浏览器: - **侧边栏** — 列出所有带有类型指示器的操作,可按 Queries / Mutations / Subscriptions 进行筛选 - **智能搜索** — 按操作名称、参数名称、响应字段或原始查询文本进行搜索 - **详情面板** — 包含 Required 标志的参数表格、响应字段标签,以及带有复制按钮的完整原始查询 - **Endpoint** — 在顶部显示自动检测到的 GraphQL URL ## 不同 APK 类型的运行结果 | APK 类型 | 发现的操作数 | 使用的策略 | |----------|-----------------|---------------| | Apollo Kotlin + assets | 200+ | Assets + DEX + smali | | Apollo Kotlin obfuscated | 100+ | DEX string pool | | Small GraphQL surface | ~8 | DEX string pool | | React Native + Apollo | varies | JS bundle | ## Bug Bounty 技巧 1. 寻找带有用户 ID 参数的 mutations → **IDOR 候选项** 2. 寻找带有 admin/internal 字眼的操作名称 → **越权 (Privilege Escalation) 候选项** 3. 将发现的 mutations 与 Burp 的流量进行交叉对比,以确认它们是否处于活跃状态 4. 使用 **Fields** 搜索范围来查找返回敏感数据(`email`、`phone`、`address`)的操作 5. 名称中带有 `delete`、`update`、`admin`、`internal` 的 mutations → **优先测试** ## 路线图 - [ ] 从 APK 中提取 REST API endpoint - [ ] 支持 iOS IPA - [ ] 交互模式:选择要提取的内容(GraphQL / REST / 两者) - [ ] GitHub Actions CI - [ ] PyPI 发布 (`pip install apka-p`) ## 作者 **Agrentuml** — Bug Bounty 猎人 [![Bugcrowd](https://img.shields.io/badge/Bugcrowd-Agrentuml-orange?style=flat-square&logo=bugcrowd)](https://bugcrowd.com/Agrentuml) [![GitHub](https://img.shields.io/badge/GitHub-Agrentuml-black?style=flat-square&logo=github)](https://github.com/Agrentuml) *apka-P — 因为 Introspection 被禁用绝不是你的问题。*
标签:Android安全, API安全, APK分析, Bug Bounty, GraphQL, JSON输出, Python, Schema提取, 云安全监控, 云资产清单, 众测, 动态分析, 可自定义解析器, 多模态安全, 安全测试, 攻击性安全, 无后门, 白帽黑客, 目录枚举, 移动安全, 移动应用安全, 网络安全, 逆向工具, 逆向工程, 隐私保护, 静态分析