Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.vagrant/

# Per-VM dedicated data disks — captures, flows, DVWA state, MySQL data, etc.
# Ignored so they don't bloat Git; each teammate has their own after `vagrant up`.
# Ignored so they don't bloat Git; each clone gets its own after `vagrant up`.
.vm-data/

# OS junk
Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ numbers. If ambiguous, answer the most likely interpretation and state the assum
`deploy/snapshot/nt2102-snapshot.tar.gz`, snapshot mode of `live_server.py`, image + CI, `deploy/k8s/`. Verified locally: all 24
`./selftest.sh` steps pass, the container serves the snapshot, 30-user load test OK, manifests pass a server-side dry run on the cluster.
**Not yet deployed.** User steps left: commit + merge to `main` → tag `v1.0.0` → make the GHCR package public → `terraform apply` (DNS) →
Argo sync → cluster load test, then fill the cluster numbers into `deploy/README.md`. Decisions: section 9 "Public demo"; guide: `deploy/README.md`.
Argo sync → cluster load test, then fill the cluster numbers into `deploy/README.md`. Decisions: section 9 "Public demo"; overview: `deploy/README.md`.
- SG-Det: code default = the **paper's level scale** (user, 2026-11-03): Moderate from 10, [PAPER] §7.2.1. **Live `ocr-live` runs [OURS]
Moderate from 4.5 on both hosts since 2026-11-15** (user; `live_sg_moderate_from` in `proxmox.ini`) **with the NET rule OFF** (user,
2026-11-15 05:03Z, `live_sg_require_types=none`; accepts ~5 benign red/day per host): the teammate's 11-15 react2shell run (up to 19.9)
Expand Down Expand Up @@ -294,7 +294,7 @@ history of earlier progress) and, if relevant, this section.
sessions) → `src/pipeline/alg2.py` (optional LLM thread: triage verdict + Alg. 2 l.3–15 report on red
windows) → `src/live/history.py` (persistent window history, `sessions/history.jsonl`, range queries via
`/api/history`); `etwship.py --replay` + `compare_replay.py` check the live path against the offline
pipeline. Run guide: `src/live/README.md`.
pipeline. Overview: `src/live/README.md`.
- Artefacts: `src/out/etw/experiments/<id>/` (raw, converted, windowed edges, `windows.csv`,
`experiment.json`, `check.json`, `pull.json`, benign ledger in `labels/`), `src/artifacts/runs/<run>/`
(one model: `models/`, `features/` + scaler, `experiment.json`, `lineage.json`; `exp01` predates this and
Expand Down
178 changes: 64 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,72 @@
# Live attack detection from endpoint audit logs

A self-hosted, end-to-end system that watches a Windows host's kernel activity in real time and raises
an alert on a live attack — from exploit to post-exploitation — as soon as its 5-minute window closes.
Built as a security/ML systems project (NT2102 coursework), on the core detection
method from [OCR-APT](https://doi.org/10.1145/3719027.3765219) (Aly, Mansour, Youssef, ACM CCS 2025).

**Status: proof of concept, not production-ready.** It proves the detection method works live, end to
end, on one host and one demo attack — it is not a hardened, multi-host security product. See §5.

## What this demonstrates
- **Offensive security engineering:** a realistic, ATT&CK-mapped attack chain — exploit → discovery →
lateral tooling → C2 → persistence → anti-forensics — using real, signed tools (not malware), delivered
from a dedicated attacker VM against an isolated target.
- **Applied ML on security telemetry:** a provenance-graph pipeline (process/file/network nodes) feeding
a one-class graph neural network trained only on benign behaviour, scoring live traffic with no labeled
attack data required.
- **LLM-assisted triage:** a second-opinion LLM step that turns a statistical anomaly into a
human-readable verdict and incident report — the kind of alert-fatigue reduction SOC tooling needs.

## 1. Goal

Most anomaly detectors need labeled attack data, which is scarce and expensive. This project asks: can a
model trained **only on a machine's normal behaviour** catch an attack it has never seen, live, with
enough context for a human to act on it? The target outcome: a web dashboard where a 5-minute window of
activity goes from green to red *during* a live attack, backed by an LLM-written explanation of what
happened and why it's suspicious — not just a score.

## 2. Demo scenario

**Setup:** a vulnerable internal web app (command-injection bug) exposed on the monitored host; a
separate attacker VM on an isolated network.

**Attack:** the attacker exploits the app to get a shell, then runs a realistic post-exploitation chain —
system/network discovery, an internal port scan, downloading and *executing* real admin/pentest tools
(PsExec, rclone, nmap, ncat) as a real attacker would, read-only database enumeration, a C2 beacon, a
persistence mechanism, and finally clearing the event logs and deleting its own tools.

**Outcome:** all 3 live attack runs against the current model went red, with no human writing a single
detection rule. On each alert the LLM reads the flagged subgraph and writes a verdict and an incident
report — IOCs, affected hosts, and the ATT&CK stages. Over the model's first 24 hours live (279 scored
windows) there were 7 alerts: 4 attack windows from those 3 runs, and 3 false alarms, which the LLM
marked as false positives. Two of the false alarms came from admin work on the host, one from a lone
PowerShell process. These labels come from the known run times and the LLM verdicts, not from ground truth.

The screenshot below is one red window from the latest run. The LLM's verdict and report are at the top,
built from the model's own output below them: the files, network endpoints and processes that the GNN
flagged as outside normal behaviour, and by how much.
A one-class graph neural network that learns a Windows host's normal kernel activity and turns a live attack
red within its 5-minute window, with an LLM-written incident report. Built on the core method of
[OCR-APT](https://doi.org/10.1145/3719027.3765219) (Aly, Mansour, Youssef, ACM CCS 2025). NT2102 course project.

**[Live demo](https://projects.datrollout.dev/nt2102/)** (recorded, read-only) · **[Slides](https://uitprojects.github.io/NT2102/)** · Status: proof of concept, lab torn down.

## Outcome

- **DVWA → RCE → ATT&CK chain** (`ws-etw-0`): 3 of 3 live runs went red, each with an LLM `attack` verdict.
First 24 h live: 279 windows, 7 alerts (4 attack, 3 benign false alarms).
- **Real react2shell attack** (Next.js RCE on `ws-etw-1`, run by a team member): red at subgraph score 7.24 and 19.86,
LLM `attack` 0.85 / 0.95. In-sample: the alert cut-off was tuned on this run.
- **Public demo**: 4,658 recorded windows (2026-11-02 → 11-15), 63 red, 17 LLM `attack`. Replays the scores
computed live at the time. Nothing is re-scored.

![LLM verdict and report above the flagged nodes, from one live red window](docs/demo-attack.png)

<details>
<summary>Full attack phase breakdown (ATT&CK techniques)</summary>

| phase | technique(s) | what happens |
|---|---|---|
| Initial access / execution | T1190, T1059.001 | Web app command injection → RCE shell |
| Discovery | T1033, T1082, T1057, T1016 | user/system/process/network enumeration |
| Network service scan | T1046 | internal subnet sweep |
| Tool transfer + execution | T1105, T1569.002 | downloads and runs real tools (PsExec as SYSTEM, rclone, nmap, ncat) |
| Credential access / DB | T1552, T1213 | read-only DB enumeration + dump |
| C2 | T1071 | periodic beacon to the attacker |
| Persistence | T1053.005 | scheduled task |
| Defense evasion | T1070.001, T1070.004 | clears the event logs, deletes the downloaded tools |

</details>

## 3. Infrastructure

Everything runs in an isolated, automated lab built from scratch — the only manual step is installing
Windows and Kali from their ISOs:

- **Provisioning:** Terraform defines the network and VMs on a home Proxmox hypervisor; Ansible
configures every box (collector agents, the database/web app under test, the training/serving stack,
the attacker toolkit) idempotently — re-running a playbook changes nothing on an already-configured box.
- **Network isolation:** the monitored host, a second Windows endpoint (collection only) and the
training/inference server share one firewalled lab subnet whose VMs cannot reach the home LAN. The
attacker sits on its own subnet. Attack traffic never leaves the lab.
- **Observability backbone:** our own Python ETW collector pushes kernel events to a log-aggregation
service (Loki/Grafana), which decouples collection from training and inference — the same event stream
feeds both the training pipeline and the live detector.
- **Remote access:** a VPN endpoint for off-site administration of the lab.

## 4. Pipeline

**Training** turns raw kernel event logs into a detector with no attack data in the loop: build a
provenance graph from a window of normal activity → extract a fixed feature vector per node → train a
graph neural network per node type to recognize "normal" as a tight region in embedding space (one-class
learning) → gate the result against sanity checks before it's ever served live. One command runs the
whole loop end to end. The lab's own tooling (the capture watchdog, the attack label file) is filtered
out before training and scoring, so neither the model nor the LLM learns from the harness.

**Inference** runs the same pipeline live: stream kernel events in real time → score every node against
the trained model as each 5-minute window closes → group anomalous nodes into connected subgraphs and
score each one → alert when a subgraph crosses a calibrated threshold → on alert, hand the subgraph to an
LLM for a second-opinion verdict and a written report → surface everything on a live web dashboard with
full history.

## 5. Known constraints

Shipping this honestly means stating what it is not:

- **Trained on idle behaviour only** (about 3 days, with attack and remote-session windows excluded). It
makes the demo attack easy to separate from normal, but real, varied day-to-day usage (remote sessions,
admin work) can also look unfamiliar and trigger a false alarm. Two of the 3 false alarms above were
exactly this.
- **The subgraph score grows with node count.** It sums over flagged nodes, so a large benign cluster can
cross the alert threshold just as a small attack can.
- **Features see each node alone.** They count what a node does, not who started it or whether a network
peer is new. The log-clearing step is captured but not flagged: `wevtutil.exe` looks normal by its own
behaviour, so it does not raise the alert.
- **The LLM is a second opinion, not ground truth.** It can over-read: the report above calls rclone
exfiltration, while the attack only used it to download a file. It can also hedge: one attack window
came back `uncertain`, because of a lab file that has since been filtered out.
- **One host is scored live.** The second Windows VM collects data for training, and no model has been
trained on both hosts yet.
- **The evidence is small:** 3 live runs of one scripted attack chain, not a formal evaluation.
- **Not production-hardened:** single-host demo scale, no high availability, no secrets management beyond
a local vault file, no multi-tenant support — built to prove the detection method, not to run a fleet.
## Stack

Python ETW collector · Loki / Grafana · PyTorch Geometric (RGCN, Deep SVDD loss) · FastAPI + SSE · LLM triage ·
Terraform on Proxmox · Ansible · Docker · Kubernetes / Argo CD / Traefik · GitHub Actions

## Architecture

```
Windows VM ETW kernel events (process / file / network) ──push──► Loki
Trainer Loki ─► provenance graph ─► 15 behaviour features per node ─► one OCRGCN per node type
(train: idle benign only) (live: score each 5-min window)
anomalous nodes ─► connected subgraphs + subgraph score (Alg. 1) ─► red window
red window ─► LLM verdict + incident report (Alg. 2) ─► web UI with full history
Demo recorded snapshot ─► same UI, read-only, in a container on k8s
```

## Attacks

| phase | ATT&CK |
|---|---|
| Web command injection → RCE shell | T1190, T1059.001 |
| Discovery | T1033, T1082, T1057, T1016 |
| Internal scan | T1046 |
| Real tool download + run (PsExec, rclone, nmap, ncat) | T1105, T1569.002 |
| DB enumeration + dump | T1552, T1213 |
| C2 beacon · scheduled task | T1071 · T1053.005 |
| Clear event logs, delete tools | T1070.001, T1070.004 |

Second attack: react2shell Next.js RCE → `node` → PowerShell, winPEAS, service/task enumeration.

## Limits

- Benign baseline = mostly idle activity, so real admin work can raise false alarms.
- The subgraph score sums over flagged nodes: large benign clusters can cross the threshold too.
- Thresholds were tuned on the attacks shown (in-sample). No labelled ground truth, no formal evaluation.
- The LLM is a second opinion and can over-read (for example, calling a download "exfiltration").
- Small evidence: a few runs of two attacks on two hosts.

## Repository

| path | what |
|---|---|
| `src/etw-python/` | ETW collector (stdlib + ctypes) |
| `src/pipeline/` | graph, features, OCRGCN training, scoring, Alg. 1, Alg. 2 |
| `src/live/` | live engine, FastAPI server, web UI, snapshot playback |
| `src/atomic-attack-pack/` | the RCE kill chain and its launcher |
| `src/ansible/` · `infrastructure/` | lab provisioning · Proxmox VMs and network (Terraform) |
| `deploy/` | demo image, k8s manifests, Argo CD app |
| `docs/` | design notes, deviations from the paper, explainers |
| `latex/` · `presentation/` | report · slides |

## References

Expand Down
Loading
Loading