# dessertlab/laccolith architecture

> Architecture diagram of the GitHub repository dessertlab/laccolith, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dessertlab/laccolith
- Repository: https://github.com/dessertlab/laccolith

## Overview

1. **What this repository is**
   - Laccolith is a containerized framework that orchestrates **kernel-level payload injection into a Windows guest VM** from the privileged side of the virtualization boundary.
   - Its core purpose is to automate a full adversary-emulation loop: build payloads, patch them for a target VM version, inject them into guest memory, and drive them through a C2-style control plane.

2. **Top-level deployment boundary**
   - The system runs as a **Dockerized Linux-host service**.
   - It assumes the guest VM RAM is **file-backed and exposed on the host** under `/dev/shm`, so the framework can read and write guest physical memory in near real time.
   - The host VM stack is oriented around **QEMU/KVM + libvirt** with a Windows 10 guest; the repository includes VM configuration material in `vm/`.

3. **Main runtime services**
   - The application exposes **three externally visible interfaces**:
     - a **web UI** on port 8000,
     - a **text UI over network** on port 7331,
     - a **C2 listener** on port 5000 for the injected agent.
   - The web and TUI are operator-facing control surfaces; the C2 port is the agent-facing communication endpoint.

4. **Operator control plane**
   - `app.py` is the likely entrypoint for the web application.
   - `cmd_line_over_network.py` appears to implement the richer network TUI.
   - `templates/` contains the HTML views for the web interface, so the operator UI is server-rendered and integrated into the Python app rather than being a separate frontend.

5. **C2 and agent session management**
   - The `c2/` package is the control-plane core:
     - `c2_server.py` manages the listener side,
     - `connection.py` handles agent/session transport,
     - `c2_actions.py`, `c2_operations.py`, `c2_facts.py`, and `c2_parsers.py` model command execution, campaign flow, and extracted intelligence.
   - This layer is responsible for turning raw agent communication into structured operator-visible state.

6. **Action/operation/fact model**
   - Laccolith uses a Caldera-like abstraction:
     - **Operations** represent campaign profiles,
     - **Actions** represent discrete tasks/abilities,
     - **Parsers** convert raw command output into **Facts**,
     - Facts feed later actions and the UI.
   - This is the main planning/execution boundary: operator intent is translated into a sequence of agent commands, with parser-produced facts closing the loop.

7. **Injection orchestration layer**
   - `injector.py` and `vm_drivers.py` are the host-side components that coordinate the actual memory manipulation and VM interaction.
   - `config/conf_manager.py` and `config/config.json` hold runtime parameters such as target profile, offsets, paths, and connection settings.
   - These modules sit between operator intent and the guest-memory write path.

8. **Guest-memory access path**
   - The repository includes a `devmem2/` subtree, adapted for shared-memory/physical-memory access.
   - The framework uses this to operate on the guest’s backing RAM image as if it were a writable physical memory surface.
   - Volatility is used as a companion introspection tool to resolve guest structures and version-dependent addresses, which is important for patching shellcode and locating target code regions.

9. **Payload and shellcode subsystem**
   - `kernel_shellcode_library/` is the payload factory and payload cache.
   - It contains:
     - a Rust-based shellcode library (`SassyKitdi-master/`),
     - reusable low-level crates under `src/common/`,
     - payload crates under `src/payloads/`,
     - build helpers and patching utilities.
   - The repo stores both source and generated binaries, indicating a build-time pipeline followed by runtime selection/patching.

10. **Two-stage injection architecture**
   - The payload system is split into **first-stage** and **second-stage** shellcode.
   - The first stage is the small bootstrap written into an overwritten kernel code path; it allocates and signals space for the second stage and coordinates one-time execution.
   - The second stage is the actual agent payload that establishes C2 communication and executes commands inside the guest kernel context.

11. **Version-specific patching**
   - `kernel_shellcode_library/offsets.json` and `shellcode_patching.py` encode runtime patch points for different Windows builds and payload variants.
   - This makes portability an explicit architecture concern: payload binaries are not treated as fixed artifacts, but as templates that are patched according to the target VM version.

