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
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
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).
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.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.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.
1---2name: rmagent-pack3description: >4 Artifact recipes and detection rule packs as CODE, run one-shot and5 lake-less. Borrows the facts from collector/rule libraries (Velociraptor6 artifacts, Sigma, ATT&CK) and runs them the rmagent way: a named question7 executed on the box, a capped JSON answer, holes instead of dumps. Two8 halves — collection recipes (prefetch, amcache, usb, shimcache) and pure9 rule logic (events -> filters -> thresholds -> finding). No server, no10 agent, no central store. Answers "what actually executed?" and "does this11 pattern mean abuse?", never "ship everything to a warehouse".12metadata:13 source: https://skillmd.com/skills/drolu/rmagent-pack14---1516# rmagent-pack — artifact recipes & rule packs, as code1718A **pack** is a named set of rules. A **rule** is events + filters +19thresholds + meaning. Both live in git, both have tests, both stay small.2021This is how the rmagent observatory borrows the *ideas* in Velociraptor's22artifact library and the community rule packs **without taking their23architecture**. It keeps pull-only, capped answers, holes, and no lake.2425## The two halves (deliberately separate)2627| Half | Question | Where | Network |28|---|---|---|---|29| **Collection** | "give me what's on the box" | `scripts/questions/windows/*.ps1` | one knock, capped |30| **Rule logic** | "what does it mean" | `scripts/packs/*.py` | none — pure, testable |3132Collection is a `ask()` question like any other. Rule logic is a function33over rows you already pulled. Neither needs a server.3435## Collection recipes (one-shot, no agent)3637| Question | Recipe | What it proves |38|---|---|---|39| `prefetch` | `art.prefetch` | a binary EXECUTED, even if the file is gone |40| `amcache` | `art.amcache` | first-seen path/time of an executed binary |41| `usb` | `art.usb` | USB mass-storage insertion (physical-access timeline) |42| `shimcache` | `art.shimcache` | weak execution corroboration when prefetch is off |4344Every one returns `blind: true` when its artifact is absent — a disabled45prefetch is **"execution proof unavailable"**, never "nothing ran".4647## Rule packs (the ideas)4849`kerberos_ad` — Kerberoasting (RC4 TGS sweep), AS-REP roasting, pre-auth50spray, **DCSync** (4662 + DRS replication GUIDs), DCShadow, privileged-group51adds, audit cleared.5253`artifact_recipes` — the collection ideas above, as rules with thresholds.5455### The rule shape, in code5657```python58Rule(59 id="krb.kerberoast",60 events=[4769],61 source="dc.krb",62 filters={"TicketEncryptionType": {"in": ["0x17","23"]}, # RC4 only63 "TargetUserName": {"regex": r"[^$]$"}}, # not machine accts64 thresholds={"distinct": "ServiceName", "count": 3}, # 3+ distinct SPNs65 severity="high", technique="T1558.003",66 why="the classic Kerberoast sweep",67)68```6970## The ethos, carried into the logic7172- **A blind source cannot fire.** `run(..., blind_sources={"dc.krb"})` turns73 any rule on that source into a **hole**, never a finding.74- **Thresholds have a floor.** A ratio needs a denominator of ≥ 30 (same75 floor as the thinker) or the ratio is reported as a hole.76- **Findings carry a count and ≤ 3 example rows** — enough to act, never the lake.77- **Facts borrowed, execution ours.** The event IDs / GUIDs / thresholds come78 from public rule packs; the pull, the cap, and the holes are rmagent's.7980## Run it8182```bash83cd ~/.agents/skills/rmagent-pack/scripts8485python3 test_pack.py # 19 assertions, no network86python3 packs_cli.py list # packs and rule counts87python3 packs_cli.py show kerberos_ad # every rule: events/filters/thresholds88python3 packs_cli.py run kerberos_ad --rows rows.json89python3 packs_cli.py run kerberos_ad --rows rows.json --blind dc.krb # hole, not finding90```9192`rows.json` is just `[{"eid":4769,"TicketEncryptionType":"0x17","ServiceName":"MSSQLSvc/a"}, …]`93— the output of a `so` `krb`/`dcsync` pull, or any event rows you have.9495## What this is NOT9697- **Not a Velociraptor server.** No server, no agent, no reporting home.98- **Not a lake.** Rules return counts and 3 examples; collection is capped at 32 KB.99- **Not a collection framework.** It is a place to *put the ideas* as code,100 with the few one-shot payloads needed to feed them.101102## Relationship to the other skills103104| Skill | Role |105|---|---|106| `rmagent-so` | pulls the events (krb/dcsync/dirchange) these packs reason over |107| `rmagent-fr` | files the case the findings land in (same ticket) |108| `rmagent-core` | the engine + the grain firewall that keeps this a separate grain |109| `rmagent-actuate` | response, only after a rule fires on a source that can SEE |110111## Laya-assisted hit triage112113Every capped JSON answer a recipe or rule pack returns can be scored by a fast,114typed decision model (Laya, via the `use-laya` skill) before a human reads it.115One matrix lives in `decisions/`:116117- `rule_hit.json` — suspicious (noul) / severity (score) / next (choice: run a118 follow-up rmagent question on the host, report the hit to the operator, or119 record it as an allowlisted false positive).120121```bash122echo "<capped answer>" | scripts/laya_decide.py rule_hit123```124125Policy: confidence below 0.5 is flagged ESCALATE — route those hits to the LLM126or the operator. Verdicts are advisory; recipes stay one-shot, read-only, and127capped. The matrix is an allowlist — edit it deliberately.128129## Scripts130131| File | Role |132|---|---|133| `scripts/rulepack.py` | Rule/Pack dataclasses, predicate engine, thresholds, blind-hole rule |134| `scripts/packs/kerberos_ad.py` | the DC/Kerberos rule pack |135| `scripts/packs/artifact_recipes.py` | the collection recipes |136| `scripts/packs/__init__.py` | pack registry |137| `scripts/lib.py` | `ask()` (via rmagent-core) + `run_pack()` |138| `scripts/packs_cli.py` | list / show / run |139| `scripts/test_pack.py` | 19 fixture tests |140| `scripts/questions/windows/{prefetch,amcache,usb,shimcache}.ps1` | one-shot collection |141142## Needle tier 0 — offline extraction and drift143144Alongside the Laya matrices, every skill in this family can call145**needle** — a 121M on-device model (Cactus Compute Needle, ~35 MB, no146network, no keys, ~100 MB RAM) installed once on the jump host, never on147the witnesses. It is the free tier of the judgment stack: needle extracts148and compares offline, Laya judges, the LLM reasons.149150Two scripts ship in `scripts/`:151152- `needle_extract.py` — typed field extraction from a witness fragment153 (`count`, `source_ip`, …). Rigid tokens (numbers, IPs) are reliable;154 semantic fields are not, so the wrapper validates what it can (`:ip`,155 `:int`) and blanks anything it cannot trust — never a guess.156 ```bash157 echo "<attest answer>" | scripts/needle_extract.py user count:int source_ip:ip --json158 ```159- `needle_drift.py` — baseline-drift detection via needle's 3072-dim160 embeddings: record what an answer normally looks like, score today's161 answer against it (similar / drifted / changed, thresholds calibrated162 empirically). Separates shape and topic, not field values — value drift163 stays the job of the field rules and correlate joins.164 ```bash165 echo "<routine answer>" | scripts/needle_drift.py record <host>-<question>166 echo "<today's answer>" | scripts/needle_drift.py score <host>-<question>167 ```168169The engine runs in-process on the jump host (the wrapper finds a Python170with `cactus-needle` — set `NEEDLE_PYTHON` if it lives elsewhere). No port171is opened, nothing is installed on any witness, and the baselines are172kilobyte holes under `~/.rmagent/needle-drift/`, not a lake. On an173air-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.174175176177---178179## Enterprise scope & sizing180181- **Model:** artifacts + rule packs as CODE, run one-shot — prefetch/amcache/182 usb/shimcache collection recipes and pure rule logic (events -> filters ->183 thresholds -> finding). No server, no agent, no central store: the answer184 is a capped JSON verdict, not a shipment.185- **Sizing:** one recipe on one host is seconds and kilobytes. A fleet triage186 (e.g. "which boxes ran a suspicious prefetch?") is a bounded loop of187 one-shots — 100 hosts in minutes, serialized over your existing transport188 (WinRM/SSH), zero new infrastructure.189- **Cadence:** hunt support and incident response — the "what actually190 executed here?" question. Answers "does this pattern mean abuse?", never191 "ship everything to a warehouse".192- **No-Python estates:** recipes are declarative; the collection step maps193 1:1 to native tooling (Get-WinEvent/Scheduled Tasks/registry on Windows,194 journalctl/auditd on Linux) — a PS/bash port of any recipe is mechanical.