Skip to content
Payload Playground

TTY Shell Upgrade & Stabilization

You got a shell — now stabilize it. Generate the exact upgrade commands for your situation.

Shell Configuration

Check what's installed — methods requiring unavailable tools are dimmed.

which python3 python python2 script socat perl ruby expect 2>/dev/null
ls /tmp/ 2>/dev/null
Quality:BestGoodPartial
Run on attacker
Run on target

Upgrade methods for Linux (netcat (nc))

Standard netcat shell: no job control or line editing. Python PTY or socat gives a full interactive TTY; rlwrap works locally on your nc listener.
Python PTY Spawn
Best

The go-to method. Spawns a pseudo-terminal via Python's pty module, then uses stty raw to hand control back to your terminal.

1
Target machine

Spawn a PTY on the target

# Try python3 first:
python3 -c 'import pty; pty.spawn("/bin/bash")'

# Fallback to python2 if needed:
python -c 'import pty; pty.spawn("/bin/bash")'
2
Target machine

Background the shell

Press Ctrl+Z to suspend the shell and return to your local terminal.

# Press: Ctrl + Z
3
YOUR machine (attacker)

Fix your local terminal (run on YOUR machine)

stty raw -echo; fg
4
Target machine

Reset terminal and set environment

reset
export SHELL=bash
export TERM=xterm-256color
stty rows 38 columns 116
SSH Key Injection
Best

If you can write to ~/.ssh/authorized_keys on the target, inject your public key for a full SSH session — the gold standard for interactivity.

rlwrap Wrapper
Partial

Run on YOUR machine before catching the shell. Adds readline history and arrow key support, but is NOT a full TTY — Ctrl+C will still kill the process.

Socat (Download to Target)
Good

If socat is not installed on the target, download a static binary and use it directly. Works on most Linux x86_64 systems.

script Command
Good

Uses the built-in script utility to fake a TTY. Works on systems without Python. Follow up with the stty raw trick.

Socat Full Upgrade
BestMissing: socat

The best method when socat is available on target. Gives a fully interactive PTY with no tricks needed — arrow keys, Ctrl+C, and tab completion all work.

Expect
PartialMissing: expect

Quick fallback if expect is installed. Gives limited interactivity — no stty raw needed, but Ctrl+C may still kill the shell.

Perl PTY
PartialMissing: perl

Uses Perl to spawn a PTY. Handy when Python is unavailable.

Ruby PTY
PartialMissing: ruby

Uses Ruby to spawn a PTY when other options are unavailable.

Terminal Size Fix

After upgrading, the target may not know your terminal size — causing broken output. Fix it with these commands.

# On YOUR machine — check size:
stty size

# On target — match it:
stty rows 38 cols 116

# Or auto-detect:
stty rows $(tput lines) cols $(tput cols)
Shell Environment Fixes

Run these on the target after upgrading to fix colors, PATH, and prompt issues.

export TERM=xterm-256color
export SHELL=/bin/bash
export HOME=/home/$(whoami)
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Related Tools

Companion generator

Reverse Shell Generator

Send feedback

Report an issue or suggest an improvement.

0/2000

Your report includes this page (/tools/shell-upgrade) and your browser. If you’re signed in, we include your account ID and plan so support can prioritize Pro requests. Please leave out secrets and client data.