Detection rules › YARA-L

YARA-L rules: 3a

AWS GuardDuty Penetration Testing Activity Detected

#
Severity
high
Type
Alert
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Amazon GuardDuty detects penetration testing activity from known offensive security distros such as KaliLinux, ParrotLinux or PentooLinux.

MITRE ATT&CK Coverage

TacticTechniques
Resource Development

Rule Body

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

rule aws_guardduty_penetration_testing_activity_detected {

  meta:
    author = "Google Cloud Security"
    description = "Amazon GuardDuty detects penetration testing activity from known offensive security distros such as KaliLinux, ParrotLinux or PentooLinux."
    rule_id = "mr_7dac6e7c-9d35-4093-9b85-4b0175e8bee7"
    rule_name = "AWS GuardDuty Penetration Testing Activity Detected"
    mitre_attack_tactic = "Resource Development"
    mitre_attack_technique = "Obtain Capabilities"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1588/"
    mitre_attack_version = "v13.1"
    type = "Alert"
    data_source = "AWS GuardDuty"
    platform = "AWS"
    severity = "High"
    priority = "High"

  events:
    $guardduty.metadata.vendor_name = "AMAZON"
    $guardduty.metadata.product_name = "AWS GuardDuty"
    $guardduty.metadata.product_event_type = /PenTest/
    //Filter out sample findings
    $guardduty.security_result.about.labels["Sample"] != "true"

  outcome:
    $risk_score = max(35)
    $mitre_attack_tactic = "Resource Development"
    $mitre_attack_technique = "Obtain Capabilities"
    $mitre_attack_technique_id = "T1588"
    $event_count = count_distinct($guardduty.metadata.id)
    $principal_ip = array_distinct($guardduty.principal.ip)
    $principal_ip_country = array_distinct($guardduty.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($guardduty.principal.ip_geo_artifact.location.state)
    $principal_user_display_name = $guardduty.principal.user.user_display_name
    $aws_region = $guardduty.target.location.name
    $target_resource_name = $guardduty.target.resource.name
    $target_resource_product_object_id = $guardduty.target.resource.product_object_id
    $security_result_summary = array_distinct($guardduty.security_result.summary)
    $security_result_description = array_distinct($guardduty.security_result.description)
    $security_result_severity = array_distinct($guardduty.security_result.severity)
    $security_result_severity_details = array_distinct($guardduty.security_result.severity_details)
    $metadata_product_event_type = array_distinct($guardduty.metadata.product_event_type)

  condition:
    $guardduty
}

YARA-L Rule Structure

Condition

Fires when at least one $guardduty event.

Events

$guardduty

  • metadata.product_event_type matches "PenTest"
  • security_result.about.labels["Sample"] != "true"

Outcome

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

FieldExpression
risk_scoremax(35)
event_countcount_distinct($guardduty.metadata.id)
principal_iparray_distinct($guardduty.principal.ip)
principal_ip_countryarray_distinct($guardduty.principal.ip_geo_artifact.location.country_or_region)
principal_ip_statearray_distinct($guardduty.principal.ip_geo_artifact.location.state)
principal_user_display_name$guardduty.principal.user.user_display_name
aws_region$guardduty.target.location.name
target_resource_name$guardduty.target.resource.name
target_resource_product_object_id$guardduty.target.resource.product_object_id
security_result_summaryarray_distinct($guardduty.security_result.summary)
security_result_descriptionarray_distinct($guardduty.security_result.description)
security_result_severityarray_distinct($guardduty.security_result.severity)
security_result_severity_detailsarray_distinct($guardduty.security_result.severity_details)
metadata_product_event_typearray_distinct($guardduty.metadata.product_event_type)

IP Target Prevalence

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

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 NETWORK_CONNECTION (3, 5156)

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

$prevalence entity context (IP_ADDRESS)

  • 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

Match key
$ip (target.ip)
Within
5m

Outcome

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

FieldExpression
risk_score35
event_countcount_distinct($network.metadata.id)
principal_iparray_distinct($network.principal.ip)
principal_process_pidarray_distinct($network.principal.process.pid)
principal_process_command_linearray_distinct($network.principal.process.command_line)
principal_process_file_sha256array_distinct($network.principal.process.file.sha256)
principal_process_file_full_patharray_distinct($network.principal.process.file.full_path)
principal_process_product_specific_process_idarray_distinct($network.principal.process.product_specific_process_id)
principal_process_parent_process_product_specific_process_idarray_distinct($network.principal.process.parent_process.product_specific_process_id)
target_process_pidarray_distinct($network.target.process.pid)
target_process_command_linearray_distinct($network.target.process.command_line)
target_process_file_sha256array_distinct($network.target.process.file.sha256)
target_process_file_full_patharray_distinct($network.target.process.file.full_path)
target_process_product_specific_process_idarray_distinct($network.target.process.product_specific_process_id)
target_process_parent_process_product_specific_process_idarray_distinct($network.target.process.parent_process.product_specific_process_id)
principal_user_useridarray_distinct($network.principal.user.userid)
target_user_useridarray_distinct($network.target.user.userid)

VT Relationships File Contacts IP

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

Alert on known Hash contacting known IP with VT Relationships

Telemetry Coverage

Rule Body

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

rule vt_relationships_file_contacts_ip {

  meta:
    author = "Google Cloud Security"
    description = "Alert on known Hash contacting known IP with VT Relationships"
    rule_id = "mr_d6011593-c864-40b2-b300-4275ed163f5d"
    rule_name = "VT Relationships File Contacts IP"
    type = "alert"
    tags = "vt"
    data_source = "microsoft defender atp"
    severity = "High"
    priority = "High"

  events:
    $network.metadata.event_type = "NETWORK_CONNECTION"
    $network.principal.process.file.sha256 = $file_hash
    $network.target.ip = $ip
    $network.principal.hostname = $hostname

    // Uses VirusTotal integration via entity graph, this section maps to principal process file hash
    $vt.graph.metadata.entity_type = "FILE"
    $vt.graph.metadata.source_type = "GLOBAL_CONTEXT"
    $vt.graph.metadata.vendor_name = "VirusTotal"
    $vt.graph.metadata.product_name = "VirusTotal Relationships"
    $vt.graph.entity.file.sha256 = $file_hash

    // Uses VirusTotal integration via entity graph, this section maps the hash to the ip address it contacts
    $vt.graph.relations.entity_type = "IP_ADDRESS"
    $vt.graph.relations.relationship = "CONTACTS"
    $vt.graph.relations.entity.ip = $ip

  match:
    $hostname over 5m

  outcome:
    $risk_score = 85
    $event_count = count_distinct($network.metadata.id)
    // added to populate alert graph with additional context
    $principal_ip = array_distinct($network.principal.ip)
    $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 $vt
}

YARA-L Rule Structure

Condition

Fires when at least one $network event in the 5m window and $vt matches entity context.

Events

$network NETWORK_CONNECTION (3, 5156)

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

$vt entity context (FILE)

  • graph.metadata.entity_type = "FILE"
  • graph.metadata.source_type = "GLOBAL_CONTEXT"
  • graph.metadata.vendor_name = "VirusTotal"
  • graph.metadata.product_name = "VirusTotal Relationships"
  • graph.relations.entity_type = "IP_ADDRESS"
  • graph.relations.relationship = "CONTACTS"

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
event_countcount_distinct($network.metadata.id)
principal_iparray_distinct($network.principal.ip)
target_iparray_distinct($network.target.ip)
principal_process_pidarray_distinct($network.principal.process.pid)
principal_process_command_linearray_distinct($network.principal.process.command_line)
principal_process_file_sha256array_distinct($network.principal.process.file.sha256)
principal_process_file_full_patharray_distinct($network.principal.process.file.full_path)
principal_process_product_specific_process_idarray_distinct($network.principal.process.product_specific_process_id)
principal_process_parent_process_product_specific_process_idarray_distinct($network.principal.process.parent_process.product_specific_process_id)
target_process_pidarray_distinct($network.target.process.pid)
target_process_command_linearray_distinct($network.target.process.command_line)
target_process_file_sha256array_distinct($network.target.process.file.sha256)
target_process_file_full_patharray_distinct($network.target.process.file.full_path)
target_process_product_specific_process_idarray_distinct($network.target.process.product_specific_process_id)
target_process_parent_process_product_specific_process_idarray_distinct($network.target.process.parent_process.product_specific_process_id)
principal_user_useridarray_distinct($network.principal.user.userid)
target_user_useridarray_distinct($network.target.user.userid)

Back to all YARA-L rules