> For the complete documentation index, see [llms.txt](https://itszaiden.gitbook.io/pentesting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itszaiden.gitbook.io/pentesting/writeups/dockerlabs/very-easy/vacaciones.md).

# Vacaciones

Fast port scanning, service enumeration, SSH brute-forcing, and privilege escalation via sudo on /usr/bin/ruby.

## 1 - Reconnaissance

We begin with a fast **Nmap** scan to identify open ports:

```
nmap 172.17.0.2 -p- --open -sS -Pn --min-rate 5000 -T5
```

**Result: ports 22 and 80 are open**

## 2 - Enumeration

Now we will run a service/version detection scan, targeting only the open ports we found on the previous scan:

```
nmap 172.17.0.2 -p 22,80 -sS -Pn -sCV
```

**Result:**

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FSrL6ua0Pc1yPz63vBwqj%2F(Vacaciones)%20Targeted%20Port%20Scan.png?alt=media&amp;token=751a1775-42a0-4493-a6ac-f254586f36c8" alt=""><figcaption><p>(Vacaciones) Targeted Port Scan</p></figcaption></figure>

After enumerating directories with:

```bash
ffuf -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt:FUZZ -u http://172.17.0.2/FUZZ -e .html,.php
```

we found:

**/index.htm**l -> Accessing this will show an Apache2 Debian Default Page.&#x20;

**/javascript** -> Accessing this will show a 403 Forbidden.

Knowing this, we will enumerate directories under **/javascript**. We found **/jquery** so we will keep doing the same until we find a route. After running it again, we found this is a rabbit-hole, so we will inspect the source code of the website.

We found an interesting comment where we can find two potential **SSH** usernames:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2F3675ROBfac0SscRqlOiO%2F(Vacaciones)%20Source%20Code%20Comment.png?alt=media&amp;token=a5acdf84-1b8b-434e-aad0-f5bda62ed933" alt=""><figcaption><p>(Vacaciones) Source Code Finding</p></figcaption></figure>

## 3 - Exploitation

We will run **hydra** on the usernames we found. Making a users.txt with both names and running:

```bash
hydra -L users.txt -P /usr/share/wordlists/rockyou.txt ssh://172.17.0.2
```

we found:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2F79sYsuEeG5AgDN1Rfd5z%2F(Vacaciones)%20Camilo%20Credentials.png?alt=media&amp;token=51812df6-994c-49b0-8a39-4a9e35b95879" alt=""><figcaption><p>(Vacaciones) SSH Credentials</p></figcaption></figure>

On the comment they mentioned an email, so we browse to **/var/mail** and find **correo.txt** containing credentials for the user **juan**:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FmJHLAzqe4p7TRlEvDRC7%2F(Vacaciones)%20Juan%20Credentials.png?alt=media&amp;token=ec8284cd-17c6-4b9e-819a-dfc7f8a0d53e" alt=""><figcaption><p>(Vacaciones) Plain-text Credentials on an email</p></figcaption></figure>

We can't find any interesting file or clue we could follow, so running `sudo -l` we found user **juan** can run `/usr/bin/ruby` as sudo.

## 4 - Privilege Escalation

We saw the `sudo` perms on `/usr/bin/ruby` for user **juan**, so browsing GTFOBins we found an exploit to escalate privileges to **root**;

```bash
sudo ruby -e 'exec "/bin/sh"'
```

As we can see, this spawns a **root** shell:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FmZKzV1ft6u8QaYAvrrn0%2F(Vacaciones)%20Root%20Shell.png?alt=media&amp;token=d33c93fd-9b2c-4898-aedd-39c808da640a" alt=""><figcaption><p>(Vacaciones) Root Shell</p></figcaption></figure>

## 5 - Summary

**Initial Access:**\
SSH credential brute-forcing with enumerated usernames.

**Exploitation:**\
Reconnaissance via user files and mail to extract credentials.

**Privilege Escalation:**\
Root shell obtained by abusing sudo permissions on `/usr/bin/ruby`.
