Bashed Walkthrough
Machine: Bashed#
Date: 17-03-2026 Platform: HTB Status: [Rooted]
π Recon#
Nmap:#
nmap -sC -sV -oN scans/nmap.txt $MACHINE_IP
Results:
- Port 80 β HTTP (Apache 2.4.18, Ubuntu)
Notes:
- Site title: “Arrexel’s Development Site” β hints at phpbash tool
- Single port, attack surface limited to web
π Enumeration#
Gobuster:#
gobuster dir -u http://10.129.6.1/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -x php -t 50
- Found:
/devβ containedphpbash.phpandphpbash.min.php - Found:
/uploads,/php,/images,/css,/js,/fonts - Found:
/config.php(200 but empty)
π₯ Exploitation#
- Navigated to
http://10.129.6.1/dev/phpbash.php - Interactive web shell available as
www-dataβ no exploit needed - phpbash is a tool authored by Arrexel, left on his own dev server
Result: Shell as www-data
β‘ Privilege Escalation#
Enumeration:
sudo -lβwww-datacan run anything asscriptmanager(NOPASSWD)/scripts/directory owned byscriptmanager, containstest.pytest.txtowned byrootand timestamped recently β root runs all.pyfiles in/scripts/via cron
Path to root:
- Overwrote
test.pywith malicious Python usingtee(webshell filtered>redirects):
echo "import os; os.system('cp /bin/bash /tmp/rootbash2; chmod 4755 /tmp/rootbash2')" | sudo -u scriptmanager tee /scripts/test.py
- Waited for cron to execute β
/tmp/rootbash2appeared with SUID bit - Executed with
-p -cto preserve privileges from webshell (no TTY):
/tmp/rootbash2 -p -c "cat /root/root.txt"
Successful escalation: root β
π― Loot / Flags#
- user.txt:
[FLAG REDACTED] - root.txt:
[FLAG REDACTED]
π Lessons Learned#
- Developer tools left on production servers are an immediate foothold β always check
/devdirectories CHANGELOG.txt, site titles, and generator meta tags reveal CMS/framework versions instantly- When
sudo -u user cmddoesn’t spawn a shell, use-cto run individual commands - Cron jobs running scripts as root in user-writable directories are a classic privesc vector
teeis a reliable alternative to>redirection when working inside limited shells- Use
chmod 4755(octal) instead ofchmod +swhen special characters get filtered - Always use
-pwith SUID bash copies to preserve elevated privileges -p -c "command"is the correct syntax to run commands via a SUID bash binary without an interactive shell
#Linux #HTB #Enumeration #Web #Apache #Gobuster #WebShell #PHP #CommandExecution #PrivilegeEscalation #Sudo #Cron #Python #SUID #FileWrite #PostExploitation
Adapted from MountainFlayer/htb-writeups under MIT.