收集 Snort IDS 日志

支持:

本文档介绍了如何使用 Bindplane 代理将 Snort IDS 日志注入到 Google Security Operations。

Snort 是一种开源入侵检测和防御系统,可针对网络入侵提醒、协议分析事件和流量异常生成 syslog 消息。解析器使用 grok 模式从 syslog 格式和 JSON 格式的日志中提取字段,并将其映射到统一数据模型 (UDM)。

准备工作

请确保满足以下前提条件:

  • Google SecOps 实例
  • Windows Server 2016 或更高版本,或者具有 systemd 的 Linux 主机
  • Bindplane 代理与 Snort 设备之间的网络连接
  • 如果通过代理运行,请确保防火墙端口根据 Bindplane 代理要求处于开放状态
  • 对 Snort 设备的终端访问权限

获取 Bindplane 代理的 Google SecOps 凭据

如需向 Google SecOps 验证 Bindplane 代理,请选择以下方法之一:

  • 新部署:使用 Chronicle API(选项 1)。
  • 旧版部署:继续使用数据注入身份验证文件(方法 2),直到 Ingestion API 于 2027 年 7 月 20 日停用。
  1. 登录 Google Cloud 控制台,然后选择与您的 Google SecOps 实例关联的 Google Cloud 项目。
  2. 前往 IAM 和管理 > 服务账号。
  3. 点击创建服务账号。
  4. 提供以下配置详细信息:
    • 服务账号名称:输入账号的名称(例如 bindplane-ingest)。
    • 服务账号说明:输入说明(例如 Bindplane agent log ingestion)。
  5. 点击创建并继续。
  6. 在向此服务账号授予对项目的访问权限部分,点击选择角色,然后选择 Chronicle Editor。
  7. 点击继续,然后点击完成。
  8. 点击您创建的服务账号,然后前往密钥标签页。
  9. 依次点击添加密钥 > 创建新密钥。
  10. 选择 JSON,然后点击创建。密钥文件会下载到您的计算机上。
  11. 将密钥文件另存为 Bindplane 收集器目录(Linux 上的 /opt/observiq-otel-collector/ingestion-auth.json 或 Windows 上的 C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json)中的 ingestion-auth.json,或更新 config.yaml 中的 creds_file_path 以匹配您保存该文件的路径。
  12. 前往 IAM 和管理 > 设置,然后复制项目编号。您需要此信息才能配置导出器。

方法 2:下载数据注入身份验证文件(旧版)

  1. 登录 Google SecOps 控制台。
  2. 依次前往 SIEM 设置 > 收集代理。
  3. 下载数据注入身份验证文件。
  4. 将文件安全地保存在将安装 Bindplane 代理的系统上。

获取 Google SecOps 客户 ID

  1. 登录 Google SecOps 控制台。
  2. 依次前往 SIEM 设置 > 配置文件。
  3. 从组织详细信息部分复制并保存客户 ID。

安装 Bindplane 代理

根据以下说明,在 Windows 或 Linux 操作系统上安装 Bindplane 代理。

Windows 安装

  1. 以管理员身份打开命令提示符或 PowerShell。
  2. 运行以下命令:

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    
  3. 等待安装完成。

  4. 运行以下命令,验证安装是否成功:

    sc query observiq-otel-collector
    

    该服务应显示为 RUNNING。

Linux 安装

  1. 打开具有 root 或 sudo 权限的终端。
  2. 运行以下命令:

    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
    
  3. 等待安装完成。

  4. 运行以下命令,验证安装是否成功:

    sudo systemctl status observiq-otel-collector
    

    该服务应显示为 active (running)。

其他安装资源

如需了解其他安装选项和问题排查信息,请参阅 Bindplane 代理安装指南。

配置 Bindplane 代理以注入 syslog 并将其发送到 Google SecOps

找到配置文件

  • Linux:

    sudo nano /opt/observiq-otel-collector/config.yaml
    
  • Windows:

    notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
    

修改配置文件

  • 将 config.yaml 的全部内容替换为以下配置:

    receivers:
      udplog:
        listen_address: "0.0.0.0:514"
    
    exporters:
      chronicle/snort_ids:
        protocol: https
        # Region of your instance, for example us, europe, asia-southeast1
        location: <LOCATION>
        # Project number of the Google Cloud project linked to the instance
        project: '<PROJECT_NUMBER>'
        compression: gzip
        creds_file_path: '/opt/observiq-otel-collector/ingestion-auth.json'
        customer_id: '<customer_id>'
        endpoint: chronicle.googleapis.com
        log_type: SNORT_IDS
        raw_log_field: body
    
    service:
      pipelines:
        logs/snort_ids_to_chronicle:
          receivers:
            - udplog
          exporters:
            - chronicle/snort_ids
    

