⚠️ 仅限教育用途 — 禁止在真实系统上使用。
为 BGT-Pentest-LAB 网络安全期末项目而准备。
本仓库包含对Xiaomi HyperOS System Updater组件中存在的CVE-2024-4309漏洞的深入分析、攻击模拟、检测引擎和交互式Web仪表盘,该漏洞允许远程代码执行(RCE)。
🔴 漏洞摘要
|
🎯 攻击向量
|
flowchart TD
subgraph MITM ["阶段1: 网络访问劫持 (MITM)"]
A["🌐 1. MITM (ARP Spoofing)"] --> B["🎯 2. DNS Hijack (update.miui.com)"]
end
subgraph INJECTION ["阶段2: 数据库与数据包操纵"]
B --> C["💾 3. 哈希注入 (ota_hashes.db)"]
C --> D["📦 4. 恶意OTA包准备"]
end
subgraph BYPASS ["阶段3: 安全检测绕过"]
D --> E["🔓 5. RSA签名绕过 (Fast Channel)"]
E --> F["⚡ 6. 哈希验证绕过 (strstr Bug)"]
end
subgraph EXPLOIT ["阶段4: 权限提升与数据渗出"]
F --> G["💀 7. RCE与持久Root (system.img Flash)"]
end
%% 样式定义
style MITM fill:#0f172a,stroke:#38bdf8,stroke-width:1px,color:#38bdf8
style INJECTION fill:#0f172a,stroke:#818cf8,stroke-width:1px,color:#818cf8
style BYPASS fill:#0f172a,stroke:#f59e0b,stroke-width:1px,color:#f59e0b
style EXPLOIT fill:#0f172a,stroke:#ef4444,stroke-width:2px,color:#ef4444
style A fill:#1e293b,stroke:#0284c7,stroke-width:2px,color:#e2e8f0
style B fill:#1e293b,stroke:#0284c7,stroke-width:2px,color:#e2e8f0
style C fill:#1e293b,stroke:#4f46e5,stroke-width:2px,color:#e2e8f0
style D fill:#1e293b,stroke:#4f46e5,stroke-width:2px,color:#e2e8f0
style E fill:#451a03,stroke:#d97706,stroke-width:2px,color:#fef3c7
style F fill:#451a03,stroke:#d97706,stroke-width:2px,color:#fef3c7
style G fill:#4c0519,stroke:#e11d48,stroke-width:3px,color:#ffe4e6| 步骤 | 动作 | 技术细节 |
|---|---|---|
| 1 | MITM位置 | 通过ARP欺骗或虚假Wi-Fi热点截获网络流量 |
| 2 | DNS劫持 | 将update.miui.com的DNS响应指向攻击者服务器 |
| 3 | 哈希注入 | 向ota_hashes.db数据库注入部分恶意哈希 |
| 4 | 恶意OTA包 | 创建带有X-Xiaomi-Fast-Channel: true头的虚假update.zip |
| 5 | RSA绕过 | MiuiRecoveryVerifier看到Fast Channel头,跳过RSA验证 |
| 6 | 哈希绕过 | quickHashCheck → strstr()部分匹配 → 绕过 |
| 7 | RCE | 在Recovery模式下刷入恶意system.img → 持久Root |
|
🖥️ C2 Dashboard app.py
使用高级Web面板逐步可视化攻击模拟的交互式仪表盘。 包含Kill chain、风险评分、实时日志。 |
⚔️ 攻击模拟器 attack.py
使用虚假OTA服务器进行MITM攻击模拟。 4个REST端点、恶意ZIP生成、 哈希注入和Fast Channel绕过。 |
🔍 检测引擎 detector.py
三阶段OTA安全扫描器。 包含strstr()检测、Fast Channel分析、 风险评分和IoC报告。 |
|
🔧 修复演示 fix_demo.py
strstr() vs strcmp()交互式比较与补丁演示。 |
📄 报告生成器 report_generator.py
生成PDF就绪的专业HTML 漏洞分析报告。 |
🧪 测试套件 test_suite.py
27个自动化单元测试。 攻击+检测器集成测试。 |
| ❌ 漏洞代码 (strstr) | ✅ 修复代码 (strcmp) |
|---|---|
|
|
| 🔴 8个字符足够 — 暴力破解: 2³² | 🟢 需要64个字符 — 暴力破解: 2²⁵⁶ |
📦 CVE-2024-4309-Analysis
├── 📄 README.md # 本文件
├── 📄 ROADMAP.md # 项目路线图(5个阶段)
├── 🐳 Dockerfile # 容器配置
├── 🐳 docker-compose.yml # 服务编排文件
├── 🔑 .env.example # 环境变量模板
├── 📄 .gitignore # Git排除规则
├── 📄 requirements.txt # 依赖列表(零依赖)
│
├── 📁 docs/
│ ├── 📁 presentations/ # 🎨 演示文件(HTML幻灯片, 信息图)
│ ├── 📁 research/ # 🔬 研究笔记与深入分析
│ └── 📁 references/ # 📚 参考文献与引用
│
└── 📁 src/
├── 🖥️ app.py # C2 Web仪表盘(高级UI)
├── ⚔️ attack.py # OTA MITM攻击模拟器
├── 🔍 detector.py # 多层次攻击检测引擎
├── 🔧 fix_demo.py # strstr() vs strcmp()演示
├── 📄 report_generator.py # 生成PDF就绪的HTML报告
└── 🧪 test_suite.py # 27个自动化单元测试
git clone https://github.com/Winslowe/CVE-2024-4309-Analysis.git
cd CVE-2024-4309-Analysis
cp .env.example .env
docker-compose up -d
Dashboard → http://127.0.0.1:5000
# 终端1 — C2 Dashboard
python src/app.py
# 终端2 — 攻击服务器
python src/attack.py
# 终端3 — 检测引擎
python src/detector.py
python src/test_suite.py
# 或
python -m pytest src/test_suite.py -v
| 交付 | 文件 | 状态 |
|---|---|---|
| 漏洞研究与日志 | docs/research/ | ✅ |
| PoC脚本 | src/ (6个文件) | ✅ |
| 可视化分析(信息图) | docs/presentations/ | ✅ |
| C2 Web仪表盘 | src/app.py | ✅ |
| 自动化测试套件 | src/test_suite.py (27个测试) | ✅ |
| PDF就绪报告 | report_generator.py | ✅ |
| Docker支持 | Dockerfile + docker-compose.yml | ✅ |
| 文档 | 描述 |
|---|---|
docs/research/ | 🔬 深入分析与研究笔记 |
docs/presentations/ | 🎨 HTML演示与信息图文件 |
docs/references/sources.md | 📚 完整参考文献列表 |
ROADMAP.md | 🗺️ 5阶段项目路线图 |
| 来源 | 链接 |
|---|---|
| Xiaomi Security Bulletin | trust.mi.com/misrc/bulletins/advisory |
| QDebugger Research | ota-security.q-debugger.com |
| CWE-347 | cwe.mitre.org/data/definitions/347 |
| Android RecoverySystem API | developer.android.com |
| Xiaomi OTA Research | github.com/nicene-0 |
👨🏫 导师 / Instructor
|
👤 学生 / Student
📚 课程 / Course
|