Skip to content

oussama134/-SentinelIQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SentinelIQ

An autonomous, full-stack SIEM built from scratch

ML threat detection Β· real-time correlation Β· active response Β· kill switch

Python FastAPI PyTorch React PostgreSQL MITRE ATT&CK


What is this?

SentinelIQ is a Security Information and Event Management system built entirely from scratch β€” no Elastic, no Splunk, no pre-built detection libraries. It captures live network traffic, ingests Linux system logs from remote machines, runs everything through a trained LSTM model and a 31-rule correlation engine, enriches every alert with MITRE ATT&CK mappings and real-time threat intelligence, and automatically blocks attackers on both the local Windows firewall and a remote Linux host over SSH.

When ransomware is confirmed, it can network-isolate or shut down the victim machine before encryption spreads.


Detection Pipeline

 NETWORK PATH                            LOG PATH
 ────────────────────────────            ──────────────────────────────────────
 tshark captures live traffic            ubuntu_forwarder.py tails log files
           β”‚                             /var/log/auth.log Β· nginx Β· syslog
           β–Ό                                         β”‚ HTTP POST batches
 flow_extractor.py                                   β–Ό
 PCAP β†’ 80-feature flow vectors          log_collector.py
           β”‚                             AuthLogParser Β· NginxLogParser
           β–Ό                             SyslogParser Β· UA fingerprinting
 predictor.py  (LSTM)                                β”‚
 PyTorch Β· 2 layers Β· hidden=64                      β”‚
 CICIDS2017 Β· 15 attack classes                      β”‚
 β†’ (predicted_label, confidence)                     β”‚
           β”‚                                         β”‚
           β–Ό                                         β–Ό
 NetworkFlowNormalizer               raw event β†’ UnifiedLog
 wraps prediction into UnifiedLog    { event_type, src_ip, message }
 { predicted_label, confidence,      no ML label β€” rule fires on count
   event_type, src_ip, dst_ip }                      β”‚
           β”‚                                         β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β–Ό
             UnifiedLog  (common schema for all sources)
                          β”‚
                          β–Ό
          Correlation Engine  (31 rules)
          sliding-window counts per (event_type, src_ip)
          ML confidence check β†’ count threshold check β†’ alert
          per-class thresholds Β· 60s alert suppressor
                          β”‚
                          β–Ό
          Threat Intel enrichment  (async, non-blocking)
          ip-api.com geolocation Β· AbuseIPDB reputation Β· 1h cache
                          β”‚
                    β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                    β–Ό            β–Ό
              PostgreSQL    Active Response
              7 tables      Windows Firewall (PowerShell)
                            SSH β†’ iptables / ufw (Linux)
                            Kill Switch (isolate / shutdown)
                          β”‚
                          β–Ό
                React Dashboard
                Live alerts Β· Threat Globe Β· MITRE heatmap Β· Log stream

Features

ML Detection β€” LSTM on CICIDS2017

A two-layer LSTM (hidden_dim=64, seq_len=5 flows) trained on the Canadian Institute for Cybersecurity 2017 dataset. Classifies network flows into 15 attack categories in real-time. Each class has its own minimum confidence threshold to suppress false positives on inherently noisy traffic patterns β€” DDoS requires 0.85 confidence, brute force 0.72. A post-processing layer applies hard constraints the model cannot learn from flow statistics alone: FTP brute force must target port 21, UDP traffic cannot be a SlowHTTP attack, short web flows are directory scanning not DoS.

Classes: DoS Slowloris Β· DoS Hulk Β· DoS GoldenEye Β· DoS Slowhttptest Β· DDoS Β· SSH-Patator Β· FTP-Patator Β· PortScan Β· Heartbleed Β· Web Attack–Brute Force Β· Web Attack–XSS Β· Web Attack–SQL Injection Β· Infiltration Β· Bot

Correlation Engine β€” 31 Rules

A sliding-window event counter that groups events by source IP against time-windowed thresholds, with prefix-matching rule families and a per-(IP, rule) suppressor to prevent alert storms.

Severity Count Examples
CRITICAL 10 SQL injection, Heartbleed, DDoS, root login, ransomware VSS deletion, mass encryption
HIGH 10 SSH/FTP brute force, web scanner UA, privilege escalation via sudo, path traversal
MEDIUM 7 Port scan, XSS, 4xx flood (directory probe), SSH invalid user
LOW 4 First SSH failure, first invalid username β€” early-warning reconnaissance signals

Rules R030 and R031 (ransomware detection) arm the Kill Switch in addition to generating an alert.

MITRE ATT&CK Integration

Every alert is automatically tagged with tactic, technique ID, technique name, and kill chain stage across 9 MITRE tactics. The dashboard renders a kill chain coverage heatmap.

