root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat cozyhosting.md
// writeups

CozyHosting

2 Sep 2023 · 11 min read · root access
CozyHosting - maquina de Hack The Box

Executive summary — CozyHosting is an Easy Linux box built around a Java Spring Boot app: an unauthenticated Spring Boot Actuator endpoint (/actuator/sessions) leaks active session tokens, letting us hijack an administrator's cookie and log into the admin panel; the panel's SSH form has a command injection in the username field (RCE as app). The application's .jar yields PostgreSQL credentials, the users table is dumped, the admin's bcrypt hash is cracked with hashcat, and that password is reused over SSH as josh. Root comes from abusing a sudo grant on ssh via ProxyCommand (GTFOBins). An Actuator → session hijacking → RCE → PostgreSQL → hashcat → SSH → sudo ssh → root path.

PlatformHack The Box
Operating systemLinux (Ubuntu)
DifficultyEasy
StatusRetired
Target IP10.129.16.230

Attack map

[80] Java Spring Boot app (nginx)
   │  HTTP headers + /error 500 → Spring Boot
   │  unauthenticated /actuator → /actuator/sessions leaks JSESSIONID tokens
   ▼
[hijack]  kanderson's cookie → /admin (Admin Dashboard)
   ▼
[RCE]  /executessh → command injection in «username» (space filter bypass with ${IFS})
   │  shell.sh over HTTP → shell as app
   ▼
[creds]  unzip the .jar → application.properties → PostgreSQL credentials
   │  psql → users table → admin's bcrypt hash → hashcat -m 3200 → cracked
   ▼
[SSH]  josh  (reused password)  →  user.txt
   │  sudo -l → /usr/bin/ssh (ALL)
   ▼
[ROOT]  sudo ssh -o ProxyCommand (GTFOBins)  →  root.txt

1. Reconnaissance

Full TCP port scan:

nmap -p- --min-rate 5000 -sV -sC -oA cozyhosting 10.129.16.230
22/tcp open  ssh    OpenSSH 8.9p1 Ubuntu
80/tcp open  http   nginx/1.18.0 (Ubuntu) — Cozy Hosting - Home
echo '10.129.16.230 cozyhosting.htb' | sudo tee -a /etc/hosts

Only two ports open — no SSH to brute force directly, so the focus is the web app. The HTTP headers already hint strongly at the framework:

whatweb http://cozyhosting.htb
curl -I http://cozyhosting.htb
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Language: en-US

That exact header pattern (plus Content-Language) is characteristic of Spring Boot (Java). It points the rest of the recon toward its management endpoints, Actuator.

ffuf -w /usr/share/seclists/Discovery/Web-Content/common.txt -u http://cozyhosting.htb/FUZZ -fc 404 -t 50
/admin  [401]   protected admin panel
/login  [200]   login form
/logout [204]   session logout
/error  [500]   Spring Boot error page

/error returning a 500 with Spring Boot's exact error format confirms the framework.

🔒 Clearance required

This content is Root Access only. Everything else on the site — the free tier, the whole public library — stays open.

See Root Access plans

No account? Create one free then upgrade from your console.