> 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/easy/move.md).

# Move

## 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 21, 22, 80 and 3000 are open.**

## 2 - Enumeration

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

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

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FFXs4OAtvGBx3srGQdXfr%2Fimage.png?alt=media&amp;token=a3ea3908-4aa8-424a-8c38-da55a5b1c14a" alt=""><figcaption></figcaption></figure>

Using our tool **ffuf-dir:**

```
ffuf-dir () {
	ffuf -u $1 -w /usr/share/wordlists/dirb/big.txt ${@: 2} -e .html,.php,.txt
}
```

we did `ffuf-dir http://172.17.0.2/FUZZ` we found the following routes:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FA19O43wmRwBguEG5x7yu%2Fimage.png?alt=media&amp;token=d755ede8-c1cd-46fb-a5ce-fb3863ac39c0" alt=""><figcaption></figcaption></figure>

Browsing `/index.html` gets us on a default Apache2 page, but `/maintenance.html` reveals relevant information:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FkKvieRxn07wOZwyLyJa2%2Fimage.png?alt=media&amp;token=fa2bb7f9-4533-4fee-af0b-593f210a76d0" alt=""><figcaption></figcaption></figure>

We found an exploit via `searchsploit` on Grafana, allowing Directory Traversal and Arbitrary File Read. We will try to use it to read the file we found on `/maintenance.html`.

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FwTqycPLFdLLAzJ3gPawx%2Fimage.png?alt=media&amp;token=8b7b790c-8965-4089-9881-1fc8bd470bf3" alt=""><figcaption></figcaption></figure>

## 3 - Exploitation

We will perform an `hydra` attack using a username wordlist and the password we found previously:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FdybeUBfGjqQrtnwyhVMa%2Fimage.png?alt=media&amp;token=4d8ef44d-7479-4829-86cb-125f7dda9192" alt=""><figcaption></figcaption></figure>

We got `freddy:t9sH76gpQ82UFeZ3GXZS` credentials, so we will access via SSH.

## 4 - Privilege Escalation

After running `sudo -l` we found that user `freddy` has sudo permissions as root on `/usr/bin/python3 /opt/maintenance.py`.

By changing the content on `/opt/maintenance.py` to an exploit found in GTFOBins, we obtain a root shell.

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2F6J5WgqY8aDBjAiAFKA7h%2Fimage.png?alt=media&amp;token=a4530db9-a678-42d9-b16f-7b6603e5a910" alt=""><figcaption></figcaption></figure>

## 5 - Summary
