From 430a783fe2197e307250ec7ebc21eb10cf92632b Mon Sep 17 00:00:00 2001 From: Olivier Date: Sun, 1 Feb 2026 09:16:04 +0100 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"/"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 557 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 557 insertions(+) create mode 100644 README.md 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 ! 🚀**