Creation of Hidden Files and Directories via CommandLine

Users can mark specific files as hidden simply by putting a "." as the first character in the file or folder name. Adversaries can use this to their advantage to hide files and folders on the system for persistence and defense evasion. This rule looks for hidden files or folders in common writable directories.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/04/29"
  3integration = ["endpoint"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/02/20"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Users can mark specific files as hidden simply by putting a "." as the first character in the file or folder name.
 13Adversaries can use this to their advantage to hide files and folders on the system for persistence and defense evasion.
 14This rule looks for hidden files or folders in common writable directories.
 15"""
 16false_positives = [
 17    """
 18    Certain tools may create hidden temporary files or directories upon installation or as part of their normal
 19    behavior. These events can be filtered by the process arguments, username, or process name values.
 20    """,
 21]
 22from = "now-9m"
 23index = ["logs-endpoint.events.*"]
 24language = "eql"
 25license = "Elastic License v2"
 26max_signals = 33
 27name = "Creation of Hidden Files and Directories via CommandLine"
 28risk_score = 47
 29rule_id = "b9666521-4742-49ce-9ddc-b8e84c35acae"
 30setup = """
 31
 32This rule requires data coming in from one of the following integrations:
 33- Elastic Defend
 34- Auditbeat
 35
 36### Elastic Defend Integration Setup
 37Elastic 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.
 38
 39#### Prerequisite Requirements:
 40- Fleet is required for Elastic Defend.
 41- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 42
 43#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 44- Go to the Kibana home page and click "Add integrations".
 45- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 46- Click "Add Elastic Defend".
 47- Configure the integration name and optionally add a description.
 48- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 49- 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).
 50- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 51- 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.
 52For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 53- Click "Save and Continue".
 54- 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.
 55For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 56
 57### Auditbeat Setup
 58Auditbeat 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.
 59
 60#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 61- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 62- 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).
 63- 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).
 64- 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).
 65- 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).
 66
 67#### Custom Ingest Pipeline
 68For versions <8.2, you need to add a custom ingest pipeline to populate `event.ingested` with @timestamp for non-elastic-agent indexes, like auditbeats/filebeat/winlogbeat etc. For more details to add a custom ingest pipeline refer to the [guide](https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html).
 69
 70"""
 71severity = "medium"
 72tags = [
 73        "Domain: Endpoint",
 74        "OS: Linux",
 75        "Use Case: Threat Detection",
 76        "Tactic: Defense Evasion",
 77        "Data Source: Elastic Defend"
 78        ]
 79timestamp_override = "event.ingested"
 80type = "eql"
 81
 82query = '''
 83process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
 84process.working_directory in ("/tmp", "/var/tmp", "/dev/shm") and
 85process.args regex~ """\.[a-z0-9_\-][a-z0-9_\-\.]{1,254}""" and
 86not process.name in ("ls", "find", "grep", "git", "jq", "basename")
 87'''
 88
 89[[rule.threat]]
 90framework = "MITRE ATT&CK"
 91
 92[[rule.threat.technique]]
 93id = "T1564"
 94name = "Hide Artifacts"
 95reference = "https://attack.mitre.org/techniques/T1564/"
 96
 97[[rule.threat.technique.subtechnique]]
 98id = "T1564.001"
 99name = "Hidden Files and Directories"
100reference = "https://attack.mitre.org/techniques/T1564/001/"
101
102[rule.threat.tactic]
103id = "TA0005"
104name = "Defense Evasion"
105reference = "https://attack.mitre.org/tactics/TA0005/"
106
107[[rule.threat]]
108framework = "MITRE ATT&CK"
109
110[rule.threat.tactic]
111id = "TA0003"
112name = "Persistence"
113reference = "https://attack.mitre.org/tactics/TA0003/"

Related rules

to-top