# DriftingBlues: 6 BOOT2ROOT CTF VULNHUB WRITEUP

Glad to have you back for another writeup! In this one, I’ll walk you through the step-by-step process I followed to solve the sixth stage of the DriftingBlues Boot2Root challenge from VulnHub. Let’s dive in!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F5yE3SGWdmuHeTEXZBEC8%2Fmagirevo-anis-shy.gif?alt=media&#x26;token=9c547fe4-a61e-411c-9d09-1ffd775c0eea" alt=""><figcaption></figcaption></figure>

First off, like usual, we’ll start by using `Nmap` to scan for open ports that might serve as our entryway into the system.

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

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FDp5kEBJtp6qVnBhdZNcK%2FScreenshot%20(1736).png?alt=media&#x26;token=2552c56d-76ea-473f-8dc7-8f69abfeb8ed" alt=""><figcaption><p>Only Port 80 (HTTP)</p></figcaption></figure>

As you can see from the Nmap scan, there's a subdirectory revealed: `/textpattern/textpattern`.

But let's visit the main webpage first.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FTCOwMDffMghFUIwwG7ql%2FScreenshot%20(1738).png?alt=media&#x26;token=3d620a3d-a328-40b9-b9ca-bcb25d5b8344" alt=""><figcaption><p>Just a simple DriftingBlues webpage</p></figcaption></figure>

Now let's visit the `/textpattern/textpattern` .

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Ft0OsLQ2ydici6gw83V6e%2FScreenshot%20(1739).png?alt=media&#x26;token=c8236fe0-4ca7-46bc-81b3-e8fa1aa9571e" alt=""><figcaption></figcaption></figure>

A textpattern login page.

Textpattern is a lightweight, open-source content management system (CMS) written in PHP that uses MySQL for managing website content. It’s known for producing clean, semantic code and is favored by designers who want full control over HTML and CSS. Often installed in directories like `/textpattern/`, it includes an admin panel for managing articles, templates, and plugins.

When I visit the `robots.txt` , there's a note.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FlceewHQCzqXBOO0lZC3q%2FScreenshot%20(1742).png?alt=media&#x26;token=47863722-fa5e-4b51-b991-33b2e4d41a36" alt=""><figcaption></figcaption></figure>

Now, based on the hint, let’s begin enumerating for any files with a `.zip` extension using `Gobuster`.

`gobuster dir -u http://192.168.54.188 -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -x .zip`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FW45Ha9f0EZMCarfvcEOT%2FScreenshot%20(1744).png?alt=media&#x26;token=65d2ac81-5a06-4c1a-a5e7-1d302c7a0e14" alt=""><figcaption></figcaption></figure>

There's a zip file named, `spammer.zip` .

Let's unzip the zipfile.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FXdq6TnEDKHyEPNPKuD9n%2FScreenshot%20(1746).png?alt=media&#x26;token=064b6c7e-dcb6-4363-91b1-335d0450a0c6" alt=""><figcaption></figcaption></figure>

But there's a password, let's crack it! We will use `zip2john` to get the hash of the zipfile.

`zip2john spammer.zip > hash`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FtYf7tls7R4XWBu4Mhzms%2FScreenshot%20(1747).png?alt=media&#x26;token=d46fe651-1f11-4280-a72f-c8e1937b5d4f" alt=""><figcaption></figcaption></figure>

Now let's crack the hash using `john`.

`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%2FulMYBscZQitlOmsTIWdM%2FScreenshot%20(1748).png?alt=media&#x26;token=e98f91c2-d7d1-469d-8722-ec9b4a1b18f6" alt=""><figcaption></figcaption></figure>

Now that we got the password for the zipfile, let's unzip it again!

After extracting the contents, a text file named `creds.txt` was revealed.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F9UpP6yjAEc76ZxTuggnv%2FScreenshot%20(1749).png?alt=media&#x26;token=99a96e35-2710-45ab-816a-3f3f85ec5aa2" alt=""><figcaption></figcaption></figure>

Let's see what's inside.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F2xvZ4cfhlARCwICpthIj%2FScreenshot%20(1750).png?alt=media&#x26;token=a814725f-ebd2-4877-a954-e48690c9f12f" alt=""><figcaption></figcaption></figure>

A username and a password, when I enter these credentials in textpattern, it works!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FvGzX1xnh7vZvY4Iv3El5%2FScreenshot%20(1753).png?alt=media&#x26;token=8faa7cd5-57f8-43f5-aa34-20f69b245e69" alt=""><figcaption><p>We're in!!</p></figcaption></figure>

Since we have administrative access, we can take advantage of a built-in feature in Textpattern that allows users with elevated privileges to upload files. This functionality is typically restricted to roles like the Publisher or site administrator for security reasons. Given our level of access, we can attempt to upload a malicious payload, such as a reverse shell payload.

Under the **Content** tab, you’ll find a **File** section—go ahead and click the **Upload** option and select your reverse shell payload to upload it.

You can opt to use [PentestMonkey’s](https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php) reverse shell payload, but in my case, I chose to use my [own](https://github.com/kUrOSH1R0oo/reverse-shell-payloads/blob/main/payload.php) custom PHP payload instead.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FZzHcLUYVNaOHAgdZN2Pw%2FScreenshot%20(1754).png?alt=media&#x26;token=bfd911cc-1edb-46af-bb1c-91de7423ac6c" alt=""><figcaption></figcaption></figure>

It's now uploaded, now to execute our payload, we should know the actual path of it, since it's in file, the path should be `http://target.com/textpattern/files/payload.php` . Bu before that, let's setup our listener for a while.

