GitAmanS/ZygoteExploitDemo

GitHub: GitAmanS/ZygoteExploitDemo

演示 Android Zygote 注入漏洞 CVE-2024-31317 的教育项目,展示如何提升至 SYSTEM 权限并绕过沙盒窃取其他应用数据。

Stars: 0 | Forks: 0

# 🔥 ZygoteExploitDemo - CVE-2024-31317 Android 安全实验
### 🚨 Android Zygote 注入漏洞教育演示 [![GitHub stars](https://img.shields.io/github/stars/GitAmanS/ZygoteExploitDemo?style=social)](https://github.com/GitAmanS/ZygoteExploitDemo/stargazers) [![GitHub forks](https://img.shields.io/github/forks/GitAmanS/ZygoteExploitDemo?style=social)](https://github.com/GitAmanS/ZygoteExploitDemo/network/members) [![GitHub license](https://img.shields.io/github/license/GitAmanS/ZygoteExploitDemo)](https://github.com/GitAmanS/ZygoteExploitDemo/blob/main/LICENSE)
## 📋 概述 本实验演示了 **CVE-2024-31317**,这是一个严重的 Android 漏洞,允许恶意应用将权限提升至 **SYSTEM 级别 (UID 1000)**,并绕过 Android 沙盒实时读取其他应用程序的数据。 ### 🎯 本演示展示的内容 | 阶段 | 描述 | 图示 | |-------|-------------|--------| | **1** | 用户安装了看似无害的 "Flashlight Pro" 应用 | 🔦 | | **2** | 应用利用 CVE-2024-31317 获取 SYSTEM 权限 | 💉 | | **3** | SYSTEM 级服务读取 "SecureChat" 消息 | 👁️ | | **4** | 窃取的消息显示在实时仪表板上 | 📊 | ## 🏗️ 项目结构 ``` ZygoteExploitDemo/ ├── 📱 apps/ │ ├── SecureChat/ # Victim app (Jetpack Compose) │ │ ├── Encrypted messages stored in SQLite │ │ └── Simulates WhatsApp-style encryption │ │ │ ├── FlashlightPro/ # Malicious app with exploit │ │ ├── Normal flashlight UI (distraction) │ │ ├── Background exploit service │ │ └── WRITE_SECURE_SETTINGS permission │ │ │ └── MonitorService/ # SYSTEM-level reader │ ├── Runs with UID 1000 after exploit │ ├── Reads SecureChat database │ └── Exfiltrates to dashboard │ ├── 📊 dashboard/ # Flask web dashboard │ └── app.py # Shows stolen messages live │ ├── 📜 scripts/ # Automation scripts │ ├── setup_vulnerable_emulator.sh │ ├── build_all_apps.sh │ ├── install_all_apps.sh │ ├── run_exploit.py │ └── monitor_logs.sh │ ├── 🎯 exploits/ # Exploit information │ ├── CVE-2024-31317.md │ └── payloads.txt │ └── 📁 tamplates/ # Code templates ├── exploit_template.java └── dashboard_template.html ``` ## 🔧 技术细节 ### 漏洞详情 CVE-2024-31317 存在于 Android 的 Zygote 进程处理 `hidden_api_blacklist_exemptions` 系统设置的方式中。由于缺乏输入清理,攻击者可以注入换行符以向 Zygote 命令添加任意参数。 **攻击向量:** ``` Settings.Global.putString( contentResolver, "hidden_api_blacklist_exemptions", "LClass1;->method1(\n" + "7\n" + "--setuid=1000\n" + // Run as SYSTEM "--setgid=1000\n" + // Run as SYSTEM group "--invoke-with\n" + "am start-service ...;\n" ); ``` ### 受影响版本 | 版本 | 状态 | |---------|--------| | Android 9 - 14 | ❌ 易受攻击(2024 年 6 月补丁之前) | | Android 14+ | ✅ 已修补(2024 年 6 月安全更新) | | Android 15+ | ✅ 安全 | ## 🚀 快速入门指南 ### 前置条件 - ✅ Android Studio(最新版) - ✅ Python 3.8+ 和 Flask - ✅ Android SDK 和 platform tools - ✅ 10GB 可用磁盘空间(用于模拟器) ### 第 1 步:克隆仓库 ``` git clone https://github.com/GitAmanS/ZygoteExploitDemo.git cd ZygoteExploitDemo ``` ### 第 2 步:设置易受攻击的模拟器 ``` cd scripts chmod +x *.sh ./setup_vulnerable_emulator.sh # 启动 emulator emulator -avd vulnerable_android_12 ``` ### 第 3 步:构建并安装应用 ``` # 在一个新终端中 cd ZygoteExploitDemo/scripts ./build_all_apps.sh ./install_all_apps.sh ``` ### 第 4 步:启动仪表板 ``` cd ../dashboard pip3 install flask flask-cors python3 app.py ``` 📱 **在浏览器中打开 http://localhost:5000** ### 第 5 步:运行漏洞利用程序 ``` cd ../scripts python3 run_exploit.py ``` ### 第 6 步:见证奇迹 ✨ 1. 在模拟器中打开 **SecureChat** 应用 2. 发送一些测试消息 3. 观察它们**即时!🔴** 出现在仪表板上 ## 📸 演示视频 ## 🔬 工作原理 - 逐步解析 1. **FlashlightPro** 请求 `WRITE_SECURE_SETTINGS` 权限 2. 漏洞利用代码将恶意 Payload 注入 Zygote 设置 3. Zygote 以 SYSTEM 权限 (UID 1000) 衍生 **MonitorService** 4. SYSTEM 服务绕过 Android 沙盒限制 5. 直接从 `/data/data/com.securechat/databases/` 读取数据库 6. 通过 HTTP POST 将数据渗漏至 Flask 仪表板 7. 实时显示窃取的加密消息 ## 📚 学习资源 - [Android 安全公告](https://source.android.com/security/bulletin) - [CVE-2024-31317 详情](https://nvd.nist.gov/vuln/detail/CVE-2024-31317) - [CleoV2 提供的原始 PoC](https://github.com/cleov2) ## 📄 许可证 MIT 许可证 - 详情请参阅 [LICENSE](LICENSE) 文件 ## 👨‍💻 作者 **Aman** - [@GitAmanS](https://github.com/GitAmanS)
标签:Android安全, Android漏洞, CVE-2024-31317, DNS 反向解析, HTTP工具, Jetpack Compose, JS文件枚举, SQLITE读取, SYSTEM权限, Web报告查看器, WSL, Zygote注入, 中高交互蜜罐, 协议分析, 安全实验室, 安全演示, 应用安全, 恶意软件开发, 提权漏洞, 搜索语句(dork), 数据渗出, 权限提升, 沙箱逃逸, 漏洞复现, 目录枚举, 移动安全, 网络安全, 逆向工具, 隐私保护, 隐私窃取