Skip to content
CyberNetGen
Menu

Spawning a TTY Shell

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

WriteupBy Udesh Wiyasinghe0 min read

On this page

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
python -c 'import pty; pty.spawn("/bin/sh")'
python3 -c 'import pty; pty.spawn("/bin/sh")'

Perl#

text
perl -e 'exec "/bin/sh";'

Ruby#

text
ruby -e 'exec "/bin/sh"'

lua#

text
os.execute('/bin/sh')

Bash#

sh
echo os.system('/bin/bash')
/bin/sh -i