Hackthebox released a new machine called photobomb. On this machine, we got the web server where there is a JS file where we get the username and password to access the protected route, then abuse the filetype parameter to get a rev shell as photobomb and for Privilege Escalation using path traverse to get a root shell.
Nmap
Nmap tell us there are two open ports 22 ssh and 80 http and HTTP port redirect us to http://photobomb.htb/
Let’s quickly add this in our /etc/hosts file
Port-80
There is a simple HTML page with a link which going to /printer but it’s asking for password that’s we don’t know
After that, I view the source code of the website that’s include the JS file called photobomb.js
Viewing that file, we got the username and password
Now let’s try to log in with that username and password
After login, we see that there is an option to download photo to print
I capture that request in burp and try some command injection in all parameters
I try the payload in all parameter because I don’t know in which parameter there will be command injection
But before that start your python web server
This conforms that photo and dimensions parameter is not vulnerable
Command Injection
Let’s try with file type parameter
And we got the hit, it’s mean we can get rev shell with that
RCE
I try bash payload, but that didn’t work, so let’s try python one
Before that, start your net cat listener
It’s hanging that good sign, let’s check the net cat
Boom 🎉 we got the shell as wizard user
Got the user.txt
Privilege Escalation
Before running linpeas let’s try with sudo -l
And we can see there is cleanup.sh script which we can run with sudo privilege
And the content of the script is straight forward, it’s just taking the log file and move their content into photobomb.log.old and then use truncate to clear photobomb.log to 0 byte
but if you see clearly it’s not using absolute path like cd, find we can take advantage of that and traverse the path of that binaries
Just add /bin/bash in cd file and give read, write, execute permission
I also create find file because if one failed we have backup to get shell as root
Now just run that file with sudo permission and set the PATH to /temp directory