Bounty
https://app.hackthebox.com/machines/Bounty
Last updated
https://app.hackthebox.com/machines/Bounty
Last updated
Browsing to the hosted web server we are greeted with an image of a wizard.
As there is nothing else to obtain from this page, even after checking the page source we can move on to directory brute forcing with feroxbuster
.
Using the large files word list from seclists
we discover the existence of transfer.aspx
.
Browsing to the transfer.aspx
page we are given a opportunity to select a file for upload.
Going straight in and attempting to upload an .aspx
reverse shell we see through Burpsuite
that we are given an error due to an invalid file.
In order to discover allowed file types I sent the request to Intruder and fuzzed the .aspx
extension with a list of most common extensions.
Once completed sorting the results by length we see that responses with a length of 1350 indicate file upload was successful.
Most interesting from the results is the .config
file extension. This can be used against IIS servers for gaining web shells and reverse shells under the right circumstances.
The blog post linked below covers various ways of exploiting this:
URL: https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/
We are going to use a web shell as shown below. Save the contents in a file called web.config
.
Web.config Web Shell: https://github.com/tennc/webshell/blob/master/aspx/web.config
After saving the contents upload the web.config file to the target system. After uploading we see through the response in Burpsuite
that the file upload was successful.
After uploading the file we still need to discover where to access it from. Using feroxbuster
again with a different directory word list we soon discover the directory /UploadedFiles/
.
Using Burpsuite we sent a GET request to http://10.10.10.93/UploadedFiles/web.config?cmd=whoami
. Where we have append the command we wish to run.
Looking at the response, we see we are executing commands in the context of the user merlin.
We can now use the web shell to gain a proper shell.
After setting up as per the above commands use the web shell to execute the msfvenom
payload.
Where out netcat
listener should catch the shell.
Moving into merlin's Desktop directory we notice initially that it is empty. Running the command dir /a
shows reveals hidden files, where we can now grab the user.txt
flag.
Moving onto privilege escalation we perform the basics by checking our current user privileges with whoami /priv
.
With the privilege SeImpersonatePrivilege
we may be able to perform a JuicyPotato attack to escalate privileges depending on the operating system version.
In order to identify the correct CLSID to use we can either painstakingly guess or we can use a batch script to test for each possibility.
Download the files below:
Windows Server 2008 R2 Datacenter CLSID: https://github.com/ohpe/juicy-potato/blob/master/CLSID/Windows_Server_2008_R2_Enterprise/CLSID.list
test_clsid.bat: https://github.com/ohpe/juicy-potato/blob/master/Test/test_clsid.bat
JuicyPotato.exe: https://github.com/ohpe/juicy-potato/releases/tag/v0.1
Place them in the specified folder for the SMB server we set up earlier and then on the target system copy them over.
Once downloaded run the batch file.
This will test all possible CLSID's for Windows Server 2008.
Once completed we can check the result.log file for CLSID's which will work. From here make a note of any that are running under SYSTEM.
To stage that attack we also need a copy of nc.exe
on the target system. Again, place the file on our SMB
share and copy the binary over.
Copy over nc.exe
.
From here build the attack to call back to a listening ports on the attacking system.
-l : Create a listening port
-p: Program to launch
-a: use the following arguments
-t: createprocess call: CreateProcessWithTokenW, CreateProcessAsUser, <*> try both
-c: {CLSID}
After running the command we should be given confirmation as shown below:
As well as receiving a SYSTEM shell on our listener.
From here we are able to retrieve the root.txt
flag.