Detection rules › Elastic
Command Execution via Screen Session
Detects the execution of the screen binary to execute a command or commands via a shell. Threat actors have used this technique via interactive sessions to execute commands on the host and avoid standard detections.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution |
Telemetry coverage
Rule body
[rule]
description = """
Detects the execution of the screen binary to execute a command or commands via a shell. Threat actors have used this
technique via interactive sessions to execute commands on the host and avoid standard detections.
"""
id = "232c03d2-ff5d-4ec5-88b5-5926dc491e91"
license = "Elastic License v2"
name = "Command Execution via Screen Session"
os_list = ["macos"]
version = "1.0.6"
query = '''
process where event.type == "start" and event.action == "exec" and
process.name == "screen" and
process.args in ("/bin/bash", "/usr/bin/bash", "/bin/sh", "/usr/bin/sh", "/bin/zsh", "/usr/bin/zsh", "bash", "sh", "zsh") and
process.args == "-c" and
not process.Ext.effective_parent.executable == "/Applications/kitty.app/Contents/MacOS/kitty"
'''
min_endpoint_version = "8.7.0"
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.7.0"
Stages and Predicates
Stage 1: process
process where event.type == "start" and event.action == "exec" and
process.name == "screen" and
process.args in ("/bin/bash", "/usr/bin/bash", "/bin/sh", "/usr/bin/sh", "/bin/zsh", "/usr/bin/zsh", "bash", "sh", "zsh") and
process.args == "-c" and
not process.Ext.effective_parent.executable == "/Applications/kitty.app/Contents/MacOS/kitty"
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.Ext.effective_parent.executable | eq | /Applications/kitty.app/Contents/MacOS/kitty | excludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"/Applications/kitty.app/Contents/MacOS/kitty" |
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 | in |
| field:"process.args" kind:in |
process.name | eq |
| field:"process_name" kind:eq value:"screen" |