> For the complete documentation index, see [llms.txt](https://pencer.gitbook.io/pencer-ctf-all-the-things/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pencer.gitbook.io/pencer-ctf-all-the-things/useful-stuff/upgrade-shell.md).

# Upgrade Shell

Once connected to our target the first job is to upgrade our terminal to something more useable.

Check if Python is available:

```
www-data@writer:/$ which python
which python
www-data@writer:/$ which python3
which python3
/usr/bin/python3
```

Spawn proper session:

```
python3 -c 'import pty;pty.spawn("/bin/bash")'
```

Ctrl+Z to background then get host stty size and terminal:

```
www-data@writer:/$ ^Z
zsh: suspended  nc -nlvp 1337

┌──(root💀kali)-[~/htb/writer]
└─# stty size          
52 237

┌──(root💀kali)-[~/htb/writer]
└─# echo $TERM                                                            
xterm-256color
```

Then bring session to box back to foreground and apply settings:

```
┌──(root💀kali)-[~/htb/writer]
└─# stty raw -echo; fg
[1]  + continued  nc -nlvp 1337

www-data@writer:/$ export TERM=xterm
www-data@writer:/$ stty rows 52 cols 237
```


---

# 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://pencer.gitbook.io/pencer-ctf-all-the-things/useful-stuff/upgrade-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.
