Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Penetration testing, first steps

Lab · Medium · 50 minutesFree account

Reverse Shells

Bash, Python, PHP, PowerShell, and Meterpreter reverse shells with netcat handlers.

  • reverse-shells
  • netcat
  • socat
  • msfvenom
  • rlwrap
On this page 9 sections
  1. 1Bind Shell vs Reverse Shell
  2. 2Setting Up a Netcat Listener
  3. Locked: Bash Reverse Shell
  4. Locked: Python Reverse Shell
  5. Locked: PHP Reverse Shell
  6. Locked: PowerShell (Windows)
  7. Locked: Upgrading Your Shell (TTY)
  8. Locked: msfvenom Payloads
  9. Locked: Reverse Shell One-Liners

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 127

Sign in to continue

7 more sections are for signed-in members. It is free: sign in with Google.

Related