# DriftingBlues: 1 BOOT2ROOT CTF VULNHUB WRITEUP

Welcome back to another CTF writeup! In this post, I’ll walk you through my step-by-step process of rooting **DriftingBlues: 1**, a vulnerable machine from VulnHub. I know it’s been a while since my last post,  I’ve been tied up with school projects and other responsibilities, but I’m back and ready to dive into this challenge. This is the first installment in the **DriftingBlues** series, and I’m determined to complete the entire set soon. So buckle up, because we’re about to break down the exploitation process in detail and uncover all the flags this box has to offer.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FFkfqBRnczWze1O6BP8ea%2F222805.gif?alt=media&#x26;token=8a005b87-1b07-4ded-ad2c-40912baf030b" alt=""><figcaption></figcaption></figure>

First, we will scan for the open ports for potential entry points using **Nmap**

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

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FZYYUTNmLn9PoB4bYp9nz%2FScreenshot%20(1449).png?alt=media&#x26;token=5f6e1d5b-588b-4b15-af89-5a94032c5957" alt=""><figcaption><p>Port 22 (ssh) and Port 80 (http) are open</p></figcaption></figure>

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%2FL3bSc7DEOeivfkulRV0c%2FScreenshot%20(1450).png?alt=media&#x26;token=b5be7407-b716-4c5f-976d-63aa90cfe6cd" alt=""><figcaption><p>Some simple Blog</p></figcaption></figure>

As I scroll down, I noticed something that might be useful for us

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FJbiSojwIjyxBRsKEx6s7%2FScreenshot%20(1455).png?alt=media&#x26;token=04524b56-7ebc-404f-b4b0-4c732ec13d76" alt=""><figcaption></figcaption></figure>

I noticed that there are two webmail users: **sheryl** and **eric**. To proceed, I edited the `/etc/hosts` file to map the domain to **driftingblues.box**.

While inspecting the webpage’s source code, I came across something interesting — a comment containing a Base64-encoded string.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FXQMArscENd4WyShbFkij%2FScreenshot%20(1452).png?alt=media&#x26;token=9bde04ed-e7b1-4a6a-85ad-df4c11681ed1" alt=""><figcaption></figcaption></figure>

I decoded it and this is the plaintext

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FSX3v2qlXbZE7gSOMoPVO%2FScreenshot%20(1454).png?alt=media&#x26;token=13acff1f-8f4a-4861-b2b5-817d2d4000fe" alt=""><figcaption></figcaption></figure>

It appears to be a path, so I appended it to the domain and here’s what the page returned.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FR6VM7wSUaQajT7aNFVxP%2FScreenshot%20(1453).png?alt=media&#x26;token=4edb1d5a-34ed-4825-a89a-207cc1eb5181" alt=""><figcaption><p>An Ook Programming Language, I've encountered this before. </p></figcaption></figure>

