How I Gained Root Access On A Vulnerable Web Server From Reconnaissance To Privilege Escalation
A web server allowed uploading files with a .phtml extension, which PHP executed, enabling a reverse shell as the web user. The attacker then found a SUID binary (systemctl) and used it to escalate to root.
Published on infosecwriteups.com
Penetration testing is a critical skill in web security, and understanding each phase, from reconnaissance to privilege escalation. In this walkthrough, we’ll explore how to gain access to a vulnerable server, file upload to get reverse shell, and escalate privileges to root.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could upload and execute code to gain a low-privileged shell and then escalate to root, fully compromising the server.
What the attacker needed
Network access to the target; ability to upload files; a listener on the attacker's machine
How it was found
- Scan the target with Nmap and find an HTTP service on port 3333.
- Brute-force directories to discover /internal/ and an upload page.
- Upload a .phtml file containing a reverse shell payload.
- Fuzz the /internal/ directory to find the uploaded file under /internal/uploads/.
- Set up a listener and trigger the uploaded file to get a reverse shell as www-data.
- Find SUID files, create a malicious systemd service, and use systemctl to run it as root.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The server let people upload files, and it ran certain file types as code. The attacker uploaded a file that opened a connection back to them, giving them a low-level shell. Then they found a program that runs with high privileges and abused it to become the administrator (root).
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.