12. **Build and packaging flow**
   - The payloads are compiled with Rust toolchains under `kernel_shellcode_library/SassyKitdi-master/src/payloads/...`.
   - The resulting binaries are extracted, trimmed, patched, and then consumed by the Python orchestration layer.
   - `Dockerfile` and `docker-compose.yml` package the whole runtime so the framework can be brought up as a single service stack.

13. **Test/debug environment**
   - The repo also encodes an operational lab setup: Windows guest with **KDNET kernel debugging**, compatible NIC configuration, and a fresh snapshot-based experiment loop.
   - `docs/` contains architectural diagrams and thesis/presentation material that document the intended flow, but the actual runtime architecture is concentrated in the Python orchestration, C2 stack, and payload library.

14. **End-to-end data flow**
   - Operator enters a command or selects a campaign in the web/TUI interface.
   - The control plane resolves the operation into actions, patches the appropriate payload, and writes it through the guest-memory access layer.
   - The first-stage bootstrap in guest kernel memory launches the second-stage agent.
   - The agent connects back to the C2 server on port 5000, executes requested tasks, returns outputs, and those outputs are parsed into facts for the next operator step.

Main entry points: [`injector.py`](https://github.com/dessertlab/laccolith/blob/main/injector.py) (Injector), [`app.py`](https://github.com/dessertlab/laccolith/blob/main/app.py) (App), [`c2/c2_operations.py`](https://github.com/dessertlab/laccolith/blob/main/c2/c2_operations.py) (Operations), [`kernel_shellcode_library/payloads`](https://github.com/dessertlab/laccolith/tree/main/kernel_shellcode_library/payloads) (Payload bins)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_operator["Operator plane"]
  node_app_py["App<br/>web entrypoint<br/>[app.py]"]
  node_cmd_net["Net TUI<br/>operator ui"]
  node_templates["Views<br/>server templates"]
end

subgraph group_grp_c2["C2 core"]
  node_c2_server["C2 server<br/>listener<br/>[c2_server.py]"]
  node_connection["Transport<br/>[connection.py]"]
  node_c2_actions["Actions<br/>task model<br/>[c2_actions.py]"]
  node_c2_ops["Operations<br/>campaign model<br/>[c2_operations.py]"]
  node_c2_facts["Facts<br/>intel model<br/>[c2_facts.py]"]
  node_c2_parsers["Parsers<br/>output parsing"]
end

subgraph group_grp_injection["Injection pipeline"]
  node_injector["Injector<br/>orchestrator<br/>[injector.py]"]
  node_vm_drivers["VM drivers<br/>vm control<br/>[vm_drivers.py]"]
  node_conf["Config<br/>[conf_manager.py]"]
  node_devmem2[("Shared mem<br/>memory access")]
end

subgraph group_grp_payloads["Payload library"]
  node_shellcode_patch["Patcher<br/>payload patching"]
  node_offsets["Offsets<br/>target profile<br/>[offsets.json]"]
  node_ksl_src["Rust src<br/>shellcode source"]
  node_payload_bins[("Payload bins<br/>built artifacts")]
end

subgraph group_grp_lab["Lab stack"]
  node_vm_xml["VM config<br/>guest profile<br/>[win10-3.xml]"]
  node_docker["Docker stack<br/>deployment<br/>[docker-compose.yml]"]
end

node_app_py -->|"renders"| node_templates
node_app_py -->|"plans"| node_c2_ops
node_cmd_net -->|"drives"| node_c2_ops
node_c2_ops -->|"expands"| node_c2_actions
node_c2_actions -->|"collects"| node_c2_parsers
node_c2_parsers -->|"emits"| node_c2_facts
node_c2_facts -->|"feeds"| node_c2_ops
node_c2_server -->|"accepts"| node_connection
node_connection -->|"executes"| node_c2_actions
node_c2_server -.->|"status"| node_app_py
node_injector -->|"reads"| node_conf
node_injector -->|"coordinates"| node_vm_drivers
node_vm_drivers -->|"accesses"| node_devmem2
node_injector -->|"patches"| node_shellcode_patch
node_shellcode_patch -->|"uses"| node_offsets
node_shellcode_patch -->|"produces"| node_payload_bins
node_ksl_src -->|"builds"| node_payload_bins
node_payload_bins -->|"consumes"| node_injector
node_vm_xml -.->|"describes"| node_vm_drivers
node_docker -.->|"packages"| node_app_py
node_docker -.->|"exposes"| node_c2_server
node_docker -.->|"runs"| node_injector
node_devmem2 -->|"writes"| node_payload_bins
node_connection -.->|"surfaces"| node_app_py

click node_app_py "https://github.com/dessertlab/laccolith/blob/main/app.py"
click node_cmd_net "https://github.com/dessertlab/laccolith/blob/main/cmd_line_over_network.py"
click node_templates "https://github.com/dessertlab/laccolith/tree/main/templates"
click node_c2_server "https://github.com/dessertlab/laccolith/blob/main/c2/c2_server.py"
click node_connection "https://github.com/dessertlab/laccolith/blob/main/c2/connection.py"
click node_c2_actions "https://github.com/dessertlab/laccolith/blob/main/c2/c2_actions.py"
click node_c2_ops "https://github.com/dessertlab/laccolith/blob/main/c2/c2_operations.py"
click node_c2_facts "https://github.com/dessertlab/laccolith/blob/main/c2/c2_facts.py"
click node_c2_parsers "https://github.com/dessertlab/laccolith/blob/main/c2/concrete_parsers.py"
click node_injector "https://github.com/dessertlab/laccolith/blob/main/injector.py"
click node_vm_drivers "https://github.com/dessertlab/laccolith/blob/main/vm_drivers.py"
click node_conf "https://github.com/dessertlab/laccolith/blob/main/config/conf_manager.py"
click node_devmem2 "https://github.com/dessertlab/laccolith/tree/main/devmem2"
click node_shellcode_patch "https://github.com/dessertlab/laccolith/blob/main/kernel_shellcode_library/shellcode_patching.py"
click node_offsets "https://github.com/dessertlab/laccolith/blob/main/kernel_shellcode_library/offsets.json"
click node_ksl_src "https://github.com/dessertlab/laccolith/tree/main/kernel_shellcode_library/SassyKitdi-master/src"
click node_payload_bins "https://github.com/dessertlab/laccolith/tree/main/kernel_shellcode_library/payloads"
click node_vm_xml "https://github.com/dessertlab/laccolith/blob/main/vm/win10-3.xml"
click node_docker "https://github.com/dessertlab/laccolith/blob/main/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_py,node_cmd_net,node_templates toneBlue
class node_c2_server,node_connection,node_c2_actions,node_c2_ops,node_c2_facts,node_c2_parsers toneAmber
class node_injector,node_vm_drivers,node_conf,node_devmem2 toneMint
class node_shellcode_patch,node_offsets,node_ksl_src,node_payload_bins toneRose
class node_vm_xml,node_docker toneIndigo
```

## Components

### Operator plane

Human-facing control surfaces and server-rendered UI.

- [App](https://github.com/dessertlab/laccolith/blob/main/app.py): web entrypoint · Main Python web application entrypoint. · `app.py`
- [Net TUI](https://github.com/dessertlab/laccolith/blob/main/cmd_line_over_network.py): operator ui · Text UI reachable over the network for operator control. · `cmd_line_over_network.py`
- [Views](https://github.com/dessertlab/laccolith/tree/main/templates): server templates · HTML templates for the web operator interface. · `templates`

### C2 core

Agent listener, session transport, and campaign state model.

- [C2 server](https://github.com/dessertlab/laccolith/blob/main/c2/c2_server.py): listener · Network listener that accepts agent connections. · `c2/c2_server.py`
- [Transport](https://github.com/dessertlab/laccolith/blob/main/c2/connection.py): session transport · Agent/session connection handling and message exchange. · `c2/connection.py`
- [Actions](https://github.com/dessertlab/laccolith/blob/main/c2/c2_actions.py): task model · Discrete command and ability definitions for campaigns. · `c2/c2_actions.py`
- [Operations](https://github.com/dessertlab/laccolith/blob/main/c2/c2_operations.py): campaign model · Campaign profiles and execution flow definitions. · `c2/c2_operations.py`
- [Facts](https://github.com/dessertlab/laccolith/blob/main/c2/c2_facts.py): intel model · Structured facts extracted from agent output. · `c2/c2_facts.py`
- [Parsers](https://github.com/dessertlab/laccolith/blob/main/c2/concrete_parsers.py): output parsing · Transforms raw command output into facts. · `c2/concrete_parsers.py`

### Injection pipeline

Host-side orchestration, guest-memory access, and runtime configuration.

- [Injector](https://github.com/dessertlab/laccolith/blob/main/injector.py): orchestrator · Coordinates payload selection, patching, and memory writes. · `injector.py`
- [VM drivers](https://github.com/dessertlab/laccolith/blob/main/vm_drivers.py): vm control · Interfaces to the virtualization layer and guest VM state. · `vm_drivers.py`
- [Config](https://github.com/dessertlab/laccolith/blob/main/config/conf_manager.py): runtime config · Configuration manager and runtime settings source. · `config/conf_manager.py`
- [Shared mem](https://github.com/dessertlab/laccolith/tree/main/devmem2): memory access · Shared-memory backed physical memory access tooling. · `devmem2`

### Payload library

Rust shellcode source, patching, and generated stage artifacts.

- [Patcher](https://github.com/dessertlab/laccolith/blob/main/kernel_shellcode_library/shellcode_patching.py): payload patching · Version-specific shellcode patching and offset application. · `kernel_shellcode_library/shellcode_patching.py`
- [Offsets](https://github.com/dessertlab/laccolith/blob/main/kernel_shellcode_library/offsets.json): target profile · Version-dependent patch points and target offsets. · `kernel_shellcode_library/offsets.json`
- [Rust src](https://github.com/dessertlab/laccolith/tree/main/kernel_shellcode_library/SassyKitdi-master/src): shellcode source · Rust-based shellcode library and payload source tree. · `kernel_shellcode_library/SassyKitdi-master/src`
- [Payload bins](https://github.com/dessertlab/laccolith/tree/main/kernel_shellcode_library/payloads): built artifacts · Compiled first- and second-stage shellcode binaries. · `kernel_shellcode_library/payloads`

### Lab stack

Virtualization and guest environment material used to run the framework.

- [VM config](https://github.com/dessertlab/laccolith/blob/main/vm/win10-3.xml): guest profile · Libvirt/QEMU guest configuration for the Windows lab VM. · `vm/win10-3.xml`
- [Docker stack](https://github.com/dessertlab/laccolith/blob/main/docker-compose.yml): deployment · Container packaging and compose setup for the runtime. · `docker-compose.yml`

## Connections

- App → Views: renders · Server-side web views are populated from templates.
- App → Operations: plans · Operator intent is translated into campaign operations.
- Net TUI → Operations: drives · Network TUI issues operator commands into the campaign model.
- Operations → Actions: expands · Operations decompose into discrete actions.
- Actions → Parsers: collects · Action results are parsed back into structured intel.
- Parsers → Facts: emits · Parsed output becomes facts for later steps.
- Facts → Operations: feeds · Facts update subsequent operation choices.
- C2 server → Transport: accepts · The listener hands sessions to connection handling.
- Transport → Actions: executes · Connected agents receive tasking derived from actions.
- C2 server → App: status · Agent/session state surfaces in the operator UI.
- Injector → Config: reads · Injection orchestration uses runtime configuration.
- Injector → VM drivers: coordinates · Injector delegates VM interactions to drivers.
- VM drivers → Shared mem: accesses · Drivers operate through shared-memory backed guest RAM access.
- Injector → Patcher: patches · Payload templates are patched for the target VM version.
- Patcher → Offsets: uses · Patch logic is driven by target-specific offsets.
- Patcher → Payload bins: produces · Patched binaries are emitted for injection.
- Rust src → Payload bins: builds · Rust shellcode source compiles into stage binaries.
- Payload bins → Injector: consumes · The injection pipeline selects built stage artifacts.
- VM config → VM drivers: describes · Guest VM configuration constrains VM control behavior.
- Docker stack → App: packages · Docker composition packages the operator/runtime services.
- Docker stack → C2 server: exposes · Containerized deployment exposes the listener service.
- Docker stack → Injector: runs · Containerized deployment runs the injection orchestration.
- Shared mem → Payload bins: writes · Guest-memory access is used to place payload code in RAM.
- Transport → App: surfaces · Connection state can be surfaced to the web control plane.
