Application Name: BeneFacto
Version: 1.0.0
Language: C++17
Build System: CMake 3.16+
Target Platform: Linux (Ubuntu 20.04+, Debian 11+, RHEL/Rocky 8+)
BeneFacto is a Linux endpoint security agent designed with HIDS/EDR detection logic used to capture system telemetry, normalize observations into a canonical JSON schema, run real-time local correlation rules for threat detection, buffer events with disk spooling during backend outages, and stream batched payloads to security ingestion backends.
- Telemetry Collectors: Specialized collectors poll and stream data from
/proc,/sys,/var/log, andinotifywatchers across 7 subsystems (authentication, processes, network sockets, file integrity, USB devices, system logs, and application logs). - Canonical Normalizer: Converts heterogeneous system events into structured, typed objects with UUIDv4 identifiers, UTC timestamps, and standard severities.
- Context Enricher and Redactor: Automatically injects host identity (
host_id,hostname) and redacts passwords, tokens, private keys, and authorization headers from event payloads. - Correlation Engine: Evaluates streaming observations across a 5-minute sliding window against 6 multi-event attack detection rules, emitting high-confidence alerts upon match.
- Event Queue and Disk Spooler: In-memory ring buffer backed by an encrypted disk spool (
/var/lib/skynet/spool, 100 MB limit) to prevent data loss during network disconnection or backend backpressure. - Transport Layer: Dispatches JSON batches to HTTP endpoints or writes formatted events and alerts to disk (
events.jsonl,alerts.json). - Deep Scanner: Standalone or scheduled inventory scanner for installed packages, desktop software, database instances, systemd services, and SUID/SGID privileged binaries.
Every observation captured by any collector conforms to the following schema:
{
"event_id": "00000000-0000-4000-8000-000000000002",
"schema_version": "1.0.0",
"event_type": "auth.login_failed",
"category": "auth",
"timestamp": "2026-10-04T12:01:01Z",
"observed_at": "2026-10-04T12:01:01Z",
"host_id": "be7a4e61-9c88-4fb0-a29d-43cf1812e911",
"hostname": "prod-srv-01",
"actor": "192.168.1.100",
"severity": "low",
"source": "/var/log/auth.log",
"collector_status": "ok",
"related_event_ids": [],
"details": {
"auth_method": "password",
"ip": "192.168.1.100",
"port": 48922,
"user": "admin"
}
}- Severity:
info,low,medium,high,critical - Category:
auth,process,file,network,system,usb,application,error,agent
| Collector | Data Sources | Monitored Activity | Default Interval |
|---|---|---|---|
| Auth | /var/log/auth.log, /var/log/secure |
Failed and successful logins, sudo elevations, user creation, group changes | 5s |
| Process | /proc, /proc/[pid]/stat, /proc/[pid]/cmdline |
Process lifecycles, PID/PPID hierarchy, command lines, memory spikes, /tmp execution |
10s |
| Network | /proc/net/tcp, /proc/net/udp, /proc/net/arp |
Active sockets, listening ports, outbound connections, ARP cache changes | 15s |
| File | Watched directories (/etc, /root, /home) |
File creation, modification, deletion, permission changes, /etc/shadow access via inotify |
10s |
| USB | /sys/bus/usb/devices, /proc/mounts |
Device connection, mounting, unmounting, binary execution from removable media | 5s |
| System | /var/log/syslog, /dev/kmsg |
Kernel panics, segfaults, OOM kills, permission denials, log truncation | 10s |
| Application | Web/DB logs, crontabs, browser configs, /dev/video* |
404 scanning, SQL auth failures, cron persistence, extensions, camera/mic access | 15s |
The correlation engine maintains state across a 5-minute sliding window to identify multi-stage attack scenarios:
- Trigger: 5 or more
auth.login_failedevents from the same source IP or user followed byauth.login_successorauth.root_login. - Severity: Critical (Confidence: 0.95)
- Explanation: Indicates automated credential guessing succeeded.
- Trigger:
auth.user_createdfollowed immediately byauth.group_changeadding that account tosudo,wheel, oradmin. - Severity: Critical (Confidence: 0.90)
- Explanation: Common pattern for establishing backdoor persistence.
- Trigger:
usb.device_connectedfollowed byusb.drive_mounted, followed byprocess.startedwhere the binary path is located inside the mount point. - Severity: Critical (Confidence: 0.85)
- Explanation: Indicates USB-delivered payload or automated autorun execution.
- Trigger: A web server daemon (
nginx,apache2,httpd,node,php-fpm) spawns a shell or interpreter (bash,sh,python,perl,ruby). - Severity: Critical (Confidence: 0.90)
- Explanation: Web shell execution or remote code execution vulnerability.
- Trigger: File dropped into
~/Downloadsfollowed by an execution event of that file. - Severity: High (Confidence: 0.80)
- Explanation: Drive-by download or phishing payload execution.
- Trigger:
system.log_tampering(file truncation or clearing) occurring within the same time window as other events with severity medium or higher. - Severity: Critical (Confidence: 0.85)
- Explanation: Attacker clearing system logs to cover recent activity.
- Secret Redaction: Regex-based sanitization strips passwords (
password=***), API tokens (Bearer ***), SSH private keys, and long base64 strings prior to queuing or disk output. - Zero-PII Testing: Telemetry fixtures and test cases use standardized enterprise placeholders (
sysadmin,/home/user,corporate-intranet.local) rather than personal host paths. - Resilient Spooling: In-memory ring buffer (10,000 events) flushes to disk when backend connections fail, preventing process memory exhaustion.
- Log Rotation Handling: Log watchers track underlying file inodes and file offsets to handle
logrotatetruncation and replacement without event loss.
- C++17 compiler (GCC 9+ or Clang 10+)
- CMake 3.16+
- POSIX threads (
pthread)
sudo apt-get update
sudo apt-get install -y build-essential cmakemkdir build
cd build
cmake ..
cmake --build .# Schema validation and redactor tests
./test_schema
# Attack scenario correlation rules tests
./test_correlator
# Fixture replay verification (verifies all 6 attack rules trigger on reference data)
./test_fixture_replay
# Deep scanner component tests
./test_deep_scan
# Run all tests via CTest
ctest --output-on-failure# Start live monitoring with default configuration:
./skynet-agent --config config/skynet.json
# Start live monitoring with verbose debug logs:
./skynet-agent --config config/skynet.json --debug
# Replay an event fixture file:
./skynet-agent --replay fixtures/events.jsonl
# Run a deep system inventory scan (packages, apps, databases, SUID binaries):
./skynet-agent --deep-scan
# Save deep scan inventory to a JSON file:
./skynet-agent --deep-scan scan_report.json
# Target a specific directory for deep binary scanning:
./skynet-agent --deep-scan scan_report.json --scan-dir /optReference fixtures for backend engineers implementing ingestion APIs are located in fixtures/:
fixtures/batch_payload.json: Full HTTP POST payload containing host snapshot, event batch, and correlated alerts.fixtures/events.jsonl: 21 chronological events covering baseline activity and attack chains.fixtures/alerts.json: The 6 corresponding alerts generated by the correlation engine.fixtures/host.json: Host metadata schema snapshot.fixtures/BACKEND_SCHEMA_GUIDE.md: Schema, field types, and database indexing recommendations.