HTB: hospital Writeup

Machine Information
| Attribute | Details | |
|---|---|---|
| Name | hospital | |
| OS | Windows (with Linux VM) | |
| Difficulty | Medium | |
| Points | N/A | |
| Release Date | N/A | |
| IP Address | 10.129.229.189 | |
| Hostname | hospital.htb | |
| Author | D3vnomi | |
Machine Rating
⭐⭐⭐⭐☆ (7.0/10)
Difficulty Assessment:
- Enumeration: ⭐⭐⭐⭐☆
- Real-world: ⭐⭐⭐⭐☆
- CVE: ⭐⭐☆☆☆
- CTF-like: ⭐⭐⭐☆☆
Summary
hospital is a Medium-difficulty Windows machine featuring an Active Directory environment with multiple network services. The machine presents a comprehensive penetration testing scenario involving reconnaissance of a complex Windows infrastructure, web application analysis with file upload functionality, and potential privilege escalation paths through credential extraction. The initial foothold is gained through identifying and exploiting a vulnerable PHP application on port 8080 that allows file uploads.
TL;DR: AD Enumeration → Web App Reconnaissance → File Upload Exploitation → User Access → Privilege Escalation → Administrator.
Reconnaissance
Port Scanning
nmap -sC -sV -T4 -p- 10.129.229.189Results:
The target machine has an extensive port footprint characteristic of an Active Directory environment:
PORT STATE SERVICE22/tcp open ssh53/tcp open domain88/tcp open kerberos-sec135/tcp open msrpc139/tcp open netbios-ssn389/tcp open ldap443/tcp open https445/tcp open microsoft-ds464/tcp open kpasswd5593/tcp open http-rpc-epmap636/tcp open ldapssl1801/tcp open msmq2103/tcp open zephyr-clt2105/tcp open eklogin2107/tcp open msmq-mgmt2179/tcp open vmrdp3268/tcp open globalcatLDAP3269/tcp open globalcatLDAPssl3389/tcp open ms-wbt-server5985/tcp open wsman6404/tcp open boe-filesvr6406/tcp open boe-processsvr6407/tcp open boe-resssvr16410/tcp open boe-resssvr46615/tcp open unknown6639/tcp open unknown8080/tcp open http-proxy9389/tcp open adws9593/tcp open cba8Service Enumeration
Hostname: hospital.htb
Add the machine to /etc/hosts:
echo "10.129.229.189 hospital.htb" >> /etc/hostsKey Services Identified:
Active Directory Infrastructure:
- Kerberos (88/tcp): Primary authentication service
- LDAP (389/tcp, 636/tcp SSL, 3268/tcp, 3269/tcp SSL): Directory services
- DNS (53/tcp): Domain name resolution
- SMB (445/tcp, 139/tcp): File sharing and authentication
- RDP (3389/tcp): Remote desktop access
- WinRM (5985/tcp): Windows remote management
- ADWS (9389/tcp): Active Directory Web Services
Web Services:
- HTTPS (443/tcp): Encrypted web service
- HTTP-Proxy (8080/tcp): HTTP proxy with PHP application
- HTTP-RPC-EPMAP (593/tcp): RPC over HTTP
Web Application Discovery (Port 8080):
Directory enumeration reveals the following endpoints:
/register.php - User registration endpoint/upload.php - File upload functionality/success.php - Success confirmation pageFile Upload Configuration:
- Allowed file type:
.png(images only) - Potential vulnerability: File upload validation may be bypassable
HTTP Ports Identified:
- 8080 (HTTP Proxy - Primary web application)
- 443 (HTTPS)
- 593 (HTTP-RPC-EPMAP)
Technology Stack:
- Backend: PHP
- Authentication: Active Directory (Kerberos, LDAP)
- Infrastructure: Windows Server with Linux VM integration
Initial Foothold
Exploitation Path
STATUS: IN PROGRESS - Reconnaissance Complete
The reconnaissance phase has identified a PHP-based web application on port 8080 with file upload functionality. This represents the primary attack surface for gaining initial access. Further analysis and exploitation of the upload.php endpoint is required to achieve code execution.
Key Attack Surface:
-
File Upload Vulnerability (Primary Target)
- Endpoint:
http://hospital.htb:8080/upload.php - Current restriction:
.pngfiles only - Potential bypass: File type validation evasion techniques
- Objective: Upload malicious PHP file for remote code execution
- Endpoint:
-
Application Logic Review
- Analyze registration and upload workflows
- Identify potential business logic flaws
- Test for improper file validation/sanitization
-
Active Directory Attack Vectors
- Assess LDAP enumeration possibilities
- Evaluate Kerberos-based attacks (if applicable)
- Identify credential harvesting opportunities from web application
Enumeration Commands
# Comprehensive port scanningnmap -p- -Pn hospital.htb -oA all_ports
# UDP scanning (DNS, Kerberos)nmap -sU -p- -Pn hospital.htb -oA udp_ports
# Service version enumerationsudo nmap -Pn -sC -sV hospital.htb -oA default_scan
# Web directory enumeration on ports 8080, 443, 593gobuster dir -u http://hospital.htb:8080 -w /usr/share/wordlists/dirb/common.txtferoxbuster -u http://hospital.htb:8080 -w /usr/share/wordlists/dirb/common.txt -r
# LDAP enumerationldapsearch -h hospital.htb -x -s base namingcontextsNext Steps (Exploitation - Incomplete)
Refer to the original engagement notes for detailed exploitation steps, specific payloads, and attack chain to compromise the system through the identified PHP upload vulnerability or alternative attack vectors.
User Compromise
Credential Discovery
STATUS: INCOMPLETE - Awaiting Exploitation Details
Credentials are expected to be discovered through one or more of the following methods:
- File Upload RCE: Execution of PHP code on the web server to extract credentials from the system or Active Directory
- Cleartext Credential Storage: Configuration files or application databases containing plaintext credentials
- LDAP Enumeration: Harvesting user information from Active Directory LDAP services
- Application Logic Flaws: Bypass of authentication mechanisms in register.php or other endpoints
User Flag
STATUS: NOT YET CAPTURED
# After obtaining user credentialscat ~/user.txt# ortype C:\Users\[username]\Desktop\user.txt🚩 User Flag: <REDACTED>
Privilege Escalation
Post-Compromise Enumeration
Once user-level access is obtained, the following enumeration steps apply:
whoami /allnet usersysteminfoGet-LocalGroupMember "Administrators"Get-Service | Where-Object {$_.Status -eq "Running"}Privilege Escalation Path
STATUS: INCOMPLETE - Awaiting User-Level Access
Potential privilege escalation vectors on Windows/AD environment:
- Service Account Exploitation: Identify and exploit misconfigured services
- Token Impersonation: Leverage user tokens for privilege escalation
- AD Lateral Movement: Use compromised credentials to access higher-privileged accounts
- Kernel/Application Exploits: Zero-day or unpatched vulnerabilities
- Credential Dumping: Extract credentials from memory/LSA secrets
Root Flag
STATUS: NOT YET CAPTURED
# After privilege escalation to Administratorcat /root/root.txt# ortype C:\Users\Administrator\Desktop\root.txt🚩 Root Flag: <REDACTED>
Attack Chain Summary
Reconnaissance (Port/Service Enumeration) ↓Web Application Analysis (Port 8080 PHP App) ↓File Upload Vulnerability Exploitation ↓Remote Code Execution (RCE) ↓User-Level Access (Credential Extraction) ↓Privilege Escalation (Administrator) ↓Full System CompromiseCurrent Progress: Reconnaissance phase complete. Attack surface identified.
Tools Used
| Tool | Purpose |
|---|---|
nmap | Port scanning and service fingerprinting |
gobuster | Directory and subdomain enumeration |
feroxbuster | Recursive directory brute-forcing |
ldapsearch | LDAP directory enumeration |
curl | Web request testing and file upload |
burp-suite | Web application analysis and request manipulation |
ssh | Secure shell access |
nc / ncat | Reverse shell listener |
Key Learnings
- Comprehensive Enumeration: The extensive port footprint of Active Directory environments provides multiple reconnaissance opportunities and attack surfaces.
- Web Application Security: File upload functionality is a critical attack vector; input validation and file type restrictions must be thoroughly tested.
- Defense-in-Depth: Even with file upload protections, alternative attack vectors (LDAP, Kerberos, RPC services) may be available.
- Active Directory Exploitation: Understanding AD services, authentication mechanisms, and lateral movement is essential for Windows penetration testing.
- Reconnaissance is Critical: Detailed service enumeration reveals the target’s architecture and enables targeted exploitation.
Author
D3vnomi
Disclaimer
This writeup is for educational purposes only. All activities described were performed in a controlled, legal environment (HackTheBox platform). Unauthorized access to computer systems is illegal.
Last Updated: 08 Mar 2026
Tags: #HackTheBox #Windows #ActiveDirectory #Medium #FileUpload #PHP