Somchandra17/TrashiOS
GitHub: Somchandra17/TrashiOS
TrashiOS 是一款基于 OWASP MASTG/MASVS 方法论的自动化 iOS 应用安全测试框架,通过 13 阶段静态与动态评估生成 AI 就绪的安全报告。
Stars: 0 | Forks: 0
```
,---------. .-------. ____ .-'''-. .---. .---..-./`) ,-----. .-'''-.
\ \| _ _ \ .' __ `. / _ \| | |_ _|\ .-.') .' .-, '. / _ \
`--. ,---'| ( ' ) | / ' \ \ (`' )/`--'| | ( ' )/ `-' \ / ,-.| \ _ \ (`' )/`--'
| \ |(_ o _) / |___| / |(_ o _). | '-(_{;}_)`-'`"`; \ '_ / | :(_ o _).
:_ _: | (_,_).' __ _.-` | (_,_). '. | (_,_) .---. | _`,/ \ _/ | (_,_). '.
(_I_) | |\ \ | |.' _ |.---. \ :| _ _--. | | | : ( '\_/ \ ;.---. \ :
(_(=)_) | | \ `' /| _( )_ |\ `-' ||( ' ) | | | | \ `"/ \ ) / \ `-' |
(_I_) | | \ / \ (_ o _) / \ / (_{;}_)| | | | '. \_/``".' \ /
'---' ''-' `'-' '.(_,_).' `-...-' '(_,_) '---' '---' '-----' `-...-'
```
**自动化 iOS SAST/DAST 框架**
[](https://python.org)
[](#)
[](LICENSE)
[](CHANGELOG.md)
## 什么是 TrashiOS?
TrashiOS 是一个基于终端的自动化框架,用于 **iOS 应用程序的静态 + 动态安全测试** —— 即 [TrashDroid](https://github.com/Somchandra17/TrashDroid) 的 iOS 对应版本。只需将其指向 **通过 USB 连接的越狱 iPhone** 上已安装的应用(或 `.ipa` 文件),它就会在多阶段评估中协调 `libimobiledevice`、**SSH-over-USB**、**Frida/objection** 以及 `otool`/`class-dump` —— 捕获屏幕截图并生成包含 CVSS、OWASP MASVS 映射、修复建议和命令日志的 **适配 AI 的 Markdown 报告**。
本工具基于 **OWASP MASTG/MASVS** 方法论。
## 如何从 Android (TrashDroid) 迁移过来
Android 的攻击面(Intents/Binder:导出的 Activities/Services/Receivers/Providers)**在 iOS 上并不存在**。TrashiOS 替换了这两个平台层,并重新确立了每项测试的基础:
| TrashDroid (Android) | TrashiOS (iOS) | 备注 |
|---|---|---|
| `adb` (`ADB` class) | **`IOSDevice`** — libimobiledevice + SSH-over-USB + Frida | 设备层 |
| `drozer` (`Drozer` class) | **`FridaBridge`** — objection + 原生 Frida | 运行时层 |
| Drozer 组件测试 | **URL scheme / IPC 测试** | 没有导出的组件;攻击面是自定义的 URL schemes / Universal Links |
| 本地文件系统分析 | **本地数据存储** (`/var/mobile/Containers/Data/Application/
`) | 直接映射;相同的 Presidio/regex 扫描引擎 |
| Logcat 监控 | **设备日志监控** (`idevicesyslog`) | 直接映射 |
| Manifest 分析 | **静态二进制及 Info.plist 分析** | Info.plist + entitlements + **Mach-O 加固** (PIE/canary/ARC/cryptid) |
| 注销后访问控制 | **注销后访问控制** | 通过 URL scheme 而不是 `am start` 重新启动 |
| *(无)* | **Keychain 转储与数据保护类** | iOS 关键项,全新增加 |
## 前置条件
### 主机 (macOS)
```
# libimobiledevice 套件 + SSH-over-USB 隧道
brew install libimobiledevice libusbmuxd ideviceinstaller
# runtime instrumentation
pip install -r requirements.txt # rich + frida-tools + objection
# 非交互式 SSH 密码认证(或改为设置 SSH keys)
brew install sshpass
# Mach-O / entitlement 工具
xcode-select --install # otool, codesign
brew install class-dump # optional: ObjC headers
```
### 目标设备 — 越狱的 iPhone X (A11)
1. 使用 [palera1n](https://github.com/palera1n/palera1n) 进行**越狱** (checkm8, iOS 15–16)。在 A11 上,越狱时您必须**禁用设备密码**。
2. **OpenSSH** — palera1n 在 **端口 44** 上开放 SSH,root 密码为 `alpine`。
3. **frida-server** — 在 Sileo 中添加源 `https://build.frida.re`,安装 *Frida*。在主机上使用 `frida-ps -U` 进行验证。
4. **uikittools**(用于 `uiopen`,被 URL-scheme 阶段使用)。
## 快速开始
```
git clone && cd TrashiOS
pip install -r requirements.txt
# 插上手机,然后:
idevice_id -l # confirm the UDID shows up
python main.py # interactive
# 针对已安装的 app 进行非交互式操作:
python main.py --auto --device --bundle com.example.app
# 运行特定阶段(1=static,3=keychain,5=URL schemes):
python main.py --phases 1,3,5 --bundle com.example.app
```
框架会自行启动 SSH-over-USB 隧道 (`iproxy `)。如果您的越狱使用的是端口 22(经典的 checkra1n)而不是 44,请传入 `--ssh-port 22`。
## CLI 参考
| 参数 | 描述 |
|---|---|
| `--auto` | 使用合理默认值的非交互模式 |
| `--device UDID` | 来自 `idevice_id -l` 的设备 UDID |
| `--bundle ID` | 目标 bundle identifier |
| `--ipa PATH` | `.ipa` 的路径(如果已预装则省略) |
| `--phases 2,5,10` | 逗号分隔的阶段编号(共 13 个阶段) |
| `--track all\|static\|dynamic` | 运行所有阶段、仅 SAST 或仅 DAST(默认为 `all`) |
| `--decrypt` | 授权在阶段 I 进行 FairPlay 二进制解密(默认关闭;仅限授权测试) |
| `--backup` | 在阶段 XII 运行缓慢的完整设备备份(默认关闭) |
| `--ssh-port N` | 设备 SSH 端口(palera1n=`44`,checkra1n=`22`;默认为 `44`) |
| `--ssh-pass PW` | 设备 root SSH 密码(默认为 `alpine`) |
| `--local-port N` | 用于 SSH 的本地 iproxy 端口(默认为 `2222`) |
| `--report MODE` | `client`(默认)或 `internal`(包含 AI 提示标头) |
| `--presidio` | 启用 Presidio PII 检测(regex + checksum 验证器) |
| `--ner` | 启用 GLiNER NER 后端(基于 ML 的 PII 检测) |
| `--skip-preflight` | 跳过主机工具检查 |
## 测试阶段(13 个阶段 — 完全对等)
```
Phase I ─── App Binary Decryption (SAST) frida-ios-dump [--decrypt]
Phase II ─── Static Binary & Info.plist Analysis (SAST) otool/codesign/class-dump
Phase III ─── Local Data Storage Analysis (DAST) SSH pull + Presidio scan
Phase IV ─── Dump File Verification (SAST) sqlite3 + plist deep-dive
Phase V ─── Keychain Dump & Data Protection (DAST) objection + kSecAttrAccessible
Phase VI ─── Backgrounding Snapshot Leakage (DAST) Library/Caches/Snapshots
Phase VII ─── Pasteboard Leakage (DAST) Frida UIPasteboard monitor
Phase VIII ─── Device Log Monitoring (DAST) idevicesyslog
Phase IX ─── Process Memory Analysis (DAST) Frida memory dump + lsof
Phase X ─── URL Scheme / IPC Testing (DAST) Frida openURL fuzzing
Phase XI ─── Post-Logout Access Control (DAST) token persistence + deeplinks
Phase XII ─── Backup Analysis (DAST) idevicebackup2 [--backup]
Phase XIII ─── Runtime Hardening Assessment (DAST) pinning/JB/anti-debug posture
```
使用 `--track static` 或 `--track dynamic` 仅运行 SAST 或 DAST 阶段,或使用 `--phases 2,5,10` 挑选特定阶段。
**阶段 II** 解析 Info.plist(ATS / `NSAllowsArbitraryLoads`、URL schemes、文件共享、使用字符串)、entitlements(`get-task-allow`、keychain-access-groups、app-groups、associated-domains)以及通过 `otool` 检查的 Mach-O 加固(PIE、stack canary、ARC、`cryptid`);扫描二进制文件以查找内嵌的敏感信息。
**阶段 V** 转储 keychain(objection)并标记脆弱的 `kSecAttrAccessible*` 类(`Always`,非 `ThisDeviceOnly`)。
## 输出结构
```
output//
├── iOS_DAST_Report__.md # final report (AI-ready)
├── findings__.json # machine-readable findings
├── screenshots/ # device screenshots (Frida-rendered; idevicescreenshot when a DDI is mountable)
├── bundle/ # pulled .app (Info.plist, binary, class-dump.txt)
├── bundle_decrypted/ # decrypted .ipa/.app (Phase I, if --decrypt)
├── data_container/ # pulled Data container (Documents, Library, ...)
├── keychain/ # keychain.json / dump / values
├── snapshots/ # backgrounding snapshots (Phase VI)
├── memory/ # process memory dump (Phase IX)
├── backup/ # device backup (Phase XII, if --backup)
└── syslog/ # captured device logs
```
## 状态
所有 13 个阶段均已实现(里程碑 2 已完成),并在越狱的 iPhone X(iOS 16.7.5)上进行了端到端验证。兼容 **Frida 17**(ObjC 桥接从 `frida-tools` 加载,且 agent 使用 Frida 17 API)。未来可能的改进:在阶段 X 中测试 Universal Links / app 扩展(`.appex`),在阶段 V 中为托管/反 Frida 应用提供 `keychain-dumper` SSH 后备方案,以及使报告与 Jira/VAPT 工单导出器相对齐。
## 免责声明
**由 [0xs0m](https://somm.tf) 构建**
标签:DAST, Docker支持, Frida, iOS安全, SAST, 恶意软件分析, 盲注攻击, 逆向分析, 逆向工具