# DriftingBlues: 5 BOOT2ROOT CTF VULNHUB WRITEUP

Welcome back to my writeup!! Today I will show how I solved the fifth part of the DriftingBlues series!! No further explanations, let's start!!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F7Heo1x4lyh6BRf9yNjRa%2Ficegif-1190.gif?alt=media&#x26;token=af3273b8-a984-4fba-ab7a-20f6f8ab34cf" alt=""><figcaption></figcaption></figure>

First thing that will do is always, `Nmap` scan.

`nmap -A -sC -p- -T5 -oN nmap_result.log 192.168.54.174`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FLDkvXnKbhfMv8hB22yC3%2FScreenshot%20(1672).png?alt=media&#x26;token=4f6f94c1-8606-495e-972f-d44d893771d0" alt=""><figcaption><p>Port 22, and 80 are open</p></figcaption></figure>

It's clear that the HTTP service is running WordPress. We already have an idea of how to proceed with this.

But first, let's visit the webpage.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FwEi58kDpM1Urb4r4xJv3%2FScreenshot%20(1673).png?alt=media&#x26;token=20f2fc73-808f-453a-ac71-cd81b1d18646" alt=""><figcaption></figcaption></figure>

Just a simple webpage, what to expect in driftingblues?? xD!

Next thing I did is to enumerate all the subdirectories using `Gobuster` .

`gobuster dir -u http://192.168.54.174 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x html,php,txt`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FlPIx98LTAgWdOzbei0S2%2FScreenshot%20(1674).png?alt=media&#x26;token=bc0bcfc8-03a9-470c-83e1-14f626e453c1" alt=""><figcaption><p>Nothing interesting, just normal wordpress subds</p></figcaption></figure>

Next thing I did is to use `wpscan` to scan for any vulnerabilities in this WordPress webapp, since it has a login page, we can directly bruteforce this!

`wpscan  --url http://driftingblues.box --detection-mode aggressive -e -P /usr/share/wordlists/rockyou.txt`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FnjPpOCHDxMUgC8j2eFn1%2FScreenshot%20(1676).png?alt=media&#x26;token=609d5a42-b761-4442-8f72-38cfe5521bb5" alt=""><figcaption><p>Here are the users</p></figcaption></figure>

Since the cracking attempt using `rockyou.txt` was taking too long and most of the passwords in it are relatively short, I figured the actual password might be longer. To adapt, I used **CeWL** to crawl the target site and generate a **custom wordlist** by extracting words with at least 10 characters.

`cewl http://driftingblues.box -m 10 -w passwd.txt`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Ffah32jJE8oAnCRTbGrrf%2FScreenshot%20(1679).png?alt=media&#x26;token=16f045c3-8640-4348-a79d-4afa589c6349" alt=""><figcaption></figcaption></figure>

After that, I launched the wpscan and use our new wordlist.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FWvhmv0S61faQDhE7b4Py%2FScreenshot%20(1683).png?alt=media&#x26;token=dbfafd69-1724-4bfb-9596-e38adb47e387" alt=""><figcaption></figcaption></figure>

We finally got the credential! Now let's login!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F8g1vKnEQqHori8S6sR8a%2FScreenshot%20(1684).png?alt=media&#x26;token=91d07c31-ace5-437c-ba84-1e08e47df9a9" alt=""><figcaption><p>We're in!</p></figcaption></figure>

While exploring I found nothing useful, but I've found some photos stored here, that might be our key.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FMVrAR09HsSyrI2rfOrEU%2FScreenshot%20(1687).png?alt=media&#x26;token=f4142130-8c7b-4613-a868-d04fa34c9a8f" alt=""><figcaption></figcaption></figure>

A DriftingBlues picpic, so I download it and check its metadata using `exiftool` .

`exiftool dblogo.png`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FxZsk5EbGgQ7qF2IfArXN%2FScreenshot%20(1688).png?alt=media&#x26;token=8651a80b-ef11-436a-b385-e8a0b71c1461" alt=""><figcaption></figcaption></figure>

Well, would you look at that, an SSH password! Crazy how something as simple as metadata can end up being the key to breaking into a system. That’s the thing about CTFs, especially Boot2Root challenges, the tiniest details can make the biggest difference. It’s easy to overlook stuff that seems unimportant at first glance, but more often than not, that’s where the real gold is hidden. So if there’s one lesson here, it’s this: **never ignore the small stuff.** What looks like nothing could be your ticket in.&#x20;

