
What it is
Recently I decided to add AI features to my emp3r0r C2. After adding MCP and making the C2 compatible with external AI harnesses, I thought: why not build the thing a C2 needs most?
What is the most needed feature of a C2? If you have any exposure to red teaming, you know. Modern C2 frameworks and their operators spend most of their time bypassing detection. That is also why we call it "red teaming": there are other people doing "blue teaming", trying to detect anything you attempt.
Malware development with evasion in mind is a skilled job. But even the best developer has to start from known techniques, and anything you drop somewhere will eventually get picked up.
You certainly don't want to rewrite it every time you get caught, do you?
And you don't have to. AI models have become shockingly good at coding. All you need is a pipeline an AI model can work on, the way a factory worker works on a production line.
The factory
Here is what that factory looks like.
The harness: ARTEX (norma)
No wheels were re-invented. ARTEX has been getting a lot of attention, so I adopted its harness instead. norma is pure Go, which makes it a natural fit for a Go C2 like emp3r0r.
ARTEX is the full agent stack. I took its harness, not the app. Norma is a general-purpose agent harness SDK in Go: provider adapters, a streaming tool loop, tool and permission contracts, hooks, context compaction, and transcript storage.
| What Norma gives me | What the loop uses |
|---|---|
llm + agentcore |
Anthropic, OpenAI, and OpenAI Responses adapters; normalized streaming; one persistent session per worker step; retries; turn, time, and token limits; host-owned prompts. |
tool + permission + hook |
Custom tool schemas; role-specific tool sets; read budgets; role allowlists; and the stop-hook contract that forces the planner/editor/debugger JSON. |
harness + compaction |
Streaming events; settlement at budget; detection-aware micro-compaction; summary and overflow recovery. |
transcript |
Append-only JSONL session logs under the detection store. |
Norma's coordinator, subagent, mcp, memory, skill, plan, and noa packages are not used. The loop has its own coordinator, knowledge base, and loop memory; a second orchestrator would only duplicate state. Norma also injects no system prompt. Every planner, editor, and debugger prompt is host-owned.
Raw material
Just like what you would do when using a coding agent, I exposed everything the model needs to see and edit.
The raw materials are not the stealthiest. The model is supposed to edit the detections out.
For the Windows line, the writable roots are loader_windows, go_agent, and crystal_pack. For the Linux line, they are stager_linux, c_agent, and malasada. The manager hands those trees to the workers in a source brief; the model does not have to infer them from a tool description. It can read a directory, search a subtree, edit any file under a root, and create a file whose parent already exists. It cannot edit the operator's checkout or a path outside the roots.
Those are three different jobs, not one codebase. On Windows, go_agent is the beacon, crystal_pack (or donut) wraps it into shellcode, and loader_windows carries that shellcode into the payload. Linux maps the same roles to c_agent, malasada, and stager_linux.
The agent is compiled for windows_executable or windows_dll on Windows, and as a linux_so for the Linux stager. All three roots are part of the shadow repository. Every edit records the old text, the new text, the file, the reason, whether the file was created, and whether the edit was later reverted. The model can make as many edits as a hypothesis needs. The host makes the edit set reviewable and reversible.
There is one deliberate exception to "edit everything": the host refuses the memfd_create path. Because everyone knows I hate memfd-grade Linux tradecraft.
Workers
What does a factory need? A factory is fundamentally a pipeline that produces stuff. It needs workers and machines to make that stuff.
Likewise, our malware factory ingests raw material such as your beacon source code. Three workers start working on that material, with the goal of reducing detection surface. How do they know if their product can evade detection? Well, we have a QA lab that examines their work and gives feedback if more work needs to be done.
I gave the loop three independent model sessions, one per worker. Each has its own system prompt, tool set, turn cap, and read budget.
| Worker | What it does |
|---|---|
| Planner | Reads the dossier, picks one mechanism and one prediction, then chooses test, debug, or stop. |
| Editor | Changes source or producer code, rebuilds, and runs one DetectionCycle. |
| Debugger | Goes into the guest when the payload did not run or the agent did not check in. |
All three workers can read the same databases: telemetry, the knowledge cache, and loop memory. They can also read source; only the editor can change it.
A traditional AI harness gives you one session, sometimes with sub-agents. The model takes an instruction and starts working. In this autonomous pipeline, a single session is almost guaranteed to get stuck. You cannot steer it back when it stops doing the work, the way you can in something like Claude Code. The loop gives each job its own session, so the host can restart the decision, the edit, or the diagnosis at the right level.
A factory line is deterministic. The job is clear: take the raw material, refine it, send it to the QA lab, and rework it if the result is not good enough. The models are not deterministic; the process around them has to be.
That is the design. I divide the work so each worker has one clear objective and one clear deliverable. The host orchestrator validates and gates the result.
Machinery
The machinery is the harness, the tools, the build pipeline, the QA lab, and the C2 gate. The workers just use them.
A tool call is a machine operation: SourceRead feeds raw material in, EditSource changes it, and DetectionCycle runs one pass through the line. The host orchestrator schedules the workers, dispatches tool calls, rotates agents, gates cycles, and writes the ledger.
The manager
The host orchestrator is the manager. It proves the payload ran, keeps changes reversible, rejects cycles that cannot be compared, and cuts off a worker that burns time or tokens without acting. The model proposes; the manager checks.
Execution
Every cycle gets a fresh agent UUID and shellcode. The C2 pins the first key for a UUID (TOFU), so a reused UUID is a key rotation and the C2 rejects it.
The host polls the C2 for the expected UUID after the run. execution=verified means the agent checked in. execution=offline means it did not. execution=unverified means the loop has no C2 check configured.
An offline cycle still spends budget. It tells you the payload did not run; it says nothing about detection. The host restores the last good state, and the cycle does not count as progress.
Rollback
The loader module, agent source, and producer source are recorded roots. A shadow git repository under the detection store tracks the same trees and leaves the operator's checkout alone. If a cycle does not execute or a verified cycle regresses, the host restores the last good source, shellcode, build options, producer options, agent type, and agent tags.
That rollback is what makes aggressive edits safe. The workspace can always go back.
Comparison
Each cycle stores a fingerprint: source hash, build options, producer options, producer, agent type, and agent tags. If the fingerprint matches the previous cycle, the host rejects it as a repeat. Rotating shellcode alone does not change the design.
The planner also records one prediction the next cycle can prove false. The host records whether the next cycle matched it. Each cycle carries a mechanism label. After two non-progress cycles on one mechanism, the host refuses a third.
Time and tool budget
The planner gets 5 minutes and 12 read-only calls. The editor gets 10 minutes and 24 read-only calls. The debugger gets a total tool budget when configured. Every session has a 30-minute tool-idle timeout and a 2-hour hard cap.
When a window closes or the idle timer fires, the host cancels the current call but keeps the conversation. It sends the worker back with one instruction: return the required JSON now. If a turn or time budget hits at a turn boundary, settlement hides the read tools and gives the worker two turns to answer.
Tool budgets do the same job. Once the planner or editor has spent its read-only calls, PreToolUse blocks further reads. The planner must return a plan. The editor must edit, build, or run a cycle. A model that re-reads the same file and never acts does not get to burn the rest of the run.
The ledger
A traditional AI harness reads everything into context and compacts it. But do we need all of it in context?
Detection feedback keeps growing as the loop runs new cycles. Raw telemetry eats the context window quickly and serves little purpose once the model moves on.
So I keep that out of the model context and let the model query SQLite when it needs it. The model can focus on the job at hand instead of getting lost in the noise.
The knowledge base is human-curated reference material: techniques and methodology the model can look up. Loop memory is the loop's own notepad: what edit or method worked, with the exact source change and the verified result.
The external cache comes from the notebook MCP at https://archeotech.r00ted.ch/mcp. emp3r0r knowledge-sync --url https://archeotech.r00ted.ch/mcp pulls summaries from the maldev, edrdev, redteam, amsi, staticanalysis, vulndrivers, crystalstardust, com, lsass, defender, and mynotebook notebooks; --content also caches full text. The harness playbooks are a separate local methodology notebook. The loop reads <store>/knowledge.db offline, and cached text is untrusted reference material.
SQLite is the ledger. Payloads, traces, events, findings, cycles, edits, worker runs, and loop-memory techniques are connected; the model gets joins, indexes, and one-off SELECTs instead of carrying all of it in context. TelemetryQuery exposes one read-only SELECT/WITH; attrs stays JSON for sensor-specific detail.
It is operator-side state, not payload code. One file under the detection store; no Postgres to install, expose, authenticate, or back up. WAL and a busy timeout keep reads working while imports write; one writer connection serializes writes, and a separate read-only connection serves model queries so a long analysis does not block ingestion. modernc.org/sqlite keeps the operator build CGO-free.
The knowledge cache is a separate SQLite database with FTS, opened read-only by the loop. Loop memory stays in the telemetry database because it has to join directly to findings and edits.
SQLite records what happened. Git records what changed.

