ZeroBox

Interactive TTY Stabilization & Terminal Spawning

Stabilizing non-interactive reverse shells into fully featured TTY sessions with tab-completion and terminal window resize support.

pythonsttyscriptsocat

Raw reverse shells lack arrow key navigation, tab autocompletion, job control (Ctrl+C), and editor support. Stabilizing the shell is crucial before running interactive commands like sudo or su.

1. The Standard Python + stty Technique

  1. Spawn pseudo-terminal in remote shell:
   python3 -c 'import pty; pty.spawn("/bin/bash")'
  1. Background the shell:

Press Ctrl+Z.

  1. Configure local terminal and bring shell to foreground:
   stty raw -echo; fg
  1. Export terminal environment and window dimensions:
   export TERM=xterm-256color
   stty rows 38 columns 140

2. Alternative: Using `script`

If Python is not installed on the victim:

script -qc /bin/bash /dev/null
# Then Ctrl+Z -> stty raw -echo; fg

After establishing a stable interactive TTY, proceed with 04. Linux Privilege Escalation Master Guide.

More CPTS notes

Keep these notes in your own private vault. Open CPTS notes in ZeroBox