# Rmagent Pack

> Artifact recipes and detection rule packs as CODE, run one-shot and lake-less. Borrows the facts from collector/rule libraries (Velociraptor artifacts, Sigma, ATT&CK) and runs them the rmagent way: a named question executed on the box, a capped JSON answer, holes instead of dumps. Two halves — collection recipes (prefetch, amcache, usb, shimcache) and pure rule logic (events -> filters -> thresholds -> finding). No server, no agent, no central store. Answers "what actually executed?" and "does this pattern mean abuse?", never "ship everything to a warehouse".

- Skill: `drolu/rmagent-pack` (Agent Skill, multi-file: 14 files)
- Install (CLI): `npx get-skill add drolu/rmagent-pack`
- Raw SKILL.md: https://api.skillmd.com/api/skills/drolu/rmagent-pack/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: DrOlu (https://skillmd.com/u/drolu)
- Updated: 2026-11-11
- Page: https://skillmd.com/skills/drolu/rmagent-pack

---


# rmagent-pack — artifact recipes & rule packs, as code

A **pack** is a named set of rules. A **rule** is events + filters +
thresholds + meaning. Both live in git, both have tests, both stay small.

This is how the rmagent observatory borrows the *ideas* in Velociraptor's
artifact library and the community rule packs **without taking their
architecture**. It keeps pull-only, capped answers, holes, and no lake.

## The two halves (deliberately separate)

| Half | Question | Where | Network |
|---|---|---|---|
| **Collection** | "give me what's on the box" | `scripts/questions/windows/*.ps1` | one knock, capped |
| **Rule logic** | "what does it mean" | `scripts/packs/*.py` | none — pure, testable |

Collection is a `ask()` question like any other. Rule logic is a function
over rows you already pulled. Neither needs a server.

## Collection recipes (one-shot, no agent)

| Question | Recipe | What it proves |
|---|---|---|
| `prefetch` | `art.prefetch` | a binary EXECUTED, even if the file is gone |
| `amcache` | `art.amcache` | first-seen path/time of an executed binary |
| `usb` | `art.usb` | USB mass-storage insertion (physical-access timeline) |
| `shimcache` | `art.shimcache` | weak execution corroboration when prefetch is off |

Every one returns `blind: true` when its artifact is absent — a disabled
prefetch is **"execution proof unavailable"**, never "nothing ran".

## Rule packs (the ideas)

`kerberos_ad` — Kerberoasting (RC4 TGS sweep), AS-REP roasting, pre-auth
spray, **DCSync** (4662 + DRS replication GUIDs), DCShadow, privileged-group
adds, audit cleared.

`artifact_recipes` — the collection ideas above, as rules with thresholds.

### The rule shape, in code

```python
Rule(
    id="krb.kerberoast",
    events=[4769],
    source="dc.krb",
    filters={"TicketEncryptionType": {"in": ["0x17","23"]},   # RC4 only
             "TargetUserName": {"regex": r"[^$]$"}},          # not machine accts
    thresholds={"distinct": "ServiceName", "count": 3},        # 3+ distinct SPNs
    severity="high", technique="T1558.003",
    why="the classic Kerberoast sweep",
)
```

## The ethos, carried into the logic

- **A blind source cannot fire.** `run(..., blind_sources={"dc.krb"})` turns
  any rule on that source into a **hole**, never a finding.
- **Thresholds have a floor.** A ratio needs a denominator of ≥ 30 (same
  floor as the thinker) or the ratio is reported as a hole.
- **Findings carry a count and ≤ 3 example rows** — enough to act, never the lake.
- **Facts borrowed, execution ours.** The event IDs / GUIDs / thresholds come
  from public rule packs; the pull, the cap, and the holes are rmagent's.

## Run it

```bash
cd ~/.agents/skills/rmagent-pack/scripts

python3 test_pack.py                       # 19 assertions, no network
python3 packs_cli.py list                  # packs and rule counts
python3 packs_cli.py show kerberos_ad      # every rule: events/filters/thresholds
python3 packs_cli.py run kerberos_ad --rows rows.json
python3 packs_cli.py run kerberos_ad --rows rows.json --blind dc.krb   # hole, not finding
```

`rows.json` is just `[{"eid":4769,"TicketEncryptionType":"0x17","ServiceName":"MSSQLSvc/a"}, …]`
— the output of a `so` `krb`/`dcsync` pull, or any event rows you have.

## What this is NOT

- **Not a Velociraptor server.** No server, no agent, no reporting home.
- **Not a lake.** Rules return counts and 3 examples; collection is capped at 32 KB.
- **Not a collection framework.** It is a place to *put the ideas* as code,
  with the few one-shot payloads needed to feed them.

