🐟TartarSauce – HTB Walkthrough

🛍️ Enumeration

🔍 Port Scanning

Only port 80 was open:

http://10.10.10.88/

We find arobots.txt at:

http://10.10.10.88/robots.txt

This hints at /webservices.

🔎 Directory Bruteforce

We run Gobuster on /webservices:

gobuster dir -u http://10.10.10.88/webservices -w /usr/share/dirb/wordlists/common.txt

It reveals:

/webservices/wp/

Which is a WordPress installation.


⚙️ WordPress Enumeration

We use WPScan to enumerate plugins:

We identify the vulnerable plugin: Gwolle Guestbook.

The Above was what I, was supposed to do. but even after running WPScan i did not get the plugin (i had to look at a walkthrough to get this part)


🪨 Exploitation - Gaining Shell (RFI)

🔄 Crafting the Payload

We use the standard PHP reverse shell:

Start a web server:

Then trigger the RFI:

Catch the shell:

We land as www-data.


🪍 Escalating to Onuma

Run sudo -l as www-data reveals:

Use GTFOBins’ tar exploit:

Get TTY:

Now we’re onuma.


⬆️ Root Privilege Escalation

PS, this section took me almost 2 days. I tried giving it my all, coming after work to solve it, but I couldn't get through. Finally, today (on Sunday morning), after I dedicatedly sat and tried to understand it, I was able to solve it

We discover a suspicious systemd timer (via LinPEAS):

It points to /usr/sbin/backuperer, a custom backup script running as root every few minutes.

📂 Vulnerability in backuperer

The script:

  • Archives /var/www/html to a random file in /var/tmp/

  • Waits 30 seconds

  • Extracts the archive to /var/tmp/check

  • If the integrity check fails, it doesn't delete the extracted files

  • All of this runs as root

🚩 Exploit Plan

We compile a setuid root binary:

I built this on a Docker container running Ubuntu 16.04 (same as the TartarSauce box).

Compile the SUID binary:

Structure the payload:

Deliver to the target:

Overwrite the temp file created by backuperer:(happens every 5 min)

Wait ~30s. The backup script will extract exp.tar.gz to /var/tmp/check/var/www/html.

Then:

Make sure to use sh not bash to retain SUID privileges.

Boom. Root shell.


🔒 Defensive Learnings

  • Code hygiene matters: The script didn’t clean up the check directory on integrity failure.

  • Use effective privilege separation: Line 36 should’ve checked as onuma, not as root.


📌 Appendix

  • backup script

Last updated