Persistence via WMI Standard Registry Provider

Identifies use of the Windows Management Instrumentation StdRegProv (registry provider) to modify commonly abused registry locations for persistence.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2021/03/15"
  3integration = ["endpoint"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/03/28"
  8
  9[transform]
 10[[transform.osquery]]
 11label = "Osquery - Retrieve DNS Cache"
 12query = "SELECT * FROM dns_cache"
 13
 14[[transform.osquery]]
 15label = "Osquery - Retrieve All Services"
 16query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
 17
 18[[transform.osquery]]
 19label = "Osquery - Retrieve Services Running on User Accounts"
 20query = """
 21SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
 22NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
 23user_account == null)
 24"""
 25
 26[[transform.osquery]]
 27label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
 28query = """
 29SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
 30services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
 31authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
 32"""
 33
 34[rule]
 35author = ["Elastic"]
 36description = """
 37Identifies use of the Windows Management Instrumentation StdRegProv (registry provider) to modify commonly abused
 38registry locations for persistence.
 39"""
 40from = "now-9m"
 41index = ["logs-endpoint.events.registry-*", "endgame-*"]
 42language = "eql"
 43license = "Elastic License v2"
 44name = "Persistence via WMI Standard Registry Provider"
 45note = """## Triage and analysis
 46
 47### Investigating Persistence via WMI Standard Registry Provider
 48
 49The Windows Management Instrumentation (WMI) StdRegProv is a registry provider that allows users to manage registry keys and values on Windows systems. Adversaries may abuse this functionality to modify registry locations commonly used for persistence, enabling them to maintain unauthorized access to a system.
 50
 51This rule identifies instances where the WMI StdRegProv is used to modify specific registry paths associated with persistence mechanisms.
 52
 53> **Note**:
 54> 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.
 55
 56### Possible investigation steps
 57
 58- 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.
 59- Investigate other alerts associated with the user/host during the past 48 hours.
 60- Validate if the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
 61- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
 62- Identify which process triggered this behavior.
 63- Verify whether the file specified in the run key is signed.
 64- Examine the host for derived artifacts that indicate suspicious activities:
 65  - Examine the file specified in the run key using a private sandboxed analysis system.
 66  - Observe and collect information about the following activities in both the sandbox and the alert subject host:
 67    - Attempts to contact external domains and addresses.
 68      - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
 69      - Examine the DNS cache for suspicious or anomalous entries.
 70        - $osquery_0
 71    - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
 72    - Examine the host services for suspicious or anomalous entries.
 73      - $osquery_1
 74      - $osquery_2
 75      - $osquery_3
 76  - 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.
 77
 78### False positive analysis
 79
 80- This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
 81
 82### Response and Remediation
 83
 84- Initiate the incident response process based on the outcome of the triage.
 85- Isolate the involved host to prevent further post-compromise behavior.
 86- If the triage identified malware, search the environment for additional compromised hosts.
 87  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 88  - Stop suspicious processes.
 89  - Immediately block the identified indicators of compromise (IoCs).
 90  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
 91- Remove and block malicious artifacts identified during triage.
 92- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 93- 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.
 94- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 95- 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).
 96"""
 97references = [
 98    "https://docs.microsoft.com/en-us/previous-versions/windows/desktop/regprov/stdregprov",
 99    "https://www.elastic.co/security-labs/hunting-for-persistence-using-elastic-security-part-1",
100]
101risk_score = 73
102rule_id = "70d12c9c-0dbd-4a1a-bc44-1467502c9cf6"
103severity = "high"
104tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Persistence", "Data Source: Elastic Endgame", "Data Source: Elastic Defend"]
105timestamp_override = "event.ingested"
106type = "eql"
107
108query = '''
109registry where host.os.type == "windows" and
110 registry.data.strings != null and process.name : "WmiPrvSe.exe" and
111 registry.path : (
112                  "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Command Processor\\Autorun",
113                  "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
114                  "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
115                  "HKLM\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
116                  "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
117                  "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
118                  "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
119                  "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
120                  "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
121                  "HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
122                  "HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\ServiceDLL",
123                  "HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\ImagePath",
124                  "HKEY_USERS\\*\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell\\*",
125                  "HKEY_USERS\\*\\Environment\\UserInitMprLogonScript",
126                  "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Load",
127                  "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell",
128                  "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\Shell",
129                  "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logoff\\Script",
130                  "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logon\\Script",
131                  "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Shutdown\\Script",
132                  "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Startup\\Script",
133                  "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Ctf\\LangBarAddin\\*\\FilePath",
134                  "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\*\\Exec",
135                  "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\*\\Script",
136                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Microsoft\\Command Processor\\Autorun",
137                  "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
138                  "\\REGISTRY\\MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
139                  "\\REGISTRY\\MACHINE\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
140                  "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
141                  "\\REGISTRY\\MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
142                  "\\REGISTRY\\MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
143                  "\\REGISTRY\\MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
144                  "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
145                  "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
146                  "\\REGISTRY\\MACHINE\\SYSTEM\\*ControlSet*\\Services\\*\\ServiceDLL",
147                  "\\REGISTRY\\MACHINE\\SYSTEM\\*ControlSet*\\Services\\*\\ImagePath",
148                  "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell\\*",
149                  "\\REGISTRY\\USER\\*\\Environment\\UserInitMprLogonScript",
150                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Load",
151                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell",
152                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\Shell",
153                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logoff\\Script",
154                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logon\\Script",
155                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Shutdown\\Script",
156                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Startup\\Script",
157                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Microsoft\\Ctf\\LangBarAddin\\*\\FilePath",
158                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\*\\Exec",
159                  "\\REGISTRY\\USER\\*\\SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\*\\Script"
160                  )
161'''
162
163
164[[rule.threat]]
165framework = "MITRE ATT&CK"
166[[rule.threat.technique]]
167id = "T1543"
168name = "Create or Modify System Process"
169reference = "https://attack.mitre.org/techniques/T1543/"
170[[rule.threat.technique.subtechnique]]
171id = "T1543.003"
172name = "Windows Service"
173reference = "https://attack.mitre.org/techniques/T1543/003/"
174
175
176[[rule.threat.technique]]
177id = "T1547"
178name = "Boot or Logon Autostart Execution"
179reference = "https://attack.mitre.org/techniques/T1547/"
180[[rule.threat.technique.subtechnique]]
181id = "T1547.001"
182name = "Registry Run Keys / Startup Folder"
183reference = "https://attack.mitre.org/techniques/T1547/001/"
184
185
186
187[rule.threat.tactic]
188id = "TA0003"
189name = "Persistence"
190reference = "https://attack.mitre.org/tactics/TA0003/"
191[[rule.threat]]
192framework = "MITRE ATT&CK"
193[[rule.threat.technique]]
194id = "T1047"
195name = "Windows Management Instrumentation"
196reference = "https://attack.mitre.org/techniques/T1047/"
197
198
199[rule.threat.tactic]
200id = "TA0002"
201name = "Execution"
202reference = "https://attack.mitre.org/tactics/TA0002/"

Triage and analysis

Investigating Persistence via WMI Standard Registry Provider

The Windows Management Instrumentation (WMI) StdRegProv is a registry provider that allows users to manage registry keys and values on Windows systems. Adversaries may abuse this functionality to modify registry locations commonly used for persistence, enabling them to maintain unauthorized access to a system.

This rule identifies instances where the WMI StdRegProv is used to modify specific registry paths associated with persistence mechanisms.

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

  • 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.
  • Validate if the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
  • Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
  • Identify which process triggered this behavior.
  • Verify whether the file specified in the run key is signed.
  • Examine the host for derived artifacts that indicate suspicious activities:
    • Examine the file specified in the run key using a private sandboxed analysis system.
    • Observe and collect information about the following activities in both the sandbox and 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 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
    • 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.

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).

References

Related rules

to-top