Detection rules › Elastic
Curl Execution via Application Shell Script
Detects the abnormal spawning of curl or nscurl by a shell script within an applications directory structure. Threat actors have executed and abused shell scripts within a benign applications directory structures in order to evade detection and download a second stage payload. This specific activity has been observed when the shell script creates a new shell child process ,via a fork, which is then used to execute curl or nscurl. The use of shell scripts within a macOS application to execute curl is highly abnormal espcially in this specific manner.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Command & Control |
Telemetry coverage
Rule body
[rule]
description = """
Detects the abnormal spawning of curl or nscurl by a shell script within an applications directory structure. Threat
actors have executed and abused shell scripts within a benign applications directory structures in order to evade
detection and download a second stage payload. This specific activity has been observed when the shell script creates a
new shell child process ,via a fork, which is then used to execute curl or nscurl. The use of shell scripts within a
macOS application to execute curl is highly abnormal espcially in this specific manner.
"""
id = "fce1ba4a-596c-445c-938d-3ffd73152bf2"
license = "Elastic License v2"
name = "Curl Execution via Application Shell Script"
os_list = ["macos"]
reference = [
"https://www.sentinelone.com/blog/from-the-front-lines-new-macos-covid-malware-masquerades-as-apple-wears-face-of-apt/",
"https://github.com/D00MFist/Mystikal/blob/main/Modules/DMG.py",
]
version = "1.0.11"
query = '''
sequence by process.parent.entity_id with maxspan=30s
[process where event.type == "start" and event.action == "fork" and process.name like~ ("bash", "sh", "zsh", "tclsh*") and
process.args_count == 2 and process.args like~ ("/Applications/*", "/Volumes/*", "/Users/*/Applications/*") and
process.parent.name like~ ("bash", "sh", "zsh", "tclsh*")]
[process where event.type == "start" and event.action == "exec" and process.name in ("curl", "nscurl") and
process.args in ("-o", "--output", "-O", "--remote-name") and
not process.args like~
("https://github.com/*",
"http://localhost:*",
"https://localhost:*",
"https://download.elastic.co/cloud/elastic-cloud-enterprise.sh") and
not process.args == "-X" and
not process.args == "-H" and
not process.args == "-d"]
'''
min_endpoint_version = "8.7.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1
[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1105"
name = "Ingress Tool Transfer"
reference = "https://attack.mitre.org/techniques/T1105/"
[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"
[internal]
min_endpoint_version = "8.7.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 30s, correlated by process.parent.entity_id.
Stage 1: process
[process where event.type == "start" and event.action == "fork" and process.name like~ ("bash", "sh", "zsh", "tclsh*") and
process.args_count == 2 and process.args like~ ("/Applications/*", "/Volumes/*", "/Users/*/Applications/*") and
process.parent.name like~ ("bash", "sh", "zsh", "tclsh*")]
Stage 2: process
[process where event.type == "start" and event.action == "exec" and process.name in ("curl", "nscurl") and
process.args in ("-o", "--output", "-O", "--remote-name") and
not process.args like~
("https://github.com/*",
"http://localhost:*",
"https://localhost:*",
"https://download.elastic.co/cloud/elastic-cloud-enterprise.sh") and
not process.args == "-X" and
not process.args == "-H" and
not process.args == "-d"]
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | eq | -H | excludes:process.args field:"process.args" value:"-H" |
process.args | eq | -X | excludes:process.args field:"process.args" value:"-X" |
process.args | eq | -d | excludes:process.args field:"process.args" value:"-d" |
process.args | wildcard | https://github.com/*, http://localhost:*, https://localhost:*, https://download.elastic.co/cloud/elastic-cloud-enterprise.sh | excludes:process.args |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.args | in |
| field:"process.args" kind:in |
process.args | wildcard |
| field:"process.args" kind:wildcard |
process.args_count | eq |
| field:"process.args_count" kind:eq value:"2" |
process.name | in |
| field:"process_name" kind:in |
process.name | wildcard |
| field:"process_name" kind:wildcard |
process.parent.name | wildcard |
| field:"parent_process_name" kind:wildcard |