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"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2023/11/02"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12This detection rule identifies suspicious network traffic patterns associated with TCP reverse shell activity. This
 13activity consists of a network event that is followed by the creation of a shell process with suspicious command line
 14arguments. An attacker may establish a Linux TCP reverse shell to gain remote access to a target system.
 15"""
 16from = "now-9m"
 17index = ["logs-endpoint.events.*"]
 18language = "eql"
 19license = "Elastic License v2"
 20name = "Potential Reverse Shell via Child"
 21references = [
 22    "https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md"
 23]
 24risk_score = 47
 25rule_id = "2138bb70-5a5e-42fd-be5e-b38edf6a6777"
 26setup = """
 27
 28This rule requires data coming in from Elastic Defend.
 29
 30### Elastic Defend Integration Setup
 31Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows
 32the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 33
 34#### Prerequisite Requirements:
 35- Fleet is required for Elastic Defend.
 36- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 37
 38#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 39- Go to the Kibana home page and click Add integrations.
 40- In the query bar, search for Elastic Defend and select the integration to see more details about it.
 41- Click Add Elastic Defend.
 42- Configure the integration name and optionally add a description.
 43- Select the type of environment you want to protect, either Traditional Endpoints or Cloud Workloads.
 44- 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).
 45- We suggest to select "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 46- 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.
 47For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 48- Click Save and Continue.
 49- 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.
 50For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 51
 52"""
 53severity = "medium"
 54tags = [
 55        "Domain: Endpoint",
 56        "OS: Linux",
 57        "Use Case: Threat Detection",
 58        "Tactic: Execution",
 59        "Data Source: Elastic Defend"
 60        ]
 61type = "eql"
 62query = '''
 63sequence by host.id, process.entity_id with maxspan=5s
 64  [network where event.type == "start" and 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 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[[rule.threat]]
 74framework = "MITRE ATT&CK"
 75
 76[rule.threat.tactic]
 77name = "Execution"
 78id = "TA0002"
 79reference = "https://attack.mitre.org/tactics/TA0002/"
 80
 81[[rule.threat.technique]]
 82id = "T1059"
 83name = "Command and Scripting Interpreter"
 84reference = "https://attack.mitre.org/techniques/T1059/"
 85
 86[[rule.threat.technique.subtechnique]]
 87id = "T1059.004"
 88name = "Unix Shell"
 89reference = "https://attack.mitre.org/techniques/T1059/004/"
 90
 91[[rule.threat]]
 92framework = "MITRE ATT&CK"
 93
 94[rule.threat.tactic]
 95name = "Command and Control"
 96id = "TA0011"
 97reference = "https://attack.mitre.org/tactics/TA0011/"
 98
 99[[rule.threat.technique]]
100name = "Application Layer Protocol"
101id = "T1071"
102reference = "https://attack.mitre.org/techniques/T1071/"

References

Related rules

to-top