Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.

Live LLM-investigator demo on our own ETW collector (idle baseline) - #6

Merged
ngodat0103 merged 8 commits into
mainfrom
make-sure-to-support-llm-investigator
Oct 31, 2026
Merged

ngodat0103 merged 8 commits into
mainfrom
make-sure-to-support-llm-investigator

Conversation

@ngodat0103

Copy link
Copy Markdown
Member

Makes the live OCR-APT demo work end to end on our own data, and proves the core
concept: benign stays green, a real DVWA->RCE attack goes red with an LLM verdict.

Collector + transport

  • Own Python ETW collector (etwcollect, src/etw-python) replacing SilkETW/SilkService
    and Grafana Alloy; it ships SilkETW-format lines to Loki itself. Fixes the kfile lag
    (SilkService's per-event writes fed back into Kernel-File) and the NET-owner bug.

LLM investigator

  • DeepSeek provider; always-on live capture; LLM triage + Alg. 2 report on red windows.
  • Render the LLM report as HTML in the live UI (headings, lists, GFM IoC table, code).

Benign = idle, pulled from Loki

  • Dropped the scripted benign workload: it reused the attack's living-off-the-land
    binaries, so exp04 scored the attack benign. Switched to benign = idle pulled straight
    from Loki; removed both capture scripts, the win_benign role, and collect-train.yml.

Verified live (exp05, session live-20261031T134030Z)

  • Idle windows green (<= Minor 8.0); DVWA->RCE window red (subgraph 106.96, Significant,
    alert True) flagging the attacker stage IP, downloaded_tool.bin and the RCE powershell;
    LLM triage "attack" (0.85) + report; rejudge.sh reproduces it offline.

ngodat0103 and others added 8 commits October 25, 2026 13:38
Add --llm-provider deepseek (model deepseek-flash = DeepSeek-V4.1-Flash-1017,
https://api.deepseek.com, OpenAI-compatible). A Cloudflare Workers AI attempt
for the same model was dropped: the account's Free plan refuses it (403, code
5035) and unlocking it needs a paid plan or AI Gateway credits.

The key resolves as --llm-api-key > $NT2102_DEEPSEEK_API_KEY >
~/.config/nt2102/credentials.json > a hidden terminal prompt that saves it
there (dir 0700, file 0600, atomic, other sections kept) and says so. The
unprefixed DEEPSEEK_API_KEY is deliberately not read. Without a terminal the
start fails with a message naming the flag, env var and file.

--llm-reasoning-effort none|low|high|max maps to DeepSeek's reasoning_effort,
or to thinking disabled for "none" (fastest, temperature 0 applies again).
--llm-debug / NT2102_LLM_DEBUG=1 prints each call's raw response (including
reasoning_content) or HTTP error body to stderr and keeps it as "raw" in
calls.jsonl. A cut answer (finish_reason=length) always warns. A leading
<think> block in content is stripped before parsing.

Selftests cover key precedence, the prompt/save path and file modes, and,
through the openai SDK against an httpx.MockTransport, the request shape,
the effort mapping, debug capture and a 401. User-verified real run: the
11:25 updater window of live-20261011T112141Z is judged false_positive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live capture (ws-etw): start-live.ps1 becomes a watchdog run by the SYSTEM
scheduled task etwlab-live (at boot + every 5 min). One tick keeps a
test/live-<UTC> SilkETW run capturing: starts one when SilkService is
stopped, rotates it every 6 h, deletes raw live-* runs idle for 1 day, and
leaves SilkService alone while C:\ProgramData\etwlab\live.hold exists or a
train / hand-started test capture runs. A fresh run per start is needed
because SilkService reads its output folder only at service start, so a
plain auto-start would append to the last (possibly training) run. By hand:
-Status, -Rotate (clean demo session), -Pause / -Resume. A machine-wide
mutex keeps a manual call and a task tick apart.

07-build-train-dataset.ps1 pauses a running live capture for the train
capture: it writes the hold (with its PID, so a crashed run's hold is
dropped as stale), stops live, and removes the hold in its finally.

Trainer: live_llm_args (empty = off; inventory.local.ini sets DeepSeek,
thinking off, --llm-debug) is appended to the ocr-live ExecStart, and a
non-empty value makes uv sync / uv run include the llm group. The key is
never an Ansible variable: it is saved once on the trainer with
alg2.py --ping, which sends one tiny prompt (exit 0 = answered) and prompts
for a missing key on a terminal. An hourly cron removes live-* sessions
with no write for 12 h (each keeps a ~2 GB/h raw copy, measured); a session
holding a .keep file is kept. Loki retention 30 d -> 3 d for the same
volume reason.

