Detection rules › Splunk

PowerShell DownloadFile_DownloadString (Windows Event Log)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

Adversaries have the capability to move tools or files from an external system into a compromised environment. This involves copying tools or files from an external system controlled by the adversary to the victim network through the command and control channel. This use case detects PowerShell commands related to file downloads using DownloadFile and DownloadString methods. Executions involving Invoke-WebRequest and Invoke-Expression have been excluded as they are covered by other use cases.

MITRE ATT&CK coverage

References

Telemetry coverage

Rule body

id: '29435.53027'
title: PowerShell DownloadFile_DownloadString
description: Adversaries have the capability to move tools or files from an external
  system into a compromised environment. This involves copying tools or files from
  an external system controlled by the adversary to the victim network through the
  command and control channel. This use case detects PowerShell commands related to
  file downloads using DownloadFile and DownloadString methods. Executions involving
  Invoke-WebRequest and Invoke-Expression have been excluded as they are covered by
  other use cases.
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4688) OR
  "<EventID>4688<" OR Type=Process) ("downloadfile" OR "downloadstring") "System.Net.WebClient"
  NOT ("Invoke-WebRequest" OR "Invoke-Expression") | regex process="(?i)System\.Net\.WebClient.+\.Download(file|string)"|
  regex process!="(?i)(^|\s|\;|\|)(iex|iwr)(\s|\;|\|)"| table _time, host, user, process,
  process_name, parent_process_name | bin span=1s | stats values(*) as * by _time,
  host '
techniques:
- execution:command and scripting interpreter:powershell
- execution:command and scripting interpreter
- command-and-control:ingress tool transfer
technique_id:
- T1059.001
- T1059
- T1105
data_category:
- Process command-line parameters
- Windows event logs
references:
- https://blog.talosintelligence.com/lazarus-three-rats/
- https://blog.talosintelligence.com/prometei-botnet-improves/

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4688) OR "<EventID>4688<" OR Type=Process) ("downloadfile" OR "downloadstring") "System.Net.WebClient" NOT ("Invoke-WebRequest" OR "Invoke-Expression")

Stage 2: regex

| regex process="(?i)System\.Net\.WebClient.+\.Download(file|string)"

Stage 3: regex

| regex process!="(?i)(^|\s|\;|\|)(iex|iwr)(\s|\;|\|)"

Stage 4: table

| table _time, host, user, process, process_name, parent_process_name

Stage 5: bucket

| bin span=1s

Stage 6: stats

| stats values(*) as * by _time, host

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
processregex_match"(?i)(^|\s|\;||)(iex|iwr)(\s|\;||)"excludes:process

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EventCodeeq
  • 4688 corpus 317 (splunk 283, kusto 33, elastic 1)
field:"EventID" kind:eq value:"4688"
processregex_match
  • "(?i)System.Net.WebClient.+.Download(file|string)" corpus 3 (splunk 3)
field:"CommandLine" kind:regex_match

Search terms

These SPL tokens match against raw event text.

StageTerm
1"<EventID>4688<"
1"downloadfile"
1"downloadstring"
1"System.Net.WebClient"