Detection rules › YARA-L
YARA-L rules: 2q
| Rule | Severity |
|---|---|
| MITRE ATT&CK T1003.003 WMIC Ntds.dit CISA Report | high |
| O365 Entra ID Application Creation | low |
| sap multiple password changes | medium |
MITRE ATT&CK T1003.003 WMIC Ntds.dit CISA Report
#Detects extraction of ntds.dit file using vssadmin.exe or ntdsutil.exe with wmic as identified in CISA Living off the Land pdf
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Credential Access |
References
Telemetry Coverage
Rule Body
// Copyright 2023 Google LLC. Licensed under Apache-2.0.
rule wmic_ntds_dit_T1003_003_cisa_report {
meta:
author = "Google Cloud Security"
description = "Detects extraction of ntds.dit file using vssadmin.exe or ntdsutil.exe with wmic as identified in CISA Living off the Land pdf"
rule_id = "mr_b1719d37-6689-485d-b80c-b509fdaa1af8"
rule_name = "MITRE ATT&CK T1003.003 WMIC Ntds.dit CISA Report"
type = "alert"
platform = "Windows"
data_source = "microsoft sysmon, windows event logs"
tactic = "TA0006"
technique = "T1003.003"
reference = "https://media.defense.gov/2023/May/24/2003229517/-1/-1/0/CSA_Living_off_the_Land.PDF"
severity = "High"
priority = "High"
events:
(
$process.metadata.event_type = "PROCESS_LAUNCH" and
(
// cisa report referenced cmd /c in their report throughout, can filter this in/out for tuning as needed
// other wmic switches like /user and /password, these have been excluded to focus on the commands being issued since local access does not require these
re.regex($process.target.process.command_line, `(|cmd.*/c).*wmic.*process.*call.*create.*ntdsutil.*create.*full`) nocase or
// for greater precision to align with the report, the following line can be used instead of the previous line to focus on specific folders referenced
//re.regex($process.target.process.command_line, `(|cmd.*/c).*wmic.*process.*call.*create.*ntdsutil.*create.*full.*windows\\temp\\(tmp|pro|msafee_logs)`) nocase or
re.regex($process.target.process.command_line, `(|cmd.*/c).*vssadmin.*create.*shadow`) nocase or
// To detect this without wmic being used but written to c:\windows\temp\ in general
re.regex($process.target.process.command_line, `(|cmd.*/c).*ntdsutil.*create.*full.*windows\\temp\\`) nocase
)
)
or
(
// This does not detect one of the utilities responsible for executing ntdsutil or vssadmin, but does detect .dit file being created in monitored folders
$process.metadata.event_type = "FILE_CREATION" and
re.regex($process.target.file.full_path, `\.dit$`) nocase
)
or
(
//Identify application event log actions associated with the creation of the ntds.dit file and with ntds database
$process.metadata.product_name = "ESENT" and
$process.metadata.vendor_name = "Microsoft" and
(
$process.metadata.product_event_type = "216" or
$process.metadata.product_event_type = "325" or
$process.metadata.product_event_type = "326" or
$process.metadata.product_event_type = "327"
)
)
$process.principal.hostname = $hostname
match:
$hostname over 5m
outcome:
$risk_score = 85
$event_count = count_distinct($process.metadata.id)
// added to populate alert graph with additional context
// Commented out principal.hostname because it is already represented in graph as match variable. If match changes, can uncomment to add to results
//$principal_hostname = array_distinct($process.principal.hostname)
$principal_process_pid = array_distinct($process.principal.process.pid)
$principal_process_command_line = array_distinct($process.principal.process.command_line)
$principal_process_file_sha256 = array_distinct($process.principal.process.file.sha256)
$principal_process_file_full_path = array_distinct($process.principal.process.file.full_path)
$principal_process_product_specific_process_id = array_distinct($process.principal.process.product_specific_process_id)
$principal_process_parent_process_product_specific_process_id = array_distinct($process.principal.process.parent_process.product_specific_process_id)
$target_process_pid = array_distinct($process.target.process.pid)
$target_process_command_line = array_distinct($process.target.process.command_line)
$target_process_file_sha256 = array_distinct($process.target.process.file.sha256)
$target_process_file_full_path = array_distinct($process.target.process.file.full_path)
$target_process_product_specific_process_id = array_distinct($process.target.process.product_specific_process_id)
$principal_user_userid = array_distinct($process.principal.user.userid)
condition:
$process
}
YARA-L Rule Structure
Condition
Fires when at least one $process event in the 5m window.
Events
$process
target.process.command_line matches "(|cmd.*/c).*wmic.*process.*call.*create.*ntdsutil.*create.*full"target.process.command_line matches "(|cmd.*/c).*vssadmin.*create.*shadow"target.process.command_line matches "(|cmd.*/c).*ntdsutil.*create.*full.*windows\\temp\\"target.file.full_path matches "\.dit$"metadata.product_event_typeis one of:216325326327
Match and Correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | 85 |
event_count | count_distinct($process.metadata.id) |
principal_process_pid | array_distinct($process.principal.process.pid) |
principal_process_command_line | array_distinct($process.principal.process.command_line) |
principal_process_file_sha256 | array_distinct($process.principal.process.file.sha256) |
principal_process_file_full_path | array_distinct($process.principal.process.file.full_path) |
principal_process_product_specific_process_id | array_distinct($process.principal.process.product_specific_process_id) |
principal_process_parent_process_product_specific_process_id | array_distinct($process.principal.process.parent_process.product_specific_process_id) |
target_process_pid | array_distinct($process.target.process.pid) |
target_process_command_line | array_distinct($process.target.process.command_line) |
target_process_file_sha256 | array_distinct($process.target.process.file.sha256) |
target_process_file_full_path | array_distinct($process.target.process.file.full_path) |
target_process_product_specific_process_id | array_distinct($process.target.process.product_specific_process_id) |
principal_user_userid | array_distinct($process.principal.user.userid) |
O365 Entra ID Application Creation
#Application creation is a legitimate activity but doesn't occur frequently. Alerts when a new application is created in Entra ID (formerly Azure AD).
Telemetry Coverage
| Platform | Record / event type |
|---|---|
| Microsoft 365 | Add application. |
Rules Detecting the Same Action
These rules filter on the same operation.
Rule Body
// Copyright 2023 Google LLC. Licensed under Apache-2.0.
rule o365_entra_id_application_creation {
meta:
author = "Google Cloud Security"
description = "Application creation is a legitimate activity but doesn't occur frequently. Alerts when a new application is created in Entra ID (formerly Azure AD)."
rule_id = "mr_c8daf9ab-2b39-46cc-bda9-7fd1ebb13a81"
rule_name = "O365 Entra ID Application Creation"
type = "alert"
platform = "azure"
data_source = "o365"
severity = "Low"
priority = "Medium"
events:
$app.metadata.event_type = "USER_RESOURCE_CREATION"
$app.metadata.product_name = "Office 365"
$app.metadata.vendor_name = "Microsoft"
$app.metadata.product_event_type = "Add application."
$app.security_result.action = "ALLOW"
//These events should have a userid associated with them but in case they don't we will match on the app name being created instead
strings.coalesce($app.principal.user.userid, $app.target.resource.name) = $user_or_resource
match:
$user_or_resource over 5m
outcome:
$risk_score = 35
$event_count = count_distinct($app.metadata.id)
$target_application = array_distinct($app.target.application)
$security_summary = array_distinct($app.security_result.summary)
$user_agent = array_distinct($app.network.http.user_agent)
//added to populate alert graph with additional context
$principal_user_userid = array_distinct($app.principal.user.userid)
$target_resource_name = array_distinct($app.target.resource.name)
condition:
$app
}
YARA-L Rule Structure
Condition
Fires when at least one $app event in the 5m window.
Events
$app
metadata.product_event_type = "Add application."security_result.action = "ALLOW"
Match and Correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | 35 |
event_count | count_distinct($app.metadata.id) |
target_application | array_distinct($app.target.application) |
security_summary | array_distinct($app.security_result.summary) |
user_agent | array_distinct($app.network.http.user_agent) |
principal_user_userid | array_distinct($app.principal.user.userid) |
target_resource_name | array_distinct($app.target.resource.name) |
sap multiple password changes
#Detects multiple password changes (BU2) by a single actor or targeting a single user across systems.
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Privilege Escalation |
Rule Body
// Copyright 2026 Google LLC. Licensed under Apache-2.0.
rule sap_multiple_password_changes {
meta:
author = "Google Cloud Security"
description = "Detects multiple password changes (BU2) by a single actor or targeting a single user across systems."
severity = "Medium"
tactic = "TA0004"
technique = "T1098"
events:
$e.metadata.product_name = "SAP security audit"
$e.additional.fields["msg_1"] = "BU2"
$source_user = $e.principal.user.userid
$target_user = $e.additional.fields["param2_1"]
$client = $e.target.resource.attribute.labels["slgmand_1"]
match:
$source_user over 3h
outcome:
$total_changes = count($e.metadata.product_log_id)
$distinct_targets = count_distinct($target_user)
$distinct_clients = count_distinct($client)
$admin_email = array_distinct($e.principal.user.email_addresses)
$target_users = array_distinct($target_user)
$terminal_ips = array_distinct($e.principal.ip)
condition:
#e >= 3 or #target_user >= 3
}
YARA-L Rule Structure
Condition
Fires when $e occurs at least 3 times in the 3h window or $target_user occurs at least 3 times in the 3h window.
Events
$e
additional.fields["msg_1"] = "BU2"
Match and Correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
total_changes | count($e.metadata.product_log_id) |
distinct_targets | count_distinct($target_user) |
distinct_clients | count_distinct($client) |
admin_email | array_distinct($e.principal.user.email_addresses) |
target_users | array_distinct($target_user) |
terminal_ips | array_distinct($e.principal.ip) |