HackTheBox - Validation Writeup
Box author | ippsec
Nmap
Like always, I’m going to scan the IP Address by using Nmap.
|
|
There are a bunch of filtered ports. However, there still have open ports. Such as 22,80,8080
. It’s like something is happening with these ports. Based on port 22
the host is running Ubuntu
but in port 80
it says the host running on Debian
.
Http: UHC
Well, the port 80
is open and running on Apache
. Now, I’m going to take a look at it. Surprisingly, it is a simple website about UHC and I can register on it by putting the username and selecting the country.
I’m going to register my name and the country. When I clicked the “Join Now” button, it goes to this page.
It shows my name and the county that I picked to register. When I register with the same name and a different country. It keeps showing the page as the image above and always goes through the /account.php
endpoint.
Gobuster
So, I’m going to run gobuster to enumerate the hidden directory on it. Well, it did not reveal much of the directory in other words this site is very “barebone”. However, config.php
sounds interesting but it is empty.
Http: Cookie
Honestly, I found that weird. So, I’ll try to check if this page has some sort of section or cookie. Turns out, it has a set cookie
called user
. This cookie appears to change when I register a new username.
SQL Injection
I end up running the burpsuite to analyze the response and how the register form handles the request. Then, I’ll try to add a single quote '
everywhere and nothing happens. That’s so weird!, Hold and behold I forgot to change the cookie. So, I changed it and I’ve got an error that indicates it is vulnerable to SQLi
.
SQL Injection: UNION
Then, I’ll check the columns that can be injected and display the output to me. As always, this is the first time I’m going to try and the columns must be number 1. Right? ;). So, the payloads going to be country=country' UNION ALL SELECT 1-- -
.
Shockingly, it works on the first try. Based on the output itself, I can inject it with a malicious payload and display it to me. Such as VERSION()
.
SQL Injection: RCE
I want to upload the web shell to this box. However, I can’t find any path to upload it. To be honest, I’m stuck at this point and felt defeated. Then, I manage to find this article by threatening Mr.Google (not asking nicely today sir! jk). This is possible by using OUTFILE
to write a file to the server.
The webpage still throws an error. When I navigated to the file that I created and try the id
commands it works.
Foothold: Bash reverse shell
Now, it’s time to get a reverse shell. Seems the host is running on Linux. I’m going to use bash reverse shell and encoded with URL and BOOM!
Foothold: Upgrade shell using script
Finally, I’ve got the reverse shell as the www-data
user. As always, I want to have a full working shell, and it’s time to upgrade my reverse shell. However, when I lookups python either v2 or v3 its shows no result at all. Then, it clicks in my mind. I can upgrade this shell using script
like unified box.
Foothold: Config.php
So, I’m already in /var/www/html
directory. When I list all the content in this directory. I found that config.php
is not empty after all. Not just that! I manage to grab credentials in that file as well.
Then, I’ll try to enumerate the database with those credentials but nothing useful came back. So, I check how many users are on this box by reading the /etc/passwd
file. Surprisingly, there’s only one user in this box.
Root
So, I’ll try those credentials with the root user and it works.
NICE!