配置参数

替换以下占位符:

  • 接收器配置:

    • listen_address:要监听的 IP 地址和端口:
      • 0.0.0.0,以监听所有接口(推荐)
      • 端口 514 是标准 syslog 端口(在 Linux 上需要 root 权限;对于非 root 用户,请使用 1514)
  • 导出器配置:

    • creds_file_path:服务账号 JSON 密钥文件的完整路径(选项 1):
      • Linux:/opt/observiq-otel-collector/ingestion-auth.json
      • Windows:C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
    • customer_id:从 Google SecOps 控制台复制的客户 ID
    • location:将 <LOCATION> 替换为 Google SecOps 实例所在的区域(例如 us、europe 或 asia-southeast1)。导出工具会在此值前面加上 chronicle.googleapis.com。如需查看完整列表,请参阅区域级端点。
    • project:将 <PROJECT_NUMBER> 替换为 IAM 和管理 > 设置中的项目编号。
    • endpoint:保持设置为 chronicle.googleapis.com。

旧版提取 API 导出工具

  • 如果您使用选项 2 中的数据注入身份验证文件,请将 exporters 代码块替换为以下内容。将 creds_file_path 设置为数据注入身份验证文件的路径,如果您的实例位于美国境外,请将 malachiteingestion-pa.googleapis.com 替换为您的区域端点(例如 europe-malachiteingestion-pa.googleapis.com)。

    exporters:
      chronicle/snort_ids:
        compression: gzip
        creds_file_path: '/opt/observiq-otel-collector/ingestion-auth.json'
        customer_id: '<customer_id>'
        endpoint: malachiteingestion-pa.googleapis.com
        log_type: SNORT_IDS
        raw_log_field: body
    

保存配置文件

  • 修改后,保存文件:
    • Linux:依次按 Ctrl+O、Enter 和 Ctrl+X
    • Windows:依次点击文件 > 保存

重启 Bindplane 代理以应用更改

  • 如需在 Linux 中重启 Bindplane 代理,请运行以下命令:

    sudo systemctl restart observiq-otel-collector
    
    1. 验证服务是否正在运行:

      sudo systemctl status observiq-otel-collector
      
    2. 检查日志中的错误:

      sudo journalctl -u observiq-otel-collector -f
      
  • 如需在 Windows 中重启 Bindplane 代理,请选择以下选项之一:

    • 以管理员身份运行命令提示符或 PowerShell:

      net stop observiq-otel-collector && net start observiq-otel-collector
      
    • “服务”控制台:

      1. 按 Win+R,输入 services.msc,然后按 Enter 键。
      2. 找到 observIQ OpenTelemetry 收集器。
      3. 右键点击并选择重启。
      4. 验证服务是否正在运行:

        sc query observiq-otel-collector
        
      5. 检查日志中是否存在错误:

        type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
        

在 Snort v2.x 上配置 syslog 导出

  1. 使用终端登录 Snort 设备。
  2. 修改以下文件:/etc/snort/snort.conf。
  3. 转到 6) Configure output plugins。
  4. 添加以下条目:

    # syslog output
    alert_syslog: host=<BINDPLANE_IP>:<PORT_NUMBER>, LOG_AUTH LOG_ALERT
    
    • 将 <BINDPLANE_IP> 替换为 Bindplane 代理 IP 地址,将 <PORT_NUMBER> 替换为端口号。
  5. 保存文件。

  6. 启动 snort 服务。

  7. 停止 rsyslog 服务。

  8. 修改以下文件:/etc/rsyslogd.conf:

    # remote host is: name/ip:port
    *.* @@<BINDPLANE_IP>:<PORT_NUMBER>
    
    • 将 <BINDPLANE_IP> 替换为 Bindplane 代理 IP 地址,将 <PORT_NUMBER> 替换为端口号。
  9. 启动 rsyslog 服务。

