Multi-Stage Intrusion Detection, MITRE ATT&CK Mapping, ML Anomaly Scoring & Auditable SOC Response (Windows 10/11)
SentinelIDS is a modular host and network defensive security console and CLI
pipeline. Going beyond isolated signature alerts, it tails live Suricata
eve.json telemetry (or replays saved .pcap captures), captures unauthorized
local probes via embedded SSH/HTTP decoy honeypots, correlates independent weak
signals across rolling event-time windows, enriches every incident with
MITRE ATT&CK Enterprise tactics and techniques, scores flow windows with a
supplementary Isolation Forest detector, and routes escalations through an
auditable, dry-run-by-default automated response engine backed by WAL-mode
SQLite forensics and an instant emergency kill switch.
- Overview and Core Features
- Installation and Setup
- Dual-Mode Usage Guide
- Command-Line Reference
- Runtime Outputs and Privacy
- Architecture and Project Layout
- Detection Rules and ML Layer
- Automated Tests
- Limitations and Detection Gaps
- Technology Stack
- Legal and Ethical Use
- License and Acknowledgments
Important
Authorized Lab Use & Dry-Run Default: SentinelIDS enforces
lab_only: true, ships with response.dry_run: true (simulating firewall
actions without modifying Windows Defender Firewall unless explicitly
overridden in supervised lab tests), and verifies that simulation scripts
target only loopback (127.0.0.1) or private RFC1918 hosts you own.
- Dual-Mode Operation (SOC Dashboard + Headless CLI):
- Enterprise SOC Web Dashboard (
dashboard/app.py): Localhost Streamlit + Plotly obsidian console (127.0.0.1:8501) with a persistent Session/IP/Severity Filter Bar, aligned KPI tiles, 7 investigation tabs, MITRE ATT&CK coverage heatmap, forensic timeline, and formula-safe CSV export. - Unified Pipeline CLI (
sentinel.py): Headlessrun(--mode live/--mode replay),honeypot,train-ml, and emergencyrevertcommands paired with PowerShell automation scripts.
- Enterprise SOC Web Dashboard (
- 12 Custom Suricata Detection Rules (
rules/local.rules): Signatures for ICMP sweeps (T1018), SYN port scans (T1046), SSH/RDP/FTP credential bursts (T1110.001), scanner User-Agents (T1595), cleartext HTTP POST credentials (T1040),.invalidC2 DNS (T1071.004), TCP/UDP DoS bursts (T1498.001), and HTTP traversal/.envprobes (T1190). - Event-Time Multi-Stage Correlation (
correlation/engine.py): Chains weak alerts, ML outliers, and honeypot hits across rolling parsed event-time windows (CORR-001–CORR-005) with 60s cooldown deduplication for parity between live capture and PCAP replay. - Supplementary ML Anomaly Layer (
ml_anomaly/): Scikit-learnStandardScaler+IsolationForesttrained over 7 per-host 10s flow features with shuffled holdout FPR reporting and attribution heuristics. - Local Deception Honeypot (
honeypot/): Bounded-concurrencyasynciofake SSH banner (TCP 2222) and fake HTTP/adminportal (TCP 8088) bound to loopback or local private interfaces, feedingCORR-002escalations. - Auditable Response & Kill Switch (
response/): Tiered actions (log_only→notify→quarantine), fail-closed allowlist (loopback, local NICs, default gateway, DNS resolvers, trusted CIDRs), pre-execution synchronousos.fsyncJSONL + SQLite audit writes, TTL auto-expiry reaper, and one-commandrevert_allfirewall cleanup.
Tip
Admin vs. Standard PowerShell: Run offline PCAP replay, Streamlit SOC
Dashboard, ML training, and pytest in a standard PowerShell terminal. Run
PowerShell as Administrator when capturing live traffic via Npcap or
testing live Windows Defender Firewall quarantine rules.
- Python 3.11+: Tested on 64-bit Windows 10/11 with Python
3.13.13. - Npcap: Install from npcap.com with Install Npcap in WinPcap API-compatible Mode and Support loopback traffic checked (see docs/windows_suricata_setup.md).
- Suricata Windows MSI: Tested on Suricata
8.0.864-bit MSI from suricata.io/download.
git clone https://github.com/Jaindu-Net/CodeAlpha_SentinelIDS.git
cd CodeAlpha_SentinelIDS
powershell -ExecutionPolicy Bypass -File scripts\setup_venv.ps1Or create .venv manually:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtNote
If PowerShell blocks script activation, run
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once and retry.
powershell -ExecutionPolicy Bypass -File scripts\start_suricata.ps1 -Mode test
powershell -ExecutionPolicy Bypass -File scripts\check_environment.ps1Confirm [PASS] Npcap Service Status, [PASS] Suricata Binary, and
[PASS] suricata -T configuration valid. appear before live capture.
Both interfaces share the same SQLite forensic store
(data/sentinel_forensics.db), audit logs, and correlation pipeline.
Launch the Streamlit SOC console directly in PowerShell:
.\.venv\Scripts\streamlit.exe run dashboard\app.pyIf prompted for an onboarding email on first run, press Enter to skip
(gatherUsageStats = false is configured in
.streamlit/config.toml). Open
http://127.0.0.1:8501 in your browser.
Verified end-to-end against tests\fixtures\sample_attack.pcap (159 packets
triggering all 8 rule groups):
# 1. Replay PCAP through Suricata to generate logs\eve.json
powershell -ExecutionPolicy Bypass -File scripts\start_suricata.ps1 `
-Mode replay -PcapPath tests\fixtures\sample_attack.pcap
# 2. Ingest eve.json into SQLite (normalization, correlation, dry-run audit)
.\.venv\Scripts\python.exe sentinel.py run --mode replay --eve logs\eve.json
# 3. Open the SOC Dashboard
.\.venv\Scripts\streamlit.exe run dashboard\app.pyFollow the live presentation runbook in docs/demo_script.md:
# Terminal 1 (Admin): Live Suricata capture on VMware / LAN adapter IP
powershell -ExecutionPolicy Bypass -File scripts\start_suricata.ps1 `
-Mode live -Interface "192.168.182.1"
# Terminal 2: Start SentinelIDS pipeline + honeypot + Dashboard
powershell -ExecutionPolicy Bypass -File scripts\start_sentinel.ps1
# Terminal 3: Run safe multi-stage lab attack chain against localhost or VM
.\.venv\Scripts\python.exe scripts\simulate_attacks.py `
correlation-chain --target 127.0.0.1
# Emergency Kill Switch: Revert all session and firewall rules cleanly
powershell -ExecutionPolicy Bypass -File scripts\revert_all.ps1 `
-AllSessions -LiveSweep| UI Area / Tab | Capabilities & Telemetry Displayed |
|---|---|
| Command Header & Filter Bar | Persistent Session Scope, Filter Source IP, Severity Filter, Auto-Refresh, and Refresh bar synced across KPIs & charts |
| KPI Strip (5 Cards) | Raw & ML Alerts, Escalations, Honeypot Hits, Responses, and ATT&CK Coverage |
| Command Overview | Alert Severity Posture donut, stacked Top Offending Source IPs, MITRE ATT&CK Tactic Breakdown, and top 3 incident cards |
| Live Alert Feed | Full searchable alert table (Suricata + ML Anomaly) and Excel formula-safe CSV export (sentinel_alerts.csv) |
| MITRE ATT&CK Matrix | Tactic breakdown bar + Tactic x Technique Coverage Matrix heatmap + technique hit breakdown table |
| Correlations | Escalated multi-stage incident cards (CORR-001–CORR-005) with confidence bar, evidence IDs, and ATT&CK tags |
| Honeypot Traps | Decoy SSH 2222 & HTTP 8088 interaction log with byte counts and redacted payload previews |
| Response & Audit | Filtered responses_taken table alongside the immutable response_audit.jsonl append-only trail |
| Forensic Timeline | ISO-8601 UTC window query plotting all event stages across unified_timeline |
Sidebar (<< / >> Toggle) |
Response Guard, ML Heuristic Layer (holdout FPR / training hint), and Sensor Pipeline posture cards |
SentinelIDS operates natively without launching a browser UI. Telemetry writes
directly to logs/*.jsonl and data/sentinel_forensics.db.
# Replay eve.json + optional honeypot JSONL into SQLite
.\.venv\Scripts\python.exe sentinel.py run --mode replay `
--eve logs\eve.json --honeypot-log logs\honeypot_events.jsonl
# Run standalone local fake SSH (2222) and fake HTTP /admin (8088) honeypot
.\.venv\Scripts\python.exe sentinel.py honeypot
# Generate benign baseline HTTP traffic while Suricata runs, then train ML
.\.venv\Scripts\python.exe scripts\sim_traffic_baseline.py --duration 120
.\.venv\Scripts\python.exe sentinel.py train-ml --eve logs\eve.json# Start live correlation + honeypot + audit response from current log EOF
.\.venv\Scripts\python.exe sentinel.py run --mode live --from-end
# Live mode allowing firewall blocks ONLY when settings dry_run is false
.\.venv\Scripts\python.exe sentinel.py run --mode live --enable-active-response
# Trigger all 8 rule groups or slow-scan gap test (loopback / RFC1918 only)
.\.venv\Scripts\python.exe scripts\simulate_attacks.py `
all-rules --target 127.0.0.1
.\.venv\Scripts\python.exe scripts\simulate_attacks.py `
slow-scan --target 127.0.0.1 --delay 6.0
# CLI Emergency Kill Switch
.\.venv\Scripts\python.exe sentinel.py revert --all-sessions --live| Command / Flag | Default | Description |
|---|---|---|
--settings <path> |
config/settings.yaml |
Path to YAML configuration file |
run --mode |
live |
Pipeline execution mode (live or replay) |
run --eve <path> |
config eve_log_path |
Path to Suricata eve.json (used in replay) |
run --honeypot-log <path> |
None |
Optional honeypot_events.jsonl to merge during replay |
run --no-honeypot |
False |
Disable embedded SSH/HTTP honeypot during live runs |
run --from-end |
False |
Tail eve.json and honeypot logs from current EOF |
run --enable-active-response |
False |
Permit live Windows Firewall rules if dry_run is false |
honeypot |
— | Run standalone local SSH (2222) & HTTP (8088) decoy server |
train-ml --eve <path> |
Required | Train StandardScaler + IsolationForest from baseline eve.json |
revert --all-sessions |
False |
Revert un-reverted quarantines across all sessions |
revert --live |
False |
Execute live Remove-NetFirewallRule cleanup |
| Script | Parameters | Purpose |
|---|---|---|
scripts\setup_venv.ps1 |
-PythonExe, -UpgradePip |
Create .venv and install requirements.txt |
scripts\check_environment.ps1 |
-SuricataExe, -SuricataConfig |
Audit Admin rights, Python, Npcap, Suricata -T, interfaces |
scripts\start_suricata.ps1 |
-Mode (live|replay|test), -Interface, -PcapPath |
Render config/suricata.yaml and launch Suricata |
scripts\start_sentinel.ps1 |
-NoHoneypot, -EnableActiveResponse, -DashboardPort |
Launch Streamlit UI alongside sentinel.py run --mode live |
scripts\revert_all.ps1 |
-SessionId, -AllSessions, -LiveSweep |
Emergency Kill Switch calling response.revert_all + sweep |
scripts\simulate_attacks.py |
scenario, --target, --delay |
Safe lab traffic generator (12 scenarios, private IPs only) |
Generated runtime files remain excluded from Git tracking via .gitignore:
config/suricata.yaml: Rendered locally bystart_suricata.ps1fromconfig/suricata.yaml.template(gitignored).logs/eve.json,logs/fast.log,logs/suricata.log,logs/stats.log: Suricata captures and engine logs (gitignored).logs/honeypot_events.jsonl: Captured decoy interactions with sensitive keys (password=,secret=,token=) masked inpayload_preview(gitignored).logs/response_audit.jsonl: Append-onlyos.fsyncpre-execution intent, execution outcome, and reversion trail (gitignored).data/sentinel_forensics.db: SQLite WAL forensic database (-wal,-shm,-journalexcluded via gitignoreddata/and*.db*).ml_anomaly/models/*.joblib,*.pkl,baseline_metrics.json: Trained local Isolation Forest models and baseline statistics (gitignored).
Note
Operational logs pass through RedactingFormatter
(core/logging_utils.py), YAML loaders strictly reject
quoted "false" overrides and unsafe firewall_rule_group values
(core/config.py), and dashboard CSV exports neutralize Excel
formula prefixes (=, +, -, @, \t, \r).
flowchart LR
NET["Lab Traffic (Npcap / PCAP)"] --> SUR["Suricata 8 (local.rules)"]
SUR -->|"eve.json"| TAIL["MultiFileTailer"]
HP["Local Honeypot (2222 / 8088)"] -->|"honeypot_events.jsonl"| TAIL
TAIL --> NORM["EventNormalizer + MITRE"]
NORM --> CORR["CorrelationEngine (Event-Time Windows)"]
NORM --> ML["ML Anomaly Layer (Isolation Forest)"]
ML --> CORR
NORM --> DB[("SQLite Forensic Store (WAL)")]
CORR --> DB
CORR --> RESP["ResponseEngine (Allowlist + Dry-Run Default)"]
RESP -->|"1. Sync Audit First"| AUDIT[("response_audit.jsonl + SQLite")]
RESP -->|"2. Log / Toast / Quarantine"| FW["Windows Defender Firewall"]
KILL["Kill Switch (revert_all.ps1 / .py)"] --> FW
DB --> DASH["Streamlit SOC Dashboard"]
| Path | Responsibility |
|---|---|
| sentinel.py | Unified CLI orchestrator (SentinelPipeline, run_live, run_replay, honeypot, train-ml, revert) |
| core/models.py | Canonical frozen dataclasses, UTC helpers, verified MITRE catalog (core/mitre.py), YAML loader (core/config.py) |
| rules/local.rules | 12 custom Suricata rules (1000001–1000012) embedding MITRE tactic/technique metadata |
| storage/repository.py | WAL-mode SQLite schema (storage/schema.sql: 5 tables + immutable audit table + unified_timeline) |
| correlation/engine.py | Partial-line tailer (eve_tailer.py), normalizer.py, HostWindowStore, and CORR-001–CORR-005 |
| ml_anomaly/detector.py | 10s host feature_extractor.py, shuffled holdout trainer.py, and AnomalyDetector |
| honeypot/server.py | Asyncio decoy SSH (fake_ssh.py) and HTTP /admin (fake_http.py) |
| response/engine.py | Fail-closed allowlist.py, audit.py, firewall.py, notifier.py, and revert_all.py |
| dashboard/app.py | Streamlit SOC console (charts.py, queries.py, theme.py) |
| scripts/simulate_attacks.py | Setup, environment check, Suricata runner, sentinel launcher, kill switch, and safe lab simulators |
| config/settings.yaml | Settings, allowlist.yaml, suricata.yaml.template, and capture notes |
| tests/test_audit_fixes.py | 35 unit, integration, honeypot, AppTest, and regression tests + synthetic PCAP/EVE fixtures |
| docs/architecture.md | windows_suricata_setup.md, ml_methodology.md, limitations_and_gaps.md, demo_script.md |
| SID | Rule Summary | Mechanism | MITRE Technique | Tactic |
|---|---|---|---|---|
1000001 |
ICMP Sweep Detection | itype:8, threshold count 5 / 10s (above 4-ping Windows baseline) |
T1018 Remote System Discovery |
Discovery (TA0007) |
1000002 |
TCP SYN Port Scan | flags:S,CE, threshold count 15 / 10s |
T1046 Network Service Discovery |
Discovery (TA0007) |
1000003–1000006 |
SSH / RDP / FTP Brute Force | detection_filter count 5 / 30s + FTP PASS/530 (tracks attacker IP) |
T1110.001 Password Guessing |
Credential Access (TA0006) |
1000007 |
Scanner HTTP User-Agent | http.user_agent PCRE (sqlmap, nikto, nmap, SentinelScanner, etc.) |
T1595 Active Scanning |
Reconnaissance (TA0043) |
1000008 |
Plaintext HTTP POST Credentials | http.method:POST + http.request_body password/token match |
T1040 Network Sniffing |
Credential Access (TA0006) |
1000009 |
Test Malicious C2 DNS | dns.query matching RFC-reserved .invalid lab domain |
T1071.004 DNS C2 |
Command and Control (TA0011) |
1000010–1000011 |
High SYN / UDP Flood Volume | TCP SYN 100 / 5s & UDP 150 / 5s thresholds |
T1498.001 Direct Network Flood |
Impact (TA0040) |
1000012 |
Custom Rule: Traversal / Secret Probe | http.uri matching ../, %2e%2e, /.env, /.git/config, /etc/passwd |
T1190 Exploit Public-Facing App |
Initial Access (TA0001) |
| Rule ID | Title | Signals Combined | Window | Output Tier (Confidence) |
|---|---|---|---|---|
CORR-001 |
Likely Active Intrusion Attempt | Recon (T1018 / T1046 / T1595) → Credential Access (T1110 / T1040) |
60s |
HIGH (85%) · T1110 |
CORR-002 |
Confirmed Hostile Reconnaissance | Local Honeypot Hit (is_honeypot=True) + Real-Host Suricata Alert |
120s |
CRITICAL (95%) · T1595 |
CORR-003 |
Post-Probe C2 or Credential Staging | Prior Probe/Brute/Exploit/Honeypot → Malicious DNS (T1071.004) / T1040 |
180s |
HIGH (85%) · T1071.004 / T1040 |
CORR-004 |
Behavioral Anomaly + Weak Signal | ML Outlier (IsolationForest) + >= 3 unique ports or weak Suricata alert |
90s |
HIGH (80%) · T1046 |
CORR-005 |
Confirmed Volumetric Flood Attack | Volumetric DoS alert (T1498.001) + ML traffic-rate outlier |
30s |
CRITICAL (90%) · T1498.001 |
Important
The IsolationForest layer is strictly a supplementary behavioral
heuristic, not a replacement for deterministic Suricata rules.
- 7 Per-Host Features (10s Event-Time Windows,
min_packets_per_window=3):packets_per_sec,bytes_per_sec,unique_dest_ports,unique_dest_ips,flows_per_sec,avg_bytes_per_packet, andunestablished_flow_ratio. - Synthetic Benchmark: Verified in
tests/test_ml_anomaly.py across 40 benign 10s
windows (
contamination=0.03,n_estimators=150), holdout validation FPR measured<= 15%while flagging an injected 10-port unestablished probe window (192.168.56.99) below Suricata's 15-port signature threshold (CORR-004candidate).
All 35 automated tests (pytest) pass across config safety, MITRE lookup,
tailer rotation, SQLite WAL timelines, correlation rules, ML scoring, async
honeypot handling, allowlist/kill-switch guarantees, Streamlit AppTest UI, and
regression checks:
# Run full pytest suite offline using fixtures and mocked firewall runners
.\.venv\Scripts\python.exe -m pytest -v
# Check cyclomatic complexity, style rules, and Suricata syntax
flake8 --max-complexity=12 --max-line-length=100 `
core storage correlation ml_anomaly honeypot `
response dashboard sentinel.py scripts tests
powershell -ExecutionPolicy Bypass -File scripts\start_suricata.ps1 -Mode testWarning
Live Windows Defender Firewall New-NetFirewallRule and
Remove-NetFirewallRule calls are mocked in
tests/test_response_allowlist.py so automated tests never modify host
firewall state. Live Suricata NIC capture requires Admin PowerShell and
Npcap installed.
Detailed notes live in docs/limitations_and_gaps.md:
- Slow-Scan Evasion (
slow-scan): Probing 1 TCP port every 6–10 seconds stays below Suricata's15 SYNs / 10sthreshold (sid:1000002) and can fall undermin_packets_per_window=3within 10s ML buckets. - Encrypted Protocol Visibility: Post-handshake SSH/RDP authentication relies on connection-rate heuristics, and TLS/HTTPS hides URIs, headers, and POST credentials without authorized TLS inspection.
- Windows Loopback Crash (
Suricata 8.0.8): Live capture on\Device\NPF_Loopback(DLT_NULL) triggers anmsvcrt.dll(0xc0000005) access violation in Suricata8.0.8on Windows 11. Live multi-host capture uses VMware/LAN adapters (e.g.,192.168.182.1), while single-machine tests use offline PCAP replay (-Mode replay). - Windows Loopback Firewall Bypass: Pure
127.0.0.1loopback IPC skips standardNew-NetFirewallRule -RemoteAddressfilters (and127.0.0.1is hard-allowlisted), so live packet-drop quarantine requires a VM or LAN peer. - Flow Emission Lag & Workstation Noise:
event_type: "flow"emits on flow closure or timeout, and noisy dev updates require a clean 10–15 minute baseline for ML calibration.
| Component | Technology |
|---|---|
| Packet Inspection & Rules | Suricata 8.0.8 MSI + Npcap + custom local.rules with MITRE metadata |
| Core Runtime & Orchestration | Python 3.11+ (3.13), watchdog, PyYAML |
| Forensic Storage | SQLite (WAL mode, parameterized queries, unified_timeline SQL view) |
| ML Behavioral Anomaly Layer | scikit-learn (StandardScaler + IsolationForest), NumPy, Pandas, joblib |
| Deception Listeners | Python asyncio bounded SSH (2222) & HTTP /admin (8088) servers |
| Automated Response & Audit | Windows Defender Firewall (NetSecurity PowerShell), winotify, synchronous os.fsync JSONL + SQLite |
| SOC Dashboard | Streamlit (@st.fragment non-blocking refresh) + Plotly + Obsidian CSS theme |
| Testing & Quality | pytest, pytest-asyncio, Streamlit AppTest, flake8 |
- Operate SentinelIDS strictly on loopback (
127.0.0.1), personal lab VMs, or networks you own or hold explicit written permission to monitor. - Simulation scripts (
scripts/simulate_attacks.pyandscripts/sim_traffic_baseline.py) hard-block non-loopback/non-RFC1918 IPs. - Keep
response.dry_run: trueunless intentionally testing supervised quarantine rules against an isolated lab VM, and verify rollback anytime viascripts\revert_all.ps1 -AllSessions -LiveSweep.
- License: MIT License — see LICENSE for full terms.
- Program: CodeAlpha Cyber Security Internship (
CodeAlpha_SentinelIDS). - Open-Source Ecosystem: Suricata, Npcap, Streamlit, Plotly, scikit-learn, Watchdog, NumPy, Pandas, PyYAML, winotify, and pytest.
Developed by Jaindu De Zoysa — CodeAlpha Cyber Security Internship (Task 04)