-
Notifications
You must be signed in to change notification settings - Fork 10
DLL Hijacking Overview
Daethyra edited this page Sep 26, 2025
·
1 revision
-
Initial Compromise:
An attacker sends a phishing email with a malicious Office document. When the victim enables macros, a script downloads and executes a payload (e.g., a backdoor) onto the system. -
Privilege Escalation:
The backdoor exploits a local Windows vulnerability (e.g., a DLL hijacking flaw in a system utility) to gain administrative privileges. -
DLL Injection into
explorer.exe:
The attacker deploys a malicious DLL (e.g.,malicious.dll) and injects it intoexplorer.exe, a process that:- Runs under the current user’s context (no admin rights needed post-injection).
- Restarts automatically at user login, ensuring the malware survives reboots.
- Blends into normal system activity, avoiding suspicion.
1. Malicious DLL Creation
- The attacker crafts a DLL that performs malicious actions:
-
Persistence: Writes a registry key (e.g.,
HKCU\Software\Microsoft\Windows\CurrentVersion\Run) to relaunch the malware ifexplorer.exeis terminated. - C2 Communication: Connects to a command-and-control (C2) server for further instructions.
- Payload Execution: Drops additional malware (e.g., ransomware, spyware). 2. **Injection into `explorer.exe
-
Persistence: Writes a registry key (e.g.,
-
Method:
The attacker uses a tool like Process Hacker, Metasploit’spost/windows/manage/dllinject, or custom code to:- Enumerate running processes to find
explorer.exe(PID). - Allocate memory within
explorer.exeusingVirtualAllocEx. - Write the malicious DLL path or binary into the allocated memory (
WriteProcessMemory). - Execute the DLL via
CreateRemoteThread(or APC injection) to load it intoexplorer.exe
- Enumerate running processes to find
-
Result:
The malicious DLL runs under the guise ofexplorer.exe, inheriting its permissions and appearing benign to security tools. 3. Persistence Mechanism - The DLL adds a registry entry to reload itself if the process dies:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
Value: "LegitApp" = "C:\Windows\System32\explorer.exe /loadmalicious"
- Because
explorer.exeis a legitimate Windows process, security software may ignore the activity.
Kovter, a fileless malware strain, abused DLL injection into explorer.exe for persistence:
- Initial Access: Delivered via malicious ad campaigns or phishing.
-
Injection:
- Stored payloads in registry keys (encoded as blobs) instead of files to evade detection.
- Injected code into
explorer.exeto decode and execute the payload from memory.
-
Persistence:
- Modified registry keys to reload the malicious code every time
explorer.exestarted (e.g., user login).
- Modified registry keys to reload the malicious code every time
Once the DLL is running inside explorer.exe:
-
Evasion:
- Network traffic appears to originate from
explorer.exe, bypassing firewalls. - Process hollowing or reflective DLL injection hides the malicious code.
- Network traffic appears to originate from
-
Lateral Movement:
- Uses
explorer.exe’s access to network shares or clipboard data (e.g., stealing credentials).
- Uses
-
Payload Execution:
- Deploys ransomware (e.g., LockBit) or spyware (e.g., keyloggers).
- Tools: Sysinternals Process Explorer, Autoruns, or EDR solutions.
-
Signatures:
- Unexpected child processes of
explorer.exe. - Unusual registry entries under
RunorAppInit_DLLs. - Memory anomalies in
explorer.exe(e.g., unexpected modules).
- Unexpected child processes of
-
Restrict DLL Injection:
Use tools like Microsoft Attack Surface Reduction (ASR) to block untrusted processes from injecting code. -
Monitor Process Behavior:
Alert onexplorer.exespawningcmd.exe,powershell.exe, or making network connections. -
Application Whitelisting:
Block unsigned DLLs from loading into critical processes. -
Registry Auditing:
Monitor changes toRunkeys orAppInit_DLLs.
#dllhijacking