Potential Reverse Shell

This detection rule identifies suspicious network traffic patterns associated with TCP reverse shell activity. This activity consists of a parent-child relationship where a network event is followed by the creation of a shell process. 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/07/04"
  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 parent-child relationship where a network event is followed by the creation of a shell process.
 14An 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"
 21references = [
 22    "https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md"
 23]
 24risk_score = 47
 25rule_id = "48b3d2e3-f4e8-41e6-95e6-9b2091228db3"
 26setup = """## Setup
 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 the 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 selecting "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"
 60query = '''
 61sequence by host.id with maxspan=5s
 62  [network where event.type == "start" and event.action in ("connection_attempted", "connection_accepted") and 
 63   process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat") and destination.ip != null and 
 64   not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")] by process.entity_id
 65  [process where event.type == "start" and event.action in ("exec", "fork") and 
 66   process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and (
 67     (process.args : ("-i", "-l")) or (process.parent.name == "socat" and process.parent.args : "*exec*")
 68   )] by process.parent.entity_id
 69'''
 70
 71[[rule.threat]]
 72framework = "MITRE ATT&CK"
 73
 74[rule.threat.tactic]
 75name = "Execution"
 76id = "TA0002"
 77reference = "https://attack.mitre.org/tactics/TA0002/"
 78
 79[[rule.threat.technique]]
 80id = "T1059"
 81name = "Command and Scripting Interpreter"
 82reference = "https://attack.mitre.org/techniques/T1059/"
 83
 84[[rule.threat.technique.subtechnique]]
 85id = "T1059.004"
 86name = "Unix Shell"
 87reference = "https://attack.mitre.org/techniques/T1059/004/"
 88
 89[[rule.threat]]
 90framework = "MITRE ATT&CK"
 91
 92[rule.threat.tactic]
 93name = "Command and Control"
 94id = "TA0011"
 95reference = "https://attack.mitre.org/tactics/TA0011/"
 96
 97[[rule.threat.technique]]
 98name = "Application Layer Protocol"
 99id = "T1071"
100reference = "https://attack.mitre.org/techniques/T1071/"

References

Related rules

to-top