← Documentation / Operator Guide

Templates & Building

Pre-compiled agent templates and how to build agents

Krait ships with pre-compiled agent templates for every combination of transport, format, and traffic profile. Build agents from the operator Web UI or the CLI console — the server patches your config into the selected template and produces a ready-to-deploy binary in seconds.

How It Works

Templates are agent binaries compiled with placeholder values (sentinels) for the C2 address, port, evasion flags, and other config fields. The build system finds these sentinels and replaces them with your real values — producing a ready-to-deploy agent without needing a compiler.

Template (sentinel values) → Build (your config) → Agent binary (ready to deploy)

Template Matrix

Windows

24 templates compiled with MSVC:

TransportFormatsProfiles
HTTPSEXE + DLLdefault (no mimicry), slack, discord, teams, gdrive, onedrive, github, npm, docker-registry
SMBEXE + DLL(none — SMB doesn’t use HTTP profiles)
TCPEXE + DLL(none)
DNSEXE + DLL(none)

Linux

10 templates:

TransportProfiles
HTTPSdefault (no mimicry), slack, discord, teams, gdrive, onedrive, github, npm, docker-registry
DNS(none)

Building from the Web UI

The Build page (http://localhost:50051/build) provides a visual interface for all build options. Select the platform (Windows/Linux), transport, profile, evasion flags, and cover profile, then click Generate. The patched binary downloads automatically when ready.

Building from the CLI

The build command in the operator console patches a template with your configuration.

Quick Start

krait> build windows -s 10.0.0.5
krait> build linux -s 10.0.0.5

Help

krait> build -h                    # Overview
krait> build windows -h            # Windows-specific options
krait> build linux -h              # Linux-specific options
krait> build templates             # List available templates
krait> build profiles              # List cover/mask/traffic profiles
krait> build status <id>           # Check build status

Windows Build

krait> build windows -s <host> [options]

Required:

FlagDescription
-s, --serverC2 server address

Connection:

FlagDefaultDescription
-p, --port8443C2 listener port
-i, --interval60Poll interval in seconds
-j, --jitter20Jitter percentage (0-100)
--external-portSame as --portPort the agent connects to (behind a reverse proxy)

Template selection:

FlagDescription
--transporthttps (default), smb, tcp, dns
--profileTraffic profile: slack, discord, teams, gdrive, onedrive, github, npm, docker-registry
--dllUse DLL template instead of EXE

Evasion:

All evasion flags are boolean toggles. They compose freely — use any combination.

FlagDescription
--all-evasionEnable all evasion flags (except mutually exclusive ghost/herpaderp)
--hwbp-bypassHardware breakpoint AMSI/ETW bypass
--hwbp-all-threadsApply HWBP to all threads, not just the main thread
--stack-spoofFabricate legitimate stack frames during sleep
--stack-encryptXOR-encrypt stack during sleep
--module-stompMap PE into sacrificial DLL
--module-overloadVariant of module stomping
--loadlib-proxyRoute DLL loads through manual PE mapper
--pe-fluctuationEncrypt PE at rest with VEH
--heap-encryptEncrypt heap during sleep
--etw-nop-callNOP out ETW event write calls
--tampered-syscallsTampered syscalls via ntdll return address
--peer-reconnectFall back to HTTPS if SMB/TCP parent dies
--sleep-methodekko (default) or foliage (APC-based NtContinue)

Migration:

FlagDescription
--context-hijackThread context hijack instead of APC
--section-mapShared section mapping instead of cross-process write
--delayed-suspendCreate process then suspend
--phantom-dllSEC_IMAGE mapping instead of pagefile
--remote-threadNtCreateThreadEx instead of context hijack/APC
--ghostProcess ghosting migration
--herpaderpProcess herpaderping migration

Cover & signing:

FlagDescription
-c, --coverProcess masquerade profile (see Cover Profiles below)
--machine-lockLock to machine by ProductId hash
--signAuthenticode sign with PFX certificate
--sign-passwordPassword for the PFX certificate

Transport sub-options:

FlagDescription
--pipe-nameSMB named pipe name (default: msagent_default)
--tcp-hostTCP parent host to connect to
--tcp-portTCP parent port (default: 4444)
--dns-domainDNS C2 domain
--dns-serverDNS server IP (default: same as --server)
--dns-portDNS port (default: 53)

Output:

FlagDescription
-o, --outputOutput filename (default: agent_<id>.exe)

Recommended engagement build:

krait> build windows -s your-c2.example.com -p 443 \
    --profile slack --all-evasion --cover svchost

Linux Build

krait> build linux -s <host> [options]

Supports the same connection, transport (HTTPS and DNS), and profile flags as Windows. Linux-specific options:

FlagDescription
-m, --maskProcess mask (kworker, kthreadd, ksoftirqd, cron, dbus, etc.)
-c, --coverBinary cover (systemd-resolved, cups-browsed, sshd, etc.)

Examples:

krait> build linux -s 10.0.0.1
krait> build linux -s 10.0.0.1 -m kthreadd -c systemd-resolved
krait> build linux -s 10.0.0.1 --profile discord
krait> build linux -s 10.0.0.1 --transport dns --dns-domain c2.lab.local

Cover Profiles

Windows

Spoof PE metadata (version info, timestamps, internal name) to match legitimate Windows processes.

CoverMasquerades As
RuntimeBrokerRuntimeBroker.exe (default)
svchostsvchost.exe
taskhostwtaskhostw.exe
dllhostdllhost.exe
smartscreensmartscreen.exe
sihostsihost.exe
SearchHostSearchHost.exe
ctfmonctfmon.exe
slackslack.exe
discordDiscord.exe
teamsms-teams.exe
gdriveGoogleDriveSync.exe
onedriveOneDrive.exe

When --profile is used, the matching SaaS cover is auto-selected. --cover overrides.

krait> build profiles              # List all covers, masks, and traffic profiles

Linux

Linux covers replace the binary name and cmdline. Masks set the thread name visible in /proc.

krait> build linux -s 10.0.0.1 -m kworker -c systemd-resolved

Machine Lock

Lock an agent to a specific Windows machine by its ProductId:

krait> build windows -s 10.0.0.5 --machine-lock "00330-80000-00000-AA123"

The agent will refuse to run on any machine with a different ProductId. Use the get-productid BOF to retrieve the target’s ProductId.

Code Signing

Sign the output binary with an Authenticode certificate:

krait> build windows -s 10.0.0.5 --sign cert.pfx --sign-password mypassword

Requires osslsigncode installed on the server host.

Polymorphism

Every build randomizes the hash seed, XOR key, and AMSI variant. Two agents built from the same template will have different binary signatures.

Verifying Templates

Each template directory contains a manifest.json with SHA-256 hashes for integrity verification. The build system automatically verifies that all templates are patchable after compilation.