Detection rules › YARA-L

YARA-L rules: 0z

ADFS DKM Key Access

#
Severity
high
Type
alert
Time window
5m
Match by
hostname
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects access to the AD contact object to read the AD FS DKM (distributed key manager) master key value

MITRE ATT&CK Coverage

TacticTechniques
Credential Access

References

Telemetry Coverage

Rule Body

// Copyright 2023 Google LLC. Licensed under Apache-2.0.

rule adfs_dkm_key_access {

  meta:
    author = "Google Cloud Security"
    description = "Detects access to the AD contact object to read the AD FS DKM (distributed key manager) master key value"
    rule_id = "mr_2517eaa0-0915-4a9e-8ca2-abce955eb635"
    rule_name = "ADFS DKM Key Access"
    reference = "https://github.com/OTRF/BHEU22-ADFS/blob/main/Slide-Deck.pdf"
    type = "alert"
    tactic = "TA0006"
    technique = "T1552.004"
    platform = "Windows"
    data_source = "windows security events"
    severity = "High"
    priority = "High"

  events:
    $object.metadata.event_type = "USER_RESOURCE_ACCESS"
    $object.metadata.product_name = "Microsoft-Windows-Security-Auditing"
    $object.metadata.vendor_name = "Microsoft"
    $object.metadata.product_event_type = "4662"
    any $object.security_result.detection_fields.value = "properties:{8d3bca50-1d7e-11d0-a081-00aa006c33ed}"
    $object.principal.labels["SubjectLogonId"] = $subject

    $login.metadata.event_type = "USER_LOGIN"
    $login.metadata.product_name = "Microsoft-Windows-Security-Auditing"
    $login.metadata.vendor_name = "Microsoft"
    $login.metadata.product_event_type = "4624"
    $login.target.labels["TargetLogonId"] = $subject
    $login.principal.hostname = $hostname

  match:
    $hostname over 5m

  outcome:
    $risk_score = 85
    //added to populate alert graph with additional context
    //Commented out because it is the same as the match variable, if match variable changes, uncomment to use
    //$principal_hostname = array_distinct($logon.principal.hostname)
    $object_principal_process_pid = array_distinct($object.principal.process.pid)
    $object_principal_user_userid = array_distinct($object.principal.user.userid)
    //$principal_user_windows_sid = array_distinct($object.principal.user.windows_sid)
    $object_target_resource_name = array_distinct($object.target.resource.name)

  condition:
    $object and $login
}

YARA-L Rule Structure

Condition

Fires when at least one $object event in the 5m window and at least one $login event in the 5m window.

Events

$login USER_LOGIN (4624)

  • metadata.product_event_type = "4624"

$object USER_RESOURCE_ACCESS (4662)

  • metadata.product_event_type = "4662"
  • security_result.detection_fields.value = "properties:{8d3bca50-1d7e-11d0-a081-00aa006c33ed}"

Match and Correlation

Match key
$hostname (principal.hostname)
Within
5m

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_score85
object_principal_process_pidarray_distinct($object.principal.process.pid)
object_principal_user_useridarray_distinct($object.principal.user.userid)
object_target_resource_namearray_distinct($object.target.resource.name)

WHOIS Recently Created Domain Access

#
Severity
info
Type
alert
Time window
1h
Match by
domain
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects access attempts to a newly created domain via WHOIS enrichment.

Telemetry Coverage

Rule Body

// Copyright 2023 Google LLC. Licensed under Apache-2.0.

