> For the complete documentation index, see [llms.txt](https://rfc1918.gitbook.io/offsec/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rfc1918.gitbook.io/offsec/network-pivoting/proxies-and-port-fowarding/metasploit.md).

# Metasploit

## Autoroute

<pre><code><strong>meterpreter > 
</strong><strong>run autoroute -s 10.1.13.0/24
</strong></code></pre>

## PortFwd

> The **portfwd** command from within the Meterpreter shell is most commonly used as a pivoting technique, allowing direct access to machines otherwise inaccessible from the attacking system.&#x20;

Meterpreter-based portfwd command that adds a forwarding rule to the current Meterpreter session. This rule forwards network traffic on port 3300 on the local machine to port 3389 (RDP) on the target.

```
portfwd add -l 3300 -p 3389 -r <IPaddressofTarget>
```

### Add

```
meterpreter > 
portfwd add –l 3389 –p 3389 –r  [target host]
```

* **add** will add the port forwarding to the list and will essentially create a tunnel for us. Please note, this tunnel will also exist outside the Metasploit console, making it available to any terminal session.
* **-l 3389** is the local port that will be listening and forwarded to our target. This can be any port on your machine, as long as it’s not already being used.
* **-p 3389** is the destination port on our targeting host.
* **-r \[target host]** is the our targeted system’s IP or hostname.

### Delete

Entries are deleted very much like the previous command. Once again from an active Meterpreter session, we would type the following:

```
meterpreter > 
portfwd delete –l 3389 –p 3389 –r [target host]
```

### List

This argument needs no options and provides us with a list of currently listening and forwarded ports.

```
meterpreter > 
portfwd list
```

### Flush

This argument will allow us to remove all the local port forward at once.

```
meterpreter > 
portfwd flush
```

## References

{% embed url="<https://www.offensive-security.com/metasploit-unleashed/pivoting/>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://rfc1918.gitbook.io/offsec/network-pivoting/proxies-and-port-fowarding/metasploit.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.
