Writeup by wook413

Recon

Nmap

As usual, I started with three Nmap scans. The first was a full TCP port scan (all 65,535 ports) to identify open ports, followed by a service version scan on those discovered ports. The final scan targeted the top 10 UDP ports.

Initial Access

I confirmed that only ports 3000 and 9090 were open on the target host. I then ran the Nmap http-enum script against both of them.

HTTP 3000

Port 3000 was running Grafana v8.3.0

image-20260209213910007

While Gobuster was performing directory brute-forcing, I checked the service on port 9090 to further my enumeration.

HTTP 9090

Port 9090 was running Prometheus . I explored the service but couldn’t find any significant leads.

image-20260209213917275

image-20260209213924788

image-20260209213929825

I searched for “Grafana 8.3.0” on Searchsploit and found an exploit for an Arbitrary File Read vulnerability.

Using this exploit, I successfully read the /etc/passwd file. However, my attempts to read id_rsa files of existing users failed.

To find a way forward, I searched Google for “Grafana important files location” and discovered the existence of the /var/lib/grafana/grafana.db file.

image-20260209213939318

I retrieved a basicAuthPassword using the previous exploit, but my attempt to log in as the sysadmin user with that password failed.

image-20260209213944584

After reviewing the exploit code, I used curl to download the database file and confirmed it was a SQLite file.

image-20260209213950465

I manually dumped the data using sqlite3 , but I still only found the same password and no other significant information.

I eventually learned through further research that Grafana passwords use a specific encryption method. I found a way to decrypt them in the following Github repository.

https://github.com/Sic4rio/Grafana-Decryptor-for-CVE-2021-43798

While reading the README of the repository, I noticed a familiar-looking password. It was identical to the encrypted password I had found earlier. Even before running the tool, I realized it would decrypt to SuperSecureP@ssw0rd .

image-20260209214003432

Just to be sure, I installed the necessary dependencies and ran the decrypt.py script, which confirmed the plaintext password.

image-20260209214008967

Shell as sysadmin

I successfully logged in as the sysadmin user using the obtained plaintext password.

found local.txt

Privilege Escalation

The initial shell felt unstable, so I established a new reverse shell using penelope . Upon running the id command, I discovered that the sysadmin user was a member of the disk group.

From my experience with previous CTF machines, I knew that being in the disk group allows a user to bypass filesystem permissions and read disk blocks directly. Furthermore, if a disk is mounting the root directory (/), member of the disk group can access the entire file system.

I ran df -h and confirmed that the /dev/sda2 partition was indeed mounted as the root directory.

I was able to read proof.txt using the debugfs command.

Shell as root

Beyond simply reading the proof.txt flag, I aimed for a root shell. I accessed the root user’s private key, saved it locally, and used it to log in via SSH to obtain a full root shell.

Found proof.txt