Tactic Techniques
Reconnaissance T1046 Network Service Discovery
Initial Access T1189 Drive-by Β· T1190 Exploit Public App
Credential Access T1110 Brute Force Β· T1552.004 Heartbleed
Privilege Escalation T1548.003 Sudo abuse
Discovery T1083 File/Directory (path traversal)
Lateral Movement T1210 Remote Services exploitation
Command & Control T1071.001 Application Layer Protocol
Defense Evasion T1562 Impair Defenses
Impact T1499 DoS Β· T1498 DDoS Β· T1486 Ransomware Β· T1490 VSS deletion

Multi-Source Log Ingestion

ubuntu_forwarder.py runs on any Linux host, tails four log sources in real-time, batches every 2 seconds, and ships to the SIEM over HTTP. Handles log rotation, syslog noise pre-filtering, and PCAP upload via tcpdump. Zero external dependencies β€” standard library only.

Source What it catches
/var/log/auth.log SSH failures, invalid users, root login attempts, sudo commands
/var/log/nginx/access.log SQL injection, XSS, path traversal, scanner User-Agents, 4xx floods
/var/log/apache2/access.log Same as nginx
/var/log/syslog UFW blocks, service failures, OOM killer, iptables events (keyword pre-filtered)

Active Defense

Detection triggers enforcement immediately through registered callbacks:

  • Windows Firewall β€” New-NetFirewallRule via PowerShell blocks attacker IPs on the SIEM machine
  • Remote Linux firewall β€” SSH to victim machine, executes iptables -I INPUT -s {ip} -j DROP or ufw insert 1 deny from {ip}
  • SSH circuit breaker β€” opens after 3 consecutive SSH failures, auto-resets after 120 seconds; prevents 20-second thread hangs when victim VM is offline
  • HTTP rate limiting β€” 150 requests per 30s triggers auto-ban; 16 attack-tool User-Agents (sqlmap, nikto, hydra, metasploit, nuclei…) are auto-banned on first request
  • Analyst controls β€” manual ban/unban per IP, flush all blocks by device, live ban list in dashboard

Kill Switch

Ransomware detection (Volume Shadow Copy deletion or mass file encryption) triggers an SSH response that runs in a daemon thread β€” never blocking the alert pipeline:

  • Isolate β€” drops all iptables traffic except the analyst's SSH port; machine stays up for memory forensics and disk imaging
  • Shutdown β€” shutdown -h now β€” stops encryption spread immediately

Every action is written to an in-process audit log with timestamp, action, host, reason, and success/failure status.

Threat Intelligence

Every alert's source IP is asynchronously enriched after alert persistence (never blocking):

  • Geolocation via ip-api.com β€” country, city, ISP, VPN/proxy flag (free, no key)
  • Reputation via AbuseIPDB β€” confidence score 0–100, total community reports, TOR exit node flag
  • Caching β€” in-memory, 1-hour TTL, 2000-entry FIFO limit to cap memory on high-volume deployments
  • Private/RFC1918 IPs are skipped automatically

Stack

Layer Technology
Machine Learning PyTorch Β· scikit-learn Β· CICIDS2017
Backend API Python 3.11 Β· FastAPI Β· uvicorn Β· asyncio
Database PostgreSQL Β· SQLAlchemy async Β· asyncpg
Packet capture tshark (Windows) Β· tcpdump (Linux)
Frontend React 18 Β· Tailwind CSS Β· lucide-react
Authentication JWT Β· bcrypt
Threat Intel aiohttp Β· ip-api.com Β· AbuseIPDB
Remote response OpenSSH Β· iptables Β· ufw Β· PowerShell

Project Structure

sentineliq/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI app β€” 40+ endpoints, capture loop, response orchestration
β”‚   β”‚   β”œβ”€β”€ lstm_model.py        # PyTorch LSTM architecture
β”‚   β”‚   β”œβ”€β”€ predictor.py         # Inference pipeline with per-class confidence filtering
β”‚   β”‚   β”œβ”€β”€ flow_extractor.py    # PCAP β†’ network flow feature vectors
β”‚   β”‚   └── traffic_filter.py   # Pre-inference noise filter + post-process business rules
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ correlation.py       # 31-rule sliding-window engine, thread-safe
β”‚   β”‚   β”œβ”€β”€ ingestion.py         # Log parsers + UnifiedLog schema
β”‚   β”‚   β”œβ”€β”€ log_collector.py     # Advanced auth/nginx/syslog parsers, UA fingerprinting
β”‚   β”‚   β”œβ”€β”€ mitre.py             # MITRE ATT&CK mappings β€” all 15 CICIDS classes + 18 event types
β”‚   β”‚   β”œβ”€β”€ threat_intel.py      # Async IP enrichment with in-memory cache
β”‚   β”‚   β”œβ”€β”€ active_defense.py    # In-memory bans, rate limiting, firewall callbacks
β”‚   β”‚   β”œβ”€β”€ kill_switch.py       # Ransomware response β€” isolate or shutdown via SSH
β”‚   β”‚   └── auth.py              # JWT authentication
β”‚   β”œβ”€β”€ database.py              # 7-table ORM schema
β”‚   └── config.py                # Pydantic settings loaded from .env
β”œβ”€β”€ frontend/src/
β”‚   β”œβ”€β”€ App.jsx                  # Main dashboard β€” live alert stream, filtering, stats
β”‚   └── components/
β”‚       β”œβ”€β”€ AlertDetail.jsx      # Alert detail β€” MITRE, threat intel, timeline, response actions
β”‚       β”œβ”€β”€ ThreatGlobe.jsx      # Geographic attack source visualization
β”‚       β”œβ”€β”€ LogExplorer.jsx      # Real-time normalized log stream
β”‚       └── ConfigPanel.jsx      # Live threshold and capture interface controls
└── ubuntu_forwarder.py          # Standalone Linux agent β€” zero dependencies

