---
description: Delivery Hackthebox Walkthrough
---

# Delivery (Easy)

## Enumeration

### Nmap

```
nmap -sC -sV -oA nmap/delivery 10.10.10.222
```

```
# Nmap 7.91 scan initiated Tue May 18 11:26:53 2021 as: nmap -sC -sV -oA nmap/delivery 10.10.10.222
Nmap scan report for 10.10.10.222
Host is up (0.14s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 9c:40:fa:85:9b:01:ac:ac:0e:bc:0c:19:51:8a:ee:27 (RSA)
|   256 5a:0c:c0:3b:9b:76:55:2e:6e:c4:f4:b9:5d:76:17:09 (ECDSA)
|_  256 b7:9d:f7:48:9d:a2:f2:76:30:fd:42:d3:35:3a:80:8c (ED25519)
80/tcp open  http    nginx 1.14.2
|_http-server-header: nginx/1.14.2
|_http-title: Welcome
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue May 18 11:27:26 2021 -- 1 IP address (1 host up) scanned in 33.21 seconds
```

We can see that port 80 is open. Lets navigate to that.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8OzJfgMG6UlEeG8Ku%2F-Ma8P8LOQjhREQo8tQNc%2Fimage.png?alt=media\&token=a7df40df-2a0d-4e76-bdab-e0f1b62323d1)

After some exploration, I found out that **CONTACT US** and **HELPDESK** will lead us to another link.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8TVUXlOuJt_yG11oX%2F-Ma8UmsPt-z7om_TTAKK%2Fimage.png?alt=media\&token=4e2fef28-fedc-4dff-8b20-34f08a44127a)

Contact us will lead us to a service called **Mattermost**

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8OzJfgMG6UlEeG8Ku%2F-Ma8POJQikvJmGcpNmE5%2Fimage.png?alt=media\&token=00699b21-85bf-4768-9f91-6aeeb523ffc4)

Meanwhile, notice that we can't access this link as it redirects to this domain, we need to add the IP and the domain to the /etc/host file.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8OzJfgMG6UlEeG8Ku%2F-Ma8PU0YHlZMuRqXVd-J%2Fimage.png?alt=media\&token=bbc41e59-3ae2-425f-b25e-4cfc614f314a)

After that, we will get a completely new webpage.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8OzJfgMG6UlEeG8Ku%2F-Ma8PYkikxelwd1Gh-OE%2Fimage.png?alt=media\&token=5051dc9b-cacf-47a5-96e4-9e993e54dc8d)

After poking around, we can create a new ticket by clicking the Open New Ticket

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8UxU97WKaKkkS8tk_%2F-Ma8WpTV6n4495foXgST%2Fimage.png?alt=media\&token=ecb49f1b-3f9c-45fc-84f9-037998f557b4)

After submitting, a ticket will be created.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8UxU97WKaKkkS8tk_%2F-Ma8WxCbB10N-R3aIVFr%2Fimage.png?alt=media\&token=f8e7aaf5-f07e-44b8-8b53-7c408b688fe6)

From the message above, we can see that if we want to add more information to the ticket, just email the email provided at the body message.

When we explore the account creation for the Mattermost service, when we use our own gmail to register, we can't seem to receive the email verification (or should I say we must use the domain email to register)

Link with the email provided above, we can use that email to register.

Then, we can use check ticket status by input the email and ticket ID that provided just now.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8UxU97WKaKkkS8tk_%2F-Ma8XF-Di1SGOWjwG018%2Fimage.png?alt=media\&token=7d3474a2-cb38-4987-a7b6-35bf330f7e22)

Wow, got the verification. We proceed to verify it and login.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8UxU97WKaKkkS8tk_%2F-Ma8XWo1--Ft3k9CbsV4%2Fimage.png?alt=media\&token=a6eb3a84-24a7-4e6a-bddb-53c102edd355)

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8UxU97WKaKkkS8tk_%2F-Ma8XaRJhSFMIOb7Gaoj%2Fimage.png?alt=media\&token=1c0d0f1a-16ba-4402-9390-32c6dcc77d08)

There are some messages provided by root and there is a credentials given.

```
maildeliverer:Youve_G0t_Mail!
```

Remember there is a port 22 open? Lets SSH into it.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8UxU97WKaKkkS8tk_%2F-Ma8Y2_FTP-muG6FWghX%2Fimage.png?alt=media\&token=bf7ae3e8-cf8d-4aae-8583-a59d549a05cf)

Finally got a foothold.

## Privilege Escalation

After poking around for some time, we found that MySQL is running and we found a **config.json** that is inside the **/opt/Mattermost/config** directory.

```
    "SqlSettings": {
        "DriverName": "mysql",
        "DataSource": "mmuser:Crack_The_MM_Admin_PW@tcp(127.0.0.1:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",
        "DataSourceReplicas": [],
        "DataSourceSearchReplicas": [],
        "MaxIdleConns": 20,
        "ConnMaxLifetimeMilliseconds": 3600000,
        "MaxOpenConns": 300,
        "Trace": false,
        "AtRestEncryptKey": "n5uax3d4f919obtsp1pw1k5xetq1enez",
        "QueryTimeout": 30,
        "DisableDatabaseSearch": false
    },
```

We can see the credentials above which is

```
mmuser:Crack_The_MM_Admin_PW
```

Log in to the mysql server and we can output the data records for table **Users**

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8YBnOBng1IBREenko%2F-Ma8ZOj3jo6AGP_PqCSY%2Fimage.png?alt=media\&token=64b8f8e3-b094-4d3a-8284-83cb61b1c09e)

> Note: I just select username and password because the full output is too messy

Notice that we got the hash of root password.

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8YBnOBng1IBREenko%2F-Ma8ZiAuNozBR_kb8_9a%2Fimage.png?alt=media\&token=cf4e564d-7960-4049-964d-bde069aa5c58)

Recalling back the root messages from Mattermost service, it is hint to use hashcat rules to crack the password.

### Hashcat

We first need to create a wordlist for cracking the password. For this round we just need to input **PleaseSubscribe!**

Then we need to specify the type of the attack which the hash is in Bcrypt and the rules for attacking it.

We going to use the rules from **/usr/share/hashcat/rules/best64.rule**

```
hashcat -a 0 -m 3200 hash wordlist -r /usr/share/hashcat/rules/best64.rule -o cracked.txt -w 3 -O
```

After running the command above, we finally crack the hash which is **PleaseSubscribe!21**

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8_NVVNG6qUWRVG67n%2F-Ma8a54wD0GQFI0lm988%2Fimage.png?alt=media\&token=1ef5b8bd-b0e1-4cee-a6bd-425db9499077)

Finally we can **su** to root!

![](https://1595701629-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jqZqh8dnhmWJDpTuf%2F-Ma8_NVVNG6qUWRVG67n%2F-Ma8aLr48RIQM9uKoy-D%2Fimage.png?alt=media\&token=4db3621e-bda8-4bdc-a85e-d8cbb7145b95)

Congrats!

