CTF··4 min read

HTB Keeper Writeup: How a Danish Dessert Unlocked Root Access

Initial Foothold: Web Application Vulnerability

Root Access: Privilege Escalation Path

Add given ip to host file keeper.htb

nano /etc/hosts

Terminal showing nano /etc/hosts with line '10.129.229.41 keeper.htb' added.

Conduct nmap scan ->

fast-forward full scope

nmap -sV -sC -T4 -p- 10.129.229.41

22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.3

80/tcp open http nginx 1.18.0 (Ubuntu)

Only ports below were open.

Terminal output of nmap scan showing open ports 22/tcp and 80/tcp on 10.129.229.41.

No results for keeper.htb in fuzzing ->

Terminal output of gobuster fuzzing for keeper.htb showing no results.

Let’s check port 80

Web browser showing default nginx page for keeper.htb with link to tickets.keeper.htb.

Simple html with referencing another page let’s add this also hosts file.

Terminal showing /etc/hosts file with added line '10.129.229.41 tickets.keeper.htb'.

Now I conducted fuzzing on tickets.keeper.htb subdomain.

Terminal output of gobuster fuzzing for tickets.keeper.htb showing /rt/ directory.

Jump to /rt/ endpoint directly.

Web browser showing Request Tracker login page at tickets.keeper.htb/rt/.

I did not see any exploit regarding to application login bypass via searchsploit. Therefore, I tried to search for default creds ->

Terminal output of searchsploit for request tracker showing no relevant exploits.

On base endpoint / credentials did not work ,so I also applied on /rt/ so as to ensure myself to be in correct backend proxy position.

Web browser showing Request Tracker login page with default credentials root:password entered.

Now I am in admin dashboard. Enumerate users ->

Web browser showing Request Tracker admin dashboard after login.
Web browser showing Request Tracker user list with comment revealing password for lnorgaard.

Observe that user pass includes in comments section. Let’s connect through SSH.

Terminal showing SSH login as lnorgaard@keeper.htb and command 'sudo -l' output.

Begin to see available binaries.

Terminal showing user flag captured in /home/lnorgaard/user.txt.

Took user flag:

Terminal showing unzip of RT30000.zip revealing passcodes.kdbx and KeePass.DMP.

Unzip zip file ->

unzip RT30000.zip

Terminal showing scp command to copy RT30000.zip to local /tmp/.

I searched for keepass keyword and found a repo related vulnerability -> CVE-2023–32784 https://github.com/z-jxy/keepass_dump

To analyze, retrieve files to local:

scp lnorgaard@keeper.htb:~/RT30000.zip /tmp/

Terminal showing git clone of keepass_dump repository and moving files.

clone the repo -> git clone https://github.com/z-jxy/keepass_dump?tab=readme-ov-file

unzip again and move .dmp, kdbx files to keepass-password-dumper directory

Terminal output of keepass-password-dumper showing partial password 'dgrd med flde'.

The process terminated ,yet I found really extraordinary string

dgrd med flde

Web browser search results for 'dgrd med flde' showing Danish dessert 'rødgrød med fløde'.

Sent to search engine

Web browser showing Wikipedia page for 'rødgrød med fløde'.

The found string is a dessert ->

rødgrød med fløde

Terminal showing apt install keepass2 and launching keepass2.

The string is associated with the master password of KeePass ,so I identified a apt package called keepass2 just by apt install keepass then it recommended correlated GUI tool.

KeePass2 GUI window with open database dialog.

Simply run the tool as keepass2 then click folder icon (open database).

KeePass2 GUI file picker showing passcodes.kdbx selected.

Find and select passcodes.kdbx file

KeePass2 GUI prompt for master password with 'rødgrød med fløde' entered.

Now it will ask the master password which is rødgrød med fløde ->

KeePass2 GUI dialog asking to save changes, clicking No.

Click no by default.

KeePass2 GUI showing root entry with masked password.

Simply click the masked password on root user

Terminal showing SSH attempt with root:F4><3K0nd! failing.

Now authenticate as root:F4><3K0nd!

KeePass2 GUI showing root entry with password and note about Putty key.

It did not work. Notice Putty user key file can be seen here ->

Web browser showing Super User question about converting PPK to OpenSSH key.

Now I did not have previous experience on how to conver Putty user key file to SSH ,so I discovered such a useful resource about it.

https://superuser.com/questions/232362/how-to-convert-ppk-key-to-openssh-key-under-linux

Terminal showing puttygen conversion command and resulting root_id_rsa file.

I passed through private-openssh so as to connect via root user.

puttygen /home/kali/Desktop/putty.ppk -O private-openssh -o /home/kali/Desktop/root_id_rsa

Connect with private key ->

ssh -i root_id_rsa root@keeper.htb

Terminal showing SSH login as root@keeper.htb using private key.

Get the root flag ->

Terminal showing root flag captured in /root/root.txt.

May The Pentest Be With You ! ! !