RegistryTwo - HTB
https://app.hackthebox.com/machines/552
Last updated
https://app.hackthebox.com/machines/552
Last updated
First of all, I won't go into deep detail for every step. Sometimes I'll skip certain aspects, but my focus will be on delivering the exploit, vulnerability, and how to exploit them efficiently. This will be a quick and concise writeup."
First lets start with port 5001
With fuzzing the web dirs ,we can find /auth
you can refer back to the docker registry documentation HERE for further details
also specifically HERE will tell you what to do with the token ,but first it required more modifications in order to access the docker registry image and pull it.
As per documentation we also need :
To craft your own token ,we used this added URL scope as the documentation suggest to access _catalog
https://webhosting.htb:5001/auth?service=Docker%20registry&scope=registry:catalog:
*
Craft another token to get hosting-app image information
https://webhosting.htb:5001/auth?service=Docker%20registry&scope=repository:hosting-app:pull
Reading the image information will gives you a clue what web app they are using and alot of other information to find your way for the user foothold
Now we move to Port 443
Register with a new user then login
as we know previously they are using tomcat v9.0.2 ,referring to HERE we find that website is vulnerable to Path Traversal (..;/)
Now we are able to access the application manager
Now we are able to access the example scripts which we can modify token sessions to access unavailable things
as you can see (s_EditingMedia_{tmpID}) ,u can get {tmpID} by creating a domain then try to write/edit the file index.html or any created file
i have automated the process by creating this simple python script
just make sure to change {cookie} + {tmpID} to yours ,after you get successfully respond ,you can refresh the tmpID page to see the file ,also note you are able to modify the file with what ever you want if you have write access to that file.
now we can get the hosting.war that we found in previous docker registry image that we pulled
view the webpage source ,and scroll down to ' value=atob(`{BASE64}`)
try to just get the {base64} and remove the rest ,and use base64 -d to > hosting.war file
after reading the source code ,we know we can set manager role
adding &rmi.host={ip} and %00.htb to bypass the check
now we have to request anything through our created domain to trigger the RMI
i used ermir tool ,and make sure your current java version is 11 in order for the payload and exploit to work, u can use below commands to list/change your java version
after enumeration ,we can actually interact with the RMI server again to escape the docker
you will find all used tools in my repository
i brute force developer folder using Sec-List/Discovery/Web-Content/dirsearch.txt
and found a hidden file contain credentials
za