Suspicious rc.local Error Message
This rule monitors the syslog log file for error messages related to the rc.local process. The rc.local file is a script that is executed during the boot process on Linux systems. Attackers may attempt to modify the rc.local file to execute malicious commands or scripts during system startup. This rule detects error messages such as "Connection refused," "No such file or directory," or "command not found" in the syslog log file, which may indicate that the rc.local file has been tampered with.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/06/21"
3integration = ["system"]
4maturity = "production"
5updated_date = "2024/09/23"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule monitors the syslog log file for error messages related to the rc.local process. The rc.local file is a script
11that is executed during the boot process on Linux systems. Attackers may attempt to modify the rc.local file to execute
12malicious commands or scripts during system startup. This rule detects error messages such as "Connection refused," "No
13such file or directory," or "command not found" in the syslog log file, which may indicate that the rc.local file has
14been tampered with.
15"""
16from = "now-9m"
17index = ["logs-system.syslog-*"]
18language = "kuery"
19license = "Elastic License v2"
20name = "Suspicious rc.local Error Message"
21references = [
22 "https://www.intezer.com/blog/malware-analysis/hiddenwasp-malware-targeting-linux-systems/",
23 "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",
24 "https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/",
25 "https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms",
26]
27risk_score = 21
28rule_id = "69c116bb-d86f-48b0-857d-3648511a6cac"
29setup = """## Setup
30
31This rule requires data coming in from one of the following integrations:
32- Filebeat
33
34### Filebeat Setup
35Filebeat is a lightweight shipper for forwarding and centralizing log data. Installed as an agent on your servers, Filebeat monitors the log files or locations that you specify, collects log events, and forwards them either to Elasticsearch or Logstash for indexing.
36
37#### The following steps should be executed in order to add the Filebeat for the Linux System:
38- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
39- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/setup-repositories.html).
40- To run Filebeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/running-on-docker.html).
41- To run Filebeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/running-on-kubernetes.html).
42- For quick start information for Filebeat refer to the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/8.11/filebeat-installation-configuration.html).
43- For complete Setup and Run Filebeat information refer to the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/setting-up-and-running.html).
44
45#### Rule Specific Setup Note
46- This rule requires the Filebeat System Module to be enabled.
47- The system module collects and parses logs created by the system logging service of common Unix/Linux based distributions.
48- To run the system module of Filebeat on Linux follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-system.html).
49"""
50severity = "low"
51tags = ["Domain: Endpoint", "OS: Linux", "Use Case: Threat Detection", "Tactic: Persistence"]
52timestamp_override = "event.ingested"
53type = "query"
54
55query = '''
56host.os.type:linux and event.dataset:system.syslog and process.name:rc.local and
57message:("Connection refused" or "No such file or directory" or "command not found")
58'''
59
60
61[[rule.threat]]
62framework = "MITRE ATT&CK"
63[[rule.threat.technique]]
64id = "T1037"
65name = "Boot or Logon Initialization Scripts"
66reference = "https://attack.mitre.org/techniques/T1037/"
67[[rule.threat.technique.subtechnique]]
68id = "T1037.004"
69name = "RC Scripts"
70reference = "https://attack.mitre.org/techniques/T1037/004/"
71
72
73
74[rule.threat.tactic]
75id = "TA0003"
76name = "Persistence"
77reference = "https://attack.mitre.org/tactics/TA0003/"
References
Related rules
- At Job Created or Modified
- DNF Package Manager Plugin File Creation
- Executable Bit Set for Potential Persistence Script
- Git Hook Child Process
- Git Hook Command Execution