默认检测规则

YARA-L 规则语言

YARA-L 是由 Google 开发的检测规则语言。YARA-L 的用途 从单纯的数据查询检测转为实际的事件驱动型检测 调查。YARA-L 衍生自 YARA 语言中常用的 恶意软件分析L 代表日志。YARA-L 使你可以利用 检测中来自多个来源的所有信息,并将 将这些事件转换为可作为行动依据的提醒有关详情,请参阅 YARA-L 2.0 语言

Google Security Operations 示例检测规则

为了帮助您加速采用 Google Security Operations 检测引擎, 您可以找到包含示例代码的 GitHub 代码库 规则。此代码库包含 几种不同类别的检测规则,具体如下:

  • Google Cloud CloudAudit
  • Google Workspace
  • 信息性警告
  • 恶意软件
  • MITRE ATT&CK
  • SOC 首要规则
  • 可疑事件

每个类别在查看数据源和 指定要使用的事件和匹配语句。

示例规则和调整

以下规则会创建一个事件变量 $e1,用于跟踪 事件类型。事件变量可以是对数据有意义的任何值 。此事件中评估的 UDM 字段为 metadata.eventype,因此可以将其命名为 e1。下面几行 在 e1 中搜索正则表达式匹配出现的特定实例。必须 在 $e1 发生任何事件时,在 Google Security Operations 中创建检测 位置。为进行调参,提供了 not 条件来排除某些 非恶意路径。其他 not 条件 如果您发现 其他已知文件路径。

rule suspicious_unusual_location_svchost_execution

{
 meta:
   author = "Google Cloud Security"
   description = "Windows 'svchost' executed from an unusual location"
   yara_version = "YL2.0"
   rule_version = "1.0"

 events:
   $e1.metadata.event_type = "PROCESS_LAUNCH"
   re.regex($e1.principal.process.command_line, `\bsvchost(\.exe)?\b`) nocase
   not re.regex($e1.principal.process.command_line, `\\Windows\\System32\\`) nocase

condition:
   $e1
}

指定多个事件变量

YARA-L 支持在规则中包含多个事件变量。在 在以下示例中,规则包含事件 $e1$e2。条件说明 触发检测的逻辑条件。

rule ExcludeZeroValues {
  meta:
    author = "noone@google.com"

  events:
    $e1.metadata.event_type = "NETWORK_DNS"
    $e1.principal.hostname = $hostname

    // $e1.principal.user.userid may be empty string.
    $e1.principal.user.userid != "Guest"

    $e2.metadata.event_type = "NETWORK_HTTP"
    $e2.principal.hostname = $hostname

    // $e2.target.asset_id cannot be empty string as explicitly specified.
    $e2.target.asset_id != ""

  match:
    // $hostname cannot be empty string.
    $hostname over 1h

  condition:
    $e1 and $e2
}

规则结果部分

使用结果部分将规则检测中的保留变量设置为 可为下游使用提供丰富信息例如,您可以添加严重级别 根据所分析事件的数据来生成评分信息。通过 以下检测会检查两个事件以归因 $hostname 值。如果 $hostnames 值在 5 分钟内匹配,严重级别分数为 。使用时间段时,Google Security Operations 检测引擎仅 检查您指定的离散时间段。

rule OutcomeRuleMultiEvent {
    meta:
      author = "noone@google.com"
    events:
      $u.udm.principal.hostname = $hostname
      $asset_context.graph.entity.hostname = $hostname

      $severity = $asset_context.graph.entity.asset.vulnerabilities.severity

    match:
      $hostname over 5m

    outcome:
      $risk_score =
        max(
            100
          +   if($hostname = "my-hostname", 100, 50)
          +   if($severity = "HIGH", 10)
          +   if($severity = "MEDIUM", 5)
          +   if($severity = "LOW", 1)
        )

      $asset_id_list =
        array(
          if($u.principal.asset_id = "",
             "Empty asset id",
             $u.principal.asset_id
          )
        )

      $asset_id_distinct_list = array_distinct($u.principal.asset_id)

      $asset_id_count = count($u.principal.asset_id)

      $asset_id_distinct_count = count_distinct($u.principal.asset_id)

    condition:
      $u and $asset_context and $risk_score > 50 and not arrays.contains($asset_id_list, "id_1234")
}

总结

YARA-L 是一种灵活的检测语言, 而不仅仅是返回数据查询事件变量用于 在规则的条件部分跟踪所使用的字段值。您 可以使用单个事件、多个事件随时间的变化情况、将特定事件 单个值(例如来自不同数据源的 $hostname),甚至可以使用 例如正则表达式来提供匹配项。请务必根据您自己的代码 这可以通过在逻辑中指定排除项来实现您 还可以利用参考列表将内容分为一组 添加到规则中别忘了,Google Security Operations 不需要 要发出提醒的检测。你可以同时跟踪 并且仅针对您认为最重要的 环境