Detection rules › YARA-L

YARA-L rules: 2d

Okta User Login Out Of Hours

#
Severity
low
Type
Alert
Time window
1h
Match by
user
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects out of hours successful authentication.

MITRE ATT&CK Coverage

TacticTechniques
Initial Access
Persistence
Privilege Escalation
Stealth

References

Rule Body

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

rule okta_user_login_out_of_hours {

  meta:
    author = "Google Cloud Security"
    description = "Detects out of hours successful authentication."
    rule_id = "mr_36840037-a41c-47d0-b0eb-4096f28855e1"
    rule_name = "Okta User Login Out Of Hours"
    reference = "https://support.okta.com/help/s/article/User-Signin-and-Recovery-Events-in-the-Okta-System-Log"
    mitre_attack_tactic = "Defense Evasion, Persistence, Privilege Escalation, Initial Access"
    mitre_attack_technique = "Valid Accounts"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1078/"
    mitre_attack_version = "v13.1"
    type = "Alert"
    data_source = "Okta"
    severity = "Low"
    priority = "Low"

  events:
    $login.metadata.product_name = "Okta"
    $login.metadata.vendor_name = "Okta"
    $login.metadata.event_type = "USER_LOGIN"
    $login.target.user.email_addresses = $user
    $login.security_result.action = "ALLOW"
    $login.metadata.event_timestamp.seconds = $timestamp

    (
        01 = timestamp.get_day_of_week($timestamp, "UTC") or //Sunday
        07 = timestamp.get_day_of_week($timestamp, "UTC")  //Saturday
    )

  match:
    $user over 1h

  outcome:
    $risk_score = max(
        if (01 = timestamp.get_day_of_week($timestamp, "UTC"), 10) +
        if (07 = timestamp.get_day_of_week($timestamp, "UTC"), 15) +
        if ( ( timestamp.get_hour($timestamp, "UTC") >= 0 and timestamp.get_hour($timestamp,"UTC")<= 7) or timestamp.get_hour($timestamp,"UTC") > 20, 50)
    )
    $mitre_attack_tactic = "Defense Evasion, Persistence, Privilege Escalation, Initial Access"
    $mitre_attack_technique = "Valid Accounts"
    $principal_ip = array_distinct($login.principal.ip)
    $principal_ip_country = array_distinct($login.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($login.principal.ip_geo_artifact.location.state)
    $principal_ip_city = array_distinct($login.principal.location.city)
    $security_result_summary = array_distinct($login.security_result.summary)
    $principal_user_managers_email_addresses = array_distinct($login.principal.user.managers.email_addresses)
    $principal_user_userid = array_distinct($login.principal.user.userid)
    $dc_principal_user_userid = count_distinct($login.principal.user.userid)
    $target_user_email_addresses = array_distinct($login.target.user.email_addresses)
    $target_user_userid = array_distinct($login.target.user.userid)
    $target_user_agent = array_distinct($login.network.http.user_agent)
    $security_result_description = array_distinct($login.security_result.description)

  condition:
    $login
}

YARA-L Rule Structure

Condition

Fires when at least one $login event in the 1h window.

Events

$login USER_LOGIN

  • security_result.action = "ALLOW"

Match and Correlation

Match key
$user (target.user.email_addresses)
Within
1h

Outcome

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

FieldExpression
risk_scoremax( if (01 = timestamp.get_day_of_week($timestamp, "UTC"), 10) + if (07 = timestamp.get_day_of_week($timestamp, "UTC"), 15) + if ( ( timestamp.get_hour($timestamp, "UTC") >= 0 and timestamp.get_hour($timestamp,"UTC")<= 7) or timestamp.get_hour($timestamp,"UTC") > 20, 50) )
principal_iparray_distinct($login.principal.ip)
principal_ip_countryarray_distinct($login.principal.ip_geo_artifact.location.country_or_region)
principal_ip_statearray_distinct($login.principal.ip_geo_artifact.location.state)
principal_ip_cityarray_distinct($login.principal.location.city)
security_result_summaryarray_distinct($login.security_result.summary)
principal_user_managers_email_addressesarray_distinct($login.principal.user.managers.email_addresses)
principal_user_useridarray_distinct($login.principal.user.userid)
dc_principal_user_useridcount_distinct($login.principal.user.userid)
target_user_email_addressesarray_distinct($login.target.user.email_addresses)
target_user_useridarray_distinct($login.target.user.userid)
target_user_agentarray_distinct($login.network.http.user_agent)
security_result_descriptionarray_distinct($login.security_result.description)

sap deactivation of security audit log

#
Severity
critical
Time window
1h
Match by
sid
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects the deactivation of the SAP Security Audit Log (AUJ). This is a critical event as it stops further security logging.

MITRE ATT&CK Coverage

TacticTechniques
Defense Impairment

Rule Body

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

rule sap_deactivation_of_security_audit_log {
  meta:
    author = "Google Cloud Security"
    description = "Detects the deactivation of the SAP Security Audit Log (AUJ). This is a critical event as it stops further security logging."
    severity = "Critical"
    tactic = "TA0005"
    technique = "T1562"

  events:
    $e.metadata.log_type = "SAP_SECURITY_AUDIT"

    $e.additional.fields["msg_1"] = "AUJ"

    $e.additional.fields["param1_1"] = "0"

    $sid = $e.target.application
    $user = $e.principal.user.userid

  match:
    $sid over 1h

  outcome:
    $risk_score = 95
    $source_user = array_distinct($user)
    $terminal_ip = array_distinct($e.principal.ip)
    $target_sid = array_distinct($sid)
    $client = array_distinct($e.target.resource.attribute.labels["slgmand_1"])
    $instance = array_distinct($e.target.resource.name)
    $report_name = array_distinct($e.principal.process.file.names)
    $log_description = array_distinct($e.metadata.description)

  condition:
    $e
}

YARA-L Rule Structure

Condition

Fires when at least one $e event in the 1h window.

Events

$e

  • metadata.log_type = "SAP_SECURITY_AUDIT"
  • additional.fields["msg_1"] = "AUJ"
  • additional.fields["param1_1"] = "0"

Match and Correlation

Match key
$sid
Within
1h

Outcome

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

FieldExpression
risk_score95
source_userarray_distinct($user)
terminal_iparray_distinct($e.principal.ip)
target_sidarray_distinct($sid)
clientarray_distinct($e.target.resource.attribute.labels["slgmand_1"])
instancearray_distinct($e.target.resource.name)
report_namearray_distinct($e.principal.process.file.names)
log_descriptionarray_distinct($e.metadata.description)

Suspicious Windows Service Installation Detected

#
Type
alert
Time window
15m
Match by
hostname, service_name
Author
Georg Lauenstein - suresecure GmbH
Source
github.com/chronicle/detection-rules

This detection rule identifies the creation of a Windows service with a suspicious or known malicious name, as logged by Windows Event ID 7045 (A service was installed in the system). Threat actors, including those associated with ransomware and other advanced persistent threats (APTs), often create services to achieve persistence, lateral movement, remote execution, or privilege escalation. Detection of such activity is critical for identifying early-stage post-compromise behavior.

MITRE ATT&CK Coverage

References

Telemetry Coverage

Rule Body

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

rule win_susp_or_malicious_service_created {

  meta:
    author = "Georg Lauenstein - suresecure GmbH"
    description = "This detection rule identifies the creation of a Windows service with a suspicious or known malicious name, as logged by Windows Event ID 7045 (`A service was installed in the system`). Threat actors, including those associated with ransomware and other advanced persistent threats (APTs), often create services to achieve persistence, lateral movement, remote execution, or privilege escalation. Detection of such activity is critical for identifying early-stage post-compromise behavior."
    rule_id = "mr_965f922f-7a20-4579-a9df-1b1dea70672e"
    rule_name = "Suspicious Windows Service Installation Detected"
    tactic = "TA0003"
    technique = "T1543.003"
    reference = "https://github.com/mthcht/awesome-lists/blob/main/Lists/suspicious_windows_services_names_list.csv"
    type = "alert"
    platform = "Windows"
    data_source = "Windows System Event Log"
    severity = "Medium"  // Adjust based on your risk assessment
    priority = "Medium"  // Adjust based on your incident response process

  events:
    $suspicious_service.metadata.event_type = "SERVICE_CREATION"
    $suspicious_service.metadata.product_name = "Service Control Manager"
    $suspicious_service.metadata.product_event_type = "7045"

    // Capture the hostname where the event occurred
    $suspicious_service.principal.hostname = $hostname
    $suspicious_service.target.application = $service_name

    // Create a reference list named `suspicious_windows_service_names` and populate it with suspicious service names such as the list found at https://github.com/mthcht/awesome-lists/blob/main/Lists/suspicious_windows_services_names_list.csv
    $service_name in %suspicious_windows_services_names

  match:
    $hostname, $service_name over 15m

  outcome:
    $risk_score = max(65)
    $event_count = count_distinct($suspicious_service.metadata.id)
    $principal_hostname = array_distinct($suspicious_service.principal.hostname)
    $principal_user_userid = array_distinct($suspicious_service.principal.user.userid)
    $principal_user_windows_sid = array_distinct($suspicious_service.principal.user.windows_sid)

  condition:
    $suspicious_service
}

YARA-L Rule Structure

Condition

Fires when at least one $suspicious_service event in the 15m window.

Events

$suspicious_service SERVICE_CREATION (7045)

  • metadata.product_event_type = "7045"
  • target.application in "%suspicious_windows_services_names"

Match and Correlation

Match key
$hostname (principal.hostname), $service_name (target.application)
Within
15m

Outcome

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

FieldExpression
risk_scoremax(65)
event_countcount_distinct($suspicious_service.metadata.id)
principal_hostnamearray_distinct($suspicious_service.principal.hostname)
principal_user_useridarray_distinct($suspicious_service.principal.user.userid)
principal_user_windows_sidarray_distinct($suspicious_service.principal.user.windows_sid)

Back to all YARA-L rules