> For the complete documentation index, see [llms.txt](https://book.dragonsploit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.dragonsploit.com/shells.md).

# Shells

## Introduction

Getting command execution is a wonderful thing, but wouldn't you rather have an interactive shell? There are two types of shells you can interact with: bind shell or reverse shell.

## Bind Shells

SSHD can be seen as an example of a bind shell (at least in my mind). A bind shell binds to an IP and port on the server which when connected to serves a shell.

## Reverse Shells

Reverse shells send a shell to a listening server.

## Shell in Shell

Sometimes you want to run a shell inside another shell. This can be problematic if the parent shell dies it will kill the second shell. You can get around this by using `setsid` in linux. I think `start` allows you to create a new process group as well but not 100% sure on that.

### Linux Example

```bash
setsid -f revShell
```

## Upgrade Shells

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

```bash
stty raw -echo; fg
```
