Summary
Reset is a Linux box built around a chain of web application logic flaws and a legacy authentication misconfiguration. Initial access starts with a password reset endpoint that leaks the new admin password directly in its JSON response, granting admin access to a log-viewer dashboard. That dashboard has an unvalidated file-path parameter (LFI), which is chained with Apache access-log poisoning (injecting PHP via the User-Agent header) to achieve remote code execution as www-data. From there, group membership (adm) exposes the user flag. Privilege escalation to a second user (sadm) abuses a hosts.equiv host-based trust misconfiguration exploitable via the legacy rlogin service, requiring no password. Finally, a misconfigured sudo rule permitting nano is escaped via GTFOBins to obtain a root shell and the root flag.
1. Reconnaissance
1.1 Nmap Scan
nmap -A -Pn <MACHINE_IP> -oA nmap
| Port | Service | Version |
|---|---|---|
| 22/tcp | ssh | OpenSSH 8.9p1 Ubuntu 3ubuntu0.13 |
| 80/tcp | http | Apache httpd 2.4.52 (Ubuntu) — "Admin Login" |
| 512/tcp | exec | netkit-rsh rexecd |
| 513/tcp | login | rlogind |
| 514/tcp | shell | Netkit rshd |
The presence of the legacy r-services (rexec, rlogin, rsh on 512–514) is unusual for a modern box and hints that host-based trust authentication (.rhosts / hosts.equiv) will be relevant later.
The PHPSESSID cookie was flagged as missing the httponly flag by http-cookie-flags.
2. Web Enumeration
Browsing to http://<MACHINE_IP>/ presents an Admin Login page (Bootstrap 3.3.7 themed) with a "Forgot Password?" modal that POSTs a username to reset_password.php via AJAX.
<form id="resetPasswordForm">
<input type="text" id="resetUsername" name="username" required>
<button type="submit">Send Reset Email</button>
</form>
$.ajax({
url: 'reset_password.php',
method: 'POST',
data: { username: username },
success: function(data) { ... }
});