// HackTheBox  ·  writeup

Lockpick4.0

HackTheBox Insane 7-ZipPythonpefileobjdump
Malware Analysis

Scenario

Forela.org’s IT Helpdesk has been receiving reports from employees experiencing unusual behaviour on their Windows systems. Within 30 minutes, the number of affected systems increased drastically, with employees unable to access their files or run essential business applications. An ominous ransom note appeared on many screens, asking the users to communicate with the ransomware group’s customer service department. It became apparent that Forela.org was under a significant ransomware attack. As a member of Forela.org’s Incident Response (IR) team, you have been assigned a critical task. A ticket has been created for you to reverse engineer the ransomware that has compromised Forela.org’s Windows systems. Your objective is to fully understand the ransomware’s capabilities and extract any Indicators of Compromise (IOCs) to feed into the organization’s detection tools, preventing further infection.Analysis of an advanced multi-stage ransomware payload targeting the Windows operating system.

Executive Summary

The ransomware arrived as a password-protected archive holding a VHDX image. Inside was a JavaScript dropper that decoded an embedded image and a PowerShell stage, and hid a Defender-named executable and a DLL in NTFS alternate data streams. The PowerShell stage checked for local administrator membership, used a CMSTP INF to bypass UAC, excluded its working files from Defender and launched the signed Defender binary, which sideloaded the malicious DLL. The DLL carried layered anti-debugging, XOR-obfuscated strings and an AES-encrypted configuration with the target extensions, the C2 host and the ransom note. All of it was recovered statically; nothing was executed.

Artifacts

Timestamp note: The case has no timestamps to anchor a timeline, so this page has no Forensic Timeline section.

Execution

Q1 — What is the MD5 hash of the first file the ransomware writes to disk?

Unpack the archive with the password from DANGER.txt and list the VHDX with 7z. The disk holds defenderscan.js plus alternate data streams. The script decodes a base64 blob, b64img, and writes it to disk as redbadger.webp before anything else, then decodes a second blob, b64s, into the PowerShell stage. Extract the first blob, decode it and hash the decoded file.

7z x defenderscan.vhdx
md5sum redbadger.webp
Click flag to reveal 2c92c3905a8b978787e83632739f7071

Privilege Escalation

Q2 — What is the string that the ransomware uses to check for local administrator privileges?

stage1.ps1 opens with a function that gates the rest of the script on group membership. It runs whoami /groups and matches the output against a well-known SID. That SID is the built-in local Administrators group, so the check is the ransomware’s test for local administrator rights.

grep -n 'whoami' stage1.ps1
Click to reveal answer S-1-5-32-544
Q3 — What is the MITRE ATT&CK ID for the technique used by the threat actor to elevate their privileges?

When the admin check fails, stage1.ps1 writes an INF file and runs cmstp.exe /au against it. CMSTP auto-elevates and executes the INF’s install section, which is the classic UAC bypass. Microsoft Connection Manager Profile Installer maps to System Binary Proxy Execution: CMSTP.

grep -n 'cmstp' stage1.ps1

Note: this is a reference-knowledge mapping from the observed cmstp.exe /au behaviour, and the question asks about privilege elevation. CMSTP is catalogued under defense evasion, but it is the technique the actor used to elevate.

Click flag to reveal T1218.003

Defense Evasion

Q4 — The ransomware starts a process using a signed binary, what is the full name of the signer?

The dropper’s ADS holds msmpeng.exe, the Windows Defender engine binary, which the script launches after setting up the sideload. Parse its Authenticode certificate directory with pefile and read the signer subject.

python3 -I -c "import pefile,sys; p=pefile.PE(sys.argv[1]); d=p.OPTIONAL_HEADER.DATA_DIRECTORY[4]; print(hex(d.VirtualAddress), d.Size)" msmpeng.exe
strings -a msmpeng.exe | grep -i 'Microsoft Corporation'
Click to reveal answer Microsoft Corporation
Q6 — How many Anti-Debugging techniques does the ransomware implement and what is the Windows API function that the final technique leverages?

The DLL has three distinct debugger checks. The first calls IsDebuggerPresent. The second walks the process list with the Toolhelp API to check the parent process. The last installs a handler with SetUnhandledExceptionFilter and triggers an int3 (near 0x180001eb0), so a debugger swallows the exception and the handler never runs.

objdump -d --start-address=0x180001eb0 --stop-address=0x180001f40 mpsvc.dll

Note: the count and the API were reasoned from the three checks found in disassembly plus the answer format, not read from a single labelled artifact. HTB accepted it.

Click to reveal answer 3, SetUnhandledExceptionFilter

Persistence and Execution of the Payload

Q5 — What is the final payloads' entry point function?

mpsvc.dll is the payload msmpeng.exe loads. List its export table: it has a single export, which is where execution lands once the signed binary loads the DLL.

python3 -I -c "import pefile,sys; p=pefile.PE(sys.argv[1]); [print(e.name) for e in p.DIRECTORY_ENTRY_EXPORT.symbols]" mpsvc.dll
Click flag to reveal ServiceCrtMain
Q9 — What is the MITRE ATT&CK ID the ransomware uses to run its final payload?

The signed msmpeng.exe resolves mpsvc.dll from its own directory rather than from System32, so the attacker’s copy is loaded in its place. That is DLL hijacking through the search order.

