commit 430a783fe2197e307250ec7ebc21eb10cf92632b Author: Olivier Date: Sun Feb 1 09:16:04 2026 +0100 Téléverser les fichiers vers "/" diff --git a/README.md b/README.md new file mode 100644 index 0000000..be2ad17 --- /dev/null +++ b/README.md @@ -0,0 +1,557 @@ +# 🤖 NetWatch AI - Bot de Surveillance Réseau Intelligent + +**Projet complet de surveillance réseau avec IA, détection d'OS, identification de fabricants et dashboard web moderne.** + +![Version](https://img.shields.io/badge/version-2.0-blue) +![Python](https://img.shields.io/badge/python-3.8+-green) +![License](https://img.shields.io/badge/license-MIT-orange) + +--- + +## 📦 Contenu du Projet + +### Scripts Principaux + +- **`network_ai_bot.py`** - Bot principal de scan réseau avec IA +- **`mac_vendor_db.py`** - Module de détection de fabricants (base OUI IEEE) +- **`web_dashboard.py`** - Dashboard web avec interface moderne +- **`nmap_os_detector.py`** - Module optionnel pour détection OS avancée avec nmap + +### Fichiers de Configuration + +- **`ports_config.txt`** - Configuration des 73+ ports à scanner (auto-chargé) +- **`config.example.json`** - Exemple de configuration avancée +- **`requirements.txt`** - Dépendances Python + +### Scripts Utilitaires + +- **`install.sh`** - Script d'installation automatique +- **`demo.py`** - Démonstration du bot sans scan réel + +### Interface Web + +- **`templates/dashboard.html`** - Interface HTML du dashboard +- **`static/css/dashboard.css`** - Design cybersécurité/tech noir +- **`static/js/dashboard.js`** - Logique frontend complète + +### Documentation + +- **`README.md`** - Ce fichier (vue d'ensemble) +- **`QUICKSTART.md`** - Guide de démarrage rapide +- **`WEB_DASHBOARD_GUIDE.md`** - Guide du dashboard web +- **`OUI_DATABASE_GUIDE.md`** - Guide d'utilisation de la base OUI +- **`PORT_SCAN_GUIDE.md`** - Guide du scan de ports +- **`OS_DETECTION_GUIDE.md`** - Guide de détection d'OS +- **`TIMEOUT_FIX.md`** - Résolution des problèmes de timeout + +--- + +## 🚀 Installation Rapide + +### Méthode 1 : Installation Automatique (Recommandé) + +```bash +# 1. Extraire l'archive +tar -xzf netwatch-complete-project.tar.gz +cd netwatch-complete-project/ + +# 2. Lancer l'installation automatique +bash install.sh +``` + +Le script va : +- ✅ Vérifier Python 3 +- ✅ Installer les dépendances +- ✅ Installer et démarrer Ollama +- ✅ Télécharger le modèle IA +- ✅ Configurer les permissions + +### Méthode 2 : Installation Manuelle + +```bash +# 1. Installer les dépendances +pip install -r requirements.txt --break-system-packages + +# 2. Installer Ollama +curl -fsSL https://ollama.com/install.sh | sh +ollama serve + +# 3. Télécharger un modèle IA +ollama pull llama3.2 + +# 4. (Optionnel) Télécharger la base OUI +wget https://standards-oui.ieee.org/oui/oui.txt +``` + +--- + +## 🎯 Utilisation + +### 1. Scan Simple + +```bash +python3 network_ai_bot.py +``` + +**Résultat :** +``` +🌐 Réseau détecté: 192.168.1.0/24 +✅ Configuration ports chargée: 73 ports depuis ports_config.txt +✅ Base MAC Vendor chargée (30456 fabricants) + +🔍 Scan du réseau 192.168.1.0/24... + ✅ 192.168.1.1 router [Network Device] (TP-Link Corp.) Ports: 80/HTTP, 443/HTTPS + ✅ 192.168.1.10 proxmox [Linux/Unix] (Dell Inc.) Ports: 22/SSH, 8006/Proxmox-Web, 8086/InfluxDB + ✅ 192.168.1.25 iphone-jean [iOS] (Apple, Inc.) +✅ Scan terminé: 3 appareil(s) trouvé(s) + +🧠 ANALYSE IA EN COURS... + ................................. + +📊 État général : +Votre réseau compte 3 appareils : 1 routeur TP-Link, 1 serveur Proxmox Dell, et 1 iPhone. + +⚠️ Points d'attention : +Proxmox expose les ports 8006 et 8086 - vérifiez la sécurité. + +💡 Recommandations : +Activez l'authentification forte sur l'interface Proxmox. +``` + +### 2. Dashboard Web + +```bash +python3 web_dashboard.py +``` + +Accédez à : **http://localhost:5000** + +**Fonctionnalités :** +- 📊 Vue d'ensemble en temps réel +- 💻 Liste de tous les appareils +- 📈 Graphiques et analytics +- 🤖 Chat IA interactif +- ⚙️ Configuration + +### 3. Mode Interactif (Chat IA) + +```bash +python3 network_ai_bot.py --interactive +``` + +Posez des questions : +- "Quels appareils Windows sont connectés ?" +- "Y a-t-il des ports suspects ouverts ?" +- "Identifie les appareils par fabricant" + +### 4. Monitoring Continu + +```bash +# Scan toutes les 5 minutes +python3 network_ai_bot.py --continuous --interval 300 +``` + +--- + +## 🔧 Configuration + +### Fichiers Auto-Chargés + +Le bot charge **automatiquement** ces fichiers s'ils existent : + +1. **`ports_config.txt`** - Ports à scanner (73 ports par défaut) +2. **`oui.txt`** - Base IEEE des fabricants MAC (30 000+ entrées) + +**Pas besoin de les spécifier en ligne de commande !** + +### Options de Ligne de Commande + +```bash +# Réseau spécifique +python3 network_ai_bot.py --network 10.0.0.0/24 + +# Modèle IA différent +python3 network_ai_bot.py --model mistral + +# Config ports personnalisée +python3 network_ai_bot.py --ports-config my_ports.txt + +# Mode continu +python3 network_ai_bot.py --continuous --interval 600 +``` + +### Personnalisation des Ports + +Éditez `ports_config.txt` pour ajouter vos ports : + +``` +# Mes services +8086 = InfluxDB/Proxmox +9000 = Portainer +3000 = Grafana +``` + +--- + +## 📊 Fonctionnalités Principales + +### ✅ Détection Multi-Niveau + +1. **Scan Réseau** + - Détection automatique du réseau local + - Scan parallèle rapide (50 threads) + - Détection IP, Hostname, MAC + +2. **Détection OS (4 méthodes)** + - Analyse TTL (Linux/Windows/Network Device) + - Banner Grabbing (SSH, HTTP) + - Pattern Hostname + - Fabricant MAC (via base OUI) + +3. **Identification Fabricant** + - Base IEEE OUI complète (30 000+ fabricants) + - Apple, Samsung, Dell, HP, Cisco, TP-Link, etc. + - Cache JSON pour chargement ultra-rapide + +4. **Scan de Ports** + - 73+ ports par défaut + - Proxmox (8006, 8086) + - Docker, Kubernetes, Monitoring + - Bases de données, Web, Windows, etc. + +### 🧠 Analyse IA + +- **Génération de rapports** en langage naturel +- **Détection de changements** (nouveaux/déconnectés) +- **Recommandations de sécurité** +- **Chat interactif** pour questions + +### 💾 Base de Données + +- **SQLite** pour historique complet +- Suivi des appareils dans le temps +- Statistiques et évolution +- Export CSV + +### 🌐 Dashboard Web + +- **Design moderne** cybersécurité +- **5 vues** : Dashboard, Appareils, Analytics, IA Chat, Paramètres +- **Graphiques** Chart.js +- **Auto-scan** configurable +- **API REST** complète + +--- + +## 📁 Structure du Projet + +``` +netwatch-complete-project/ +├── network_ai_bot.py # Bot principal ⭐ +├── mac_vendor_db.py # Détection fabricants +├── web_dashboard.py # Dashboard web 🌐 +├── nmap_os_detector.py # Détection OS avancée +├── demo.py # Démonstration +│ +├── ports_config.txt # Config ports (auto-chargé) +├── config.example.json # Config avancée +├── requirements.txt # Dépendances Python +├── install.sh # Installation auto +│ +├── templates/ +│ └── dashboard.html # Interface web +├── static/ +│ ├── css/ +│ │ └── dashboard.css # Design +│ └── js/ +│ └── dashboard.js # Logique frontend +│ +└── Documentation/ + ├── README.md # Ce fichier + ├── QUICKSTART.md # Démarrage rapide + ├── WEB_DASHBOARD_GUIDE.md # Guide dashboard + ├── OUI_DATABASE_GUIDE.md # Guide base OUI + ├── PORT_SCAN_GUIDE.md # Guide ports + ├── OS_DETECTION_GUIDE.md # Guide détection OS + └── TIMEOUT_FIX.md # Résolution timeout +``` + +--- + +## 🎓 Guides Détaillés + +### Pour Débuter +- 📖 **QUICKSTART.md** - Installation et premiers scans en 5 minutes + +### Fonctionnalités Avancées +- 🌐 **WEB_DASHBOARD_GUIDE.md** - Tout sur le dashboard web +- 🏷️ **OUI_DATABASE_GUIDE.md** - Utiliser la base de fabricants +- 🔍 **PORT_SCAN_GUIDE.md** - Scanner vos ports personnalisés +- 🖥️ **OS_DETECTION_GUIDE.md** - Méthodes de détection d'OS + +### Dépannage +- ⏱️ **TIMEOUT_FIX.md** - Résoudre les problèmes de timeout Ollama + +--- + +## 🔒 Sécurité & Permissions + +### Linux + +```bash +# Option 1 : Exécuter avec sudo +sudo python3 network_ai_bot.py + +# Option 2 : Donner les permissions (permanent) +sudo setcap cap_net_raw+ep $(which python3) +``` + +### macOS + +```bash +sudo python3 network_ai_bot.py +``` + +### Windows + +Exécutez PowerShell ou CMD en tant qu'**Administrateur**. + +--- + +## 🎯 Cas d'Usage + +### 1. Audit Réseau + +```bash +# Scan complet avec rapport IA +python3 network_ai_bot.py > audit_$(date +%Y%m%d).txt +``` + +### 2. Monitoring Serveurs + +```bash +# Surveillance continue +python3 network_ai_bot.py --continuous --interval 300 +``` + +### 3. Détection Intrusions + +```bash +# Dashboard web avec alertes +python3 web_dashboard.py +# Activer auto-scan dans l'interface +``` + +### 4. Inventaire Matériel + +```bash +# Export CSV des appareils +# Via le dashboard : Appareils → Exporter CSV +``` + +--- + +## 🚀 Performance + +### Ressources Recommandées + +- **CPU** : 4+ cœurs (votre i9 12 cœurs est parfait ✅) +- **RAM** : 8-16 Go +- **Stockage** : ~500 MB (scripts + cache + DB) + +### Vitesse de Scan + +- **Scan rapide** (9 ports) : ~2-5s par appareil +- **Scan complet** (73 ports) : ~10-20s par appareil +- **Réseau /24** (254 IPs) : ~2-5 minutes + +### Modèles IA + +| Modèle | RAM | Vitesse | Qualité | +|--------|-----|---------|---------| +| llama3.2:1b | 2 GB | ⚡⚡⚡ | ⭐⭐⭐ | +| llama3.2 | 3 GB | ⚡⚡ | ⭐⭐⭐⭐ | +| mistral | 5 GB | ⚡ | ⭐⭐⭐⭐⭐ | + +--- + +## 🛠️ Dépendances + +### Python (requirements.txt) + +``` +requests>=2.31.0 +flask>=3.0.0 +flask-cors>=4.0.0 +``` + +### Système + +- **Ollama** - Moteur IA local +- **Python 3.8+** +- **arp** - Détection MAC (préinstallé Linux/macOS) +- **ping** - Test connectivité (préinstallé) + +### Optionnel + +- **nmap** - Détection OS avancée +- **oui.txt** - Base fabricants IEEE (auto-téléchargeable) + +--- + +## 📝 Exemples d'Utilisation + +### Exemple 1 : Premier Scan + +```bash +$ python3 network_ai_bot.py + +🌐 Réseau détecté: 192.168.1.0/24 +✅ Configuration ports chargée: 73 ports +✅ Base MAC Vendor chargée (30456 fabricants) + +🔍 Scan du réseau 192.168.1.0/24... + ✅ 192.168.1.1 livebox [Network Device] (Sagemcom SAS) Ports: 80/HTTP + ✅ 192.168.1.10 nas-synology [Linux/Unix] (Synology Inc.) Ports: 22/SSH, 5000/Web, 5001/HTTPS + ✅ 192.168.1.50 rpi-homeassistant [Linux] (Raspberry Pi) Ports: 22/SSH, 8123/Home-Assistant +✅ Scan terminé: 3 appareil(s) trouvé(s) +``` + +### Exemple 2 : Chat IA + +```bash +$ python3 network_ai_bot.py --interactive + +💬 MODE INTERACTIF +Posez des questions sur votre réseau (tapez 'exit' pour quitter) + +🔹 Votre question: Quels appareils ont des ports web ouverts ? + +🤔 Réflexion... + +🤖 Réponse: +Deux appareils ont des ports web ouverts : +1. La Livebox (192.168.1.1) - port 80 (HTTP) +2. Le NAS Synology (192.168.1.10) - ports 5000 (HTTP) et 5001 (HTTPS) + +Le Raspberry Pi exécute Home Assistant sur le port 8123. +``` + +### Exemple 3 : Dashboard Web + +```bash +$ python3 web_dashboard.py + +============================================================ +🌐 DASHBOARD WEB - BOT AI DE SURVEILLANCE RÉSEAU +============================================================ + +📡 Serveur démarré sur: http://localhost:5000 +🔗 Accédez au dashboard: http://localhost:5000 + +Appuyez sur Ctrl+C pour arrêter +============================================================ +``` + +--- + +## ❓ FAQ + +### Q: Pourquoi certains appareils ne sont pas détectés ? + +**R:** Vérifiez : +- Que vous êtes sur le bon réseau +- Les permissions (sudo sur Linux) +- Que le pare-feu n'est pas actif +- Que les appareils répondent au ping + +### Q: Comment ajouter mes propres ports ? + +**R:** Éditez `ports_config.txt` : +``` +9999 = Mon-Service +``` + +### Q: Ollama ne démarre pas ? + +**R:** +```bash +# Vérifier l'installation +ollama --version + +# Redémarrer +pkill ollama +ollama serve +``` + +### Q: La détection de fabricant ne fonctionne pas ? + +**R:** Téléchargez la base OUI : +```bash +wget https://standards-oui.ieee.org/oui/oui.txt +``` + +### Q: Comment accéder au dashboard depuis une autre machine ? + +**R:** Le serveur écoute sur `0.0.0.0:5000` + +Accédez via : `http://IP_DU_SERVEUR:5000` + +--- + +## 🤝 Contribution + +Ce projet est open source. Améliorations bienvenues ! + +**Idées de fonctionnalités :** +- [ ] Notifications push/email +- [ ] Détection d'anomalies ML +- [ ] Scan de vulnérabilités +- [ ] Intégration MQTT +- [ ] Export Grafana +- [ ] Mode WiFi sniffer + +--- + +## 📄 Licence + +MIT License - Libre d'utilisation et modification + +--- + +## 🙏 Remerciements + +- **IEEE** - Base OUI des fabricants MAC +- **Ollama** - Moteur IA local +- **Flask** - Framework web Python +- **Chart.js** - Graphiques JavaScript + +--- + +## 📞 Support + +Pour toute question : +1. Consultez les guides dans `/Documentation` +2. Vérifiez la section FAQ ci-dessus +3. Testez avec `demo.py` pour valider l'installation + +--- + +**NetWatch AI - Surveillance Réseau Intelligente** 🤖🔍 + +*Détection complète • Analyse IA • Dashboard moderne* + +**Créé avec ❤️ pour la sécurité réseau** + +--- + +## 🎉 Démarrage Immédiat + +```bash +# Installation complète en 3 commandes +bash install.sh +ollama pull llama3.2 +python3 network_ai_bot.py +``` + +**C'est parti ! 🚀**