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

# Allien

## 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, 80, 139 and 445 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 22, 80, 139, 445 -sS -Pn -sCV
```

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2F6nzyevW4blVfB4NfxwTh%2Fimage.png?alt=media&amp;token=bd640bae-0a5c-42bb-8f2f-b16c76ee7b1a" alt=""><figcaption></figcaption></figure>

We tried to find exploits or shellcodes using **searchsploit** but there wasn't any. Our next step will be directory enumeration. 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` and 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%2FXSNn7edYo3TFaHewsD9R%2Fimage.png?alt=media&amp;token=bb1a4eed-3ca9-48ea-8a5e-480c8a5f9c13" alt=""><figcaption></figcaption></figure>

All those routes are either rabbitholes suggesting potential vulnerabilities or don't have any useful data at all, so we will move to enumerate SMB.

Using `smbmap -H 172.17.0.2` we list the following shares:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FgBUIIc6UaEYXIZLapjQ6%2Fimage.png?alt=media&amp;token=e515c17f-a684-4211-bd38-4390d689608f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FXHBZmTAJ6kTusjQ3LuRW%2Fimage.png?alt=media&amp;token=aa1249d6-a33e-415b-b5bd-cbdacc9dc375" alt=""><figcaption></figcaption></figure>

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2F1POyfEFyrhq8hDVRJ9Jy%2Fimage.png?alt=media&amp;token=e52fea37-dccd-4cd7-aedf-932554a1c37a" alt=""><figcaption></figcaption></figure>

Using Cyberchef we can see it's a JWT token, with the following decrypted data:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FIaix4NzHJv27VSAh9IND%2Fimage.png?alt=media&amp;token=f992932b-7ae2-4133-b8e8-1e2846bb5f96" alt=""><figcaption></figcaption></figure>

Using `crackmapexec smb 172.17.0.2 --users` we list the domain users, getting this list:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FVxFehYvIsp9Zn67auxy3%2Fimage.png?alt=media&amp;token=680f3a63-249c-4b31-a50a-743a5979b543" alt=""><figcaption></figcaption></figure>

## 3 - Exploitation

We will do a bruteforce attack to **satriani7** using **rockyou.txt** as wordlist using:

```
crackmapexec smb 172.17.0.2 -u satriani7 -p /usr/share/wordlists/rockyou.txt | grep '[+]'
```

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FqT9p6B75SPjdXVIZ7Zm1%2Fimage.png?alt=media&amp;token=9f996438-458a-4512-9170-eaf46101fff2" alt=""><figcaption></figcaption></figure>

Using those credentials we will login in the share `backup24`:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FjjcEJ1dIbC5JCHqI8srY%2Fimage.png?alt=media&amp;token=d055e60a-e3b5-4223-9523-ccd2ec4d7b6d" alt=""><figcaption></figcaption></figure>

We find an interesting file, `credentials.txt`:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FarO3qeIxNcjHyWrnT4tM%2Fimage.png?alt=media&amp;token=cb58389e-e192-4be2-881e-3c06a731f826" alt=""><figcaption></figcaption></figure>

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FH37DPIKSADoICnp3XwZS%2Fimage.png?alt=media&amp;token=856c0f4f-266a-46bf-a6b5-c9c63866303e" alt=""><figcaption></figcaption></figure>

Using those admin credentials `administrator:Adm1nP4ss2024` we will login into `home` share:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FwpHlIA2dlPHKOzhTeC3i%2Fimage.png?alt=media&amp;token=58738acc-658f-4191-8326-34cab447f3b4" alt=""><figcaption></figcaption></figure>

We can see this is the share where the website files are stored, so uploading a reverse shell and navigating to `172.17.0.2/revshell.php` will grant us access to the machine.

We will use the PentestMonkey PHP Reverse shell, and using `penelope` as shell handler, we will have instantly a fully upgraded TTY.

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FCXGY5YeWfQfmgLNTa1lE%2Fimage.png?alt=media&amp;token=12a207a2-b3b5-4c19-8eff-aeaca3458c33" alt=""><figcaption></figcaption></figure>

## 4 - Privilege Escalation

After running `sudo -l` we found that user `www-data` has sudo permissions as root on `` /usr/sbin/service` `` . After using a GTFOBins exploit we instantly obtain a root shell:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FiomHQZjFVXgahL99LK4C%2Fimage.png?alt=media&amp;token=ca63eeee-c08e-402f-abb9-62611298b9be" alt=""><figcaption></figcaption></figure>

## 5 - Summary

**Initial Access:**

SMB enumeration revealed a read-only share without authentication, containing a file with an encoded JWT token.

**Exploitation:**

We obtained `satriani7:50cent` credentials via `hydra` attack using `rockyou.txt` as wordlist, obtaining `administrator:Adm1nP4ss2024` credentials.

We uploaded a reverse shell on the SMB share hosting the website content, and querying it we catched the reverse shell via `penelope`

**Privilege Escalation:**

`www-data` user had sudo rights on `/usr/sbin/service` . Using a GTFOBins exploit we obtained a root shell.
