Upgrade to full shell / Spawning TTY Shell

Upgrade a shell to a “full shell”. For example after receiving a Netcat connection.

Can also be used to escape jail shells!

Spawn a TTY shell

python -c 'import pty;pty.spawn("/bin/bash")'
python3 -c 'import pty;pty.spawn("/bin/bash")'
echo os.system('/bin/bash')
/bin/sh -i
perl -e 'exec "/bin/bash";'
perl: exec "/bin/bash";
ruby: exec "/bin/bash"
lua: os.execute('/bin/bash')

Within IRB

exec "/bin/bash"

Within vi

:!bash
:set shell=/bin/bash:shell

Within Nmap (sudo nmap –interactive)

!sh