# socat

## Remote port forwarding

```bash
# General
./socat tcp-l:<link-port> tcp-l:<local-port>,fork,reuseaddr &
./socat tcp:<attacker-IP-address>:<link-port> tcp:<destination-IP-address>:<destination-port>,fork &
http://127.0.0.1:<local-port>

# Ejemplo para acceder al puerto 80 de la máquina a la cual deseamos pivotear
# máquina atacante
./socat tcp-l:8001 tcp-l:8000,fork,reuseaddr &
# máquina que nos permite pivotear
./socat tcp:<attacker-IP-address>:8001 tcp:<destination-IP-address>:80,fork &
# máquina atacante
http://127.0.0.1:8000
```

* \<link-port> = puerto link entre nuestra máquina (atacante) y máquina que nos permite pivotear.
* \<local-port> = puerto local de nuestra máquina (atacante).
* \<attacker-IP-address> = dirección IP de nuestra máquina (atacante).
* \<destination-IP-address> = dirección IP de la máquina de destino a la cual deseamos pivotear.&#x20;
* \<destination-port> = puerto de la máquina de destino a la cual deseamos pivotear.

## Port forwarding

```bash
# Linux/Unix
## proceso en foreground
./socat TCP-LISTEN:<listen-local-port>,fork tcp:<destination-IP-address>:<destination-port>
## proceso en background
./socat TCP-LISTEN:<listen-local-port>,fork tcp:<destination-IP-address>:<destination-port> &

# Windows
## proceso en foreground
socat.exe TCP-LISTEN:<listen-local-port>,fork tcp:<destination-IP-address>:<destination-port>
## proceso en background
start /B socat.exe TCP-LISTEN:<listen-local-port>,fork tcp:<destination-IP-address>:<destination-port>
```

* \<listen-local-port> = puerto local de la máquina que realiza el port forwarding.
* \<destination-IP-address> = puerto de la máquina de destino.
* \<destination-port> = dirección IP de la máquina de destino.


---

# Agent Instructions: 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:

```
GET https://pentesting.mrw0l05zyn.cl/post-explotacion/pivoting/socat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
