
Spawning a TTY Shell
Learn how to spawn a TTY shell using Python and Bash.

Udesh
· 1 Min
Spawning a TTY Shell – Break out of Jail or limited shell
A TTY shell is a shell that is connected to a TTY device. It is a terminal that allows you to interact with the system. When you have a limited shell, you can spawn a TTY shell to break out of the restricted environment and gain full access to the system.
Python
python -c 'import pty; pty.spawn("/bin/sh")'
python3 -c 'import pty; pty.spawn("/bin/sh")'
Perl
perl -e 'exec "/bin/sh";'
Ruby
ruby -e 'exec "/bin/sh"'
lua
os.execute('/bin/sh')
Bash
echo os.system('/bin/bash')
/bin/sh -i