// HackTheBox  ·  writeup

OpTinselTrace-5

HackTheBox Hard EvtxECmdPythonstringspdftotext
DFIR

Scenario

You’ll notice a lot of our critical server infrastructure was recently transferred from the domain of our MSSP - Forela.local over to Northpole.local. We actually managed to purchase some second-hand servers from the MSSP who have confirmed they are as secure as Christmas is! It seems not as we believe Christmas is doomed and the attackers seemed to have the stealth of a clattering sleigh bell, or they didn’t want to hide at all!!!!!! We have found nasty notes from the Grinch on all of our TinkerTech workstations and servers! Christmas seems doomed. Please help us recover from whoever committed this naughty attack!

Executive Summary

The attacker reached the domain controller from a single internal host by exploiting the Netlogon Zerologon flaw, which left an unusual service behind and an anonymous machine-account authentication in the logs within a second of each other. They then logged on with the built-in administrator and a second account, and registered a scheduled task for persistence. Files across the estate were later encrypted with a custom XOR scheme, and the key was recoverable from strings in a dropped DLL. The encrypted files could be decrypted with that key, and the recovered documents answer what the ransom note’s victim had written down. The process that wrote the encrypted files is identifiable from file virtualization events, since the collection has no memory image.

Artifacts

Timestamp note: The event log CSVs are in UTC, which is what the time questions ask for. Answer in YYYY-MM-DD hh:mm:ss.

Initial Access

Q1 — Which CVE did the Threat Actor (TA) initially exploit to gain access to DC01?

Parse the event logs and look at the System log (7045) and Security log (4742) around the first signs of trouble. A service named vulnerable_to_zerologon was installed, and an anonymous Netlogon change to the DC01$ computer account (4742) came from the internal address that shows up again in Q5. An anonymous logon changing a domain controller’s machine account is the Zerologon signature, which maps to the CVE named in the reveal.

EvtxECmd -d Logs --csv work/evtx
# filter the parsed CSV for EventIds 7045, 7036, 5805, 4742 around 2023-12-13 09:24
Click flag to reveal CVE-2020-1472
Q2 — What time did the TA initially exploit the CVE? (UTC)

The exploit shows up twice at the same second: Netlogon event 5805 in the System log and the anonymous-logon 4742 in the Security log. Both carry the same timestamp, so there is no ambiguity about when the exploit landed.

# same filter as Q1: rows with EventId in (5805, 4742) at 2023-12-13 09:24
Click to reveal answer 2023-12-13 09:24:23

Persistence

Q3 — What is the name of the executable related to the unusual service installed on the system around the time of the CVE exploitation?

The service-install event (7045) for vulnerable_to_zerologon records the binary in its ImagePath. It points at a randomly named executable under %systemroot%, the usual pattern for an exploit tool that installs and starts its payload as a service.

# EventId 7045 rows from the System log CSV; read the ImagePath field
Click flag to reveal hAvbdksT.exe
Q4 — What date & time was the unusual service start?

Service state changes are event 7036. The entry saying vulnerable_to_zerologon entered the running state is the start, one second after the exploit time from Q2.

Gotcha: The 7045 install event and the 7036 start event are different records. The question asks for the start, so take the time from the 7036 row.

# EventId 7036 rows for vulnerable_to_zerologon in the System log CSV
Click to reveal answer 2023-12-13 09:24:24
Q7 — What was the name of the scheduled task created by the TA?

The Task Scheduler operational log records task registration as event 106. One task under \Microsoft\ was registered by the bytesparkle account, one of the two accounts the attacker used (see Q6), and its name is the answer.

# EventId 106 rows from Microsoft-Windows-TaskScheduler/Operational; read the task name and user
Click flag to reveal svc_vnc

Lateral Movement

Q5 — What was the TA's IP address within our internal network?

Network logons (4624, type 3) to the domain controller for the administrator account and the DC01$ machine account share one source address. That is the same host behind the anonymous Netlogon event in Q1.

# EventId 4624, LogonType 3 rows; group by source IP
Click to reveal answer 192.168.68.200
Q6 — Please list all user accounts the TA utilised during their access. (Ascending order)