Next thing I did is to decode it using [dCode](https://www.dcode.fr/ook-language), and this is the plaintext.

```
my man, i know you are new but you should know how to use host file to reach our secret location. -eric
```

The message subtly points toward the hosts file as a potential route to uncover something hidden. Given that, I turned my focus to the website and began brute-forcing directories using **Gobuster**, hoping to uncover any overlooked paths or directories that might offer valuable clues or lead to further access.

`gobuster dir -u http://driftingblues.box -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 10`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FiUkGHNL7tXrw43jZ8pa9%2FScreenshot%20(1459).png?alt=media&#x26;token=9b906df8-30f5-4d4a-bf17-e58905cda05f" alt=""><figcaption></figcaption></figure>

The `secret.html` captured my eyes, let's take that a visit.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FQYlkVRgGyqQsvIUm5bpm%2FScreenshot%20(1460).png?alt=media&#x26;token=27e022aa-a496-4908-bcc0-0df81f5973cf" alt=""><figcaption></figcaption></figure>

And as always, a Rabbithole:<

But no worries, time to dig even deeper! Let’s try brute-forcing subdomains and see if anything useful turns up.

`gobuster vhost -u driftingblues.box -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt --append-domain -t 10`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FbeCKniXZ2LFBeqM3I4DD%2FScreenshot%20(1461).png?alt=media&#x26;token=4fedfd37-9563-4b82-ad1d-aecd37ffa8e8" alt=""><figcaption></figcaption></figure>

And it has! Next thing I did is to add **test.driftingblues.box** to our `/etc/hosts` file.

When I visit the subdomain, this is the result.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FNy7YcJ0dxqpKXibwookY%2FScreenshot%20(1463).png?alt=media&#x26;token=e2650158-13f2-4f97-bd47-0466e6c1e77d" alt=""><figcaption></figcaption></figure>

Nothing useful, so let's move on and try brute-forcing directories within this subdomain.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FoASuMt2ntYw8V8SnoDK8%2FScreenshot%20(1464).png?alt=media&#x26;token=01f3858b-88cf-40d8-ac52-b33ada865916" alt=""><figcaption></figcaption></figure>

I noticed a **`robots.txt`** file listed, let’s check it out and see if it reveals any hidden or restricted paths we can explore further.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FssgOcRmWFtOzFgo2EKtE%2FScreenshot%20(1465).png?alt=media&#x26;token=c469f49c-0d28-4ff4-b648-26434cbb9723" alt=""><figcaption></figcaption></figure>

Inside the `robots.txt` file, there’s a disallowed path named **/ssh\_cred.txt**. While "Disallow" is meant to keep web crawlers out, it doesn’t actually prevent us from visiting it directly — so let’s go ahead and check it out.&#x20;

Wait, wait, wait, before that, I'll explain the meaning of Disallow in y'all to avoid confusion.

In the context of a `robots.txt` file, **"Disallow"** is a directive used to tell web crawlers (like those from Google or Bing) **not to access or index** specific parts of a website. Here's an example.

```
User-agent: *
Disallow: /private/
```

This tells all web crawlers not to access the `/private/` directory.

**Important Note**:

* **Disallow is not a security feature** — it only provides guidance to *well-behaved* bots.
* Anyone (including you) can still visit that path manually in a browser or using tools like `curl`.

So when you see something like `Disallow: /ssh_cred.txt`, it’s more like saying, “Hey, bots, please don’t go here,” but nothing is technically stopping you from visiting it.&#x20;

Now let's visit the `/ssh_cred.txt` .

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FJRHCPFavKzdSqPCzJgUG%2FScreenshot%20(1466).png?alt=media&#x26;token=dc3b72e1-a05f-436d-95a3-48a591480a91" alt=""><figcaption></figcaption></figure>

This looks promising — we’ve got an SSH password! However, the message hints that there's a numeric value at the end of it. Since I didn’t want to manually brute-force every possibility, I took a more efficient approach.

```python
for i in range(10):
    print(f"1mw4ckyyucky{i}")
```

Then I pasted the output to `passw.txt`  and collect the two users we saw earlier, **sheryl** and **eric** to `user.txt` .

Time to bruteforce using **Hydra.**

`hydra -L user.txt -P passw.txt 192.168.22.229 ssh -t 10`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FyzxRp3Dd6nc11ovSBQZO%2FScreenshot%20(1470).png?alt=media&#x26;token=f45cb54f-31f2-457f-b759-4e4bf2c267a0" alt=""><figcaption></figcaption></figure>

We've got eric's credentials, now let's login!

`ssh eric@192.168.22.229`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FBabwGJoXa9vlpMMMY9Zy%2FScreenshot%20(1472).png?alt=media&#x26;token=bef7b668-3629-4787-a43b-9ce2cac4d1ef" alt=""><figcaption></figcaption></figure>

Yes!! We're in!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fc7xjW01t8akDWfVEpivG%2FScreenshot%20(1473).png?alt=media&#x26;token=767f0d27-e151-4ce6-a046-ce9783729f38" alt=""><figcaption><p>Got the 1st flag!</p></figcaption></figure>

I attempted to run `sudo -l`, but it seems that **eric** doesn’t have any elevated privileges.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FKt1iFba1RdY162yTO8Py%2FScreenshot%20(1474).png?alt=media&#x26;token=867d81d8-b7e0-4fdb-b33e-2155af1aedcc" alt=""><figcaption></figcaption></figure>

What I did next is to use **linPEAS**, but it doesn't give me anything valuable.

I decided to run **pspy64**, a powerful tool designed to monitor real-time processes on a Linux system without requiring root access. It’s especially useful for spotting scheduled tasks, scripts, or unusual activity that might otherwise go unnoticed.

After a short wait, I spotted some unusual processes being executed.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FHtqowjXJIreOe8IStFwR%2FScreenshot%20(1475).png?alt=media&#x26;token=8c1b8c42-11e1-4896-8e13-6906bd627085" alt=""><figcaption></figcaption></figure>

This sequence of commands reveals an automated backup process likely triggered by a cron job. It begins with `/usr/bin/zip` compressing the `/var/www/` directory into `/tmp/backup.zip`, followed by the execution of a script located at `/var/backups/backup.sh` via `/bin/sh`. The duplication of the command using `-c` suggests it's being run through a cron entry or another script. The presence of `/usr/sbin/CRON -f` confirms that cron is actively handling scheduled tasks. The use of `/bin/chmod` indicates that file permissions are being modified during the process, and most notably, the command `sudo /tmp/emergency` suggests that a privileged script or binary is executed at some point — potentially offering a privilege escalation vector if the `/tmp/emergency` file can be manipulated.

But when I checked the `/tmp` directory, the `emergency` file wasn’t there — it simply didn’t exist. This could mean that the file is either created temporarily during execution and then deleted, or it’s being generated dynamically at runtime and removed immediately after use. Either way, it suggests there's a small time window where I might be able to replace or hijack it before the system does, which opens up a potential privilege escalation opportunity if timed correctly.

The idea that came to mind was: what if I create a file named `emergency` inside `/tmp` and embed a malicious payload in it? Since the system is executing `/tmp/emergency` with root privileges, any code I place inside that file would run with the same elevated permissions — effectively giving me root access if it works.

So I went ahead and created a file named `emergency` inside `/tmp`, and here’s the payload I placed inside it.

```bash
#!/bin/bash
echo "root:kuro" | chpasswd
```

This script changes a user's password by passing the new credentials to the `chpasswd` command. When run as root, it sets the specified user's password to the one provided.

Next thing I did to make it executable

`chmod +x emergency`&#x20;

and execute `pspy64` again and wait for the modified `emergency` file to execute.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FTV2aXHgdFTOTv2H2QAtf%2FScreenshot%20(1492).png?alt=media&#x26;token=1e74f8e3-5c8a-4a8f-afee-d21e89cf639c" alt=""><figcaption></figcaption></figure>

As you can see, the `chpasswd` command runs right after `sudo /tmp/emergency` — which means the exploit worked perfectly!

All we need to do is to switch to root using `su` or `su root` and type `kuro` as our password.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F0tsaJ6U1rilcJwOkxCoH%2FScreenshot%20(1493).png?alt=media&#x26;token=d7011cd2-a56b-4f38-b6a4-74e627e1b31d" alt=""><figcaption><p>We are root!!</p></figcaption></figure>

And here's the root flag

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FpDlKBQKatZi0C9IUL1EI%2FScreenshot%20(1495).png?alt=media&#x26;token=cbfe7acc-c5ae-404b-9d4f-827187c6a5ed" alt=""><figcaption><p>piece</p></figcaption></figure>

We've successfully pwned DriftingBlues: 1!!!!

**Conclusion**

This box demonstrated a clear privilege escalation path through an insecure cron job or scheduled task that executed a script from the `/tmp` directory with root privileges. By placing a custom `emergency` script containing a password-changing payload into `/tmp`, and waiting for it to be executed by the system, I was able to successfully gain root access. This highlights the dangers of running scripts from world-writable locations without proper validation or permission controls, making it a valuable lesson in system hardening and secure task scheduling.
