> For the complete documentation index, see [llms.txt](https://personal-archive.gitbook.io/oscp-exam-prep/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://personal-archive.gitbook.io/oscp-exam-prep/commons/shells/tty-shell.md).

# TTY Shell

Sometimes when we get a reverse shell, the received shell may not be fully functional.&#x20;

The following commands will allow us to spawn a proper shell.

<pre data-overflow="wrap" data-full-width="true"><code>Python -
    python -c 'import pty; pty.spawn("/bin/sh")'
    python3 -c 'import pty;pty.spawn("/bin/bash")'; export TERM=xterm-256color

Bash -
    echo os.system('/bin/bash')
<strong>    /bin/sh -i
</strong><strong>    /bin/bash -i
</strong>    script -qc /bin/bash /dev/null

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

<strong>Ruby: exec "/bin/sh"
</strong>
Lua: os.execute('/bin/sh')

IRB: exec "/bin/sh"

vi: :!bash

vi: :set shell=/bin/bash:shell

Nmap: !sh
</code></pre>