Pivot on the Q5 address and list the account names on every 4624 logon from it. Two real user accounts appear. Sort them alphabetically as the question asks.

# EventId 4624 rows where source IP = 192.168.68.200; unique TargetUserName
Click flag to reveal Administrator, Bytesparkle

Impact

Q8 — Santa's memory is a little bad recently! He tends to write a lot of stuff down, but all our critical files have been encrypted! Which creature is Santa's new sleigh design planning to use?

The encrypted files carry the .xmax extension. Running strings on the dropped splunk_svc.dll turns up a readable XOR key, EncryptingC4Fun!. XOR-decrypting the .xmax files with it restores the originals. The documents include a topsecret image and PDF about the new sleigh, which name the animals that will pull it. This answer was read from the decrypted documents, but the decryption script is a one-off and isn’t reproduced here.

strings splunk_svc.dll | less
# XOR each .xmax file with the key from the DLL, write results to work/dec
pdftotext topsecret.pdf -

Tip: The format hint is a single word ending in n. The documents name the creature in plural, so reduce it to the singular.

Click to reveal answer Unicorn
Q9 — Please confirm the process ID of the process that encrypted our files.

The KAPE collection has no memory image, so a live process listing is not available. The UAC-FileVirtualization log has the data instead. Events 4000 and 5004 show rundll32.exe writing .xmax files, and the event header carries the ProcessId of the writer.

# EventId 4000/5004 rows from the UAC-FileVirtualization log; read the header ProcessId for rundll32.exe writing .xmax
Click flag to reveal 5828

Attack Summary

PhaseAction
Initial AccessZerologon exploited against DC01 from an internal host
PersistenceService vulnerable_to_zerologon installed with a randomly named executable and started a second later
Lateral MovementNetwork logons from the same host as the built-in administrator and a second account
PersistenceScheduled task created under the second account
ImpactFiles encrypted to .xmax with a XOR key held in the dropped DLL, written by rundll32.exe

IOCs

TypeValue
CVECVE-2020-1472
IP (attacker, internal)192.168.68[.]200
Servicevulnerable_to_zerologon
File%systemroot%\hAvbdksT.exe
Filesplunk_svc.dll
AccountBytesparkle
Scheduled task\Microsoft\svc_vnc
File extension.xmax
XOR keyEncryptingC4Fun!

MITRE ATT&CK

TechniqueIDDescription
Exploitation of Remote ServicesT1210Zerologon against the domain controller
Create or Modify System Process: Windows ServiceT1543.003vulnerable_to_zerologon service with a random-name executable
Valid Accounts: Domain AccountsT1078.002Logons as Administrator and Bytesparkle from the attacker host
Scheduled Task/Job: Scheduled TaskT1053.005svc_vnc task registered by the attacker account
Data Encrypted for ImpactT1486.xmax files encrypted with a XOR key

Defender Takeaways

An unpatched domain controller handed over the domain. Zerologon (CVE-2020-1472) has had a patch available since 2020, and the logs show an anonymous Netlogon machine-account change followed one second later by a service install. Patch DCs and enforce secure Netlogon channel enforcement mode.

Anonymous machine-account changes on a DC should alert. Event 4742 with an anonymous logon, or Netlogon 5805 failures for a DC’s own account, should be a high-severity detection on its own.

A new service with a random name on a DC is rarely benign. Event 7045 for an executable in %systemroot% with a random name is cheap to alert on, and here it was named after the vulnerability.

Hardcoded keys in malware reverse the damage. The XOR key sat in plain strings in the dropped DLL, so the victim’s files were recoverable. Keep sample DLLs from incident triage, because their strings can matter for recovery.

Log what writes to disk when you have no memory. UAC-FileVirtualization events gave the encrypting process ID when no memory image existed. Collect memory during triage where you can.

Conclusion

The attacker went from a single internal host to encrypted files by exploiting a Netlogon flaw on the domain controller, and the exploit announced itself in the logs within a second. The files were recoverable because the XOR key was left in plain strings.