Note: reasoned from the Defender binary plus a same-folder DLL, not read from an artifact. The sideload is often labelled DLL Side-Loading (T1574.002), but HTB accepted the search-order sub-technique.

Click flag to reveal T1574.001

Impact

Q7 — The ransomware targets files with specific extensions, what is the list of extensions targeted in the exact order as the ransomware configuration stores them?

List mpsvc.dll’s PE resources with pefile and pull resource 10/101. It is AES-256-CBC encrypted, with the 32-byte key stored as the first 32 bytes of the blob and the 16-byte IV as the next 16. Decrypt it statically; the config is JSON-like and its fileExtensions field lists the targets in storage order.

python3 -I -c "import pefile,sys; p=pefile.PE(sys.argv[1]); [print(r.id) for r in p.DIRECTORY_ENTRY_RESOURCE.entries]" mpsvc.dll
Click flag to reveal .doc, .docx, .xls, .xlsx, .ppt, .pptx, .pdf, .txt, .csv, .rtf
Q11 — What is the file extension used to store the newly encrypted files?

The extension appended to encrypted files is not in the config. It is a 6-byte string, 23b63f4c2973, XOR-decoded at runtime in the function at 0x180004f80 with an 8-byte key 0x656173452549d30d. Decode it offline.

objdump -d --start-address=0x180004f80 --stop-address=0x180005040 mpsvc.dll
Click flag to reveal .evil

Command and Control

Q8 — What is the FQDN of the ransomware server the malware connects to?

The server name is another XOR-obfuscated string in the DLL, at 0x18004e390, with a dword (0x9896dfb0) and byte (0x1f) tail and an 8-byte key 0x91219b1ff7f5f1d5. strings finds nothing, so decode it by hand from the data section.

objdump -s --start-address=0x18004e390 --stop-address=0x18004e3c0 mpsvc.dll
Click to reveal answer api.ltchealthcare.co
Q10 — What is the full URL including port number of the ransomware groups customer service portal?

Once the config from Q7 is decrypted, its html_content field is the ransom note. The note points victims to the group’s customer-service portal on a Tor onion address with a port.

grep -o 'html_content.*' cfg.bin
Click to reveal answer yrwm7tdvrtejpx7ogfhax2xuxkqejp2qjb634qwwyoyabkt2eydssrad.onion:9001

Attack Summary

PhaseAction
ExecutionDropper JS decodes redbadger.webp and a PowerShell stage
Privilege Escalationstage1.ps1 checks for the local Administrators SID
Privilege EscalationCMSTP INF run through cmstp.exe /au bypasses UAC
Defense EvasionDefender exclusions set; Defender engine binary and DLL hidden in ADS
ExecutionSigned msmpeng.exe sideloads mpsvc.dll, entry via its export
Defense EvasionThree anti-debug checks and XOR-obfuscated strings in the DLL
Command and ControlPayload contacts its C2 FQDN; ransom note points to an onion portal
ImpactFiles matching the configured extensions are encrypted and renamed

IOCs

TypeValue
MD5 (first dropped file)2c92c3905a8b978787e83632739f7071
Filedefenderscan.js, stage1.ps1, msmpeng.exe, mpsvc.dll
Domainapi[.]ltchealthcare[.]co
Onion portalyrwm7tdvrtejpx7ogfhax2xuxkqejp2qjb634qwwyoyabkt2eydssrad[.]onion:9001
Encrypted extension.evil

MITRE ATT&CK

TechniqueIDDescription
Command and Scripting Interpreter: JavaScriptT1059.007The dropper is defenderscan.js
Command and Scripting Interpreter: PowerShellT1059.001Base64-decoded stage1.ps1
System Binary Proxy Execution: CMSTPT1218.003cmstp.exe /au with a crafted INF to elevate
Impair Defenses: Disable or Modify ToolsT1562.001Defender exclusions added by the PowerShell stage
Hijack Execution Flow: DLL Search Order HijackingT1574.001Signed msmpeng.exe loads the malicious mpsvc.dll
Obfuscated Files or InformationT1027XOR strings and an AES-encrypted config
Debugger EvasionT1622Three anti-debugging checks in the DLL
Data Encrypted for ImpactT1486Files with the configured extensions are encrypted
Application Layer Protocol: Web ProtocolsT1071.001Payload talks to its C2 host

Defender Takeaways

A signed Microsoft binary running from a user-writable folder is the sideload tell. msmpeng.exe launching from outside the Defender install path, or loading mpsvc.dll from its own directory, is detectable with image-load telemetry. Alert on Defender component names outside ProgramData\Microsoft\Windows Defender and Program Files.

Alternate data streams hid the real payload. The binary and DLL lived as streams on a script file, so a listing of the folder showed only the dropper. Hunt for executables with ADS and for process creation paths containing a colon.

cmstp.exe /au should be rare. CMSTP with an INF argument from a script host has almost no legitimate use on endpoints. Block or alert on it and on any process that adds Defender exclusions.

Static triage was enough here. Obfuscated strings, an AES-encrypted config with its key stored in front of it, and the sideload chain were all recoverable without detonation, so the IOCs here can reach detection tooling quickly.

Conclusion

The ransomware layered a script dropper, a UAC bypass, a signed Defender binary and a hidden DLL, then kept its targets, C2 and ransom note encrypted in one resource. Every stage was recoverable statically, and the sharpest detection points were the sideload and the CMSTP call, not the encryption itself.