> For the complete documentation index, see [llms.txt](https://g4b0.gitbook.io/g4b0-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://g4b0.gitbook.io/g4b0-docs/documentation/cheatsheets/tunneling-and-portforwarding/ssh-pivoting-with-sshuttle.md).

# SSH Pivoting with Sshuttle

* **sshuttle** es una herramienta Python que elimina la necesidad de configurar proxychains para pivotar.
* Limitación clave: **solo funciona sobre SSH** — no soporta pivoting por TOR ni HTTPS proxy.
* Ventaja principal: automatiza la creación de reglas iptables en el host atacante para enrutar tráfico a través del pivot sin configuración manual.
* A diferencia de proxychains, con sshuttle puedes lanzar herramientas directamente (ej. `nmap`, `xfreerdp`) sin prefijo alguno.

***

#### 1. Instalación de sshuttle

```bash
sudo apt-get install sshuttle
```

* Instala sshuttle desde los repositorios del sistema. El paquete instalado es `sshuttle 1.0.5-1` (\~508 kB).

***

#### 2. Ejecutar sshuttle y crear el pivot

```bash
sudo sshuttle -r ubuntu@10.129.202.64 172.16.5.0/23 -v
```

* `-r ubuntu@10.129.202.64` — especifica el host pivot con usuario SSH.
* `172.16.5.0/23` — subred interna a enrutar a través del pivot.
* `-v` — modo verbose para ver las reglas iptables que se crean.

Sshuttle pedirá la contraseña SSH del usuario en el pivot host y luego levantará el servidor Python remoto.

**Output esperado:** sshuttle crea automáticamente cadenas iptables (`sshuttle-12300`) con reglas NAT que redirigen todo el tráfico TCP destinado a `172.16.5.0/23` al puerto local `12300`, que a su vez lo tunelea por SSH.

***

#### 3. Escanear a través del pivot con Nmap

```bash
sudo nmap -v -A -sT -p3389 172.16.5.19 -Pn
```

* `-v` — verbose.
* `-A` — detección agresiva: OS, versiones de servicios, scripts NSE y traceroute.
* `-sT` — TCP connect scan (requerido cuando el tráfico pasa por un tunnel).
* `-p3389` — solo el puerto RDP.
* `-Pn` — omite el host discovery (asume el host activo).

**Output esperado:**

```
PORT     STATE SERVICE       VERSION
3389/tcp open  ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info:
|   Target_Name: INLANEFREIGHT
|   NetBIOS_Computer_Name: DC01
|   DNS_Computer_Name: DC01.inlanefreight.local
|   Product_Version: 10.0.17763
```

* Confirma RDP abierto en el DC (`DC01.inlanefreight.local`), dominio `INLANEFREIGHT`, Windows Server 2019.
* La advertencia `OSScan results may be unreliable` es normal al escanear a través de un pivot TCP.

**⚠️ OpSec:** `-A` es extremadamente ruidoso — lanza scripts NSE, OS fingerprinting y traceroute. Genera eventos en el SIEM/EDR del objetivo y deja artefactos en los logs del host. Usar solo cuando el noise no sea un factor crítico en el engagement.

***

> **Nota de laboratorio:** Al iniciar el target, esperar **3-5 minutos** hasta que el lab esté completamente configurado antes de intentar la conexión SSH. Credenciales: usuario `ubuntu`, contraseña `HTB_@cademy_stdnt!`


---

# 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, and the optional `goal` query parameter:

```
GET https://g4b0.gitbook.io/g4b0-docs/documentation/cheatsheets/tunneling-and-portforwarding/ssh-pivoting-with-sshuttle.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