rule whois_recently_created_domain_access {

  meta:
    author = "Google Cloud Security"
    description = "Detects access attempts to a newly created domain via WHOIS enrichment."
    rule_id = "mr_209a5ab1-a0ea-473c-bfae-7beb67673e99"
    rule_name = "WHOIS Recently Created Domain Access"
    type = "alert"
    tags = "whois"
    data_source = "zscalar"
    severity = "Info"
    priority = "Info"

  events:
    ($access.metadata.event_type = "NETWORK_HTTP" or $access.metadata.event_type = "NETWORK_CONNECTION")

    // join access event to entity graph to use WHOIS data
    $access.target.hostname = $domain

    // Whois domains provided by GCTI Feed
    $whois.graph.entity.domain.name = $domain
    $whois.graph.metadata.entity_type = "DOMAIN_NAME"
    $whois.graph.metadata.vendor_name = "WHOIS"
    $whois.graph.metadata.product_name = "WHOISXMLAPI Simple Whois"
    $whois.graph.metadata.source_type = "GLOBAL_CONTEXT"
    $whois.graph.entity.domain.creation_time.seconds > 0

    // domain was created in the last 30 days
    2592000 > timestamp.current_seconds() - $whois.graph.entity.domain.creation_time.seconds

  match:
    $domain over 1h

  outcome:
    $risk_score = 20
    $event_count = count_distinct($access.metadata.id)
    //added to populate alert graph with additional context
    $principal_hostname = array_distinct($access.principal.hostname)
    // Commented out target.hostname because it is already represented in graph as match variable. If match changes, can uncomment to add to results
    //$target_hostname = array_distinct($access.target.hostname)
    $principal_process_pid = array_distinct($access.principal.process.pid)
    $principal_process_command_line = array_distinct($access.principal.process.command_line)
    $principal_process_file_sha256 = array_distinct($access.principal.process.file.sha256)
    $principal_process_file_full_path = array_distinct($access.principal.process.file.full_path)
    $principal_process_product_specific_process_id = array_distinct($access.principal.process.product_specific_process_id)
    $principal_process_parent_process_product_specific_process_id = array_distinct($access.principal.process.parent_process.product_specific_process_id)
    $target_process_pid = array_distinct($access.target.process.pid)
    $target_process_command_line = array_distinct($access.target.process.command_line)
    $target_process_file_sha256 = array_distinct($access.target.process.file.sha256)
    $target_process_file_full_path = array_distinct($access.target.process.file.full_path)
    $target_process_product_specific_process_id = array_distinct($access.target.process.product_specific_process_id)
    $target_process_parent_process_product_specific_process_id = array_distinct($access.target.process.parent_process.product_specific_process_id)
    $principal_user_userid = array_distinct($access.principal.user.userid)
    $target_user_userid = array_distinct($access.target.user.userid)
    $target_url = array_distinct($access.target.url)

  condition:
    $access and $whois
}

YARA-L Rule Structure

Condition

Fires when at least one $access event in the 1h window and $whois matches entity context.

Events

$access NETWORK_HTTP (3, 5156)

No field filters (binds the event for correlation only).

$whois entity context (DOMAIN_NAME)

  • graph.metadata.entity_type = "DOMAIN_NAME"
  • graph.metadata.vendor_name = "WHOIS"
  • graph.metadata.product_name = "WHOISXMLAPI Simple Whois"
  • graph.metadata.source_type = "GLOBAL_CONTEXT"
  • graph.entity.domain.creation_time.seconds > "0"
  • timestamp.current_seconds() time_arithmetic "graph.entity.domain.creation_time.seconds" or "2592000"

Match and Correlation

Match key
$domain (target.hostname)
Within
1h

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_score20
event_countcount_distinct($access.metadata.id)
principal_hostnamearray_distinct($access.principal.hostname)
principal_process_pidarray_distinct($access.principal.process.pid)
principal_process_command_linearray_distinct($access.principal.process.command_line)
principal_process_file_sha256array_distinct($access.principal.process.file.sha256)
principal_process_file_full_patharray_distinct($access.principal.process.file.full_path)
principal_process_product_specific_process_idarray_distinct($access.principal.process.product_specific_process_id)
principal_process_parent_process_product_specific_process_idarray_distinct($access.principal.process.parent_process.product_specific_process_id)
target_process_pidarray_distinct($access.target.process.pid)
target_process_command_linearray_distinct($access.target.process.command_line)
target_process_file_sha256array_distinct($access.target.process.file.sha256)
target_process_file_full_patharray_distinct($access.target.process.file.full_path)
target_process_product_specific_process_idarray_distinct($access.target.process.product_specific_process_id)
target_process_parent_process_product_specific_process_idarray_distinct($access.target.process.parent_process.product_specific_process_id)
principal_user_useridarray_distinct($access.principal.user.userid)
target_user_useridarray_distinct($access.target.user.userid)
target_urlarray_distinct($access.target.url)

Back to all YARA-L rules