less than 1 minute read

TTY Shell

A TTY (teletype) shell is a fully interactive terminal session that mimics a real terminal interface. After gaining access via a reverse or bind shell, attackers often upgrade to a TTY shell to enable features like command history, job control, and proper signal handling. This upgrade provides a more stable and user-friendly environment for interacting with the compromised system.

Python

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

Perl

perl -e 'exec "/bin/bash";'

Ruby

ruby -e 'exec "/bin/bash"'

Lua

lua -e 'os.execute("/bin/bash")'

Socat (Target must have socat installed)

socat file:`tty`,raw,echo=0 tcp-listen:4444

Bash (if not already in bash)

/bin/bash -i

Echo with Script

echo os.system('/bin/bash')

Script Command

script /dev/null -c bash

stty for Full TTY Experience

stty raw -echo; fg

Run this after backgrounding the current shell (Ctrl + Z) and then running stty.