Projet final BGT-Pentest-LAB : Analyse approfondie du contournement de la vérification de signature OTA du programme de mise à jour système Xiaomi HyperOS (CVE-2024-4309).
⚠️ UNIQUEMENT À DES FINS ÉDUCATIVES — Interdit sur les systèmes réels.
BGT-Pentest-LAB préparé dans le cadre du projet final de cybersécurité.
Ce dépôt contient l'analyse approfondie de la vulnérabilité CVE-2024-4309 trouvée dans le composant System Updater de Xiaomi HyperOS permettant l'exécution de code à distance (RCE), ainsi qu'une simulation d'attaque, un moteur de détection et un tableau de bord web interactif.
🔴 Résumé de la vulnérabilité
|
🎯 Vecteur d'attaque
|
flowchart TD
subgraph MITM ["Aşama 1: Ağ Erişimini Ele Geçirme (MITM)"]
A["🌐 1. MITM (ARP Spoofing)"] --> B["🎯 2. DNS Hijack (update.miui.com)"]
end
subgraph INJECTION ["Aşama 2: Veritabanı ve Paket Manipülasyonu"]
B --> C["💾 3. Hash Enjeksiyonu (ota_hashes.db)"]
C --> D["📦 4. Zararlı OTA Paketi Hazırlama"]
end
subgraph BYPASS ["Aşama 3: Güvenlik Kontrollerini Atlama (Bypass)"]
D --> E["🔓 5. RSA İmza Atlatma (Fast Channel)"]
E --> F["⚡ 6. Hash Doğrulama Atlatma (strstr Bug)"]
end
subgraph EXPLOIT ["Aşama 4: Yetki Yükseltme & Sızma"]
F --> G["💀 7. RCE & Kalıcı Root (system.img Flash)"]
end
%% Stil Tanımlamaları
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| Étape | Action | Détail technique |
|---|---|---|
| 1 | Position MITM | Le trafic réseau est intercepté via ARP Spoofing ou un faux hotspot Wi-Fi |
| 2 | DNS Hijack | Les réponses DNS de update.miui.com sont redirigées vers le serveur de l'attaquant |
| 3 | Hash Injection | Un hash malveillant partiel est injecté dans la base de données ota_hashes.db |
| 4 | Paquet OTA malveillant | Un faux update.zip avec l'en-tête X-Xiaomi-Fast-Channel: true est créé |
| 5 | RSA Bypass | MiuiRecoveryVerifier voit l'en-tête Fast Channel et contourne le contrôle RSA |
| 6 | Hash Bypass | quickHashCheck → correspondance partielle avec strstr() → BYPASS |
| 7 | RCE | En mode recovery, le system.img malveillant est flashé → Root persistant |
|
🖥️ C2 Dashboard app.py
Simulation d'attaque avec un panel web premium, tableau de bord interactif visualisant étape par étape. Kill chain, score de risque, logs en temps réel. |
⚔️ Attack Simulator attack.py
Simulation d'attaque MITM avec un faux serveur OTA. 4 endpoints REST, génération de ZIP malveillant, injection de hash et contournement Fast Channel. |
🔍 Detection Engine detector.py
Scanner de sécurité OTA en 3 étapes. Détection strstr(), analyse Fast Channel, score de risque et rapport IoC. |
|
🔧 Fix Demo fix_demo.py
strstr() vs strcmp() interactifcomparaison et démonstration de correctif. |
📄 Report Generator report_generator.py
HTML professionnel prêt pour PDF générateur de rapport d'analyse de vulnérabilité. |
🧪 Test Suite test_suite.py
27 tests unitaires automatisés. Tests d'intégration Attack + Detector. |
| ❌ Code vulnérable (strstr) | ✅ Code corrigé (strcmp) |
|---|---|
|
|
| 🔴 8 caractères suffisants — Brute-force: 2³² | 🟢 64 caractères nécessaires — Brute-force: 2²⁵⁶ |
📦 CVE-2024-4309-Analysis
├── 📄 README.md # Bu dosya
├── 📄 ROADMAP.md # Proje yol haritası (5 faz)
├── 🐳 Dockerfile # Konteyner yapılandırması
├── 🐳 docker-compose.yml # Servis orkestrasyon dosyası
├── 🔑 .env.example # Ortam değişkenleri şablonu
├── 📄 .gitignore # Git dışlama kuralları
├── 📄 requirements.txt # Bağımlılık listesi (sıfır bağımlılık)
│
├── 📁 docs/
│ ├── 📁 presentations/ # 🎨 Sunum dosyaları (HTML slides, infographic)
│ ├── 📁 research/ # 🔬 Araştırma notları ve derin analiz
│ └── 📁 references/ # 📚 Kaynakça ve referanslar
│
└── 📁 src/
├── 🖥️ app.py # C2 Web Dashboard (Premium UI)
├── ⚔️ attack.py # OTA MITM saldırı simülatörü
├── 🔍 detector.py # Çok aşamalı saldırı tespit motoru
├── 🔧 fix_demo.py # strstr() vs strcmp() demo
├── 📄 report_generator.py # PDF-ready HTML rapor üretici
└── 🧪 test_suite.py # 27 otomatik birim testi
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
# Terminal 1 — Tableau de bord C2
python src/app.py
# Terminal 2 — Serveur d'attaque
python src/attack.py
# Terminal 3 — Moteur de détection
python src/detector.py
python src/test_suite.py
# ou
python -m pytest src/test_suite.py -v
| Livrable | Fichier | Statut |
|---|---|---|
| Recherche de vulnérabilité et logs | docs/research/ | ✅ |
| Scripts PoC | src/ (6 fichiers) | ✅ |
| Analyse visuelle (Infographie) | docs/presentations/ | ✅ |
| C2 Web Dashboard | src/app.py | ✅ |
| Suite de tests automatisés | src/test_suite.py (27 tests) | ✅ |
| Rapport prêt pour PDF | report_generator.py | ✅ |
| Support Docker | Dockerfile + docker-compose.yml | ✅ |
| Document | Description |
|---|---|
docs/research/ | 🔬 Notes d'analyse approfondie et de recherche |
docs/presentations/ | 🎨 Fichiers de présentation HTML et infographie |
docs/references/sources.md | 📚 Liste complète des références |
ROADMAP.md | 🗺️ Feuille de route du projet en 5 phases |
| Source | Lien |
|---|---|
| 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 |
👨🏫 Instructeur / Instructor
|
👤 Étudiant / Student
📚 Cours / Course
|