Every writable root gets a shadow repository under the detection store, managed with go-git. The loop mirrors source files only, commits the baseline and every cycle, plus a final or partial snapshot, and stores the per-root commit hashes with the cycle. Workers can read the log or one full commit through GitHistory. The operator's checkout is never touched. Using go-git directly means no git binary, hooks, user config, or shell invocation.
The factory has its workers, manager, and ledger. The last piece is the QA lab that judges the product.
What the labs observe
I used LitterBox for Windows and PenguinBox for Linux. Both return the same emp3r0r.telemetry/v1 envelope. The importer normalizes events into SQLite, and the model queries rows in the telemetry database.
| Lab | Sensors | What the model can query |
|---|---|---|
| LitterBox | Static PE, YARA, CheckPlz, and Stringnalyzer; Defender, RedEdr, Moneta, pe-sieve, HollowsHunter, HSB, Patriot, Blender, YARA/CheckPlz, HolyGrail BYOVD, and EDR profiles | PE entropy, imports, sections, and checksum; file, registry, process, thread, network, and module events; ETW-TI memory writes, protections, maps, and allocations; kernel callbacks and ntdll hooks; PEB and loaded-DLL queries; Defender behavior and verdicts |
| PenguinBox | Tracee, Falco, ELF, and YARA | exec, file mutation, memory, network, mount/namespace, BPF, kexec, and kernel-module syscalls with LSM arguments; named Falco alerts with rule, priority, and evt.type; ELF and YARA matches |
Tracee is the raw behavior layer; Falco is the named-rule layer. LitterBox has the same split: ETW/ETW-TI and RedEdr are behavior; Defender and the analyzers are verdicts or summaries.
Early results
I tested the design on two lines: PenguinBox on Linux and LitterBox on Windows. This was not a benchmark. The question was narrower: could the loop make a real source change, rebuild, detonate, and prove the result?
| Line | Platform | Cycles | Verified | High | Total | Verdicts | End |
|---|---|---|---|---|---|---|---|
| Linux | PenguinBox | 17 | 17 | 10 → 0 | 14 → 4 | 2 → 0 | budget exhausted |
| Windows | LitterBox | 8 | 6 | 3 → 0 | 50 → 20 | 0 → 0 | producer stalled; last two offline |
The Linux line removed the /proc/self/maps reads, killed the stager YARA signature, and dropped the runtime maps rule. It ended with zero recorded high findings.
The Windows line cleared the static surface: entropy, imports, and checksum findings were gone. The dynamic memory anomalies stayed, and LitterBox still scored the payload 58/100. The last two cycles were offline and were not kept.
What changed
| Finding | What the model saw | Edit | Result |
|---|---|---|---|
| Linux maps | YARA and the runtime rule matched the literal /proc/self/maps read |
Encoded the path, tried a per-thread alias, then removed the read; rebuilt the map view from its own program headers, mincore, and dl_iterate_phdr |
runtime Process Memory Map Read gone at cycle 12 |
| Linux loader | PenguinBox_LinuxStager_LoaderCode matched the ABI store, syscall scan, and trampoline |
Composed the ABI magic at runtime, encoded the compares, and NOP-padded the trampoline | YARA gone at cycle 3 |
| Windows static | PE entropy from the RC4 ciphertext in .rdata; CRT imports; checksum |
Base64-bounded the ciphertext before .incbin; replaced the CRT-backed loader with a freestanding -nostdlib self-loader, PEB export walk, and fixpe post-link pass |
static findings 30 → 1; dynamic memory still scored 58 |
The model started with the cheap string changes. Encoding /proc/self/maps and aliasing it per thread cost little; the runtime rule still fired. Removing the read was structural. On Windows, base64-bounding the ciphertext changed the entropy distribution, and the freestanding loader removed the imports and checksum, but LitterBox still flagged unbacked executable memory and scored the payload 58. The execution path was still there.
The exec-memory change was the same kind of read: the rule keyed on an exec protection grant, so the model moved the grant to pkey_mprotect and created RWX mappings directly. That changed the syscall and the flags.

The useful output is the rule-to-change record.
Closing
The Linux line removed the /proc/self/maps reads and the stager YARA signature. The Windows line cleared the static findings; its dynamic memory behavior remained. Both runs produced a rule-to-change record, and the loop stopped when the evidence stopped moving.
The design is far from perfect, although it already yields decent results.
A major blocker in Windows evasion is the host's forced exit after two non-improving producer cycles. The model could have spent more cycles making its plan work, but the host aborted the mechanism.
Comments
comments powered by Disqus