File and Directory Discovery

Enumeration of files and directories using built-in tools. Adversaries may use the information discovered to plan follow-on activity.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2020/12/04"
 3deprecation_date = "2022/08/02"
 4maturity = "deprecated"
 5updated_date = "2022/08/02"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10Enumeration of files and directories using built-in tools. Adversaries may use the information discovered to plan
11follow-on activity.
12"""
13false_positives = [
14    """
15    Enumeration of files and directories may not be inherently malicious and noise may come from scripts, automation
16    tools, or normal command line usage. It's important to baseline your environment to determine the amount of expected
17    noise and exclude any known FP's from the rule.
18    """,
19]
20from = "now-9m"
21index = ["logs-endpoint.events.*", "winlogbeat-*", "logs-windows.*"]
22language = "eql"
23license = "Elastic License v2"
24name = "File and Directory Discovery"
25note = """## Triage and analysis
26
27### Investigating File and Directory Discovery
28
29After successfully compromising an environment, attackers may try to gain situational awareness to plan their next steps.
30This can happen by running commands to enumerate network resources, users, connections, files, and installed security
31software.
32
33This rule looks for three directory-listing commands in one minute, which can indicate attempts to locate valuable files,
34specific file types or installed programs.
35
36#### Possible investigation steps
37
38- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files
39for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
40- Identify the user account that performed the action and whether it should perform this kind of action.
41- Investigate other alerts associated with the user/host during the past 48 hours.
42- Investigate abnormal behaviors observed using the account, such as commands executed, files created or modified, and
43network connections.
44
45### False positive analysis
46
47- Discovery activities are not inherently malicious if they occur in isolation. As long as the analyst did not identify
48suspicious activity related to the user or host, such alerts can be dismissed.
49
50### Response and remediation
51
52- Initiate the incident response process based on the outcome of the triage.
53- Isolate the involved hosts to prevent further post-compromise behavior.
54- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are
55identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business
56systems, and web services.
57- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and
58malware components.
59- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
60- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the
61mean time to respond (MTTR).
62"""
63risk_score = 21
64rule_id = "7b08314d-47a0-4b71-ae4e-16544176924f"
65severity = "low"
66tags = ["Elastic", "Host", "Windows", "Threat Detection", "Discovery"]
67type = "eql"
68
69query = '''
70sequence by agent.id, user.name with maxspan=1m
71[process where event.type in ("start", "process_started") and
72  ((process.name : "cmd.exe" or process.pe.original_file_name == "Cmd.Exe") and process.args : "dir") or
73    process.name : "tree.com"]
74[process where event.type in ("start", "process_started") and
75  ((process.name : "cmd.exe" or process.pe.original_file_name == "Cmd.Exe") and process.args : "dir") or
76    process.name : "tree.com"]
77[process where event.type in ("start", "process_started") and
78  ((process.name : "cmd.exe" or process.pe.original_file_name == "Cmd.Exe") and process.args : "dir") or
79    process.name : "tree.com"]
80'''
81
82
83[[rule.threat]]
84framework = "MITRE ATT&CK"
85[[rule.threat.technique]]
86id = "T1083"
87name = "File and Directory Discovery"
88reference = "https://attack.mitre.org/techniques/T1083/"
89
90
91[rule.threat.tactic]
92id = "TA0007"
93name = "Discovery"
94reference = "https://attack.mitre.org/tactics/TA0007/"

Triage and analysis

Investigating File and Directory Discovery

After successfully compromising an environment, attackers may try to gain situational awareness to plan their next steps. This can happen by running commands to enumerate network resources, users, connections, files, and installed security software.

This rule looks for three directory-listing commands in one minute, which can indicate attempts to locate valuable files, specific file types or installed programs.

Possible investigation steps

  • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
  • Identify the user account that performed the action and whether it should perform this kind of action.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Investigate abnormal behaviors observed using the account, such as commands executed, files created or modified, and network connections.

False positive analysis

  • Discovery activities are not inherently malicious if they occur in isolation. As long as the analyst did not identify suspicious activity related to the user or host, such alerts can be dismissed.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved hosts to prevent further post-compromise behavior.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

Related rules

to-top