Potential Reverse Shell via Child

This detection rule identifies suspicious network traffic patterns associated with TCP reverse shell activity. This activity consists of a network event that is followed by the creation of a shell process with suspicious command line arguments. An attacker may establish a Linux TCP reverse shell to gain remote access to a target system.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/11/02"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/05/21"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This detection rule identifies suspicious network traffic patterns associated with TCP reverse shell activity. This
 11activity consists of a network event that is followed by the creation of a shell process with suspicious command line
 12arguments. An attacker may establish a Linux TCP reverse shell to gain remote access to a target system.
 13"""
 14from = "now-9m"
 15index = ["logs-endpoint.events.*"]
 16language = "eql"
 17license = "Elastic License v2"
 18name = "Potential Reverse Shell via Child"
 19references = [
 20    "https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md",
 21]
 22risk_score = 47
 23rule_id = "2138bb70-5a5e-42fd-be5e-b38edf6a6777"
 24setup = """## Setup
 25
 26
 27This rule requires data coming in from Elastic Defend.
 28
 29### Elastic Defend Integration Setup
 30Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows
 31the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 32
 33#### Prerequisite Requirements:
 34- Fleet is required for Elastic Defend.
 35- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 36
 37#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 38- Go to the Kibana home page and click Add integrations.
 39- In the query bar, search for Elastic Defend and select the integration to see more details about it.
 40- Click Add Elastic Defend.
 41- Configure the integration name and optionally add a description.
 42- Select the type of environment you want to protect, either Traditional Endpoints or Cloud Workloads.
 43- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 44- We suggest to select "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 45- Enter a name for the agent policy in New agent policy name. If other agent policies already exist, you can click the Existing hosts tab and select an existing policy instead.
 46For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 47- Click Save and Continue.
 48- To complete the integration, select Add Elastic Agent to your hosts and continue to the next section to install the Elastic Agent on your hosts.
 49For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 50"""
 51severity = "medium"
 52tags = [
 53    "Domain: Endpoint",
 54    "OS: Linux",
 55    "Use Case: Threat Detection",
 56    "Tactic: Execution",
 57    "Data Source: Elastic Defend",
 58]
 59type = "eql"
 60
 61query = '''
 62sequence by host.id, process.entity_id with maxspan=5s
 63  [network where event.type == "start" and host.os.type == "linux" and
 64     event.action in ("connection_attempted", "connection_accepted") and
 65     process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat") and destination.ip != null and
 66     not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")]
 67  [process where event.type == "start" and host.os.type == "linux" and event.action == "exec" and
 68     process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and (
 69       (process.args : ("-i", "-l")) or (process.parent.name == "socat" and process.parent.args : "*exec*")
 70   )]
 71'''
 72
 73
 74[[rule.threat]]
 75framework = "MITRE ATT&CK"
 76[[rule.threat.technique]]
 77id = "T1059"
 78name = "Command and Scripting Interpreter"
 79reference = "https://attack.mitre.org/techniques/T1059/"
 80[[rule.threat.technique.subtechnique]]
 81id = "T1059.004"
 82name = "Unix Shell"
 83reference = "https://attack.mitre.org/techniques/T1059/004/"
 84
 85
 86
 87[rule.threat.tactic]
 88id = "TA0002"
 89name = "Execution"
 90reference = "https://attack.mitre.org/tactics/TA0002/"
 91[[rule.threat]]
 92framework = "MITRE ATT&CK"
 93[[rule.threat.technique]]
 94id = "T1071"
 95name = "Application Layer Protocol"
 96reference = "https://attack.mitre.org/techniques/T1071/"
 97
 98
 99[rule.threat.tactic]
100id = "TA0011"
101name = "Command and Control"
102reference = "https://attack.mitre.org/tactics/TA0011/"

References

Related rules

to-top