Adding Hidden File Attribute via Attrib
Adversaries can add the 'hidden' attribute to files to hide them from the user in an attempt to evade detection.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/02/18"
3integration = ["endpoint", "windows", "system"]
4maturity = "production"
5updated_date = "2024/08/07"
6
7[transform]
8[[transform.osquery]]
9label = "Osquery - Retrieve DNS Cache"
10query = "SELECT * FROM dns_cache"
11
12[[transform.osquery]]
13label = "Osquery - Retrieve All Services"
14query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
15
16[[transform.osquery]]
17label = "Osquery - Retrieve Services Running on User Accounts"
18query = """
19SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
20NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
21user_account == null)
22"""
23
24[[transform.osquery]]
25label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
26query = """
27SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
28services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
29authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
30"""
31
32
33[rule]
34author = ["Elastic"]
35description = "Adversaries can add the 'hidden' attribute to files to hide them from the user in an attempt to evade detection."
36from = "now-9m"
37index = [
38 "winlogbeat-*",
39 "logs-endpoint.events.process-*",
40 "logs-windows.*",
41 "endgame-*",
42 "logs-system.security*",
43]
44language = "eql"
45license = "Elastic License v2"
46name = "Adding Hidden File Attribute via Attrib"
47note = """## Triage and analysis
48
49### Investigating Adding Hidden File Attribute via Attrib
50
51The `Hidden` attribute is a file or folder attribute that makes the file or folder invisible to regular directory listings when the attribute is set.
52
53Attackers can use this attribute to conceal tooling and malware to prevent administrators and users from finding it, even if they are looking specifically for it.
54
55This rule looks for the execution of the `attrib.exe` utility with a command line that indicates the modification of the `Hidden` attribute.
56
57> **Note**:
58> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
59
60#### Possible investigation steps
61
62- Identify the user account that performed the action and whether it should perform this kind of action.
63- Contact the account owner and confirm whether they are aware of this activity.
64- 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.
65- Investigate other alerts associated with the user/host during the past 48 hours.
66- Examine the command line to identify the target file or folder.
67 - Examine the file, which process created it, header, etc.
68 - If suspicious, retrieve the files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
69- Examine the host for derived artifacts that indicate suspicious activities:
70 - Observe and collect information about the following activities in the alert subject host:
71 - Attempts to contact external domains and addresses.
72 - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
73 - Examine the DNS cache for suspicious or anomalous entries.
74 - $osquery_0
75 - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
76 - Examine the host services for suspicious or anomalous entries.
77 - $osquery_1
78 - $osquery_2
79 - $osquery_3
80
81### False positive analysis
82
83- This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
84
85### Response and remediation
86
87- Initiate the incident response process based on the outcome of the triage.
88- Isolate the involved host to prevent further post-compromise behavior.
89- If the triage identified malware, search the environment for additional compromised hosts.
90 - Implement temporary network rules, procedures, and segmentation to contain the malware.
91 - Stop suspicious processes.
92 - Immediately block the identified indicators of compromise (IoCs).
93 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
94- Remove and block malicious artifacts identified during triage.
95- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
96- 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.
97- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
98- 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).
99"""
100risk_score = 21
101rule_id = "4630d948-40d4-4cef-ac69-4002e29bc3db"
102severity = "low"
103tags = [
104 "Domain: Endpoint",
105 "OS: Windows",
106 "Use Case: Threat Detection",
107 "Tactic: Defense Evasion",
108 "Tactic: Persistence",
109 "Data Source: Elastic Endgame",
110 "Resources: Investigation Guide",
111 "Data Source: Elastic Defend",
112 "Data Source: System",
113]
114timeline_id = "e70679c2-6cde-4510-9764-4823df18f7db"
115timeline_title = "Comprehensive Process Timeline"
116timestamp_override = "event.ingested"
117type = "eql"
118
119query = '''
120process where host.os.type == "windows" and event.type == "start" and
121 (process.name : "attrib.exe" or ?process.pe.original_file_name == "ATTRIB.EXE") and process.args : "+h" and
122 not (process.parent.name: "cmd.exe" and process.command_line: "attrib +R +H +S +A *.cui")
123'''
124
125
126[[rule.threat]]
127framework = "MITRE ATT&CK"
128[[rule.threat.technique]]
129id = "T1222"
130name = "File and Directory Permissions Modification"
131reference = "https://attack.mitre.org/techniques/T1222/"
132[[rule.threat.technique.subtechnique]]
133id = "T1222.001"
134name = "Windows File and Directory Permissions Modification"
135reference = "https://attack.mitre.org/techniques/T1222/001/"
136
137
138[[rule.threat.technique]]
139id = "T1564"
140name = "Hide Artifacts"
141reference = "https://attack.mitre.org/techniques/T1564/"
142[[rule.threat.technique.subtechnique]]
143id = "T1564.001"
144name = "Hidden Files and Directories"
145reference = "https://attack.mitre.org/techniques/T1564/001/"
146
147
148
149[rule.threat.tactic]
150id = "TA0005"
151name = "Defense Evasion"
152reference = "https://attack.mitre.org/tactics/TA0005/"
153[[rule.threat]]
154framework = "MITRE ATT&CK"
155
156[rule.threat.tactic]
157id = "TA0003"
158name = "Persistence"
159reference = "https://attack.mitre.org/tactics/TA0003/"
Triage and analysis
Investigating Adding Hidden File Attribute via Attrib
The Hidden
attribute is a file or folder attribute that makes the file or folder invisible to regular directory listings when the attribute is set.
Attackers can use this attribute to conceal tooling and malware to prevent administrators and users from finding it, even if they are looking specifically for it.
This rule looks for the execution of the attrib.exe
utility with a command line that indicates the modification of the Hidden
attribute.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
Possible investigation steps
- Identify the user account that performed the action and whether it should perform this kind of action.
- Contact the account owner and confirm whether they are aware of this activity.
- 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.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Examine the command line to identify the target file or folder.
- Examine the file, which process created it, header, etc.
- If suspicious, retrieve the files' SHA-256 hash values using the PowerShell
Get-FileHash
cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
- Examine the host for derived artifacts that indicate suspicious activities:
- Observe and collect information about the following activities in the alert subject host:
- Attempts to contact external domains and addresses.
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
process.entity_id
. - Examine the DNS cache for suspicious or anomalous entries.
- $osquery_0
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
- Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
- Examine the host services for suspicious or anomalous entries.
- $osquery_1
- $osquery_2
- $osquery_3
- Attempts to contact external domains and addresses.
- Observe and collect information about the following activities in the alert subject host:
False positive analysis
- This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- 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.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through 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
- Bypass UAC via Event Viewer
- Clearing Windows Console History
- Code Signing Policy Modification Through Built-in tools
- Delete Volume USN Journal with Fsutil
- Disable Windows Event and Security Logs Using Built-in Tools