`nc -lnvp 1234`&#x20;

Now we can trigger our payload.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FAnFiTshjDvKUnfKl8gYl%2FScreenshot%20(1757).png?alt=media&#x26;token=08a8a932-bc0a-4157-9a7d-d2802be2f373" alt=""><figcaption></figcaption></figure>

We're in!!

Now, let’s upgrade our shell to a fully interactive one using a pseudo-terminal `(pty)`.

`python -c 'import pty; pty.spawn("/bin/bash")'`

After that, we’ll set our terminal type to `xterm` for better compatibility and display.

`export TERM=xterm`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fkm6xvfBUjrZYgMcTRHwy%2FScreenshot%20(1759).png?alt=media&#x26;token=fb0b1b17-c012-47a1-9b87-48b7d97ac45c" alt=""><figcaption></figcaption></figure>

When I navigated to the `/home` directory to check for existing user accounts, I found it completely empty—which is quite unusual.

So, I went ahead and decided to run `LinPEAS` at this point.

During the scan, I came across something that caught my attention.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F1lB1sGVrXdw03FI0CKFt%2FScreenshot%20(1761).png?alt=media&#x26;token=1bac3102-3e6a-4758-8f0c-702544ee96dc" alt=""><figcaption></figcaption></figure>

It turns out that this machine is susceptible to the **DirtyCOW** vulnerability!

**What is DirtyCOW?**

**DirtyCOW (CVE-2016-5195)** is a privilege escalation vulnerability in the Linux kernel that takes advantage of a race condition in the way the kernel handles the **copy-on-write (COW)** mechanism. When a process requests a private, read-only mapping of a file (like `/etc/passwd`), the kernel allows it to make a private copy if it tries to write to it. However, DirtyCOW exploits a race condition where an attacker rapidly writes to memory while simultaneously using `madvise()` to trigger the kernel’s COW process, tricking it into writing to the underlying read-only file instead of a private copy. This allows an unprivileged user to overwrite protected files, potentially inserting a new root user or modifying binaries—thus gaining full root access.

We can search the exploit using `searchsploit` .

`searchsploit dirty`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FjVsZoRmcJ3oug6mjwCuQ%2FScreenshot%20(1767).png?alt=media&#x26;token=759667a4-f869-44e4-93d5-3a343919e603" alt=""><figcaption></figcaption></figure>

In our case, we will use the `40839.c` .

`searchsploit -m linux/local/40839.c`&#x20;

Then transfer the exploit to our target machine.

Once the exploit is transferred, we’ll compile it using `gcc`. Keep in mind that DirtyCOW relies on `pthread` and `lcrypt`, so we need to include those libraries during compilation.

`gcc -pthread -lcrypt -o exploit 40839.c`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FDcQELK5LJywhoZLOl7yO%2FScreenshot%20(1768).png?alt=media&#x26;token=87e03138-4459-4769-aac2-d87cafe323d2" alt=""><figcaption></figcaption></figure>

Now let's execute our exploit!

`./exploit`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FvsxRYYZj3W2D1Iwd2msf%2FScreenshot%20(1769).png?alt=media&#x26;token=94a08f1f-d663-4b66-9911-d44a305b41e4" alt=""><figcaption></figcaption></figure>

It should work at this point, let's check the `/etc/passwd` .

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FbRDQOnUU4jelQ6qdzjpY%2FScreenshot%20(1773).png?alt=media&#x26;token=17fa2d22-8ea4-4ee6-b302-8eaa53fdd94b" alt=""><figcaption></figcaption></figure>

It worked perfectly! As you can see, the user **firefart** now has root access!

Now let's switch to **firefart**!

`su firefart`&#x20;

And enter the password we've set during the the exploit.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FFlRsCRMJbQTjdhq2IoYA%2FScreenshot%20(1775).png?alt=media&#x26;token=bdb88daf-b629-4fa5-9d09-7ab65f564673" alt=""><figcaption></figcaption></figure>

We are root!!!!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FBFxti8qZYzm4grjIgyiC%2FScreenshot%20(1776).png?alt=media&#x26;token=b796a837-eb03-48e3-8fdb-d53abd05fdfb" alt=""><figcaption><p>Root Flag</p></figcaption></figure>

We've successfully pwned DriftingBlues: 6!!!

Honestly, this machine was relatively straightforward compared to others. The steps to gain access and escalate privileges were clear, with minimal obstacles along the way. From basic enumeration and file upload to exploiting a well-known vulnerability like DirtyCOW, the entire process flowed smoothly. It’s a great box for beginners looking to practice core skills in privilege escalation and web-based exploitation.
