Executable Bit Set for Potential Persistence Script
This rule monitors for the addition of an executable bit for scripts that are located in directories which are commonly abused for persistence. An alert of this rule is an indicator that a persistence mechanism is being set up within your environment. Adversaries may create these scripts to execute malicious code at start-up, or at a set interval to gain persistence onto the system.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/06/03"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2024/07/30"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule monitors for the addition of an executable bit for scripts that are located in directories which are
11commonly abused for persistence. An alert of this rule is an indicator that a persistence mechanism is being set up
12within your environment. Adversaries may create these scripts to execute malicious code at start-up, or at a set
13interval to gain persistence onto the system.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.process*", "endgame-*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Executable Bit Set for Potential Persistence Script"
20references = [
21 "https://www.intezer.com/blog/malware-analysis/hiddenwasp-malware-targeting-linux-systems/",
22 "https://pberba.github.io/security/2022/02/06/linux-threat-hunting-for-persistence-initialization-scripts-and-shell-configuration/#8-boot-or-logon-initialization-scripts-rc-scripts",
23 "https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/",
24]
25risk_score = 21
26rule_id = "94418745-529f-4259-8d25-a713a6feb6ae"
27setup = """## Setup
28
29This rule requires data coming in from Elastic Defend.
30
31### Elastic Defend Integration Setup
32Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
33
34#### Prerequisite Requirements:
35- Fleet is required for Elastic Defend.
36- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
37
38#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
39- Go to the Kibana home page and click "Add integrations".
40- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
41- Click "Add Elastic Defend".
42- Configure the integration name and optionally add a description.
43- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
44- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
45- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
46- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
47For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
48- Click "Save and Continue".
49- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
50For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
51"""
52severity = "low"
53tags = [
54 "Domain: Endpoint",
55 "OS: Linux",
56 "Use Case: Threat Detection",
57 "Tactic: Persistence",
58 "Data Source: Elastic Endgame",
59 "Data Source: Elastic Defend"
60]
61timestamp_override = "event.ingested"
62type = "eql"
63query = '''
64process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "exec_event") and
65process.args : (
66 // Misc.
67 "/etc/rc.local", "/etc/rc.common", "/etc/rc.d/rc.local", "/etc/init.d/*", "/etc/update-motd.d/*",
68 "/etc/apt/apt.conf.d/*", "/etc/cron*", "/etc/init/*",
69
70 // XDG
71 "/etc/xdg/autostart/*", "/home/*/.config/autostart/*", "/root/.config/autostart/*",
72 "/home/*/.local/share/autostart/*", "/root/.local/share/autostart/*", "/home/*/.config/autostart-scripts/*",
73 "/root/.config/autostart-scripts/*", "/etc/xdg/autostart/*", "/usr/share/autostart/*",
74
75 // udev
76 "/lib/udev/*", "/etc/udev/rules.d/*", "/usr/lib/udev/rules.d/*", "/run/udev/rules.d/*"
77
78) and (
79 (process.name == "chmod" and process.args : ("+x*", "1*", "3*", "5*", "7*")) or
80 (process.name == "install" and process.args : "-m*" and process.args : ("7*", "5*", "3*", "1*"))
81) and not process.parent.executable : "/var/lib/dpkg/*"
82'''
83
84[[rule.threat]]
85framework = "MITRE ATT&CK"
86
87[[rule.threat.technique]]
88id = "T1037"
89name = "Boot or Logon Initialization Scripts"
90reference = "https://attack.mitre.org/techniques/T1037/"
91
92[[rule.threat.technique.subtechnique]]
93id = "T1037.004"
94name = "RC Scripts"
95reference = "https://attack.mitre.org/techniques/T1037/004/"
96
97[[rule.threat.technique]]
98id = "T1053"
99name = "Scheduled Task/Job"
100reference = "https://attack.mitre.org/techniques/T1053/"
101
102[[rule.threat.technique.subtechnique]]
103id = "T1053.003"
104name = "Cron"
105reference = "https://attack.mitre.org/techniques/T1053/003/"
106
107[[rule.threat.technique]]
108id = "T1547"
109name = "Boot or Logon Autostart Execution"
110reference = "https://attack.mitre.org/techniques/T1547/"
111
112[[rule.threat.technique.subtechnique]]
113id = "T1547.013"
114name = "XDG Autostart Entries"
115reference = "https://attack.mitre.org/techniques/T1547/013/"
116
117[rule.threat.tactic]
118id = "TA0003"
119name = "Persistence"
120reference = "https://attack.mitre.org/tactics/TA0003/"
References
Related rules
- Persistence via KDE AutoStart Script or Desktop File Modification
- SSH Key Generated via ssh-keygen
- Suspicious File Creation in /etc for Persistence
- System V Init Script Created
- Process Capability Set via setcap Utility