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"
  5min_stack_comments = "The sampling feature within EQL was introduced in 8.6.0"
  6min_stack_version = "8.6.0"
  7updated_date = "2024/02/19"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12This detection rule identifies a sample of suspicious Linux system file reads used for system fingerprinting, leveraged 
 13by the Metasploit Meterpreter shell to gather information about the target that it is executing its shell on. Detecting
 14this pattern is indicative of a successful meterpreter shell connection. 
 15"""
 16from = "now-9m"
 17index = ["auditbeat-*", "logs-auditd_manager.auditd-*"]
 18language = "eql"
 19license = "Elastic License v2"
 20name = "Potential Meterpreter Reverse Shell"
 21risk_score = 47
 22rule_id = "5c895b4f-9133-4e68-9e23-59902175355c"
 23setup = """## Setup
 24
 25This rule requires data coming in from one of the following integrations:
 26- Auditbeat
 27- Auditd Manager
 28
 29### Auditbeat Setup
 30Auditbeat 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.
 31
 32#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 33- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 34- 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).
 35- 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).
 36- 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).
 37- 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).
 38
 39### Auditd Manager Integration Setup
 40The Auditd Manager Integration receives audit events from the Linux Audit Framework which is a part of the Linux kernel.
 41Auditd 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.
 42
 43#### The following steps should be executed in order to add the Elastic Agent System integration "auditd_manager" on a Linux System:
 44- Go to the Kibana home page and click “Add integrations”.
 45- In the query bar, search for “Auditd Manager” and select the integration to see more details about it.
 46- Click “Add Auditd Manager”.
 47- Configure the integration name and optionally add a description.
 48- Review optional and advanced settings accordingly.
 49- 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.
 50- Click “Save and Continue”.
 51- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/auditd_manager).
 52
 53#### Rule Specific Setup Note
 54Auditd Manager subscribes to the kernel and receives events as they occur without any additional configuration.
 55However, 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.
 56- For this detection rule the following additional audit rules are required to be added to the integration:
 57  -w /proc/net/ -p r -k audit_proc
 58  -w /etc/machine-id -p wa -k machineid
 59  -w /etc/passwd -p wa -k passwd
 60"""
 61severity = "medium"
 62tags = [
 63        "Data Source: Auditd Manager",
 64        "Domain: Endpoint",
 65        "OS: Linux",
 66        "Use Case: Threat Detection",
 67        "Tactic: Execution"
 68        ]
 69timestamp_override = "event.ingested"
 70type = "eql"
 71query = '''
 72sample by host.id, process.pid, user.id
 73  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/etc/machine-id"]
 74  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/etc/passwd"]
 75  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/route"]
 76  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/ipv6_route"]
 77  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/if_inet6"]
 78'''
 79
 80[[rule.threat]]
 81framework = "MITRE ATT&CK"
 82
 83[rule.threat.tactic]
 84name = "Execution"
 85id = "TA0002"
 86reference = "https://attack.mitre.org/tactics/TA0002/"
 87
 88[[rule.threat.technique]]
 89id = "T1059"
 90name = "Command and Scripting Interpreter"
 91reference = "https://attack.mitre.org/techniques/T1059/"
 92
 93[[rule.threat.technique.subtechnique]]
 94id = "T1059.004"
 95name = "Unix Shell"
 96reference = "https://attack.mitre.org/techniques/T1059/004/"
 97
 98[[rule.threat]]
 99framework = "MITRE ATT&CK"
100
101[rule.threat.tactic]
102name = "Command and Control"
103id = "TA0011"
104reference = "https://attack.mitre.org/tactics/TA0011/"
105
106[[rule.threat.technique]]
107name = "Application Layer Protocol"
108id = "T1071"
109reference = "https://attack.mitre.org/techniques/T1071/"

Related rules

to-top