在 Snort v3.1.53 上配置 syslog 导出

  1. 使用终端登录 Snort 设备。
  2. 停止 rsyslog 和 snort 服务。
  3. 前往 Snort 安装目录:/usr/local/etc/snort/。
  4. 修改 Snort 配置文件:snort.lua。
  5. 在配置输出选项中,附加以下代码:

    alert_syslog = {
        facility = 'local3',
        level = 'info',
    }
    
  6. 保存 Snort 配置文件。

  7. 前往 rsyslog 服务默认配置文件目录:/etc/rsyslog.d。

  8. 创建新文件:3-snort.conf。

  9. 如需通过 TCP 或 UDP 发送日志,请添加以下配置:

    local3.* @@<BINDPLANE_IP>:<PORT_NUMBER>
    
    • 将 <BINDPLANE_IP> 替换为 Bindplane 代理 IP 地址,并将 <PORT_NUMBER> 替换为端口号。
  10. 保存文件。

  11. 启动 rsyslog,然后启动 snort 服务。

UDM 映射表

日志字段 UDM 映射 逻辑
agent.hostname observer.hostname 值取自原始日志中的 agent.hostname 字段。
agent.id observer.asset_id 从原始日志中的 agent.id 字段获取的值,并与 agent.type 串联,如下所示:agent.type:agent.id。
agent.type observer.application 值取自原始日志中的 agent.type 字段。
agent.version observer.platform_version 值取自原始日志中的 agent.version 字段。
alert.category security_result.category_details 从原始日志的 alert.category 字段中获取的值。
alert.rev security_result.rule_version 值取自原始日志中的 alert.rev 字段。
alert.rule security_result.summary 从原始日志的 alert.rule 字段中提取的值,并移除了双引号。
alert.severity security_result.severity 如果 alert.severity 大于或等于 4,则设置为 LOW。如果 alert.severity 为 2 或 3,则设置为 MEDIUM。如果 alert.severity 为 1,则设置为 HIGH。否则,请将其设置为 UNKNOWN_SEVERITY。
alert.signature security_result.rule_name 值取自原始日志中的 alert.signature 字段。
alert.signature_id security_result.rule_id 从原始日志的 alert.signature_id 字段中获取的值。
app_proto network.application_protocol 如果 app_proto 为 dns、smb 或 http,则转换为大写并使用该值。否则,请将其设置为 UNKNOWN_APPLICATION_PROTOCOL。
类别 security_result.category 如果 category 为 trojan-activity,则设置为 NETWORK_MALICIOUS。如果 category 为 policy-violation,则设置为 POLICY_VIOLATION。否则,请将其设置为 UNKNOWN_CATEGORY。
classtype security_result.rule_type 如果原始日志中的 classtype 字段不为空或 unknown,则取自该字段的值。
community_id network.community_id 从原始日志的 community_id 字段中获取的值。
date_log 如果 time 字段为空,则用于设置事件时间戳。
降序 metadata.description 值取自原始日志中的 desc 字段。
dest_ip target.ip 值取自原始日志中的 dest_ip 字段。
dest_port target.port 从原始日志中的 dest_port 字段获取并转换为整数的值。
dstport target.port 从原始日志的 dstport 字段中获取的值,并转换为整数。
file.filename security_result.about.file.full_path 如果原始日志中的 file.filename 字段不为空或不为 /,则取自该字段的值。
file.size security_result.about.file.size 从原始日志的 file.size 字段中获取的值,并转换为无符号整数。
host.name principal.hostname 值取自原始日志中的 host.name 字段。
主机名 principal.hostname 值取自原始日志中的 hostname 字段。
inter_host intermediary.hostname 从原始日志的 inter_host 字段中获取的值。
log.file.path principal.process.file.full_path 从原始日志的 log.file.path 字段中获取的值。
metadata.version metadata.product_version 从原始日志的 metadata.version 字段中获取的值。
proto network.ip_protocol 从原始日志的 proto 字段中获取的值。如果它是数字,则使用对照表将其转换为相应的 IP 协议名称。
rule_name security_result.rule_name 值取自原始日志中的 rule_name 字段。
signature_id security_result.rule_id 值取自原始日志中的 signature_id 字段。
signature_rev security_result.rule_version 值取自原始日志中的 signature_rev 字段。
src_ip principal.ip 值取自原始日志中的 src_ip 字段。
src_port principal.port 从原始日志中的 src_port 字段获取并转换为整数的值。
srcport principal.port 从原始日志的 srcport 字段中获取的值,并转换为整数。
时间 用于设置事件时间戳。
metadata.event_type 一律设置为 SCAN_NETWORK
metadata.log_type 硬编码为 SNORT_IDS。
metadata.product_name 硬编码为 SNORT_IDS。
metadata.vendor_name 硬编码为 SNORT。
security_result.action 如果 alert.action 为 allowed,则设置为 ALLOW,否则设置为 UNKNOWN_ACTION。

更新日志

查看此解析器的更新日志

需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。