In one sentence
A reverse shell is a command shell where the compromised machine initiates the connection out to the attacker's listener, rather than the attacker connecting in — a design that neatly steps around inbound firewall rules, which is exactly why it is the default payload after a foothold.
Why it matters
Once an attacker gets code execution on a host, they want an interactive shell — and the direction of the connection is everything. A bind shell opens a listening port on the victim for the attacker to connect to, which almost always fails: inbound connections are what firewalls block. A reverse shell flips it: the victim connects out to the attacker's waiting listener. Outbound traffic, especially on 443, is usually allowed, so the reverse shell sails through the perimeter that stopped the bind shell. That single insight is why "reverse shell" is the near-universal post-exploitation payload.
For defenders it reframes the problem. You will not catch this at the inbound firewall — you catch it by noticing a server process that has no business making outbound connections suddenly dialling a strange host, and by controlling egress. Understanding the mechanism tells you where to look: the callback, not the break-in.
Listener, callback and encoding
There are two halves. The attacker starts a listener (classically nc -lvnp 443) and waits. The payload run on the victim opens a socket back to that listener and wires the host's shell (/bin/bash, cmd.exe, PowerShell) to it, so the attacker's keystrokes run on the victim and its output streams back.
- The payload is written in whatever the victim already has —
bash,nc,python,php,perl,ruby, PowerShell,socat,openssl. Living off existing interpreters (see LOLBins) avoids dropping a new binary that an EDR would flag. - Payloads are often encoded to survive the delivery channel and dodge naive signatures — URL-encoding to pass through a web parameter, Base64, or PowerShell's
-EncodedCommand(UTF-16LE Base64, usually with-NoP -W Hidden). - A raw reverse shell is fragile (no job control, no tab-completion); attackers "upgrade" it to a full pseudo-terminal, and a C2 framework replaces the raw
nclistener entirely for encryption, session management and persistence.
It is a means to an end: the shell usually lands with the web/app service's privileges, and the next move is privilege escalation.
Detect it yourself hands-on
The mechanism tells you where to look, so build the detection rather than the payload. The offensive half — the Reverse Shell Generator and the LOLBin Browser — now lives on our red-team sister site OffensiveRamen.com; here we build the blue-team answer to it.
- Start from the behaviour: open the MITRE ATT&CK Search and look up T1059 Command and Scripting Interpreter. Read what a spawned interpreter and its outbound socket actually look like on an endpoint — that is the signal, not the exploit that delivered it.
- On Windows, the callback usually starts with a process-creation event: in the Windows Event ID Lookup read 4688 (and Sysmon Event 1) to see the parent/child and command-line fields that give away
powershell -enc …or a web-server process launchingcmd.exe. - Write the detection once so it survives a SIEM change: in the Sigma Rule Builder, compose a rule for a service account (a web or app process) spawning a shell and making an outbound connection. That is the outbound-callback pattern the perimeter firewall never sees.
Result: a portable detection aimed at the connection you can actually catch — the callback — instead of the inbound break-in that never happens.
Common misreadings
- Blocking inbound does nothing here. The dangerous connection is outbound. Egress filtering and outbound-connection monitoring are the controls that matter.
- A shell is not domain admin. It typically runs as the exploited service account; treat it as the start of the intrusion, not the end — the real damage follows privilege escalation and lateral movement.
- Authorisation and scope are the whole game. Generating or running these against systems you are not explicitly permitted to test is a crime in most places, regardless of intent.