Unattended
Executive summary -- Unattended chains a 2-stage nested SQL injection that ends in a local file inclusion (LFI), session poisoning to turn the LFI into code execution as
www-data, a cron job that executes a writable database value to pivot to the userguly, and finally a boot key derivable from the initramfs (readable by thegrubgroup) that turns out to be root's password.
| Platform | Hack The Box |
| Operating system | Linux |
| Difficulty | Medium |
| Status | Retired |
| Target IP | 10.129.84.164 |
Attack map
[443/HTTPS] www.nestedflanders.htb -- nginx -> internal Apache/PHP
| 2-stage nested SQLi in index.php?id= (CWE-89)
| the final value ends up in include() = LFI
v
[LFI] read index.php (DB credentials) and a PHP config file
| cookies -> $_SESSION -> session file -> session poisoning
v
[RCE] www-data
| config table (id=86, checkrelease): guly's cron executes its value
v
[RCE] guly (user.txt) -- persistent shell via a custom control channel
| guly in group grub -> can read /boot/initrd.img-*
| cryptroot reveals: /sbin/uinitrd <arg> prints the key (= root password)
v
[ROOT] su - with the recovered password (root.txt)
1. Reconnaissance
sudo nmap -p- --min-rate 2000 -T4 -Pn -oN scans/allports.txt 10.129.84.164
Only two open ports, 80 and 443. There is no SSH exposed, so all post-exploitation has to go through HTTP(S).
sudo nmap -p80,443 -sCV -Pn -oN scans/svc.txt 10.129.84.164
80/tcp open http nginx 1.10.3
443/tcp open ssl/http nginx 1.10.3
| ssl-cert: Subject: commonName=www.nestedflanders.htb/organizationName=Unattended ltd/...
| Not valid before: 2018-12-19T09:43:58
Why it matters: the TLS certificate leaks the vhost
www.nestedflanders.htb. Without that name, nginx does not serve the real application.
echo '10.129.84.164 nestedflanders.htb www.nestedflanders.htb' | sudo tee -a /etc/hosts
On https://www.nestedflanders.htb/ there is a portfolio with links such as index.php?id=25, id=465 and id=587. nginx acts as a TLS proxy in front of an internal Apache/PHP on 127.0.0.1:8080.
Root Access unlocks the content you can't see — everything else on the site is already open.
See Root Access plansNo account? Create one free then upgrade from your console.