# Matrix-Breakout: 2 Morpheus BOOT2ROOT CTF VULNHUB WRITEUP

Hey everyone, welcome back to my write-up! Today’s a special day — it’s my birthday — and to celebrate, I’ve decided to share something equally exciting: my walkthrough of the *Matrix-Breakout: 2 – Morpheus* machine from VulnHub. This is a **Boot2Root challenge**, and in this post, I’ll walk you through how I approached, enumerated, exploited, and rooted the box. Let’s dive into the rabbit hole and see what Morpheus has in store for us!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FHh04KvwRrwW9PjQt0HfR%2F6bfcbb252a151933a16fe101c77cc9fa.gif?alt=media&#x26;token=afc6963b-35bf-4ab9-b890-a76ec04ab02c" alt=""><figcaption></figcaption></figure>

**Reconnaissance**

Let's begin by scanning our target to discover open ports that could serve as potential entry points, using Nmap.

`nmap -A -sC -T5 -p- -oN nmap_result.log <target_ip>`&#x20;

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F3YelQc4Ntmedy5qrAG1W%2FScreenshot%20(1240).png?alt=media&#x26;token=3605092d-4b16-4c2a-8760-8c1d03f8d8e6" alt=""><figcaption><p>Port 22 (ssh), Port 80 (http), Port 81 (http/nginx)</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%2FwCTZ2KbgOSgDIp44yRfe%2FScreenshot%20(1241).png?alt=media&#x26;token=583be360-245e-4596-af6a-99c445d54b7e" alt=""><figcaption></figcaption></figure>

Next, I proceeded to enumerate all the subdirectories with **Gobuster**. I forgot to take a screenshot of the results, haha, but here’s the command I used.

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

During the scan, a file named `graffiti.php` appeared — 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%2FBZCwoqeKbAc7y1Vsuup5%2FScreenshot%20(1243).png?alt=media&#x26;token=3592fa0e-41c6-44de-93aa-cb12441241cf" alt=""><figcaption><p>Graffiti Wall = Freedom Wall??? XDD</p></figcaption></figure>

The next step was to post a message to observe how it responds.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F2k3k8RJayVhhFgadBkLU%2FScreenshot%20(1246).png?alt=media&#x26;token=5a6f5239-3777-4d0c-b284-1cab14d5eeb3" alt=""><figcaption></figcaption></figure>

When I submitted a message(kuro), the webpage refreshed and displayed my post.

What’s next? Let’s take a closer look at how it functions and handles data — time to intercept the traffic using **BurpSuite**.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FRQ6SMdfVFXct2kbMUZCP%2FScreenshot%20(1248).png?alt=media&#x26;token=2f74b508-6eb2-40e0-bc33-71aaad77a626" alt=""><figcaption></figcaption></figure>

It seems that whatever we submit on `graffiti.php` gets saved into `graffiti.txt`. Here lies a vulnerability — what if I modify the filename? What do you think would happen?

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FZZR1HoK1kvOX054BjKvE%2FScreenshot%20(1249).png?alt=media&#x26;token=96cc2788-499e-4cdd-97d3-254be3a1aadb" alt=""><figcaption></figcaption></figure>

And it works!! As you can see, **kurokuro** is the only message posted in the response. To verify, let's visit the `kurokiri.txt`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FDRdgnvtXysJIyXZ06bz1%2FScreenshot%20(1250).png?alt=media&#x26;token=51e66c24-76f8-4627-b6f3-bd1b57f74c9d" alt=""><figcaption><p>It works!!</p></figcaption></figure>

Looks like the application allows full control over both the **filename** (`file` parameter) and the **content** (`message` parameter) when submitting data through `graffiti.php`. By intercepting and modifying these parameters using BurpSuite, I was able to create or overwrite arbitrary files on the server with custom content. This type of vulnerability is classified as **Arbitrary File Write** or sometimes **Unrestricted File Upload**. It’s particularly dangerous because an attacker can upload malicious files—like web shells—which may lead to **remote code execution (RCE)** if the server executes those files.

Now it's time to abuse this vulnerability to gain a reverse shell!

