Practice library / Penetration testing, first steps
Lab · Medium · 50 minutesFree account
Reverse Shells
Bash, Python, PHP, PowerShell, and Meterpreter reverse shells with netcat handlers.
On this page 9 sections
Before you start
Firewalls usually block inbound connections, so the compromised host dials home instead. A reverse shell is often the first interactive foothold after an RCE, and incident responders frequently report seeing one. Set up netcat listeners, trigger reverse shells in bash, Python, PHP and PowerShell, then upgrade them to a full interactive TTY.
Lab Objectives
- Understand the difference between bind shells and reverse shells
- Set up a netcat listener on your attacker machine
- Use multiple languages to establish a reverse shell
- Upgrade a basic shell to a fully interactive TTY
- Generate payloads with msfvenom for different platforms
Step 1: Bind Shell vs Reverse Shell
Bind Shell
Victim opens a port. Attacker connects TO the victim. Blocked by most firewalls.
Reverse Shell
Victim connects back TO attacker. Bypasses firewalls that block inbound but allow outbound.
Reverse shells appear in most real-world exploitation because firewalls typically allow outbound connections while blocking inbound ones.
Step 2: Setting Up a Netcat Listener
Before sending any reverse shell, start a listener on your Kali machine to catch the connection.
# Start listener on port 4444
nc -lvnp 4444
# Flags explained:
# -l → listen mode
# -v → verbose (show connections)
# -n → no DNS resolution (faster)
# -p → port number
# Use rlwrap for arrow key support (much nicer shell)
rlwrap nc -lvnp 4444
# Your listener is now waiting for the victim to connect
# You need your attacker IP (the IP the victim will connect to)
ip a | grep "inet " | grep -v 127Sign in to continue
7 more sections are for signed-in members. It is free: sign in with Google.