Stealthy DNS Threat Detection & Intelligence Engine
SPECTRE is an intelligent DNS threat detection engine that identifies covert tunneling, anomalous DNS behavior, suspicious query patterns, and potential data exfiltration through real-time traffic analysis, behavioral correlation, and unsupervised machine learning.
SPECTRE addresses the challenge of identifying DNS-based threats hidden within legitimate network traffic. Its hybrid detection architecture combines deterministic analysis, statistical baselining, and machine learning to identify suspicious DNS activity and generate explainable risk assessments.
Unlike conventional threshold-based monitoring, SPECTRE evaluates multiple behavioral indicators and correlates them into a unified risk score, helping security analysts distinguish potentially malicious DNS activity from normal network behavior.
- Real-Time DNS Monitoring — Captures and analyzes UDP and TCP DNS traffic using Scapy.
- DNS Tunneling Detection — Identifies suspicious query lengths, high-entropy labels, encoded patterns, and abnormal subdomain structures.
- Behavioral Analysis — Detects unusual query frequencies, unique-subdomain ratios, TXT record concentration, and NXDOMAIN spikes.
- Statistical Baselining — Maintains rolling per-host behavioral baselines to identify deviations from normal DNS activity.
- Machine Learning Detection — Uses an unsupervised Isolation Forest model to identify anomalous DNS patterns.
- Explainable Risk Scoring — Correlates multiple detection signals into a unified 0–100 risk score with supporting evidence.
- Dynamic Target Scoping — Supports IP addresses, CIDR networks, hostnames, domains, and URLs.
- Live Monitoring Dashboard — Provides real-time event visibility, severity classification, and dynamic target switching.
- Persistent Event Logging — Stores detection events in JSON with a dedicated log monitoring utility.
SPECTRE implements a layered hybrid detection pipeline designed to identify DNS threats through multiple independent signals.
| Layer | Module | Responsibility |
|---|---|---|
| 01 | Feature Extraction | Extracts lexical, encoding, and behavioral DNS features. |
| 02 | Rule Engine | Applies weighted deterministic detection rules. |
| 03 | Statistical Analysis | Identifies deviations using rolling per-host baselines. |
| 04 | ML Anomaly Detection | Uses Isolation Forest for unsupervised anomaly scoring. |
| 05 | Correlation Engine | Combines detection signals into an explainable risk verdict. |
| 06 | Event Storage | Persists findings and provides historical event access. |
| Score | Severity |
|---|---|
| 85–100 | CRITICAL |
| 70–84 | HIGH |
| 50–69 | SUSPICIOUS |
| 25–49 | LOW |
| 0–24 | BENIGN |
| Component | Function |
|---|---|
main.py |
CLI orchestration, privilege management, and execution control. |
collector/ |
Asynchronous DNS packet capture using Scapy. |
core/ |
Configuration, target parsing, and monitoring scope management. |
features/ |
Lexical, entropy, encoding, and frequency feature extraction. |
detection/ |
Rule-based analysis, statistical baselines, ML scoring, and correlation. |
dashboard/ |
Flask-based live monitoring interface and API endpoints. |
storage/ |
Thread-safe JSON event persistence and retrieval. |
Loggings.py |
Standalone detection log monitoring utility. |
tests/ |
Automated tests for detection logic, target scoping, and collector behavior. |
config.yaml |
Detection thresholds and rule-weight configuration. |
- Python 3.9+
- Scapy 2.5+
- Flask 3.0+
- NumPy
- Scikit-learn
- PyYAML
- Colorama
- libpcap (Linux) or Npcap (Windows)
Linux is recommended for packet capture and deployment.
git clone https://github.com/project-hellhound-org/Spectre.git
cd SpectreDebian / Kali Linux:
sudo apt update
sudo apt install python3 python3-venv python3-pip libpcap-devpython3 -m venv venv
source venv/bin/activatepip install -e .This registers the following commands:
dnstune— Main DNS monitoring engine.dnstune-logs— Standalone detection log viewer.
Start monitoring a specific IP address, network, or domain:
dnstune 192.168.1.100dnstune 192.168.1.0/24dnstune example.comSPECTRE also accepts full URLs and prompts for a target when launched without one.
Specify the interface used for packet capture:
dnstune 192.168.1.0/24 --interface eth0Launch SPECTRE using a custom dashboard port:
dnstune 192.168.1.0/24 --port 8080Disable automatic browser launching:
dnstune 192.168.1.0/24 --no-browserThe dashboard is served locally at:
http://127.0.0.1:5000
SPECTRE provides an interactive console for managing monitoring sessions.
| Command | Description |
|---|---|
status |
Displays the current monitoring scope and event statistics. |
swap <target> |
Changes the monitoring target without restarting. |
swap all |
Removes target restrictions. |
logs |
Opens the integrated detection log viewer. |
quit |
Terminates the monitoring session. |
Example:
dnstune> status
dnstune> swap 10.0.0.0/24
dnstune> logs
dnstune> quit
Run SPECTRE without the interactive console:
dnstune 192.168.1.0/24 --no-repl --no-browserFor persistent background operation, use nohup or the included systemd service template.
Access historical and live detection events:
dnstune-logsDisplay the latest 50 events:
dnstune-logs --no-follow --limit 50Filter high-severity findings:
dnstune-logs --severity HIGHCustomize detection thresholds and scoring weights through config.yaml.
detection:
entropy_threshold: 4.2
max_fqdn_length: 50
max_label_count: 5
window_seconds: 300
qps_threshold: 5.0
txt_ratio_threshold: 0.5
nxdomain_ratio_threshold: 0.3SPECTRE supports configurable detection thresholds and weighted rule scoring, allowing monitoring behavior to be adjusted for different network environments.
Run the built-in self-test:
dnstune --self-testExecute the automated test suite:
pip install -e ".[dev]"
python3 -m pytest tests/ -vTests cover detection rules, lexical analysis, target parsing, network capture orchestration, and privilege handling.
- SOC Operations: Monitor DNS traffic and identify suspicious communication patterns.
- Threat Hunting: Investigate potential DNS tunneling and covert communication channels.
- Data Exfiltration Detection: Identify unusual DNS query structures and behavioral indicators associated with potential data leakage.
- Network Security Monitoring: Establish behavioral baselines and detect anomalous DNS activity.
- Security Research: Analyze DNS-based attack techniques in controlled environments.
- Incident Investigation: Review historical DNS events and correlate suspicious activity using detection evidence.
- Monitors conventional DNS traffic over UDP and TCP port 53.
- Requires packet capture privileges and a supported packet capture backend.
- Does not directly inspect encrypted DNS protocols such as DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT).
- Machine learning anomaly scoring requires sufficient historical feature data before meaningful model scoring begins.
- Detection results are risk assessments, not definitive proof of malicious activity.
- Domain grouping currently uses a simplified registered-domain heuristic.
Developed by Project Hellhound
Part of the Project Hellhound ecosystem.
