How karib0u/rustinel works
1. What this repo is
Rustinel is a Windows-only, user-mode EDR agent. Its core architecture is a pipeline: ETW telemetry in, normalization/enrichment in the middle, detection/response decisions after that, and ECS NDJSON alerts/logs out to disk for SIEM ingestion.
2. Top-level runtime boundary
The main executable is src/main.rs, with shared application logic in src/lib.rs. There is also a separate maintenance binary, src/bin/validate_rules.rs, for validating Sigma/YARA rule files. The repo is organized as a long-running agent, not a request/response service.
3. Telemetry collection layer
src/collector/ is the ingestion boundary. Per the README, it collects kernel telemetry via ETW for process, network, file, registry, DNS, PowerShell, WMI, services, and tasks. This layer also applies some noise reduction early, such as keyword filtering and router-level filtering for high-volume event types.
4. Normalization and schema mapping
src/normalizer/ converts raw ETW events into a Sysmon-compatible internal schema. This is the key adapter layer that makes downstream Sigma rules usable. The mapping/field translation logic lives in field_maps.rs and mapper.rs, which suggests a deliberate separation between raw event shapes and the normalized event model.
5. Core event model
src/models/ecs.rs and src/models/mod.rs define the output-facing ECS structure. The alert payloads are designed to be ECS NDJSON lines, which is the architectural contract with downstream log shipping and SIEM tooling.
6. Detection engines are split by modality
src/engine/ is the Sigma behavioral detection engine. src/scanner/ is the YARA file-scanning worker. src/ioc/ handles atomic IOC matching for hashes, IPs/CIDRs, domains, and path regexes. These are intentionally separate because they operate on different event types and have different performance characteristics.
7. Where detection happens in the flow
Sigma runs on normalized telemetry events, YARA is triggered on process creation and runs in a background worker, and IOC checks are mixed between inline checks and background hashing. The design keeps the hot path light by only attaching expensive context and doing heavier work when needed.
8. State and correlation services
src/state/ is the shared cache/correlation layer. The README calls out process correlation, SID-to-username resolution, DNS caching/reverse mapping, and optional connection aggregation, so this module likely backs cross-event enrichment and deduplication. This is the main in-memory boundary that makes alerts more contextual than the raw ETW stream.
9. Enrichment and utility boundaries
src/utils/ contains supporting cross-cutting helpers: path normalization, PE metadata extraction, process/user helpers, time, and log rate limiting. These utilities support enrichment without polluting the collector or detection logic, which keeps the pipeline modular.
10. Alerting and active response
src/alerts.rs and src/response/ are the output/actuation side. Alerts are written as daily ECS NDJSON files, while active response can optionally terminate processes on critical detections. This is a clean separation between “observe and record” and “enforce.”
11. Hot reload and operational control
src/reload/ manages in-place reloading of Sigma, YARA, and IOC files with debounce and atomic swaps. src/config.rs owns configuration precedence across defaults, config.toml, environment variables, and CLI flags. This means the agent can be tuned and updated without restarting, which is important for endpoint operations.
12. External interfaces and deployment shape
The agent supports Windows service mode and console mode, but it remains a single-host, local-first product: rules live on disk under rules/, alerts/logs go to local files under logs/, and ingestion happens directly from ETW rather than from a remote backend. The repo also includes docs, examples, and CI workflows, but those support the agent rather than defining runtime architecture.
13. Architecture summary in one sentence
ETW events enter through a user-mode collector, are normalized into a Sysmon-like internal schema, enriched from local state/caches, evaluated by Sigma/YARA/IOC engines, and then emitted as ECS alerts or used for optional active response.
Main entry points: normalizer/mod.rs Normalizer · lib.rs Core Lib · collector/mod.rs Collector · engine/mod.rs Sigma Engine
Components 21
Runtime
Long-running agent entrypoints and operational control.
- Agent · Windows service/console entrypoint for the EDR agent.
src/main.rs - Core Lib · Shared application logic used by the binaries.
src/lib.rs - Rule Check · Standalone validator for Sigma and YARA rule files.
src/bin/validate_rules.rs - Config · Configuration precedence and runtime options.
src/config.rs
Pipeline
Telemetry ingestion, normalization, enrichment, and alerting flow.
- Collector · Kernel telemetry ingestion and early noise reduction.
src/collector/mod.rs - Normalizer · Maps raw ETW events into a Sysmon-like internal schema.
src/normalizer/mod.rs - Field Maps · Field translation and schema mapping definitions.
src/normalizer/field_maps.rs - Mapper · Transforms raw events into normalized event models.
src/normalizer/mapper.rs - Alerts · Writes ECS NDJSON alerts and logs to disk.
src/alerts.rs - Response · Optional process termination on critical detections.
src/response/mod.rs
Detection
Rule engines and matching modalities.
- Sigma Engine · Sigma rule evaluation over normalized telemetry.
src/engine/mod.rs - Handler · Event handling and detection dispatch logic.
src/engine/handler.rs - YARA Scanner · Background file scanning worker for YARA rules.
src/scanner/mod.rs - IOC Match · Hash, IP, domain, CIDR, and path-regex matching.
src/ioc/mod.rs
Support
Shared state, models, and utilities.
- State · Process correlation, DNS cache, SID lookup, and aggregation state.
src/state/mod.rs - Utils · Cross-cutting enrichment helpers for path, PE, process, user, and time.
src/utils/mod.rs - ECS Models · ECS-facing alert and log structures.
src/models/mod.rs - ECS · NDJSON alert/log record definitions.
src/models/ecs.rs
Rules
On-disk rule packs and validation tooling.
- Sigma Rules · On-disk Sigma detection rules.
rules/sigma/example_whoami.yml - YARA Rules · On-disk YARA scanning rules.
rules/yara/example_test_string.yar - IOC Lists · On-disk IOC lists for hashes, domains, IPs, and regex paths.
rules/ioc/hashes.txt
Connections 21
- Agent → Core Lib: uses · Main runtime is built on shared library logic.
- Rule Check → Sigma Rules: checks · Validates Sigma rule files.
- Rule Check → YARA Rules: checks · Validates YARA rule files.
- Core Lib → Config: loads · Configuration is initialized from shared startup logic.
- Core Lib → Collector: starts · Agent boots the ETW collector.
- Collector → Normalizer: emits · Raw telemetry is passed into normalization.
- Normalizer → Field Maps: uses · Schema translation relies on field maps.
- Normalizer → Mapper: applies · Event mapping is performed by the mapper.
- Normalizer → State: enriches with · Normalized events are correlated with shared state.
- Normalizer → Utils: calls · Normalization uses common helper utilities.
- Normalizer → Sigma Engine: feeds · Sigma evaluates normalized telemetry.
- Collector → IOC Match: inline checks · High-volume telemetry can be filtered or matched early.
- Core Lib → YARA Scanner: spawns · Process creation can trigger background YARA scanning.
- YARA Scanner → YARA Rules: loads · YARA worker consumes local rule files.
- Sigma Engine → Handler: dispatches · Matches are routed through the engine handler.
- Sigma Engine → Sigma Rules: evaluates · Sigma detection uses local Sigma rules.
- IOC Match → IOC Lists: loads · IOC matcher reads local hash/IP/domain/path lists.
- Handler → Alerts: writes · Detections are written as ECS NDJSON alerts.
- Handler → Response: may trigger · Critical detections can invoke active response.
- Alerts → ECS Models: formats as · Alert output is shaped by ECS models.
- ECS Models → ECS: defines · ECS payload structure is implemented in the ECS module.