Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔬 IoT Firmware AI Offensive & Defensive Lab

ESP32 simulé – environnement contrôlé

Python 3.10+ License: MIT


📋 Objectif

Laboratoire complet permettant :

  1. Simulation d'un firmware IoT vulnérable (type ESP32) compilé en C, exécuté sous QEMU
  2. Reverse engineering du firmware (call graph, entropie, analyse binaire)
  3. Identification et exploitation de vulnérabilités (buffer overflow, stack-based exploits)
  4. IA offensive : fuzzing intelligent (RL/PPO + Bayesian Optimization) + génération d'exploits (LSTM)
  5. IA défensive : détection comportementale (autoencoder), classification firmware compromis (RandomForest/MLP)
  6. Dashboard live via Streamlit + API FastAPI

🏗️ Architecture

[ Simulated Firmware (ESP32-like / QEMU) ]
                  |
           [ Network Layer ]
                  |
         -------------------
         |                 |
   [ IA Fuzzer ]     [ IDS AI ]
         |                 |
         ---------- API ----------
                     |
                Dashboard

📁 Structure du projet

iot-firmware-ai-lab/
│
├── firmware/              # Firmware C vulnérable (compilé pour QEMU)
│   ├── main.c             # Point d'entrée, serveur TCP
│   ├── mqtt.c             # Handler MQTT simplifié
│   ├── ota.c              # Mise à jour OTA (vulnérable)
│   ├── auth.c             # Authentification (vulnérable)
│   └── Makefile           # Compilation cross-compile ARM
│
├── analysis/              # Outils d'analyse statique/dynamique
│   ├── reverse/           # Scripts Ghidra / analyse binaire
│   ├── callgraph.py       # Génération graphe d'appel
│   └── entropy_analysis.py # Analyse entropie mémoire
│
├── attack/                # IA offensive
│   ├── fuzzer_rl.py       # Fuzzer guidé par Reinforcement Learning (PPO)
│   ├── bayes_optimizer.py # Optimisation bayésienne (Optuna)
│   └── exploit_generator.py # Génération d'exploits (LSTM)
│
├── defense/               # IA défensive
│   ├── autoencoder.py     # Détection anomalie réseau
│   ├── classifier.py      # Classification firmware sain/compromis
│   └── anomaly_detector.py # Détection OTA malveillante
│
├── api/                   # Backend FastAPI
│   └── main.py
│
├── ui/                    # Dashboard Streamlit
│   └── dashboard.py
│
├── docs/                  # Documentation technique
│   ├── threat_model.md
│   ├── attack_strategy.md
│   └── results.md
│
├── docker/                # Containerisation
│   ├── Dockerfile
│   └── docker-compose.yml
│
├── requirements.txt
├── .gitignore
└── README.md

🚀 Installation

Prérequis

  • Windows 11 + WSL2 Ubuntu (recommandé)
  • Python 3.10+
  • QEMU
  • GCC ARM cross-compiler

1. Installer WSL2

wsl --install -d Ubuntu

2. Installer les dépendances système

sudo apt update
sudo apt install build-essential git python3 python3-pip python3-venv \
    qemu-system gcc-arm-none-eabi binutils-arm-none-eabi

3. Cloner et configurer

git clone https://github.com/DanielMBouyou/embedded-iot-ai-hacklab.git
cd embedded-iot-ai-hacklab
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

4. Compiler le firmware

cd firmware
make

5. Lancer le firmware simulé

make run
# OU directement :
qemu-system-arm -M lm3s6965evb -nographic -kernel firmware.elf

📊 Utilisation

Lancer l'API

cd api
uvicorn main:app --reload --host 0.0.0.0 --port 8000

Lancer le Dashboard

cd ui
streamlit run dashboard.py

Endpoints API

Méthode Endpoint Description
POST /fuzz/start Démarre le fuzzing IA
POST /attack/generate Génère un exploit
GET /status État du firmware
GET /metrics Métriques (crash rate, etc.)
POST /defense/train Entraîne le modèle défensif

🧮 Modélisation Mathématique

Automate fini du firmware

$$S = (Q, \Sigma, \delta)$$

  • $Q$ = {Idle, Auth, Command, OTA, Error}
  • $\Sigma$ = entrées réseau
  • $\delta$ = fonction de transition

Analyse entropie mémoire

$$H = -\sum p(x) \log p(x)$$

Objectif fuzzing IA

$$\max_{input} P(\text{crash} | \text{input})$$

Autoencoder (détection anomalie)

$$\min |x - \hat{x}|^2$$


📈 Métriques mesurées

  • Crash discovery rate : % d'inputs provoquant un crash
  • Temps moyen pour trouver une vulnérabilité
  • Success exploit rate : % d'exploits réussis
  • False positive IDS : taux de fausses alertes
  • Detection latency : temps de réaction IDS

🎬 Scénario Démo

  1. Lancer le firmware simulé
  2. Montrer fonctionnement normal (commandes TCP)
  3. Lancer fuzzing aléatoire → faible crash rate
  4. Lancer IA fuzzer (PPO) → crash rapide
  5. Générer exploit automatiquement
  6. Activer IDS IA
  7. Montrer détection en temps réel sur dashboard

🔧 Options avancées

  • Intégration Ghidra automation (scripting headless)
  • Symbolic execution (angr)
  • Graph Neural Networks sur call graph
  • Analyse dynamique mémoire (Valgrind)

📝 Licence

MIT License – Projet éducatif uniquement. Usage en environnement contrôlé.


Développé par DanielMBouyou

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages