Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ CVE-2024-4309

Xiaomi HyperOS System Updater — OTA Signature Verification Bypass & RCE


CVSS RCE Python


Status Course License Docker Tests Zero Deps


⚠️ YALNIZCA EĞİTİM AMAÇLIDIR — Gerçek sistemlerde kullanmak yasaktır.




📋 Proje Özeti / Project Overview

BGT-Pentest-LAB siber güvenlik final projesi kapsamında hazırlanmıştır.

Xiaomi HyperOS System Updater bileşeninde bulunan ve uzaktan kod çalıştırmaya (RCE) imkan tanıyan CVE-2024-4309 zafiyetinin derinlemesine analizi, saldırı simülasyonu, tespit motoru ve interaktif web dashboard'u bu depoda yer almaktadır.

🔴 Zafiyet Özeti

Alan Değer
CVE ID CVE-2024-4309
Bileşen System Updater (HyperOS)
Ciddiyet 🔴 Critical (CVSS 9.1)
CWE CWE-347: Improper Crypto Signature Verification
Etki Persistent RCE, Root Access
Düzeltme HyperOS 1.0.4.0+

🎯 Saldırı Vektörü

Metrik Değer
Attack Vector Adjacent Network
Complexity Low
Privileges None
User Interaction None
Scope Changed
CVSS Vector AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N



💀 Saldırı Akışı / Attack Kill Chain

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
Loading
📖 Detaylı Açıklama — Her adımın teknik detayı için tıklayın
Adım Aksiyon Teknik Detay
1 MITM Pozisyonu ARP Spoofing veya sahte Wi-Fi hotspot ile ağ trafiği ele geçirilir
2 DNS Hijack update.miui.com DNS yanıtları saldırganın sunucusuna yönlendirilir
3 Hash Injection ota_hashes.db veritabanına kısmi zararlı hash enjekte edilir
4 Zararlı OTA Paketi X-Xiaomi-Fast-Channel: true başlıklı sahte update.zip oluşturulur
5 RSA Bypass MiuiRecoveryVerifier Fast Channel başlığını görür, RSA kontrolünü atlar
6 Hash Bypass quickHashCheckstrstr() ile kısmi eşleşme → BYPASS
7 RCE Recovery modunda zararlı system.img flash edilir → Kalıcı Root



⚙️ Geliştirilen Araçlar / Developed Tools




🖥️ C2 Dashboard
app.py

Premium web paneli ile saldırı simülasyonunu
adım adım görselleştiren interaktif dashboard.
Kill chain, risk skoru, gerçek zamanlı loglar.




⚔️ Attack Simulator
attack.py

Sahte OTA sunucusu ile MITM saldırı simülasyonu.
4 REST endpoint, zararlı ZIP üretimi,
hash injection ve Fast Channel bypass.




🔍 Detection Engine
detector.py

3 aşamalı OTA güvenlik tarayıcısı.
strstr() tespiti, Fast Channel analizi,
risk skoru ve IoC raporu.


🔧 Fix Demo
fix_demo.py

strstr() vs strcmp() interaktif
karşılaştırma ve yama demonstrasyonu.


📄 Report Generator
report_generator.py

PDF-ready profesyonel HTML
zafiyet analiz raporu üretici.


🧪 Test Suite
test_suite.py

27 otomatik birim testi.
Attack + Detector entegrasyon testleri.




🐛 Temel Zafiyet / Root Cause

❌ Zafiyetli Kod (strstr) ✅ Yamalı Kod (strcmp)
// NativeVerifier.cpp — BUG!
bool quickHashCheck(const char* hash) {
    for (int i = 0; i < count; i++) {
        if (strstr(whitelist[i], hash))
            return true;  // Substring eşleşme ⚠️
    }
    return false;
}
// NativeVerifier.cpp — FIXED
bool quickHashCheck(const char* hash) {
    for (int i = 0; i < count; i++) {
        if (strcmp(whitelist[i], hash) == 0)
            return true;  // Tam eşleşme ✅
    }
    return false;
}
🔴 8 karakter yeterli — Brute-force: 2³² 🟢 64 karakter gerekli — Brute-force: 2²⁵⁶



🗂 Repo Yapısı / Repository Structure

📦 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



🚀 Kurulum / Getting Started

Ön Gereksinimler

  • Python 3.12+ (harici bağımlılık yok — yalnızca standart kütüphane)
  • Docker (opsiyonel)

📥 Klonlama

git clone https://github.com/Winslowe/CVE-2024-4309-Analysis.git
cd CVE-2024-4309-Analysis
cp .env.example .env

🐳 Docker ile Çalıştırma

docker-compose up -d

Dashboard → http://127.0.0.1:5000

🐍 Docker Olmadan Çalıştırma

# Terminal 1 — C2 Dashboard
python src/app.py

# Terminal 2 — Saldırı Sunucusu
python src/attack.py

# Terminal 3 — Tespit Motoru
python src/detector.py

🧪 Testleri Çalıştırma

python src/test_suite.py
# veya
python -m pytest src/test_suite.py -v



📊 Teslimler / Deliverables

Teslim Dosya Durum
Zafiyet Araştırması ve Logları docs/research/
PoC Scriptleri src/ (6 dosya)
Görsel Analiz (Infographic) docs/presentations/
C2 Web Dashboard src/app.py
Otomatik Test Suite src/test_suite.py (27 test)
PDF-Ready Rapor report_generator.py
Docker Desteği Dockerfile + docker-compose.yml



📚 Belgeleme / Documentation

Doküman Açıklama
docs/research/ 🔬 Derin analiz ve araştırma notları
docs/presentations/ 🎨 HTML sunum ve infographic dosyaları
docs/references/sources.md 📚 Tam kaynakça listesi
ROADMAP.md 🗺️ 5 fazlı proje yol haritası



🔗 Kaynaklar / References

Kaynak 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



🎓 Akademik Bilgiler / Academic Information

👨‍🏫 Danışman / Instructor

Ad Keyvan Arasteh

👤 Öğrenci / Student

Ad Soyad SamuroDev
Öğrenci No ``

📚 Ders / Course

Ders Penetration Testing / Sızma Testi
Kod BGT006 · 3 ECTS
Dönem 2025-2026 Bahar
Üniversite İstinye Üniversitesi



Built with 🐍 Python · Zero Dependencies · Made for BGT-Pentest-LAB Final Project
© 2026 — Yalnızca eğitim ve araştırma amaçlıdır.

About

BGT-Pentest-LAB Final Project: Xiaomi HyperOS System Updater OTA Signature Verification Bypass (CVE-2024-4309) Deep Analysis.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages