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

Event coverage

Rule body yaml

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

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
processregex_match"(?i)(^|\s|\;||)(iex|iwr)(\s|\;||)"

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
EventCodeeq
  • 4688 corpus 313 (splunk 283, kusto 30)
processregex_match
  • "(?i)System.Net.WebClient.+.Download(file|string)" corpus 3 (splunk 3)

Search terms

Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.

StageTerm
1TERM
1"<EventID>4688<"
1"downloadfile"
1"downloadstring"
1"System.Net.WebClient"
1"Invoke-WebRequest"
1"Invoke-Expression"