high_risk_user_download_executable_from_macro
Description
Executable downloaded by Microsoft Excel by user with GCP entity relationship
Query · yara_l
events:
// proxy event with suspected executable download
$proxy_event.metadata.event_type = "NETWORK_HTTP"
$proxy_event.target.url = /.*\.exe$/ or
$proxy_event.network.received_bytes > 102400
$proxy_event.principal.user.userid = $user
$proxy_event.principal.user.userid != /test/
$proxy_event.target.hostname = $hostname
// correlate with EDR event indicating Excel activity
$edr_event.target.user.userid = $user
$edr_event.target.process.file.full_path = /excel/ nocase
($edr_event.metadata.event_type = "NETWORK_HTTP" or $edr_event.metadata.event_type = "NETWORK_CONNECTION")
$edr_event.target.hostname = $hostname
// first hop into entity graph to find the permissions
$user_entity.graph.entity.user.userid = $user
$user_entity.graph.metadata.entity_type = "USER"
$user_entity.graph.metadata.source_type = "ENTITY_CONTEXT"
$user_entity.graph.relations.entity.resource.name != ""
$user_entity.graph.relations.entity.resource.name = $table_name
// second hop for the table context
$table_context.graph.entity.resource.product_object_id = $table_name
$table_context.graph.metadata.entity_type = "RESOURCE"
$table_context.graph.metadata.source_type = "ENTITY_CONTEXT"
$table_context.graph.metadata.product_name = "GCP DLP CONTEXT"
match:
$user, $hostname over 5m
outcome:
$risk_score = max(if($table_context.graph.entity.resource.attribute.labels.value = "US_SOCIAL_SECURITY_NUMBER", 80))
$entity_resource_name = array_distinct($table_context.graph.entity.resource.name)
// added to populate alert graph with additional context
$principal_hostname = array_distinct($proxy_event.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($proxy_event.target.hostname)
$principal_process_pid = array_distinct($edr_event.principal.process.pid)
$principal_process_command_line = array_distinct($edr_event.principal.process.command_line)
$principal_process_file_sha256 = array_distinct($edr_event.principal.process.file.sha256)
$principal_process_file_full_path = array_distinct($edr_event.principal.process.file.full_path)
$principal_process_product_specific_process_id = array_distinct($edr_event.principal.process.product_specific_process_id)
$principal_process_parent_process_product_specific_process_id = array_distinct($edr_event.principal.process.parent_process.product_specific_process_id)
$target_process_pid = array_distinct($edr_event.target.process.pid)
$target_process_command_line = array_distinct($edr_event.target.process.command_line)
$target_process_file_sha256 = array_distinct($edr_event.target.process.file.sha256)
$target_process_file_full_path = array_distinct($edr_event.target.process.file.full_path)
$target_process_product_specific_process_id = array_distinct($edr_event.target.process.product_specific_process_id)
$target_process_parent_process_product_specific_process_id = array_distinct($edr_event.target.process.parent_process.product_specific_process_id)
// Commented out principal.user.userid because it is already represented in graph as match variable. If match changes, can uncomment to add to results
//$principal_user_userid = array_distinct($edr_event.principal.user.userid)
$target_user_userid = array_distinct($edr_event.target.user.userid)
$target_url = array_distinct($proxy_event.target.url)
condition:
$proxy_event and $edr_event and $user_entity and $table_context