Skip to main content

payloads

R4t includes a deterministic, recipe-based payload build and resolution system. Rather than maintaining a static folder of pre-compiled binaries, R4t treats payloads as build recipes that produce artifacts on demand — compiled, transformed, cached, and resolved automatically.

Why Recipe-Based

A static payload repository breaks down once the operator needs per-target configuration, multiple transports, staged vs stageless outputs, in-memory execution, or artifacts in different formats (EXE, DLL, shellcode, PIC, BOF, scripts). A recipe-based model solves this by treating builds as deterministic results of a build specification.

Architecture Overview

Modules request capabilities, not filenames. The resolver finds or builds a matching artifact automatically.

Core Concepts

Templates

A template is the source definition of something that can be built. It declares:
  • Where the source lives
  • Which build environment is required (Go, MinGW, .NET, BOF, PowerShell, Clang/LLVM)
  • Build commands and output conventions
Supported template types:

Payloads

A payload is the operator-facing logical object — a named record tied to a template with optional defaults. Payloads are not files; they are named concepts:
  • corp-http-agent
  • smb-loader
  • pic-exec
  • ldap-helper

Builds

A build is a fully specified recipe describing every parameter needed to produce output: Builds are uniquely identified by a recipe hash — a SHA-256 of the canonicalized build specification.

Artifacts

An artifact is the actual output file produced from a build: Artifacts are stored in a content-addressed store by SHA-256 hash:
This provides deduplication, immutability, integrity verification, and safe caching.

Transformations

Transformations convert one output type into another in an ordered pipeline:
Supported transformation types:

Capabilities

Capabilities are queryable traits attached to builds and artifacts. Modules request capabilities instead of specific files:

Resolution Model

Modules never ask for somefile.exe. They describe what they need, and the resolver handles the rest.

Capability Request Flow

Example Resolution

A module requests a Windows x64 PIC-capable in-memory artifact with SMB delivery:
  1. Module constructs target profile: OS=Windows, Arch=x64, AllowsInjection=true, AllowsDisk=false
  2. Module sends capability request: inmemory=true, pic=true, smb=supported
  3. Resolver checks existing completed builds
  4. No match found — computes recipe hash for: template=smb-loader, OS=windows, arch=x64, stage=stageless, transport=smb, format=dll, transforms=[srdi, pic-wrap]
  5. Build manager acquires build lock via database row
  6. Builder compiles the source template
  7. Transformation pipeline converts output to reflective DLL and PIC forms
  8. Artifacts stored, capabilities indexed
  9. Resolver returns PIC artifact bytes to the module

Build Identity and Hashing

Recipe Hash

Every build is uniquely identified by a SHA-256 hash of its canonicalized recipe:
JSON keys are canonicalized (sorted) before hashing to ensure semantically identical recipes produce identical hashes.

Artifact Hash

Each artifact is independently hashed (SHA-256 of its bytes) for content-addressed storage, deduplication, and integrity verification.

Concurrency and Build Locking

Multiple modules can request builds simultaneously. The build system uses the database build row as a lock:

Build States


Multi-Language Compilation

Each template declares its required builder environment. The Go application orchestrates builds without being the toolchain itself: Builder environments are containerized or isolated for deterministic toolchain versions and reproducible builds.

Per-Target Customization

Because configuration is part of the build recipe, the same logical payload can generate different outputs per target:

Payload Execution by Protocol

The payload factory integrates with R4t’s execution modules to deliver artifacts through different protocols:

WMI Execution

PSRemote Execution

SMB + WMI/WinRM Combination


Implementation Roadmap

The payload factory is being implemented in 10 phases:
  • Architecture — R4t’s layered application architecture
  • WMI — WMI-based remote execution
  • WinRM — WinRM remote command execution
  • PSRemote — PowerShell Remoting operations
  • SMB — SMB file transfer for payload staging
  • Database — Build state and artifact metadata storage