Potential Meterpreter Reverse Shell

This detection rule identifies a sample of suspicious Linux system file reads used for system fingerprinting, leveraged by the Metasploit Meterpreter shell to gather information about the target that it is executing its shell on. Detecting this pattern is indicative of a successful meterpreter shell connection.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/08/10"
  3integration = ["auditd_manager"]
  4maturity = "production"
  5updated_date = "2024/09/23"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This detection rule identifies a sample of suspicious Linux system file reads used for system fingerprinting, leveraged
 11by the Metasploit Meterpreter shell to gather information about the target that it is executing its shell on. Detecting
 12this pattern is indicative of a successful meterpreter shell connection.
 13"""
 14from = "now-9m"
 15index = ["auditbeat-*", "logs-auditd_manager.auditd-*"]
 16language = "eql"
 17license = "Elastic License v2"
 18name = "Potential Meterpreter Reverse Shell"
 19references = [
 20    "https://www.elastic.co/security-labs/primer-on-persistence-mechanisms",
 21    "https://www.elastic.co/security-labs/linux-detection-engineering-with-auditd",
 22]
 23risk_score = 47
 24rule_id = "5c895b4f-9133-4e68-9e23-59902175355c"
 25setup = """## Setup
 26
 27This rule requires data coming in from one of the following integrations:
 28- Auditbeat
 29- Auditd Manager
 30
 31### Auditbeat Setup
 32Auditbeat is a lightweight shipper that you can install on your servers to audit the activities of users and processes on your systems. For example, you can use Auditbeat to collect and centralize audit events from the Linux Audit Framework. You can also use Auditbeat to detect changes to critical files, like binaries and configuration files, and identify potential security policy violations.
 33
 34#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 35- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 36- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setup-repositories.html).
 37- To run Auditbeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-docker.html).
 38- To run Auditbeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-kubernetes.html).
 39- For complete “Setup and Run Auditbeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setting-up-and-running.html).
 40
 41### Auditd Manager Integration Setup
 42The Auditd Manager Integration receives audit events from the Linux Audit Framework which is a part of the Linux kernel.
 43Auditd Manager provides a user-friendly interface and automation capabilities for configuring and monitoring system auditing through the auditd daemon. With `auditd_manager`, administrators can easily define audit rules, track system events, and generate comprehensive audit reports, improving overall security and compliance in the system.
 44
 45#### The following steps should be executed in order to add the Elastic Agent System integration "auditd_manager" on a Linux System:
 46- Go to the Kibana home page and click “Add integrations”.
 47- In the query bar, search for “Auditd Manager” and select the integration to see more details about it.
 48- Click “Add Auditd Manager”.
 49- Configure the integration name and optionally add a description.
 50- Review optional and advanced settings accordingly.
 51- Add the newly installed “auditd manager” to an existing or a new agent policy, and deploy the agent on a Linux system from which auditd log files are desirable.
 52- Click “Save and Continue”.
 53- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/auditd_manager).
 54
 55#### Rule Specific Setup Note
 56Auditd Manager subscribes to the kernel and receives events as they occur without any additional configuration.
 57However, if more advanced configuration is required to detect specific behavior, audit rules can be added to the integration in either the "audit rules" configuration box or the "auditd rule files" box by specifying a file to read the audit rules from.
 58- For this detection rule the following additional audit rules are required to be added to the integration:
 59  -w /proc/net/ -p r -k audit_proc
 60  -w /etc/machine-id -p wa -k machineid
 61  -w /etc/passwd -p wa -k passwd
 62"""
 63severity = "medium"
 64tags = [
 65    "Data Source: Auditd Manager",
 66    "Domain: Endpoint",
 67    "OS: Linux",
 68    "Use Case: Threat Detection",
 69    "Tactic: Execution",
 70]
 71timestamp_override = "event.ingested"
 72type = "eql"
 73
 74query = '''
 75sample by host.id, process.pid, user.id
 76  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/etc/machine-id"]
 77  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/etc/passwd"]
 78  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/route"]
 79  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/ipv6_route"]
 80  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/if_inet6"]
 81'''
 82
 83
 84[[rule.threat]]
 85framework = "MITRE ATT&CK"
 86[[rule.threat.technique]]
 87id = "T1059"
 88name = "Command and Scripting Interpreter"
 89reference = "https://attack.mitre.org/techniques/T1059/"
 90[[rule.threat.technique.subtechnique]]
 91id = "T1059.004"
 92name = "Unix Shell"
 93reference = "https://attack.mitre.org/techniques/T1059/004/"
 94
 95
 96
 97[rule.threat.tactic]
 98id = "TA0002"
 99name = "Execution"
100reference = "https://attack.mitre.org/tactics/TA0002/"
101[[rule.threat]]
102framework = "MITRE ATT&CK"
103[[rule.threat.technique]]
104id = "T1071"
105name = "Application Layer Protocol"
106reference = "https://attack.mitre.org/techniques/T1071/"
107
108
109[rule.threat.tactic]
110id = "TA0011"
111name = "Command and Control"
112reference = "https://attack.mitre.org/tactics/TA0011/"

References

Related rules

to-top