Remote File Download via PowerShell

Last updated 4 months ago on 2025-09-04
Created 5 years ago on 2020-11-30

About

Identifies powershell.exe being used to download an executable file from an untrusted remote destination.
Tags
Domain: EndpointOS: WindowsUse Case: Threat DetectionTactic: Command and ControlData Source: Elastic DefendLanguage: eql
Severity
medium
Risk Score
47
MITRE ATT&CK™

Command and Control (TA0011)(external, opens in a new tab or window)

Execution (TA0002)(external, opens in a new tab or window)

License
Elastic License v2(external, opens in a new tab or window)

Definition

Rule Type
Event Correlation Rule
Integration Pack
Prebuilt Security Detection Rules
Index Patterns
logs-endpoint.events.network-*logs-endpoint.events.file-*
Related Integrations

endpoint(external, opens in a new tab or window)

Query
text code block:
sequence by process.entity_id with maxspan=30s [network where host.os.type == "windows" and process.name : ("powershell.exe", "pwsh.exe", "powershell_ise.exe") and network.protocol == "dns" and not dns.question.name : ( "*.microsoft.com", "*.azureedge.net", "*.powershellgallery.com", "*.windowsupdate.com", "metadata.google.internal", "dist.nuget.org", "artifacts.elastic.co", "*.digicert.com", "*.chocolatey.org", "outlook.office365.com", "cdn.oneget.org", "ci.dot.net", "packages.icinga.com", "login.microsoftonline.com", "*.gov", "*.azure.com", "*.python.org", "dl.google.com", "sensor.cloud.tenable.com", "*.azurefd.net", "*.office.net", "*.anac*", "aka.ms", "dot.net", "*.visualstudio.com", "*.local") and not user.id == "S-1-5-18" and /* Filter out NetBIOS/LLMNR-style names (e.g. host, localhost, etc.) */ dns.question.name regex """.*\.[a-zA-Z]{2,5}"""] [file where host.os.type == "windows" and event.type == "creation" and process.name : "powershell.exe" and (file.extension : ("exe", "dll", "ps1", "bat") or file.Ext.header_bytes : "4d5a*") and not file.name : "__PSScriptPolicy*.ps1" and not file.path : ( "?:\\Users\\*\\AppData\\Local\\Temp\\????????.dll", "?:\\Users\\*\\AppData\\Local\\Temp\\*\\????????.dll", "?:\\Windows\\TEMP\\ansible-tmp-*\\AnsiballZ*.ps1" ) and not user.id == "S-1-5-18"]

Install detection rules in Elastic Security

Detect Remote File Download via PowerShell in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).