## Relationship to the other skills

| Skill | Role |
|---|---|
| `rmagent-so` | pulls the events (krb/dcsync/dirchange) these packs reason over |
| `rmagent-fr` | files the case the findings land in (same ticket) |
| `rmagent-core` | the engine + the grain firewall that keeps this a separate grain |
| `rmagent-actuate` | response, only after a rule fires on a source that can SEE |

## Laya-assisted hit triage

Every capped JSON answer a recipe or rule pack returns can be scored by a fast,
typed decision model (Laya, via the `use-laya` skill) before a human reads it.
One matrix lives in `decisions/`:

- `rule_hit.json` — suspicious (noul) / severity (score) / next (choice: run a
  follow-up rmagent question on the host, report the hit to the operator, or
  record it as an allowlisted false positive).

```bash
echo "<capped answer>" | scripts/laya_decide.py rule_hit
```

Policy: confidence below 0.5 is flagged ESCALATE — route those hits to the LLM
or the operator. Verdicts are advisory; recipes stay one-shot, read-only, and
capped. The matrix is an allowlist — edit it deliberately.

## Scripts

| File | Role |
|---|---|
| `scripts/rulepack.py` | Rule/Pack dataclasses, predicate engine, thresholds, blind-hole rule |
| `scripts/packs/kerberos_ad.py` | the DC/Kerberos rule pack |
| `scripts/packs/artifact_recipes.py` | the collection recipes |
| `scripts/packs/__init__.py` | pack registry |
| `scripts/lib.py` | `ask()` (via rmagent-core) + `run_pack()` |
| `scripts/packs_cli.py` | list / show / run |
| `scripts/test_pack.py` | 19 fixture tests |
| `scripts/questions/windows/{prefetch,amcache,usb,shimcache}.ps1` | one-shot collection |

## Needle tier 0 — offline extraction and drift

Alongside the Laya matrices, every skill in this family can call
**needle** — a 121M on-device model (Cactus Compute Needle, ~35 MB, no
network, no keys, ~100 MB RAM) installed once on the jump host, never on
the witnesses. It is the free tier of the judgment stack: needle extracts
and compares offline, Laya judges, the LLM reasons.

Two scripts ship in `scripts/`:

- `needle_extract.py` — typed field extraction from a witness fragment
  (`count`, `source_ip`, …). Rigid tokens (numbers, IPs) are reliable;
  semantic fields are not, so the wrapper validates what it can (`:ip`,
  `:int`) and blanks anything it cannot trust — never a guess.
  ```bash
  echo "<attest answer>" | scripts/needle_extract.py user count:int source_ip:ip --json
  ```
- `needle_drift.py` — baseline-drift detection via needle's 3072-dim
  embeddings: record what an answer normally looks like, score today's
  answer against it (similar / drifted / changed, thresholds calibrated
  empirically). Separates shape and topic, not field values — value drift
  stays the job of the field rules and correlate joins.
  ```bash
  echo "<routine answer>" | scripts/needle_drift.py record <host>-<question>
  echo "<today's answer>" | scripts/needle_drift.py score <host>-<question>
  ```

The engine runs in-process on the jump host (the wrapper finds a Python
with `cactus-needle` — set `NEEDLE_PYTHON` if it lives elsewhere). No port
is opened, nothing is installed on any witness, and the baselines are
kilobyte holes under `~/.rmagent/needle-drift/`, not a lake. On an
air-gapped estate this tier keeps working — and the judgment tier with it: Laya is offline too (pre-seed its HF-cache checkpoint on air-gapped hosts), so no matrix judgment waits for a connected session.



---

## Enterprise scope & sizing

- **Model:** artifacts + rule packs as CODE, run one-shot — prefetch/amcache/
  usb/shimcache collection recipes and pure rule logic (events -> filters ->
  thresholds -> finding). No server, no agent, no central store: the answer
  is a capped JSON verdict, not a shipment.
- **Sizing:** one recipe on one host is seconds and kilobytes. A fleet triage
  (e.g. "which boxes ran a suspicious prefetch?") is a bounded loop of
  one-shots — 100 hosts in minutes, serialized over your existing transport
  (WinRM/SSH), zero new infrastructure.
- **Cadence:** hunt support and incident response — the "what actually
  executed here?" question. Answers "does this pattern mean abuse?", never
  "ship everything to a warehouse".
- **No-Python estates:** recipes are declarative; the collection step maps
  1:1 to native tooling (Get-WinEvent/Scheduled Tasks/registry on Windows,
  journalctl/auditd on Linux) — a PS/bash port of any recipe is mechanical.