Let's login!!

`ssh gill@192.168.54.174`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FssqHXG5xXnC4qv01EBgU%2FScreenshot%20(1693).png?alt=media&#x26;token=fb67aef6-aa0d-402c-ba46-75c064ddfdcd" alt=""><figcaption></figcaption></figure>

We're in!!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F1zg4ZxJkvPQNASCmNsxv%2FScreenshot%20(1697).png?alt=media&#x26;token=1a8ad90f-5f40-4288-b0fb-0302710b7e08" alt=""><figcaption><p>User Flag!!</p></figcaption></figure>

Now time for the root!!

Alongside with user flag, there's a file named `keyfile.kdbx` .

In simple terms, a `.kdbx` file is a database used by **KeePass**, a password manager designed to securely store login credentials.

I started by transferring the file to my attacker machine. Since the database is protected by a master password that we don’t know yet, the next step is to extract the hash using `keepass2john` so we can attempt to crack it.

`keepass2john keyfile.kdbx > hash`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FU6bvxZmKh3JY4GqB2kTC%2FScreenshot%20(1702).png?alt=media&#x26;token=016a6672-31c2-4b59-8dc4-590395a509c0" alt=""><figcaption></figcaption></figure>

Now let's crack it!

`john --wordlist=/usr/share/wordlists/rockyou.txt hash`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F7Ck1Ykcv1eVBN8buZ5o9%2FScreenshot%20(1705).png?alt=media&#x26;token=82e07ee1-9ab9-4493-b91d-eb620746bcaa" alt=""><figcaption></figcaption></figure>

We got the master key, let’s check out what’s inside this `.kdbx` file. To peek into it, I’ll be using `keepassxc-cli`, which is just the command-line tool for working with KeePassXC password databases.

Before we dive in, here’s a quick rundown of what a KeePass file actually is and how it works:

**So, what’s a `.kdbx` file?**

Think of it like a **digital vault**. It’s used by KeePass to store things like usernames, passwords, URLs, and even notes — all safely encrypted in one place. To open it, you usually need a **master key**, which could be just a password, a special key file, or both (like a second layer of protection).

Inside the file, the saved entries are neatly organized into **groups and subfolders**, kind of like folders on your desktop. For example, you might have groups like "Emails", "SSH Logins", or "Social Media", and inside each one are entries with:

* The title of the entry (e.g., “GitHub”),
* Username,
* Password,
* Website URL,
* And maybe some notes.

All of that info is encrypted — so even if someone has the `.kdbx` file, they can't see anything without the correct master key.

Alright, back to the challenge — let’s list out all the groups in the database! To list, we will just use the `ls` parameter of `keepassxc-cli`.

`keepassxc-cli ls keyfile.kdbx`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FYBm2eNKXpei0cuZpCDC4%2FScreenshot%20(1709).png?alt=media&#x26;token=df348dbf-ca5b-46d1-84de-9535b9226997" alt=""><figcaption></figcaption></figure>

Here are the groups! Now let’s dive in and check out the passwords saved inside.

`keepassxc-cli show keyfile.kdbx "group_name" --show-protected`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FC374bJOmvfaKmRk3ghOT%2FScreenshot%20(1712).png?alt=media&#x26;token=58429c73-4ab5-4f57-9eb7-8bbe5183322f" alt=""><figcaption></figcaption></figure>

But..... All of the groups has no passwords.. That's why I think that this is a rabbithole.&#x20;

Let's go back to the target machine. I used `LinPEAS` to find out more about this system.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FyCoduUyKiRCyxzWdet8c%2FScreenshot%20(1713).png?alt=media&#x26;token=6b2da290-9dc9-407f-b7e7-946ab0cc162f" alt=""><figcaption></figcaption></figure>

After the scan, I noticed a strange directory in root, the `/keyfolder` . Let's check it out.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FHz2MAftSR9M7VyefWzF1%2FScreenshot%20(1726).png?alt=media&#x26;token=b4c46556-974e-413b-a28e-2c13d5602c1a" alt=""><figcaption></figcaption></figure>

Looking at the permissions, we can see that other users have write access to this directory — even though it's owned by root! This could be our way to escalate privileges and gain root access.

When I looked inside, the directory was empty — leaving me completely unsure of what to do next.

