Detection of DLL Downloads via PowerShell Cmdlets
This brief covers the detection of suspicious PowerShell activity involving the use of web download cmdlets to retrieve and save DLL files to the local file system.
Adversaries frequently leverage living-off-the-land binaries (LotL) such as PowerShell to facilitate the delivery and execution of malicious payloads. A common technique observed in various malware distribution campaigns involves the use of PowerShell cmdlets - specifically Invoke-WebRequest, Invoke-RestMethod, and their respective aliases (IWR, IRM) - to download remote payloads directly from attacker-controlled infrastructure. When these commands are utilized with the 'OutFile' parameter to save a file with a '.dll' extension, it often indicates an attempt to stage a malicious library for side-loading or reflective loading. Monitoring for these specific command-line patterns allows security operations teams to identify potential initial access or secondary stage malware delivery attempts before the payload is executed.
Attack Chain
- Initial access is established, potentially via a phishing document or a malicious link.
- The attacker triggers a PowerShell process (powershell.exe) from the initial infection point.
- The process executes a download command using Invoke-WebRequest or Invoke-RestMethod.
- The command specifies a remote URL (HTTP/HTTPS) as the source.
- The 'OutFile' parameter is used to write the response body to a local file path.
- The target filename is specified with a .dll extension.
- The downloaded DLL is staged on the disk for future loading by an application.
- Final objective is achieved through the subsequent execution of the malicious DLL via techniques like DLL side-loading.
Impact
Successful exploitation of this technique allows an attacker to download arbitrary code onto a target system. If the downloaded DLL is malicious, it can lead to full system compromise, remote access, or the deployment of secondary malware payloads, enabling long-term persistence and data exfiltration.
Recommendation
Deploy the provided Sigma rule to identify PowerShell command-line activity that matches the download-to-DLL pattern. Focus investigations on the source URL identified in the logs and the parent process responsible for spawning the PowerShell instance. Enable process-creation auditing with command-line logging to ensure the 'CommandLine' field is captured for analysis.
Immediate actions
Enable PowerShell command line logging via GPO
Threat Hunt
Search for historical process creation events containing 'OutFile' and '.dll' in command lines
Data: Process creation events (Event ID 4688 or Sysmon ID 1)
Mitigations
Restrict outbound internet access for non-essential servers to prevent unauthorized tool downloads
T1105
Detection coverage 1
Detect Potential DLL File Download via PowerShell
mediumDetects potential DLL files being downloaded using the PowerShell Invoke-WebRequest or Invoke-RestMethod cmdlets
Detection queries are available on the platform. Get full rules →