Goal: Gain a foothold on a web server running an outdated CMS, escalate to root, and retrieve both flags (user.txt and root.txt). Target: 10.64.144.100 (re-deployed mid-box as 10.64.161.87, both appear in the screenshots below)


1. Reconnaissance

Kicked things off with a standard nmap scan:

nmap 10.64.144.100 -sV -p-

nmap results

Two ports open. 22 (SSH) and 80 (HTTP/Apache2). Nothing else exposed, so the web server is the obvious way in.

While the scan ran, I checked the site in the browser: default Apache2 Ubuntu landing page. robots.txt and sitemap.xml both came back empty, and viewing the raw HTML turned up nothing hidden in comments.

With nothing on the root page, moved to directory brute-forcing:

gobuster dir -u http://10.64.144.100 -x .php,.html -w /usr/share/wordlists/seclists/Discovery/Web-Content/common.txt

gobuster results

One entry stands out: /content.


2. Enumerating the CMS

/content serves a half-finished site sitting on an install/setup page.

/content landing page

The page links out to http://www.basic-cms.org/docs/5-things-need-to-be-done-when-SweetRice-installed/, which no longer resolves to the real docs, it 302s off to https://go-get-some.net/go/2429217..........

Rabbit hole. I looked into this for a few minutes wasting my time. The basic-cms.org domain expired years ago and is now parked on an ad/redirect network. Ignore it and keep enumerating.

Ran a second, targeted gobuster against /content to map the app properly (IP differs from here on due to a machine restart on TryHackMe):

gobuster dir -u http://10.64.161.87/content -w /usr/share/wordlists/dirb/common.txt -x .php,.txt,.html

/content directory listing

Digging through those directories confirms the version - changelog.txt reveals SweetRice 1.5.1.

SweetRice 1.5.1 confirmed

searchsploit sweetrice returns several hits for this version. Three are relevant:

ExploitEDB-IDUse
SweetRice 1.5.1: Backup Disclosure40718Unauthenticated read of MySQL backups
SweetRice 1.5.1: Cross-Site Request Forgery (Add Admin) / arbitrary PHP via Ads40700Authenticated RCE
SweetRice 1.5.1: Arbitrary File Upload40716Authenticated upload to Media Centre (alternate path)

3. Credential Disclosure

The backup disclosure exploit points at an unauthenticated directory:

http://10.64.161.87/content/inc/mysql_backup/

Sure enough, a .sql dump is sitting there.

mysql_backup directory

Downloaded and cat’d the file. Inside the INSERT statements for the SweetRice options table, there’s an admin account: user manager with an MD5 password hash.

credentials in the SQL dump

The hash is unsalted MD5 and already in every rainbow table on the internet. CrackStation cracks it instantly.

cracked hash

The SweetRice admin panel lives at /content/as. Logged in with the cracked creds:

logged into SweetRice admin


4. Initial Access (www-data)

SweetRice’s Ads feature writes whatever you paste into it straight to a .php file under /content/inc/ads/. That’s arbitrary PHP file creation as an authenticated admin, exactly what EDB-40700 abuses via CSRF, except we already have the session, so we can just do it directly.

Pasted the PentestMonkey PHP reverse shell into a new ad, with $ip and $port set to my Kali box.

creating the ad with the reverse shell

Started a listener locally:

nc -lvnp 9001

From here, we can execute it by viewing /content/inc/ads, then clicking the new ad you created. Alternatively, go straight to the file:

http://10.64.161.87/content/inc/ads/revshell.php

triggering the shell

Shell as www-data.

shell caught

Upgraded to a proper TTY, which matters for the privesc step later. The root shell I end up spawning is interactive, and it won’t behave without a real terminal:

python3 -c 'import pty; pty.spawn("/bin/bash")'
# Ctrl+Z
stty raw -echo; fg
export TERM=xterm

Note to self: user.txt was sitting in /home/itguy/ and readable by www-data the whole time, I could have grabbed it right here. I skipped straight to privesc and only collected it at the end alongside the root flag. Listing home directories should be the first thing I do after landing a shell.


5. Privilege Escalation

Started with the usual checks, both of which were dead ends:

find / -type f -perm -4000 2>/dev/null    # nothing unusual
cat /etc/crontab                          # nothing

SUID search crontab

Then remembered to run the one thing I should have run first:

sudo -l

sudo -l output

User www-data may run the following commands on THM-Chal:
    (ALL) NOPASSWD: /usr/bin/perl /home/itguy/backup.pl

Looking further at the script:

cat /home/itguy/backup.pl

backup.pl contents

It does one thing, shells out to /etc/copy.sh. And /etc/copy.sh already contains a hardcoded netcat reverse shell haha.

/etc/copy.sh contents

The key detail: /etc/copy.sh is world-writable, and backup.pl runs it as root. So whatever I put in copy.sh executes as root.

Overwrote it with an interactive bash and triggered it through the sudo entry:

echo "/bin/bash -i" > /etc/copy.sh
sudo /usr/bin/perl /home/itguy/backup.pl

id confirms uid=0(root).

As root, I grabbed both flags - /home/itguy/user.txt and /root/root.txt.

flags


Summary

StepActionFinding / Result
1. Reconnmap -sV -p-Ports 22 (SSH), 80 (Apache2) open
2. Web enumgobuster dir/content → SweetRice CMS
3. Version IDchangelog.txtSweetRice 1.5.1
4. Exploit researchsearchsploit sweetriceBackup disclosure (40718), Ads RCE (40700)
5. Cred disclosure/content/inc/mysql_backup/manager + MD5 hash
6. CrackingCrackStation / hashcat -m 0Plaintext admin password
7. Auth/content/asAdmin access to SweetRice
8. RCEAds → PHP reverse shell → /content/inc/ads/revshell.phpShell as www-data
9. Privesc enumsudo -l(ALL) NOPASSWD: /usr/bin/perl /home/itguy/backup.pl
10. PrivescOverwrote world-writable /etc/copy.sh, ran backup.pl via sudoRoot shell
11. Flags/home/itguy/user.txt, /root/root.txtBoth collected as root

Key Takeaways