Detection rules › YARA-L
IP Target Prevalence
Detect events that are communicating to IP addresses that have a low rolling max prevalence.
Telemetry coverage
Rule body
// Copyright 2023 Google LLC. Licensed under Apache-2.0.
rule ip_target_prevalence {
meta:
author = "Google Cloud Security"
description = "Detect events that are communicating to IP addresses that have a low rolling max prevalence."
rule_id = "mr_0de02f28-2a7d-4128-aa31-02308491e744"
rule_name = "IP Target Prevalence"
type = "alert"
tags = "prevalence"
data_source = "crowdstrike, gcp firewall, microsoft sysmon, gcp scc, microsoft defender atp, corelight zeek, microsoft windows events"
severity = "Low"
priority = "Low"
events:
$network.metadata.event_type = "NETWORK_CONNECTION"
$network.target.ip = $ip
// derived from events ingested by Google SecOps
$prevalence.graph.metadata.entity_type = "IP_ADDRESS"
$prevalence.graph.metadata.source_type = "DERIVED_CONTEXT"
$prevalence.graph.entity.artifact.prevalence.day_count = 10
$prevalence.graph.entity.artifact.prevalence.rolling_max <= 3
$prevalence.graph.entity.artifact.prevalence.rolling_max > 0
$prevalence.graph.entity.artifact.ip = $ip
match:
$ip over 5m
outcome:
$risk_score = 35
$event_count = count_distinct($network.metadata.id)
// added to populate alert graph with additional context
$principal_ip = array_distinct($network.principal.ip)
// Commented out target.ip because it is already represented in graph as match variable. If match changes, can uncomment to add to results
//$target_ip = array_distinct($network.target.ip)
$principal_process_pid = array_distinct($network.principal.process.pid)
$principal_process_command_line = array_distinct($network.principal.process.command_line)
$principal_process_file_sha256 = array_distinct($network.principal.process.file.sha256)
$principal_process_file_full_path = array_distinct($network.principal.process.file.full_path)
$principal_process_product_specific_process_id = array_distinct($network.principal.process.product_specific_process_id)
$principal_process_parent_process_product_specific_process_id = array_distinct($network.principal.process.parent_process.product_specific_process_id)
$target_process_pid = array_distinct($network.target.process.pid)
$target_process_command_line = array_distinct($network.target.process.command_line)
$target_process_file_sha256 = array_distinct($network.target.process.file.sha256)
$target_process_file_full_path = array_distinct($network.target.process.file.full_path)
$target_process_product_specific_process_id = array_distinct($network.target.process.product_specific_process_id)
$target_process_parent_process_product_specific_process_id = array_distinct($network.target.process.parent_process.product_specific_process_id)
$principal_user_userid = array_distinct($network.principal.user.userid)
$target_user_userid = array_distinct($network.target.user.userid)
condition:
$network and $prevalence
}
YARA-L rule structure
Condition
Fires when at least one $network event in the 5m window and $prevalence matches entity context.
Events
$network
$prevalence
graph.metadata.entity_type = "IP_ADDRESS"graph.metadata.source_type = "DERIVED_CONTEXT"graph.entity.artifact.prevalence.day_count = "10"graph.entity.artifact.prevalence.rolling_max <= "3"graph.entity.artifact.prevalence.rolling_max > "0"
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($network.metadata.id) |
principal_ip | array_distinct($network.principal.ip) |
principal_process_pid | array_distinct($network.principal.process.pid) |
principal_process_command_line | array_distinct($network.principal.process.command_line) |
principal_process_file_sha256 | array_distinct($network.principal.process.file.sha256) |
principal_process_file_full_path | array_distinct($network.principal.process.file.full_path) |
principal_process_product_specific_process_id | array_distinct($network.principal.process.product_specific_process_id) |
principal_process_parent_process_product_specific_process_id | array_distinct($network.principal.process.parent_process.product_specific_process_id) |
target_process_pid | array_distinct($network.target.process.pid) |
target_process_command_line | array_distinct($network.target.process.command_line) |
target_process_file_sha256 | array_distinct($network.target.process.file.sha256) |
target_process_file_full_path | array_distinct($network.target.process.file.full_path) |
target_process_product_specific_process_id | array_distinct($network.target.process.product_specific_process_id) |
target_process_parent_process_product_specific_process_id | array_distinct($network.target.process.parent_process.product_specific_process_id) |
principal_user_userid | array_distinct($network.principal.user.userid) |
target_user_userid | array_distinct($network.target.user.userid) |