Overview
Conversor is a Linux box on Hack The Box at 10.10.11.92. The web application processes user-supplied XSLT files, enabling an attacker to write arbitrary files to the webroot. This leads to credential discovery via a SQLite database and SSH access. Privilege escalation abuses needrestart running as root via sudo with a crafted config file.
TL;DR
- Foothold: XSLT injection to write a Python script under the webroot, exposing
users.dbwith credentialsfismathack:Keepmesafeandwarm - Privesc:
sudo /usr/sbin/needrestart -c <crafted_config>spawns a root shell
Recon
Nmap Scan
|
|
| Port | Service | Version |
|---|---|---|
| 22 | SSH | OpenSSH 8.9p1 |
| 80 | HTTP | Apache/2.4.52 |
Add the virtual host:
|
|
Web App & XSLT Discovery
The web application processes user-supplied XSLT files. Using payloads from PayloadsAllTheThings XSLT Injection, we can read and write server files.
The XSLT payload uses extension elements (ptswarm:document or similar) to write Python files into /var/www/conversor.htb/scripts/.
Foothold
Writing a Webshell via XSLT
- Craft an XSLT payload that writes
/var/www/conversor.htb/scripts/shell.pycontaining a reverse shell or command execution stub - Upload the XSLT file through the vulnerable endpoint
- Confirm the file is accessible:
http://conversor.htb/scripts/shell.py
Example reverse shell payload (replace placeholders):
|
|
Credentials Discovery
The webroot contained a users.db SQLite database with an INSERT statement:
|
|
Cracking the MD5 hash yields: fismathack:Keepmesafeandwarm
SSH Access
|
|
User flag obtained from user.txt.
Privilege Escalation — needrestart
Checking sudo permissions:
|
|
needrestart accepts a -c flag to specify a config file. The config file is parsed as Perl, allowing arbitrary code execution.
Variant A — system() directive
|
|
Variant B — exec with preserved privileges
|
|
Both variants spawn a root shell. Read the flag:
|
|
Lessons Learned
- XSLT processors should never allow extension elements that write to the filesystem
- SQLite databases in the webroot are a common source of credential leaks
needrestartwith sudo and arbitrary config file access is a known privesc vector — the config is parsed as Perl code