Checked: selftests (14/14), ansible --syntax-check, local template renders
(ExecStart unchanged when the LLM is off), and a PowerShell 5.1 parse of
start-live.ps1 and 07 on ws-etw (0 errors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
live_llm_args had a "" default in group_vars/all.yml, which outranks the
inventory's [ubuntu:vars], so the DeepSeek flags in inventory.local.ini
were silently ignored (and uv sync removed the llm group again). The
default is gone; the template and the uv sync task use
live_llm_args | default('').

replay.sh named every replay of a session "replay-raw" (a session's copy
is always raw/), so replays of different sessions shared one folder. A
session replay is now named replay-<session-id>.

Docs: the first live full-flow run with the LLM (2026-10-25) exposed a
collector blocker. SilkService writes Kernel-File events minutes late
(about 20-25 % of real-time speed from a fresh run, mostly its own writes
plus Alloy's reads), so the live engine drops every file event as late.
The Oct 22 live "attack detected" result had zero Read/Write edges and is
marked invalid (DEVIATIONS D8 correction). In the rerun no attack node was
flagged; the only red window was a benign msedge launch, which the LLM
correctly judged a false positive (D9). PROGRESS lists the kfile-lag
diagnosis as the next step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016bXvsQ3vTwv9ULcuM7piSa
SilkService (SilkETW v0.8) writes every event with File.AppendAllText, so each
line it writes adds Kernel-File events of its own; together with Alloy's reads
this loop left live windows without file events. Replace it with src/etw-python
(uv project, stdlib + ctypes): one real-time ETW session, TDH-decoded payloads,
the collector's own I/O dropped before formatting, one batched write per file
per second, and a shipper that pushes the run files to Loki with Alloy's labels.

- Vagrant mounts src/etw-python at C:\etw-python locally; cloud clones the repo.
- win_collector installs uv, builds the venv, registers the SYSTEM task
  etwlab-collector; etwctl/start-live/07 drive it (collector=python), Alloy is
  stopped and disabled. SilkService stays installed only until removal.
- Converter: network events take the owner from the payload PID (_PID); 77 % of
  knet events had a different header PID.
- Verified on ws-etw: live selftest, 20 s parity with SilkService (100 % of
  events matched, no field mismatch), live path late_dropped = 0.
- Docs: CLAUDE.md, DEVIATIONS D8/D10, PROGRESS, docs/notes/silkservice-kfile-lag.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCx5NxSphANRKqvrtUUw3W
etwcollect (src/etw-python) passed on ws-etw: live selftest, 20 s parity
with SilkService (kproc 620/620, kfile 88,612/88,612, knet 26/26, 0 field
mismatches), a 32-min lag test (kfile within +-4 s, EventsLost 0, ~10 % of
a core) and a Loki outage drain (Loki counts == file lines). So the
win_alloy role goes, win_collector uninstalls SilkService/SilkETW and
Alloy, etwctl/start-live/07 use the collector task, verify-windows asserts
both are gone, and the docs (CLAUDE.md, DEVIATIONS D10, PROGRESS, READMEs,
report, slides) describe the new collector. CLAUDE.md section 8 lists the
next steps: benign capture with 07, exp04, then the DVWA->RCE full flow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCx5NxSphANRKqvrtUUw3W
The scripted benign workload taught the one-class model the attack's own
living-off-the-land binaries (netcheck/download/files ran ipconfig/curl/
cmd/net), so on exp04 the live DVWA->RCE attack scored entirely below
threshold and raised no alert, while benign windows were green.

Switch the benign baseline to idle activity pulled directly from Loki (the
always-on live capture already ships it): no capture script at all. Against
an idle baseline the attack's discovery+RCE burst is out-of-distribution and
separates cleanly. Verified live (exp05, session live-20261031T134030Z):
idle windows green (<= Minor 8.0), the DVWA->RCE window red (subgraph 106.96,
Significant, alert True) flagging the attacker stage IP, downloaded_tool.bin
and the RCE powershell; LLM triage "attack" (0.85) + report; rejudge.sh
reproduces the subgraph offline.

- Remove src/scripts/06-benign-workload.ps1 and 07-build-train-dataset.ps1.
- Remove the win_benign role (+ its line in windows.yml) and the legacy
  collect-train.yml; fix verify-windows.yml.
- Update CLAUDE.md, DEVIATIONS D2, PROGRESS, and the READMEs/LABELING/teammate
  report to "benign = idle pulled from Loki".

Caveat: an idle baseline is thin (net val_fpr=1.0), so the SG-Det cut-off
carries the separation and benign demo windows must stay idle. Noted as
follow-ups: render the live LLM report as HTML; steady the model with a
larger idle pull.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DxFwFUt1hUmhjnRsfTCZpg
The Alg. 2 attack report is markdown (headings, bold, inline-code paths,
bullet lists, a GFM IoC table), but the UI's md() only styled headings and
**bold**, so tables and lists showed as raw markdown text.

Replace md() with a small self-contained markdown->HTML renderer (no
external lib; the UI must work offline): headings, **bold**, *italic*,
`code`, -/*/+ and ordered lists, GFM tables, and hr. Text is HTML-escaped
first so LLM output can't inject tags. Expand the .report CSS to style the
rendered elements (sans body, mono code, bordered table). Verified by
rendering a real sg3_report.md: table -> 3 headers/36 cells, 9 lists,
128 code spans, no raw markdown leaking.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DxFwFUt1hUmhjnRsfTCZpg
The slides still described the removed architecture: the pipeline diagram
showed SilkETW -> Grafana Alloy -> Loki, and the benign data was a seeded
scripted workload (06-benign-workload.ps1).

- OurPipeline.vue: drop the Alloy node; the collector is now etwcollect
  pushing ETW->JSON directly to Loki (one HTTP arrow etw -> loki).
- slides.md: benign = idle pulled from Loki (lab slide, windowing, runbook);
  drop the 06-benign-workload.ps1 demo command; refresh the cut-off
  limitation now that the attack was tested (idle <= 8.0 vs attack 106.96).
- note.txt: add a Q&A backup with the verified exp05 demo result and why
  idle (keeps the LOLBin chain out of the benign distribution).

No slides added/removed (35 delimiters unchanged, so slide-number citations
hold). `npx slidev build` passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DxFwFUt1hUmhjnRsfTCZpg
@ngodat0103
ngodat0103 merged commit acd64e8 into main Oct 31, 2026
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant