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/06/21"
 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,"
13"No such file or directory," or "command not found" in the syslog log file, which may indicate that the rc.local file
14has been 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]
26risk_score = 21
27rule_id = "69c116bb-d86f-48b0-857d-3648511a6cac"
28setup = """## Setup
29
30This rule requires data coming in from one of the following integrations:
31- Filebeat
32
33### Filebeat Setup
34Filebeat 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.
35
36#### The following steps should be executed in order to add the Filebeat for the Linux System:
37- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
38- 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).
39- 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).
40- 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).
41- 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).
42- 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).
43
44#### Rule Specific Setup Note
45- This rule requires the Filebeat System Module to be enabled.
46- The system module collects and parses logs created by the system logging service of common Unix/Linux based distributions.
47- 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).
48"""
49severity = "low"
50tags = [
51    "Domain: Endpoint",
52    "OS: Linux",
53    "Use Case: Threat Detection",
54    "Tactic: Persistence",
55]
56timestamp_override = "event.ingested"
57type = "query"
58query = '''
59host.os.type:linux and event.dataset:system.syslog and process.name:rc.local and
60message:("Connection refused" or "No such file or directory" or "command not found")
61'''
62
63[[rule.threat]]
64framework = "MITRE ATT&CK"
65
66[[rule.threat.technique]]
67id = "T1037"
68name = "Boot or Logon Initialization Scripts"
69reference = "https://attack.mitre.org/techniques/T1037/"
70
71[[rule.threat.technique.subtechnique]]
72id = "T1037.004"
73name = "RC Scripts"
74reference = "https://attack.mitre.org/techniques/T1037/004/"
75
76[rule.threat.tactic]
77id = "TA0003"
78name = "Persistence"
79reference = "https://attack.mitre.org/tactics/TA0003/"

References

Related rules

to-top