
Una piattaforma di monitoraggio di rete basata su eventi che esegue cattura di pacchetti in tempo reale (Npcap), analisi del traffico a bassa latenza e rilevamento delle minacce non supervisionato tramite un Autoencoder PyTorch, supportata da un motore di allerta asincrono multi-canale.
Motore di osservabilità di rete e rilevamento delle minacce in tempo reale, ad alte prestazioni e basato sull'IA
NetSentryx PRO è una piattaforma di monitoraggio di rete e threat intelligence di nuova generazione, basata su eventi. Combinando firme basate su regole con un Deep Autoencoder PyTorch, offre rilevamento di anomalie su pacchetti e netflow in meno di 10 ms, alerting automatizzato multi-canale (Slack, Discord, Email) e una dashboard SOC interattiva in tempo reale.
Il seguente diagramma di flusso illustra l'ingestione dei dati, l'inferenza deep learning in tempo reale, la pipeline di alerting e il livello di visualizzazione WebSocket:
flowchart TD
subgraph Capture & Ingestion
A[Network Interface / Packet Simulator] -->|Raw Traffic Events| B(Lightweight Event Bus)
B -->|Packet Stream| C[Flow Aggregation Engine]
end
subgraph Deep Learning Inference
C -->|Aggregated Telemetry Vectors| D[PyTorch TrafficAutoencoder]
D -->|MSE Reconstruction Loss| E{Threshold Evaluation}
end
subgraph Alert Dispatch
E -->|No Anomaly| F[Status: Optimal]
E -->|Anomaly Detected| G[FastAPI BackgroundTasks]
G -->|Save Event| H[(SQLite Datastore)]
G -->|Broadcast WebSocket| I[HTML Live Dashboard]
G -->|Dispatch Webhooks| J[Slack / Discord / Custom Webhook]
G -->|Dispatch SMTP| K[Email Alerting]
end
style D fill:#EE4C2C,stroke:#fff,stroke-width:2px,color:#fff
style I fill:#005571,stroke:#fff,stroke-width:2px,color:#fff
style G fill:#00bf8f,stroke:#fff,stroke-width:2px,color:#fffTrafficAutoencoder) per rilevare exploit zero-day sofisticati, scansioni o attacchi DDoS basandosi sull'errore di ricostruzione di feature multivariate.Mean + 3 * Std) durante l'avvio del server, rendendolo pienamente funzionante fin da subito.BackgroundTasks di FastAPI.NetSentryx/
├── config/
│ ├── config.yaml # System, dashboard, and alerting channel configurations
│ └── rules.yaml # Threat detection thresholds and rule properties
├── src/
│ ├── alerts/
│ │ ├── ml_detection.py # PyTorch TrafficAutoencoder & feature scaling
│ │ ├── manager.py # Async alert dispatcher (Discord, Slack, Email)
│ │ └── detection.py # Rule-based packet signature detection engine
│ ├── core/
│ │ ├── config_loader.py # Configuration loader utilities
│ │ ├── logger.py # Database-integrated system logger
│ │ └── time_utils.py # Timezone-aware timestamp utilities
│ ├── dashboard/
│ │ ├── templates/
│ │ │ └── index.html # Live HTML5 Dashboard template
│ │ └── server.py # FastAPI API Router and WebSocket broadcast controller
│ ├── database/
│ │ ├── manager.py # SQLite connection & database actions
│ │ └── models.py # SQLAlchemy schema definitions (Alerts, Logs, Flows)
│ ├── flows/
│ │ ├── capture.py # Scapy packet sniffer thread
│ │ └── processor.py # Flow aggregation and metric extractor
│ └── main.py # Application entrypoint
└── main.py # Root script runner
Assicurati di avere Python 3.10+ installato. Se acquisisci interfacce di rete live:
libpcap-dev tramite sudo apt-get install libpcap-dev.Clona il repository e installa le dipendenze (l'uso di uv è altamente consigliato per un'installazione più rapida):
# Clone the repository
git clone https://github.com/yourusername/netsentryx.git
cd netsentryx
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install requirements
pip install -r requirements.txt
.env)Crea un file .env nella radice del progetto per configurare le credenziali di notifica:
# Discord Configuration
DISCORD_ENABLED=true
DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/your-webhook-id/your-webhook-token"
# Slack Configuration
SLACK_ENABLED=true
SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR_WORKSPACE_ID/YOUR_CHANNEL_ID/YOUR_SECRET_TOKEN"
# SMTP Email Configuration
SMTP_ENABLED=true
SMTP_SERVER="smtp.gmail.com"
SMTP_PORT=587
SMTP_USERNAME="[email protected]"
SMTP_PASSWORD="your-app-password"
SMTP_FROM_EMAIL="[email protected]"
SMTP_TO_EMAIL="[email protected]"
python main.py --simulate
python main.py
Apri il browser e vai su http://localhost:8000 per visualizzare la dashboard live.
/api/v1/telemetry/analyzePOSTapplication/json{
"packet_count": 550,
"byte_count": 850000,
"flow_duration": 4.5,
"syn_flag_ratio": 0.85,
"port_entropy": 3.2,
"byte_rate": 188888.8,
"source_ip": "192.168.1.120",
"dest_ip": "10.0.0.5",
"protocol": "TCP"
}
{
"status": "NORMAL",
"threat_level": "low",
"anomaly_score": 0.3083,
"threshold": 2.1319
}
{
"status": "ANOMALOUS",
"threat_level": "critical",
"anomaly_score": 117999.03,
"threshold": 2.1319,
"alert": {
"id": 12,
"timestamp": "2026-08-05T14:13:31.373Z",
"rule_id": "ml_autoencoder_anomaly",
"rule_name": "ML Autoencoder Anomaly",
"source_ip": "192.168.1.120",
"severity": "critical",
"description": "Deep autoencoder reconstruction error exceeded anomaly threshold (score: 117999.0300, threshold: 2.1320).",
"metrics": { ... }
}
}
| Endpoint | Metodo | Descrizione | Risposta di Esempio |
|---|---|---|---|
/api/alerts | GET | Recupera i recenti avvisi di minaccia salvati nel DB | [{"id": 1, "rule_name": "Port Scanning", ...}] |
/api/flows | GET | Recupera i recenti log di telemetria dei flussi di rete | [{"source_ip": "192.168.1.10", "packet_count": 45, ...}] |
/api/logs | GET | Recupera i log di audit del sistema backend | [{"level": "INFO", "message": "ML engine trained...", ...}] |
Questo progetto è distribuito sotto la Licenza MIT - consulta il file LICENSE per i dettagli.