Wirewolf is a high-performance, local AI-driven network threat detection engine built in C++. It analyzes network traffic in real-time or from offline capture files. The pipeline captures packets, reassembles TCP flows, and passes the payloads to a local Large Language Model (Llama 3.1 8B) to identify and classify potential threats into structured JSON alerts.
- Packet Capture (Npcap / Offline PCAP): Sniffs raw packets from a network interface or reads from
.pcapfiles. - TCP Reassembly: Reconstructs interleaved packets back into continuous application-layer payloads.
- Primary Filtration (Statistical / OpenVINO): Anomaly detection pre-filter using entropy analysis, packet variance, inter-arrival timing, and suspicious character ratios. Optional OpenVINO acceleration.
- Threat Analysis (LLM / llama.cpp): Analyzes raw reassembled payloads using a quantized
Llama-3.1-8B-Instructmodel on NVIDIA GPU (CUDA). - JSON Structuring: Outputs strict JSON format for easy ingestion by SIEM or logging dashboards.
We have implemented several layers of protection against the "Reality Check" limitations of local LLM inference:
- Context Window Truncation: Payloads are truncated to a configurable limit (default 2048 characters) before tokenization, preventing VRAM exhaustion.
- Asynchronous Processing: A Thread-Safe Queue with configurable capacity (default 1024 items) decouples capture from inference. Overflow items are dropped with tracking, ensuring the capture engine stays live.
- Statistical Pre-Filter: Entropy analysis, packet length variance, inter-arrival timing, and suspicious character ratio detection filter ~85% of benign traffic before reaching the LLM.
- Hallucination Suppression: The inference engine utilizes a Strict ChatML Few-Shot Template. This explicitly trains the model on examples of benign traffic (Kerberos, DNS, domain handshakes) to return
[Empty {}]instead of false positives. - Structured Logging: Timestamped, severity-leveled logging across all components with thread-safe output.
- Windows 10/11
- Visual Studio 2022 (Desktop development with C++)
- CMake (v3.20+)
- NVIDIA CUDA Toolkit (v12.x+)
- Npcap SDK (WinPcap compatibility enabled)
.\scripts\download_models.ps1The build script automatically handles llama.cpp and Npcap fetching:
.\build.ps1 # Standard build
.\build.ps1 -Test # Build + run unit tests
.\build.ps1 -OpenVINO # Build with OpenVINO support
.\build.ps1 -Test -Run # Build, test, then run.\build\Release\wirewolf.exe "\Device\NPF_{GUID}" "models\model.xml" "models\llama.gguf"Wirewolf automatically detects .pcap extensions and switches to offline mode:
.\build\Release\wirewolf.exe "C:\path\to\capture.pcap" "models\model.xml" "models\llama.gguf"--log-level N 0=DEBUG, 1=INFO (default), 2=WARN, 3=ERROR
--queue-capacity N Max items per pipeline queue (default: 1024)
--payload-limit N Max chars sent to LLM (default: 2048)
--max-tokens N Max LLM output tokens (default: 512)
--max-flow-size N Flow size trigger in bytes (default: 1MB)
--openvino Use OpenVINO model instead of statistical filter
--entropy-high F High entropy threshold (default: 7.0)
--entropy-low F Low entropy threshold (default: 1.0)
src/- Implementation (Reassembly, Filter, LLM Worker Loop).include/- Headers (Config, Logger, Thread-Safe Queue, Packet Types).tests/- Unit tests (Catch2).models/- Quantized LLM (GGUF) and OpenVINO IR files.scripts/- Automation scripts for builders and model fetching.CMakeLists.txt- Configuration for CUDA/OpenVINO/Llama/Catch2 linking.
Alerts are printed to stdout in strict JSON:
{
"threat_type": "SQLi",
"severity": "High",
"snippet": "SELECT * FROM users WHERE id='1' OR '1'='1'"
}If traffic is determined to be benign, the engine returns an empty object {}.