> For the complete documentation index, see [llms.txt](https://strange-1.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://strange-1.gitbook.io/notes/shells/spawning-a-tty-shell.md).

# Spawning a TTY Shell

### Spawning TTY Shells

<pre class="language-bash"><code class="lang-bash">/bin/sh -i

/usr/bin/script -qc /bin/bash /dev/null

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

<strong># Python
</strong>python3 -c 'import pty;pty.spawn.("/bin/bash");'

<strong># Perl
</strong>perl —e 'exec "/bin/sh";'
perl: exec "/bin/sh"; # it should be run from a script

<strong># Ruby
</strong>ruby: exec "/bin/sh" # it should be run from a script

<strong># Lua
</strong>lua: os.execute('/bin/sh') # it should be run from a script

<strong># AWK
</strong>awk 'BEGIN {system("/bin/sh")}'

<strong># Find
</strong>find / -name nameoffile -exec /bin/awk 'BEGIN {system("/bin/sh")}' \\;
find . -exec /bin/sh \\; -quit

<strong># Vim
</strong>vim -c ':!/bin/sh'

<strong># Vim Escape
</strong>vim
:set shell=/bin/sh
:shell
</code></pre>

### Upgrading TTY Shells

```bash
# After getting a shell and spawing tty shell using one of the above methods, follow below step

# Hit ctrl[z]
^Z
# run below commands
stty raw -echo
fg
# If it shows blamk screen, press enter or input reset command to get the shell prompt
[Enter]
[Enter]
www-data@remotehost$

# To use full screen 
# In New Tab, note the output of both 
echo $TERM
stty size

# On our nc Shell on target
export TERM=xterm-256color
stty rows 67 columns 318 
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://strange-1.gitbook.io/notes/shells/spawning-a-tty-shell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
