Detection rules › Splunk

PowerShell DownloadFile_DownloadString (Sysmon)

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

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

id: '29435.55089'
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_sysmon` (TERM(EventCode=1) OR "<EventID>1<")
  ("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:
- Windows Sysmon
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_sysmon` (TERM(EventCode=1) OR "<EventID>1<") ("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
  • 1 corpus 241 (splunk 225, kusto 15, elastic 1)
field:"EventID" kind:eq value:"1"
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>1<"
1"downloadfile"
1"downloadstring"
1"System.Net.WebClient"