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