HackTheBox | Ambassador Walkthrough
Hi!
Please ignore any type of grammar errors.

let’s get started with enumeration.
Enumeration
Nmap Scan
nmap -T4 -v -p- -sCV <target_ip>


We got four open ports: port 22 running a SSH, port 80 running HTTP and 3000 Unknown and 3306 running MySQL.
Web
We got a normal web page, so I run diresearch
to fuzz directories.

After analyzing the web pages, We’ve got nothing important.
So let’s see what port 3000 is running.
Port 3000
After checking it in the browser, I got redirected to grafana
login page.

I noticed its version. So I searched on google with its version and I got CVE-2021–43798 for Directory Traversal and Arbitrary File Read.
Here I used ExploitDB code (https://www.exploit-db.com/exploits/50581), to run the exploit.
First I checked the vulnerability by read /etc/passwd
file.

Here I decided to read the configuration file and after searching online for grafana configuration file path, I got the path /etc/grafana/grafana.ini
and I tried to read it.

I worked!!
After I reading it, I noticed something interesting related to grafana database password.

I decided to continue reading the file and I got credentials.

Here I used the credentials to login through the website, but I got nothing.
I returned back to reading files.
I decided to read grafana database, So I googled grafana database file path and I got the path /var/lib/grafana/grafana.db
and I saved it.

I used grep
to match anything related to grafana and I got another creds.

So let’s login to MySQL server.
MySQL
mysql -h <target_ip> -u grafana -p

After navigating through the database, I found developer password.

It’s base64 encoded, So let’s decode it.

Lateral Movement
SSH Login
Let’s try to login to ssh using developer user and password.
ssh developer@<target_ip>

Here, I noticed interesting file in developer directory called .gitconfig
.

I decided to read it.

It’s related to /opt/my-app
.
So let’s get the logs of the repo.
git log

I opened the first commit.

I found interesting command called consul
. So I decided to search for exploits.
I found an exploitation and I used this repo https://github.com/owalid/consul-rce.
Privilege Escalation
I follewed the POC, So let’s run the exploit.

And it worked, So let’s get root.
Root

Conclusion
Always Search, Google is your friend :)
This was great fun!
I hope you enjoyed the walkthrough. I waiting for your feedbacks.
Don’t forget to check other walkthroughs.