Detection rules › Elastic
Background Process Execution via Shell
Detects when a binary located in a suspicious location gets executed by a shell interpreter and put in the background via the & operator. Malwares may execute their payloads in the background in an effort to remain hidden.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution |
Telemetry coverage
Rule body
[rule]
description = """
Detects when a binary located in a suspicious location gets executed by a shell interpreter and put in the background
via the & operator. Malwares may execute their payloads in the background in an effort to remain hidden.
"""
id = "603ac59e-9cca-4c48-9750-e38399079043"
license = "Elastic License v2"
name = "Background Process Execution via Shell"
os_list = ["macos"]
version = "1.0.19"
query = '''
process where event.type == "start" and event.action == "exec" and
process.name like~ ("bash", "sh", "zsh", "tclsh*") and
process.args == "-c" and process.args like~ ("/* &", "/*&") and
process.args_count == 3 and
process.parent.executable like~
("/private/tmp/*",
"/var/tmp/*",
"/tmp/*",
"/var/folders/*",
"/Library/Containers/*",
"/Library/Graphics/*",
"/Users/Shared/*",
"/Users/*/Library/Preferences/*",
"/var/root/*",
"/Library/WebServer/*",
"/Library/Preferences/*",
"/Library/Services/*",
"/Library/Fonts/*",
"/usr/local/bin/*")
'''
min_endpoint_version = "8.10.2"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.004"
name = "Unix Shell"
reference = "https://attack.mitre.org/techniques/T1059/004/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[internal]
min_endpoint_version = "8.10.2"
Stages and Predicates
Stage 1: process
process where event.type == "start" and event.action == "exec" and
process.name like~ ("bash", "sh", "zsh", "tclsh*") and
process.args == "-c" and process.args like~ ("/* &", "/*&") and
process.args_count == 3 and
process.parent.executable like~
("/private/tmp/*",
"/var/tmp/*",
"/tmp/*",
"/var/folders/*",
"/Library/Containers/*",
"/Library/Graphics/*",
"/Users/Shared/*",
"/Users/*/Library/Preferences/*",
"/var/root/*",
"/Library/WebServer/*",
"/Library/Preferences/*",
"/Library/Services/*",
"/Library/Fonts/*",
"/usr/local/bin/*")
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"exec" |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.args | eq |
| field:"process.args" kind:eq value:"-c" |
process.args | wildcard |
| field:"process.args" kind:wildcard |
process.args_count | eq |
| field:"process.args_count" kind:eq value:"3" |
process.name | wildcard |
| field:"process_name" kind:wildcard |
process.parent.executable | wildcard |
| field:"ParentImage" kind:wildcard |