
BGT-Pentest-LAB Progetto Finale: Xiaomi HyperOS System Updater OTA Signature Verification Bypass (CVE-2024-4309) Analisi Approfondita.
⚠️ SOLAMENTE A SCOPO DIDATTICO — È vietato l'uso su sistemi reali.
BGT-Pentest-LAB siber güvenlik final projesi kapsamında hazırlanmıştır.
L'analisi approfondita della vulnerabilità CVE-2024-4309 presente nel componente System Updater di Xiaomi HyperOS, che consente l'esecuzione remota di codice (RCE), la simulazione dell'attacco, il motore di rilevamento e la dashboard web interattiva sono contenuti in questo repository.
🔴 Riepilogo della Vulnerabilità
|
🎯 Vettore d'Attacco
|
flowchart TD
subgraph MITM ["Fase 1: Intercettazione di Rete (MITM)"]
A["🌐 1. MITM (ARP Spoofing)"] --> B["🎯 2. DNS Hijack (update.miui.com)"]
end
subgraph INJECTION ["Fase 2: Manipolazione del Database e del Pacchetto"]
B --> C["💾 3. Iniezione di Hash (ota_hashes.db)"]
C --> D["📦 4. Preparazione del Pacchetto OTA Dannoso"]
end
subgraph BYPASS ["Fase 3: Bypass dei Controlli di Sicurezza"]
D --> E["🔓 5. Bypass della Firma RSA (Fast Channel)"]
E --> F["⚡ 6. Bypass della Verifica Hash (Bug strstr)"]
end
subgraph EXPLOIT ["Fase 4: Elevazione dei Privilegi & Infiltrazione"]
F --> G["💀 7. RCE & Root Persistente (Flash di system.img)"]
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
| Passo | Azione | Dettaglio Tecnico |
|---|---|---|
| 1 | Posizione MITM | Il traffico di rete viene intercettato tramite ARP Spoofing o un hotspot Wi-Fi falso |
| 2 | DNS Hijack | Le risposte DNS di update.miui.com vengono reindirizzate al server dell'attaccante |
| 3 | Iniezione di Hash | Un hash parziale dannoso viene iniettato nel database ota_hashes.db |
| 4 | Pacchetto OTA Dannoso | Viene creato un falso update.zip con intestazione X-Xiaomi-Fast-Channel: true |
| 5 | Bypass RSA | MiuiRecoveryVerifier vede l'intestazione Fast Channel e salta il controllo RSA |
| 6 | Bypass Hash | quickHashCheck → corrispondenza parziale con strstr() → BYPASS |
| 7 | RCE | Il system.img dannoso viene flashato in modalità Recovery → Root Persistente |
|
🖥️ C2 Dashboard app.py
Dashboard interattivo che visualizza passo dopo passo la simulazione dell'attacco con un pannello web premium. Kill chain, punteggio di rischio, log in tempo reale. |
⚔️ Attack Simulator attack.py
Simulazione dell'attacco MITM con un server OTA falso. 4 endpoint REST, generazione di ZIP dannoso, iniezione di hash e bypass Fast Channel. |
🔍 Detection Engine detector.py
Scanner di sicurezza OTA a 3 fasi. Rilevamento strstr(), analisi Fast Channel, punteggio di rischio e report IoC. |
|
🔧 Fix Demo fix_demo.py
Confronto interattivo e dimostrazione della patch tra strstr() e strcmp().
|
📄 Report Generator report_generator.py
Generatore di report di analisi delle vulnerabilità HTML professionale pronto per PDF. |
🧪 Test Suite test_suite.py
27 test unitari automatici. Test di integrazione Attack + Detector. |
| ❌ Codice Vulnerabile (strstr) | ✅ Codice Corretto (strcmp) |
|---|---|
|
|
| 🔴 8 caratteri sufficienti — Forza bruta: 2³² | 🟢 64 caratteri necessari — Forza bruta: 2²⁵⁶ |
📦 CVE-2024-4309-Analysis
├── 📄 README.md # Questo file
├── 📄 ROADMAP.md # Roadmap del progetto (5 fasi)
├── 🐳 Dockerfile # Configurazione del contenitore
├── 🐳 docker-compose.yml # File di orchestrazione del servizio
├── 🔑 .env.example # Template delle variabili d'ambiente
├── 📄 .gitignore # Regole di esclusione Git
├── 📄 requirements.txt # Elenco delle dipendenze (zero dipendenze)
│
├── 📁 docs/
│ ├── 📁 presentations/ # 🎨 File di presentazione (diapositive HTML, infografica)
│ ├── 📁 research/ # 🔬 Note di ricerca e analisi approfondita
│ └── 📁 references/ # 📚 Bibliografia e riferimenti
│
└── 📁 src/
├── 🖥️ app.py # Dashboard Web C2 (Interfaccia Premium)
├── ⚔️ attack.py # Simulatore di attacco MITM OTA
├── 🔍 detector.py # Motore di rilevamento attacchi multi-fase
├── 🔧 fix_demo.py # Demo strstr() vs strcmp()
├── 📄 report_generator.py # Generatore di report HTML pronto per PDF
└── 🧪 test_suite.py # 27 test unitari automatici
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
# Terminale 1 — C2 Dashboard
python src/app.py
# Terminale 2 — Server di Attacco
python src/attack.py
# Terminale 3 — Motore di Rilevamento
python src/detector.py
python src/test_suite.py
# oppure
python -m pytest src/test_suite.py -v
| Consegna | File | Stato |
|---|---|---|
| Ricerca della Vulnerabilità e Log | docs/research/ | ✅ |
| Script PoC | src/ (6 file) | ✅ |
| Analisi Visiva (Infografica) | docs/presentations/ | ✅ |
| C2 Web Dashboard | src/app.py | ✅ |
| Suite di Test Automatici | src/test_suite.py (27 test) | ✅ |
| Report Pronto per PDF | report_generator.py | ✅ |
| Supporto Docker | Dockerfile + docker-compose.yml | ✅ |
| Documento | Descrizione |
|---|---|
docs/research/ | 🔬 Analisi approfondita e note di ricerca |
docs/presentations/ | 🎨 File di presentazione HTML e infografica |
docs/references/sources.md | 📚 Elenco completo delle fonti |
ROADMAP.md | 🗺️ Roadmap del progetto in 5 fasi |
| Fonte | Link |
|---|---|
| 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 |
👨🏫 Consulente / Istruttore
|
👤 Studente
📚 Corso / Course
|