# Shell Upgrades

### Most reliable

Lacks some functions but reliable and easy

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

### Python

Lacks some functions but reliable and easy

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

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

### Spawn TTY Shell

SSH like functions, preffered method of upgrading the shell

```bash
# Spawn Python shell
python -c 'import pty; pty.spawn("/bin/bash")'

# Background the shell
Ctrl + Z

# Get current Rows and Columns
stty -a | head -n1 | cut -d ';' -f 2-3 | cut -b2- | sed 's/; /\n/'

# Bring shell back to the foreground
stty raw -echo; fg

# Set size for the remote shell 
# (where ROWS and COLS are the values from the 3rd command)
stty rows ROWS cols COLS

# Add some colours
export TERM=xterm-256color

# Reload bash to apply the TERM variable
exec /bin/bash
```

### Spawn TTY Shell #2

Similar to above, slightly less function but easier to implement.

```python
# Spawn Python shell
python -c 'import pty;pty.spawn("/bin/bash")'

# Give terminal functions
export TERM=xterm

# Background the shell
Ctrl + Z

# Bring shell back to the foreground 
stty raw -echo; fg
```


---

# Agent Instructions: 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://viperone.gitbook.io/pentest-everything/everything/everything-linux/shell-upgrades.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.