At this point, I ran `pspy64` to monitor scheduled tasks and see if anything interesting was running via **cronjobs**.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FgmTAnPNJy9aDZsOEesNE%2FScreenshot%20(1715).png?alt=media&#x26;token=45b5b9a7-4d22-4814-96ab-6c17bc1b1b74" alt=""><figcaption></figcaption></figure>

While watching the output from `pspy64`, I noticed the system was running `/root/key.sh` using both `/bin/sh` and `/bin/bash`. That basically means there’s a script in the root directory being executed automatically.

Let’s go back for a bit. In the `/root` directory, I found a folder named `/keyfolder`, and based on the presence of the `/root/key.sh` script, I suspected it was meant to generate or process some kind of password. I figured the script might output something important — maybe the root flag — into that folder. But when I looked, it was completely empty. Earlier, I had cracked the `.kdbx` file, and if you recall, the group names inside it looked a lot like potential passwords. So I thought, maybe creating a file in `/keyfolder` using one of those group names as the filename would trigger the script. At first, nothing worked — no output, no reaction. I kept trying different group names, and just when it was starting to feel hopeless… one of them finally worked!&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FR0KXx14fbp9OpTGZmFNO%2FScreenshot%20(1718).png?alt=media&#x26;token=4f5eead2-cf9b-4036-9e60-9b1197af7e79" alt=""><figcaption></figcaption></figure>

After creating a directory named **fracturedocean** — which was one of the entries found in the `.kdbx` file, I waited a bit for the `key.sh` script to run. Soon after, a new file called `rootcreds.txt` was generated.

Honestly, this vulnerability was tough to spot, and it took quite a bit of trial and error to even come close to figuring it out.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fqi61LgOvvT48xO8ygHX1%2FScreenshot%20(1720).png?alt=media&#x26;token=94ff5174-d2dd-4125-9c17-51dd1222fc01" alt=""><figcaption><p>Root Password</p></figcaption></figure>

Now let's login as root!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FDdFSHpZQceOt61xP4WX0%2FScreenshot%20(1721).png?alt=media&#x26;token=5560759a-9143-4bdc-a827-2eb52c324768" alt=""><figcaption></figcaption></figure>

We are now root!!!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F9mnsj5X2extKR4FxJ59P%2FScreenshot%20(1724).png?alt=media&#x26;token=ecdc1665-edf5-4127-93d7-1f5b0aaeb084" alt=""><figcaption><p>Root Flag!</p></figcaption></figure>

We've successfully pwned DriftingBlues: 5!!

Let's check the content of `key.sh`  to make it clear.

```bash
#!/bin/bash                                                                                                                                                                                  
                                                                                                                                                                                             
if [[ $(ls /keyfolder) == "fracturedocean" ]]; then                                                                                                                                          
        echo "root creds" >> /keyfolder/rootcreds.txt                                                                                                                                        
        echo "" >> /keyfolder/rootcreds.txt                                                                                                                                                  
        echo "imjustdrifting31" >> /keyfolder/rootcreds.txt                                                                                                                                  
fi
```

The `key.sh` script is a simple bash script that checks if the `/keyfolder` directory contains exactly one item named **fracturedocean**. If that condition is true, it writes a file called `rootcreds.txt` inside `/keyfolder`, containing the text "root creds" followed by the actual password `imjustdrifting31`. This explains why, after creating a directory named **fracturedocean** — which was a group name found in the `.kdbx` file — and waiting for the script to execute, the `rootcreds.txt` file was generated. The script is designed to look for that specific name, making the `.kdbx` group names a subtle hint toward the solution and showing how closely tied the cracked file and privilege escalation path are in this challenge.

This challenge was a perfect example of how Capture The Flag scenarios often test more than just technical skills — they challenge your attention to detail, creativity, and problem-solving mindset. What seemed like small or insignificant clues, like metadata or group names in a KeePass database, turned out to be key elements in solving the puzzle. By combining enumeration, password cracking, file inspection, and process monitoring, the path to privilege escalation gradually revealed itself. The solution wasn’t handed directly — it had to be pieced together from subtle hints and smart assumptions.

In the end, this challenge reinforced an important lesson: **never overlook the small stuff**. Whether it’s a file name, a group label, or a scheduled script, the smallest details can lead to the biggest breakthroughs. Stay curious, think outside the box, and always follow your instincts — they often point you in the right direction.