Lab Setup

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    192.168.56.0/24    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Windows 10 Host    │◄─────────────────────►│   Ubuntu 22.04 VM    β”‚
β”‚   SIEM + ML Server   β”‚                        β”‚   Victim / Target    β”‚
β”‚   192.168.56.1       β”‚                        β”‚   192.168.56.200     β”‚
β”‚                      │◄── log batches ────────│                      β”‚
β”‚   tshark (capture)   │◄── PCAP windows ───────│   ubuntu_forwarder   β”‚
β”‚   FastAPI backend    │──── SSH iptables ──────►│   tcpdump Β· auth.log β”‚
β”‚   React dashboard    β”‚                        β”‚   nginx Β· syslog     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β–²
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚   Kali Linux VM    β”‚
                   β”‚   192.168.56.101   β”‚
                   β”‚   Attack source    β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

False Positive Reduction

Getting a model to fire on attacks is straightforward. Keeping it quiet on legitimate traffic is the engineering challenge. SentinelIQ handles this at three independent layers:

Pre-inference filter β€” drops DNS, DHCP, NTP, mDNS, SSDP, LLMNR, multicast, subnet broadcasts (*.255), and CDN prefixes (Google, Cloudflare, AWS, GitHub, Microsoft, Fastly) before data reaches the model.

Per-class confidence thresholds β€” DDoS requires 0.85, DoS variants 0.70–0.82, brute force 0.72. Classes the model finds ambiguous get higher bars.

Business-rule post-processing β€” hard constraints the model cannot infer from flow statistics:

  • UDP flows cannot be Slowhttp attacks
  • FTP brute force must target port 21; web attacks must target 80/443/8080/8443
  • Router IPs need 0.98 confidence before any DoS alert fires
  • Flows with fewer than 15 packets labeled as DoS/DDoS are re-labeled BENIGN (these are directory brute-force connections, not flood attacks)

Getting Started

Prerequisites

  • Python 3.11+, Node.js 18+, PostgreSQL
  • Wireshark / tshark (Windows) or tcpdump (Linux)

Backend

cd backend
pip install -r requirements.txt

cp .env.example .env
# Set DB credentials, ABUSEIPDB_API_KEY, SMTP settings, REMOTE_RESPONSE_HOST

uvicorn src.main:app --host 0.0.0.0 --port 8000

Frontend

cd frontend
npm install
npm start
# β†’ http://localhost:3000   (default: admin / admin)

Ubuntu Agent

# Run on the Linux host to monitor
sudo python3 ubuntu_forwarder.py \
  --siem http://<SIEM_IP>:8000 \
  --device-id production-server

Simulate Attacks

cd backend/src
python log_simulator.py             # Auth log attack sequences
python attack_simulator_multi_ip.py # Multi-source network attacks

Configuration

Variable Purpose Default
DB_HOST/PORT/NAME/USER/PASSWORD PostgreSQL localhost / sentineliq
SECRET_KEY JWT signing change in production
ABUSEIPDB_API_KEY IP reputation empty
SMTP_USER / SMTP_PASSWORD Email alerts empty
REMOTE_RESPONSE_ENABLED SSH→Linux firewall false
REMOTE_RESPONSE_HOST Linux host IP to protect β€”
REMOTE_RESPONSE_BACKEND iptables or ufw iptables
KILL_SWITCH_ENABLED Arm ransomware kill switch false
KILL_SWITCH_ACTION isolate or shutdown isolate
SENTINELIQ_CAPTURE_INTERFACE tshark interface index 4

Author

Oussama Aouass β€” Final Year Cybersecurity Engineering Project

Every component built from scratch. No managed detection libraries. No pre-built SIEM engines.

LinkedIn Email


If this project interests you β€” for a role, a collaboration, or just to talk security β€” reach out.

About

πŸ›‘οΈ SentinelIQ: An AI-powered SIEM and Network Intrusion Detection System utilizing LSTM neural networks, real-time log correlation, and active firewall defense to detect and block cyber threats.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors