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

Hospital

18 Nov 2023 · 16 min read · root access
Hospital - maquina de Hack The Box

Executive summary — Hospital is a Medium box with two worlds: a Linux container and the Windows host (a Domain Controller). A medical-report upload portal (8080) blocks .php but accepts .phar, giving RCE as www-data inside an Ubuntu 23.04 container. Its 5.19.0-35 kernel is vulnerable to GameOver(lay) (CVE-2023-2640/32629), combining unshare, OverlayFS and misconfigured capabilities to escape the container and reach root, exposing /etc/shadow. We crack drwilliams's password, reused on the Roundcube instance (443), where an email from drbrown asks for .eps files for GhostScript — CVE-2023-36664 lets us embed a PowerShell payload inside the .eps itself via a %pipe% directive, giving a shell as drbrown on Windows. Since Apache/XAMPP runs as SYSTEM and its document root is writable, a webshell there executes with full privileges.

PlatformHack The Box
Operating systemWindows
DifficultyMedium
StatusRetired
Target IP10.129.229.189

Attack map

[Recon] 30 open ports -- Kerberos/LDAP/SMB/RDP/WinRM (Domain Controller)
      +-> [8080] Medical-report upload portal -- blocks .php, allows .phar
        |
[www-data]  p0wny-shell.phar -> RCE in a Linux container (Ubuntu 23.04)
      +-> stable reverse shell (named pipe + nc)
      +-> kernel 5.19.0-35 -> GameOver(lay) (CVE-2023-2640 / CVE-2023-32629)
      +-> unshare + overlayfs + setcap -> container escape -> root
        |
[/etc/shadow]  drwilliams hash -- John -> qwe123!@#
        |
[443] Roundcube (webmail) -- login drwilliams:qwe123!@#
      an email from drbrown asks for .eps files for GhostScript
        |
[CVE-2023-36664] GhostScript command injection in .eps
      PowerShell payload (UTF-16LE, base64) via a %pipe% directive
      +-> attached and emailed -> executed by drbrown on Windows
        |
[drbrown @ Windows]  C:\xampp\htdocs is writable -- Apache/XAMPP runs as SYSTEM
      +-> shell.php with shell_exec(powershell reverse shell)
      +-> GET https://<TIP>/shell.php
        |
[SYSTEM]  root.txt

1. Reconnaissance

nmap -p- --min-rate=1000 -T4 -oN nmap_all_ports.txt 10.129.229.189

30 ports come up open. Among the relevant ones: 22 (SSH), 53 (DNS), 88 (Kerberos), 135 (MSRPC), 139 (NetBIOS), 389 (LDAP), 443 (HTTPS), 445 (SMB), 3389 (RDP), 5985 (WinRM), 8080 (HTTP) and 9389 (ADWS).

This combination — Kerberos + LDAP + SMB + ADWS — is the classic fingerprint of an Active Directory Domain Controller. The two web ports (443/8080) are the realistic entry vector: we won't attack AD directly, but through the applications exposed on top of it.

nmap -p22,53,88,135,139,389,443,445,464,593,636,1801,2103,2105,2107,2179,3268,3269,3389,5985,6032,6404,6406,6407,6409,6613,6637,8080,9389 -sC -sV -oN nmap_services.txt 10.129.229.189

Port 443 serves a Roundcube instance — the login page reads "Hospital Webmail :: Welcome to Hospital Webmail". Port 8080 serves a "Hospital" application inviting users to upload medical records ("In order to get more personalized treatment, please upload your medical records") and allows open account registration — that open, unmoderated sign-up is the sign that the entry point is there.

🔒 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.