user.txt Walkthrough
1. Service Enumeration
Run an initial scan with Nmap:
Output:
2. Web Enumeration
Browse to http://10.129.254.162:3000, then run ffuf for content discovery:
Discovered Paths:
3. Fingerprinting the Web App
Check site metadata:
Output:
From this, we confirm the service is Grafana 8.0.0, which is vulnerable to CVE-2021-43798.
4. Exploit LFI (Local File Inclusion)
Read /etc/passwd:
Also exfiltrate Grafana configuration and database files:
-
/etc/grafana/grafana.ini -
/var/lib/grafana/grafana.db
5. Analyze grafana.db (SQLite)
Transfer grafana.db to your Kali box and explore:
Example user Table Output:
6. Convert Grafana Hashes for Hashcat
Clone and run grafana2hashcat:
Prepare input (hashes.txt):
Run the tool:
Output:
7. Crack the Password with Hashcat
Recovered Credential:
The admin password could not be cracked.
8. SSH into the Host
9. Capture the User Flag
root.txt
We already had access to the machine as user boris, having retrieved user.txt. Now we aim to escalate to root by abusing a Docker misconfiguration.
1. Enumerate sudo Rights
Output:
This tells us that boris can run any docker exec command as root without a password, but only docker exec, not other Docker commands.
2. Use Grafana LFI to Leak Hostname (Docker Container ID)
From our prior Grafana LFI (CVE-2021-43798), we use the following request to read /etc/hostname, which reveals the container ID:
Output:
This matches the container name.
3. Spawn a Root Shell Inside the Container
Now inside the container as root:
4. Attempt Breakout from Container
Inspect mounts:
Key discovery:
This implies /dev/sda1 is the host filesystem, and we can mount it manually:
We now see the full host filesystem: