> For the complete documentation index, see [llms.txt](https://gitbook.nori-zamurai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.nori-zamurai.com/pentesting-cheatsheets/shell/upgrade-shell.md).

# Upgrade Shell

## Shell Spawning

#### Python

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

#### Echo

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

#### /bin/sh

```
/bin/sh -i
```

#### Perl

```
perl —e 'exec "/bin/sh";'

perl: exec "/bin/sh";
```

#### Ruby

```
ruby: exec "/bin/sh"
```

#### Lua

```
lua: os.execute('/bin/sh')
```

#### Exec from within IRB

```
exec "/bin/sh"
```

#### From within vi

```
:!bash

:set shell=/bin/bash:shell
```

#### From within Nmap

```
!sh
```

{% embed url="<https://netsec.ws/?p=337>" %}
