Detection rules › Elastic

File Download Piped to Script Interpreter

Time window
2m
Sequence by
Effective_process.entity_id, process.Ext.effective_parent.entity_id
Source
github.com/elastic/protections-artifacts

Detects when curl or wget is utilized to download a payload and pipe it to a script interpreter for immediate execution. This activity occurs when a file is downloaded and passed to a interpreter via a shell.

MITRE ATT&CK coverage

Telemetry coverage

Rule body

[rule]
description = """
Detects when curl or wget is utilized to download a payload and pipe it to a script interpreter for immediate execution.
This activity occurs when a file is downloaded and passed to a interpreter via a shell.
"""
id = "2b616880-0a1b-42ef-a916-dea5864cd9b9"
license = "Elastic License v2"
name = "File Download Piped to Script Interpreter"
os_list = ["macos"]
version = "1.0.19"

query = '''
sequence with maxspan=2m
[process where event.type == "start" and event.action == "exec" and 
  process.name in ("curl", "nscurl") and
  process.args in ("-o", "--output", "-O", "-o-", "O", "-dl", "--download", "-ld", "--large-download") and
  process.command_line : ("/Users/Shared/*", "/tmp/*", "/private/tmp/*", "/var/tmp/*", "/private/var/tmp/*")] by process.Ext.effective_parent.entity_id
[file where event.action == "modification" and process.name in ("curl", "nscurl") and file.extension in ("sh", "scpt")] by Effective_process.entity_id
[process where event.type == "start" and event.action == "exec" and
 process.name like~ ("python*", "perl*", "ruby*", "sh", "bash", "zsh", "osascript") and
 process.parent.name in ("sh", "bash", "zsh", "osascript") and 
 ((process.args like~ ("python*", "perl*", "ruby*", "bash", "sh", "zsh", "osascript") and process.args_count == 1) or
  (process.args in ("bash", "sh", "zsh") and process.args == "-s" and process.args_count <= 2))] by process.Ext.effective_parent.entity_id
'''

min_endpoint_version = "8.16.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 2

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 2

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"


[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"

[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "8.16.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 2m, correlated by Effective_process.entity_id, process.Ext.effective_parent.entity_id.

Stage 1: process

[process where event.type == "start" and event.action == "exec" and 
  process.name in ("curl", "nscurl") and
  process.args in ("-o", "--output", "-O", "-o-", "O", "-dl", "--download", "-ld", "--large-download") and
  process.command_line : ("/Users/Shared/*", "/tmp/*", "/private/tmp/*", "/var/tmp/*", "/private/var/tmp/*")] by process.Ext.effective_parent.entity_id

Stage 2: file

[file where event.action == "modification" and process.name in ("curl", "nscurl") and file.extension in ("sh", "scpt")] by Effective_process.entity_id

Stage 3: process

[process where event.type == "start" and event.action == "exec" and
 process.name like~ ("python*", "perl*", "ruby*", "sh", "bash", "zsh", "osascript") and
 process.parent.name in ("sh", "bash", "zsh", "osascript") and 
 ((process.args like~ ("python*", "perl*", "ruby*", "bash", "sh", "zsh", "osascript") and process.args_count == 1) or
  (process.args in ("bash", "sh", "zsh") and process.args == "-s" and process.args_count <= 2))] by process.Ext.effective_parent.entity_id

Indicators

These rows show field, operator, and value matches.