Potential Reverse Shell via UDP

This detection rule identifies suspicious network traffic patterns associated with UDP reverse shell activity. This activity consists of a sample of an execve, socket and connect syscall executed by the same process, where the auditd.data.a0-1 indicate a UDP connection, ending with an egress connection event. An attacker may establish a Linux UDP reverse shell to bypass traditional firewall restrictions and gain remote access to a target system covertly.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/07/04"
  3integration = ["auditd_manager"]
  4maturity = "production"
  5updated_date = "2024/09/23"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This detection rule identifies suspicious network traffic patterns associated with UDP reverse shell activity. This
 11activity consists of a sample of an execve, socket and connect syscall executed by the same process, where the
 12auditd.data.a0-1 indicate a UDP connection, ending with an egress connection event. An attacker may establish a Linux
 13UDP reverse shell to bypass traditional firewall restrictions and gain remote access to a target system covertly.
 14"""
 15from = "now-9m"
 16index = ["auditbeat-*", "logs-auditd_manager.auditd-*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Potential Reverse Shell via UDP"
 20references = [
 21    "https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md",
 22    "https://www.elastic.co/security-labs/primer-on-persistence-mechanisms",
 23    "https://www.elastic.co/security-labs/linux-detection-engineering-with-auditd",
 24]
 25risk_score = 47
 26rule_id = "a5eb21b7-13cc-4b94-9fe2-29bb2914e037"
 27setup = """## Setup
 28
 29This rule requires data coming in from one of the following integrations:
 30- Auditbeat
 31- Auditd Manager
 32
 33### Auditbeat Setup
 34Auditbeat 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.
 35
 36#### The following steps should be executed in order to add the Auditbeat on a 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/auditbeat/current/setup-repositories.html).
 39- 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).
 40- 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).
 41- 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).
 42
 43### Auditd Manager Integration Setup
 44The Auditd Manager Integration receives audit events from the Linux Audit Framework which is a part of the Linux kernel.
 45Auditd 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.
 46
 47#### The following steps should be executed in order to add the Elastic Agent System integration "auditd_manager" on a Linux System:
 48- Go to the Kibana home page and click “Add integrations”.
 49- In the query bar, search for “Auditd Manager” and select the integration to see more details about it.
 50- Click “Add Auditd Manager”.
 51- Configure the integration name and optionally add a description.
 52- Review optional and advanced settings accordingly.
 53- 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.
 54- Click “Save and Continue”.
 55- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/auditd_manager).
 56
 57#### Rule Specific Setup Note
 58Auditd Manager subscribes to the kernel and receives events as they occur without any additional configuration.
 59However, 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.
 60- For this detection rule no additional audit rules are required to be added to the integration.
 61"""
 62severity = "medium"
 63tags = [
 64    "Data Source: Auditd Manager",
 65    "Domain: Endpoint",
 66    "OS: Linux",
 67    "Use Case: Threat Detection",
 68    "Tactic: Execution",
 69]
 70timestamp_override = "event.ingested"
 71type = "eql"
 72
 73query = '''
 74sample by host.id, process.pid, process.parent.pid
 75  [process where host.os.type == "linux" and event.type == "start" and event.action == "executed" and process.name : (
 76    "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "perl", "python*", "nc", "ncat", "netcat", "php*",
 77    "ruby", "openssl", "awk", "telnet", "lua*", "socat"
 78    )]
 79  [process where host.os.type == "linux" and auditd.data.syscall == "socket" and process.name : (
 80    "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "perl", "python*", "nc", "ncat", "netcat", "php*",
 81    "ruby", "openssl", "awk", "telnet", "lua*", "socat"
 82    ) and auditd.data.a1 == "2"]
 83  [network where host.os.type == "linux" and event.type == "start" and event.action == "connected-to" and
 84   process.name : (
 85    "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "perl", "python*", "nc", "ncat", "netcat", "php*",
 86    "ruby", "openssl", "awk", "telnet", "lua*", "socat"
 87    ) and network.direction == "egress" and destination.ip != null and
 88   not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")]
 89'''
 90
 91
 92[[rule.threat]]
 93framework = "MITRE ATT&CK"
 94[[rule.threat.technique]]
 95id = "T1059"
 96name = "Command and Scripting Interpreter"
 97reference = "https://attack.mitre.org/techniques/T1059/"
 98[[rule.threat.technique.subtechnique]]
 99id = "T1059.004"
100name = "Unix Shell"
101reference = "https://attack.mitre.org/techniques/T1059/004/"
102
103
104
105[rule.threat.tactic]
106id = "TA0002"
107name = "Execution"
108reference = "https://attack.mitre.org/tactics/TA0002/"
109[[rule.threat]]
110framework = "MITRE ATT&CK"
111[[rule.threat.technique]]
112id = "T1071"
113name = "Application Layer Protocol"
114reference = "https://attack.mitre.org/techniques/T1071/"
115
116
117[rule.threat.tactic]
118id = "TA0011"
119name = "Command and Control"
120reference = "https://attack.mitre.org/tactics/TA0011/"

References

Related rules

to-top