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