Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NetSentryx PRO πŸ›‘οΈ

AI-Driven, High-Performance Real-Time Network Observability & Threat Detection Engine

FastAPI PyTorch Python License: MIT Build Status

NetSentryx PRO is a next-generation, event-driven network monitoring and threat intelligence platform. Combining rule-based signatures with a PyTorch Deep Autoencoder, it provides sub-10ms packet and netflow anomaly detection, automated multi-channel alerting (Slack, Discord, Email), and an interactive real-time SOC dashboard.


πŸ—οΈ System Architecture

The following flow diagram illustrates the data ingestion, real-time deep learning inference, alerting pipeline, and WebSocket visualization layer:

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:#fff
Loading

πŸš€ Key Features

  • ⚑ Real-Time Traffic Ingestion: Aggregates packet frames into rich netflow summaries on the fly with minimal latency.
  • 🧠 PyTorch Deep Autoencoder Anomaly Detection: Utilizes a lightweight PyTorch neural network (TrafficAutoencoder) to detect sophisticated zero-day exploits, scanning, or DDoS attacks based on multivariate feature reconstruction error.
  • πŸ“ˆ Zero-Manual-Training Startup: Features automated synthetic fitting and statistical threshold calibration (Mean + 3 * Std) during server startup, making it fully functional out of the box.
  • ⏱️ Sub-10ms Inference Latency: Optimized inference pipeline ensures real-time evaluation of high-throughput packet flows.
  • πŸ“£ Multi-Channel Alert Dispatching: Asynchronously pushes detailed intrusion alerts to Slack webhooks, Discord webhooks, Custom HTTP APIs, and SMTP emails using FastAPI's BackgroundTasks.
  • πŸ“Š Interactive SOC Dashboard: Elegant, dark-mode dashboard powered by Tailwind CSS, Chart.js, and WebSockets for real-time visualization of throughput metrics and live threat feeds.

πŸ“ Project Structure

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

πŸ› οΈ Quickstart & Setup Guide

1. Prerequisites

Ensure you have Python 3.10+ installed. If capturing live network interfaces:

  • Windows: Install Npcap (select "Install Npcap in WinPcap API-compatible Mode").
  • Linux: Install libpcap-dev via sudo apt-get install libpcap-dev.

2. Installation

Clone the repository and install dependencies (using uv is highly recommended for faster installation):

# 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

3. Environment Setup (.env)

Create a .env file in the project root to configure notification credentials:

# 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="your-soc-email@gmail.com"
SMTP_PASSWORD="your-app-password"
SMTP_FROM_EMAIL="your-soc-email@gmail.com"
SMTP_TO_EMAIL="admin@domain.com"

4. Running the Platform

πŸ§ͺ Simulation Mode (Includes synthetic traffic simulator)

python main.py --simulate

🌐 Live Sniffing Mode (Requires administrator/sudo privileges)

python main.py

Open your browser and navigate to http://localhost:8000 to view the live dashboard.


πŸ“– API Documentation

Telemetry & Inference Endpoint

  • URL: /api/v1/telemetry/analyze
  • Method: POST
  • Content-Type: application/json

Request Payload

{
  "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"
}

Response (Normal Traffic)

{
  "status": "NORMAL",
  "threat_level": "low",
  "anomaly_score": 0.3083,
  "threshold": 2.1319
}

Response (Anomalous Traffic)

{
  "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": { ... }
  }
}

Historical Queries

Endpoint Method Description Sample Response
/api/alerts GET Fetches recent threat alerts saved in DB [{"id": 1, "rule_name": "Port Scanning", ...}]
/api/flows GET Fetches recent network flow telemetry logs [{"source_ip": "192.168.1.10", "packet_count": 45, ...}]
/api/logs GET Fetches backend system audit logs [{"level": "INFO", "message": "ML engine trained...", ...}]

πŸ›‘οΈ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An event-driven network monitoring platform that performs live packet capture (Npcap), low-latency traffic analytics, and unsupervised threat detection using a PyTorch Autoencoder, backed by an async multi-channel alert engine.

Topics

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages