Detection rules › Elastic
Shell Execution of Non-Executable File
Detects the execution of an un-executable file, per file extension, via a shell interpreter. Sometimes threat actors will masquerade their payloads as non-executable files in order to avoid suspicion and go unnoticed.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | |
| Stealth |
Rule body
[rule]
description = """
Detects the execution of an un-executable file, per file extension, via a shell interpreter. Sometimes threat actors
will masquerade their payloads as non-executable files in order to avoid suspicion and go unnoticed.
"""
id = "4c61fca2-6f77-474d-a537-2d7fd9ec75e0"
license = "Elastic License v2"
name = "Shell Execution of Non-Executable File"
os_list = ["linux"]
version = "1.0.10"
query = '''
process where event.type == "start" and event.action == "exec" and process.args_count == 2 and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
process.args in (
"/bin/bash", "/usr/bin/bash", "/bin/sh", "/usr/bin/sh", "/bin/dash", "/usr/bin/dash", "/bin/zsh", "/usr/bin/zsh",
"/bin/tcsh", "/usr/bin/tcsh", "/bin/csh", "/usr/bin/csh", "/bin/ksh", "/usr/bin/ksh", "/bin/fish", "/usr/bin/fish"
) and
process.args like ("*.pid", "*.txt", "*.json", "*.bin", "*.log", "*.dat") and
not (
process.args in ("/opt/config/example.txt", "/var/lib/git/beinformed.git/subgit/authors.txt") or
process.parent.args like ("/sbin/init", "/var/opt/eset/RemoteAdministrator/Agent/*") or
process.parent.executable in ("/usr/bin/emscli", "./runc") or
process.command_line in (
/* Manage Engine UEMS Agent */
"/bin/bash /opt/DesktopCentral/UEMS_LinuxAgent.bin", "/bin/bash ./UEMS_LinuxAgent.bin"
)
)
'''
min_endpoint_version = "7.15.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.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/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1036"
name = "Masquerading"
reference = "https://attack.mitre.org/techniques/T1036/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "7.15.0"
Stages and Predicates
Stage 1: process
process where event.type == "start" and event.action == "exec" and process.args_count == 2 and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
process.args in (
"/bin/bash", "/usr/bin/bash", "/bin/sh", "/usr/bin/sh", "/bin/dash", "/usr/bin/dash", "/bin/zsh", "/usr/bin/zsh",
"/bin/tcsh", "/usr/bin/tcsh", "/bin/csh", "/usr/bin/csh", "/bin/ksh", "/usr/bin/ksh", "/bin/fish", "/usr/bin/fish"
) and
process.args like ("*.pid", "*.txt", "*.json", "*.bin", "*.log", "*.dat") and
not (
process.args in ("/opt/config/example.txt", "/var/lib/git/beinformed.git/subgit/authors.txt") or
process.parent.args like ("/sbin/init", "/var/opt/eset/RemoteAdministrator/Agent/*") or
process.parent.executable in ("/usr/bin/emscli", "./runc") or
process.command_line in (
"/bin/bash /opt/DesktopCentral/UEMS_LinuxAgent.bin", "/bin/bash ./UEMS_LinuxAgent.bin"
)
)
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | in | /opt/config/example.txt, /var/lib/git/beinformed.git/subgit/authors.txt | excludes:process.args field:"process.args" value:"/opt/config/example.txt" field:"process.args" value:"/var/lib/git/beinformed.git/subgit/authors.txt" |
process.command_line | in | /bin/bash ./UEMS_LinuxAgent.bin, /bin/bash /opt/DesktopCentral/UEMS_LinuxAgent.bin | excludes:process.command_line field:"process.command_line" value:"/bin/bash ./UEMS_LinuxAgent.bin" field:"process.command_line" value:"/bin/bash /opt/DesktopCentral/UEMS_LinuxAgent.bin" |
process.parent.args | wildcard | /sbin/init, /var/opt/eset/RemoteAdministrator/Agent/* | excludes:process.parent.args field:"process.parent.args" value:"/sbin/init" field:"process.parent.args" value:"/var/opt/eset/RemoteAdministrator/Agent/*" |
process.parent.executable | in | ./runc, /usr/bin/emscli | excludes:process.parent.executable field:"process.parent.executable" value:"./runc" field:"process.parent.executable" value:"/usr/bin/emscli" |
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 | 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 |