← Glossary

Techniques & Tradecraft

Reverse Shell

Also: reverse shell · bind shell · callback shell · connect-back shell

Last reviewed:

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 nc listener 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.

Try it yourself hands-on

Generate the two halves for an authorised engagement and see why the encoding options exist. (Only ever against systems you own or are contracted to test — the tool carries an "authorized use only" notice for a reason.)

  1. Open the Reverse Shell Generator, set your Listener IP and port (e.g. 443), and pick Reverse. Browse the templates across shells — bash, nc, python, php, PowerShell, socat, openssl — and note it also gives you the matching listener helper (nc -lvnp 443), the half people forget.
  2. Flip Reverse to Bind and compare the commands: the bind variant listens on the victim, the reverse variant connects out. Reading them side by side is the clearest way to internalise why the reverse form beats a firewall.
  3. Switch the encoding to Base64, URL or PS -EncodedCommand and watch the payload transform — that is what lets a one-liner ride through a URL parameter or a Windows command line without breaking on quotes.
  4. See the "live off the land" angle in the LOLBin Browser: which built-in binaries can fetch or execute a payload, and the ATT&CK technique each maps to — the detection you would build against this.

Result: both sides of a reverse shell for a lab or a sanctioned test, and a concrete sense of the outbound-callback signal defenders should alert on.

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.