Good thing that I have my own collection of payloads in my [Github](https://github.com/kUrOSH1R0oo/reverse-shell-payloads), all we need to do is to copy the PHP payload and treat as the message, modify the IP and Port, then turn the filename to a PHP file.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F3Na6V30XWJ7Yfx2US1BS%2FScreenshot%20(1253).png?alt=media&#x26;token=e2ec2cfe-ac0e-490c-8cf4-df0d89d536a6" alt=""><figcaption></figcaption></figure>

Success! Now it’s time to execute the payload through the browser — but first, let’s set up our **Netcat** listener to catch the reverse shell.

`nc -lnvp 1234`

Trigger the payload in the browser, and we should receive a reverse shell connection!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FGNEwaDLDGNrPpYevCIQ4%2FScreenshot%20(1254).png?alt=media&#x26;token=5236baaa-e12d-4ea0-b9e8-7cc8eb9c78e9" alt=""><figcaption></figcaption></figure>

Time to make our shell interactive!

`python3 -c 'import pty;pty.spawn("/bin/bash")'`&#x20;

then ^Z

`stty raw -echo && fg`

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FQ1o0znLAGiajoDiXxVG9%2FScreenshot%20(1256).png?alt=media&#x26;token=a2689abb-2a86-4b85-b57e-e6ffa3740779" alt=""><figcaption></figcaption></figure>

After looking around and finding nothing of interest, I decided to run **linPEAS** to check for any potential privilege escalation opportunities.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fw7Xt3gE3ioA57AkkYXVT%2FScreenshot%20(1257).png?alt=media&#x26;token=d430c772-1f58-4c48-b9c1-816d6c3d565b" alt=""><figcaption></figcaption></figure>

The system appears to be vulnerable to **DirtyPipe** (CVE-2022-0847), a critical Linux privilege escalation exploit discovered in 2022. It affects kernel versions 5.8 and above, allowing an unprivileged user to overwrite read-only files by abusing flaws in the way the kernel handles pipe buffers. This can be leveraged to inject malicious content into sensitive files, potentially leading to full **root access**. Given the kernel version on the target, this vulnerability presents a clear path to privilege escalation.

I used **SearchSploit** to locate and retrieve the exploit script.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FKIaw6LWAF3CUOFBWytlv%2FScreenshot%20(1260).png?alt=media&#x26;token=461b2dc4-fe7b-4a67-bec4-96772125a215" alt=""><figcaption></figcaption></figure>

To retrieve the exploit

`searchsploit -m <exploit_path>`&#x20;

Next thing we did is to transfer the exploit to our target using **wget**

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FuBN97iEyIIGX3O9NcHsW%2FScreenshot%20(1262).png?alt=media&#x26;token=bd60fdbc-2a19-44bb-9d3c-57c7fc693303" alt=""><figcaption></figcaption></figure>

Let's compile it using **gcc**

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FWBGnbGZxTomYFLSDmUqS%2FScreenshot%20(1264).png?alt=media&#x26;token=bc988d52-faab-4ffc-9e7b-a5af6af0bbe8" alt=""><figcaption></figcaption></figure>

Now, let's execute our exploit!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2FKVxijEXuexzSNc0ZIhKX%2FScreenshot%20(1265).png?alt=media&#x26;token=decd3440-c3f4-451e-8cf5-b52f5d471053" alt=""><figcaption></figcaption></figure>

It seems we need to specify a SUID binary to hijack — in this case, since we're aiming for root access, we'll target `/usr/bin/su`.

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2Fpv0XVDBqocJCrkZzrVNV%2FScreenshot%20(1267).png?alt=media&#x26;token=e204d3be-8a28-4d59-b567-00a8e9f4a060" alt=""><figcaption></figcaption></figure>

We are root!!!! We've successfully pwned Morpheus!!

<figure><img src="https://271954773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYsivTjPn2jLXI0ZgVqeF%2Fuploads%2F15KJFMBXM2XTS9Cn4hQU%2FScreenshot%20(1268).png?alt=media&#x26;token=6abcf2c7-eb2d-47f6-8e8d-41a523fb5c6b" alt=""><figcaption><p>Root Flag</p></figcaption></figure>

This CTF challenge showcased two impactful vulnerabilities that led to a full compromise of the target system. The first was an **Arbitrary File Write (AFW)** vulnerability, where I was able to manipulate both the filename and the file content via HTTP parameters. This flaw allowed me to write a reverse shell script directly to the server and execute it, establishing a foothold. With initial access obtained, I explored the system further and discovered that it was running a Linux kernel version vulnerable to **DirtyPipe** (CVE-2022-0847). This critical privilege escalation exploit allowed me to overwrite read-only files and hijack a SUID binary — in this case, `/usr/bin/su` — to escalate my privileges and gain full **root access**. By chaining AFW and DirtyPipe, I successfully completed the Boot2Root challenge.
