收集 Nix 系统 Red Hat 日志

支持的语言:

本文档介绍了如何使用 Bindplane 将 RHEL Server(Unix 系统)日志注入到 Google Security Operations。解析器会提取 syslog 和 JSON 格式的日志,将各种 UDM 字段初始化为空字符串,对 message 字段执行多项字符串替换操作,然后尝试将消息解析为 JSON。如果 JSON 解析失败,它会使用 grok 模式根据 messageevent_details.original 内容提取字段,并根据事件类型和各种条件检查将提取的字段映射到 UDM,从而处理来自各种 Unix 系统进程和服务的不同日志格式和结构。

准备工作

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

  • Google SecOps 实例
  • 如果在代理后运行,防火墙端口处于开放状态
  • 对 RHEL 服务器的特权访问权限

获取 Google SecOps 注入身份验证文件

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

获取 Google SecOps 客户 ID

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

安装 Bindplane 代理

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
    

其他安装资源

如需了解其他安装选项,请参阅安装指南

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

  1. 访问配置文件:
    • 找到 config.yaml 文件。通常,它位于 Linux 上的 /etc/bindplane-agent/ 目录中。
    • 使用文本编辑器(例如 nanovi)打开该文件。
  2. 按如下方式修改 config.yaml 文件:

          receivers:
              filelog/linux:
              include:
                - /var/log/messages
                - /var/log/lastlog
                - /var/log/btmp
                - /var/log/wtmp
                - /var/log/secure
                - /var/log/cron
                - /var/log/maillog
                - /var/log/boot
              start_at: end
              poll_interval: 5s
    
          exporters:
              chronicle/linux:
                  # Adjust the path to the credentials file you downloaded in Step 1
                  creds: '/path/to/ingestion-authentication-file.json'
                  # Replace with your actual customer ID from Step 2
                  customer_id: <customer_id>
                  endpoint: malachiteingestion-pa.googleapis.com
                  # Add optional ingestion labels for better organization
                  log_type: 'NIX_SYSTEM'
                  override_log_type: false
                  raw_log_field: body
    
          service:
            pipelines:
              logs/linux:
                receivers:
                - filelog/linux
            exporters: [chronicle/linux]
          ```
    
  1. <customer_id> 替换为实际的客户 ID。
  2. /path/to/ingestion-authentication-file.json 更新为获取 Google SecOps 提取身份验证文件部分中保存身份验证文件的路径。

    启动 Bindplane 代理并应用更改

  3. 启动 Bindplane 代理:

    sudo systemctl start bindplane-agent
    
  4. 启用 observIQ otel 收集器服务:

    systemctl enable --now bindplane-agent
    
  5. 如有必要,请重启 Bindplane 代理:

    sudo systemctl restart bindplane-agent
    

UDM 映射表

日志字段 UDM 映射 逻辑
AccessControlRuleAction security_result.action 如果 AccessControlRuleActionAllow,则设置为 ALLOW。如果 AccessControlRuleActionBlock,则设置为 BLOCK
ACPolicy security_result.rule_labels 键:ACPolicy,值:ACPolicy
AccessControlRuleName security_result.rule_name 直接映射。
acct event.idm.read_only_udm.target.user.userid 移除英文引号和反斜杠后的直接映射。
addr event.idm.read_only_udm.target.ipevent.idm.read_only_udm.target.asset.ip 如果不是空值、?UNKNOWN,则为直接映射。
ApplicationProtocol event.idm.read_only_udm.network.application_protocol 直接映射。
auid event.idm.read_only_udm.additional.fields 键:auid,值:auid
comm event.idm.read_only_udm.target.process.command_line 直接映射。
command event.idm.read_only_udm.target.process.command_line 移除开头/结尾处的空格后的直接映射。
Computer event.idm.read_only_udm.principal.hostnameevent.idm.read_only_udm.principal.asset.hostname 直接映射。如果为空,则使用 HostName
ConnectionID security_result.detection_fields 键:Connection ID,值:ConnectionID
cwd event.idm.read_only_udm.target.process.file.full_path 移除引号后的直接映射。
data message 用于 Grok 模式。
desc security_result.description 直接映射。
description event.idm.read_only_udm.metadata.descriptionsecurity_result.description 直接映射。
descript security_result.description 移除哈希后的直接映射。
DeviceUUID event.idm.read_only_udm.metadata.product_log_id 直接映射。
DNSQuery event.idm.read_only_udm.additional.fields 键:DNSQuery,值:DNSQuery
DNSRecordType event.idm.read_only_udm.additional.fields 键:DNSRecordType,值:DNSRecordType
DNSResponseType event.idm.read_only_udm.additional.fields 键:DNSResponseType,值:DNSResponseType
DNS_TTL event.idm.read_only_udm.additional.fields 键:DNS_TTL,值:DNS_TTL
DstIP event.idm.read_only_udm.target.ipevent.idm.read_only_udm.target.asset.ip 直接映射。
DstPort event.idm.read_only_udm.target.port 直接映射,转换为整数。
dvc event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ipevent.idm.read_only_udm.principal.hostnameevent.idm.read_only_udm.principal.asset.hostnameevent.idm.read_only_udm.intermediary.ipevent.idm.read_only_udm.target.ipevent.idm.read_only_udm.target.asset.ipevent.idm.read_only_udm.target.hostnameevent.idm.read_only_udm.target.asset.hostname 如果为有效 IP,则映射到正文/目标 IP。如果为 hostname,则映射到正文/目标主机名。如果 IP 有效,也用于中间 IP。
EgressInterface event.idm.read_only_udm.principal.asset.attribute.labels 键:EgressInterface,值:EgressInterface
EgressVRF event.idm.read_only_udm.principal.asset.attribute.labels 键:EgressVRF,值:EgressVRF
EgressZone event.idm.read_only_udm.target.location.name 直接映射。
eventType event.idm.read_only_udm.metadata.product_event_typeevent.idm.read_only_udm.target.application 直接映射。对于 SERVICE_STARTSERVICE_STOP,映射到 target.application,然后清除。
EventTime @timestamp 解析为时间戳。
exe event.idm.read_only_udm.target.process.command_line 移除英文引号和反斜杠后的直接映射。
extended_description event.idm.read_only_udm.metadata.description 移除连字符和引号后的直接映射。
Facility event.idm.read_only_udm.principal.resource.attribute.labels 键:Facility,值:Facility
filepath event.idm.read_only_udm.principal.process.file.full_path 直接映射。
file_path event.idm.read_only_udm.target.file.full_path 直接映射。
file_path_value event.idm.read_only_udm.target.file.full_path 直接映射。
FirstPacketSecond security_result.detection_fields 键:FirstPacketSecond,值:FirstPacketSecond
from event.idm.read_only_udm.network.email.from 移除尖括号后的直接映射。
generic_ip event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 如果 IP 有效且不是 A256:,则直接映射。
gid event.idm.read_only_udm.target.user.group_identifiers 直接映射。
grp event.idm.read_only_udm.target.group.group_display_name 移除英文引号和反斜杠后的直接映射。
hashing_algo security_result.summary 直接映射。
home event.idm.read_only_udm.target.file.full_path 直接映射。
HostName Computer 如果 Computer 为空,则使用此属性。
HostIP event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 提取 HostIP% 之前的部分,并将其映射为 validated_ip
hostname event.idm.read_only_udm.target.hostnameevent.idm.read_only_udm.target.asset.hostnameevent.idm.read_only_udm.principal.hostnameevent.idm.read_only_udm.principal.asset.hostname 如果非空或 ?,则直接映射。
host_name event.idm.read_only_udm.target.hostnameevent.idm.read_only_udm.target.asset.hostname 直接映射。
InitiatorBytes event.idm.read_only_udm.network.sent_bytes 直接映射,转换为无符号整数。
InitiatorPackets event.idm.read_only_udm.network.sent_packets 直接映射,转换为整数。
insertId event.idm.read_only_udm.metadata.product_log_id 直接映射。
InstanceID security_result.detection_fields 键:Instance ID,值:InstanceID
int_dvc event.idm.read_only_udm.intermediary.hostname 直接映射。
ip event.idm.read_only_udm.target.ipevent.idm.read_only_udm.target.asset.ipevent.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 直接映射。
ip_protocol event.idm.read_only_udm.network.ip_protocol 直接映射。
laddr event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 如果非空或 ?,则直接映射。
level security_result.severity 如果为 info,则设置为 INFORMATIONAL
log.syslog.facility.name event.idm.read_only_udm.target.application 直接映射。
log.syslog.severity.name security_result.severity 如果为 Emergency,则设置为 HIGH
logName logname 直接映射。
log_description security_result.description 直接映射。
log_level security_result.severity 如果为 error,则设置为 ERROR
log_summary security_result.summary 直接映射。
logger_name event.idm.read_only_udm.principal.resource.attribute.labels 键:logger_name,值:logger_name
log_type event.idm.read_only_udm.metadata.log_type 硬编码为 NIX_SYSTEM
lport event.idm.read_only_udm.principal.port 直接映射,转换为整数。
MG event.idm.read_only_udm.principal.resource.attribute.labels 键:MG,值:MG
method event.idm.read_only_udm.network.http.method 直接映射,转换为大写。
msg1 event.idm.read_only_udm.metadata.descriptionevent.idm.read_only_udm.additional.fieldssecurity_result.description 使用 grok 模式进行解析。如果 event_typeGENERIC_EVENT,则映射到 description
msg2 event.idm.read_only_udm.network.received_bytessecurity_result.summary 如果包含数字,则转换为无符号整数并映射到 received_bytes。否则,映射到 summary
NAPPolicy security_result.rule_labels 键:NAPPolicy,值:NAPPolicy
name event.idm.read_only_udm.target.process.file.full_path 移除引号后的直接映射。
outcome security_result.action 如果为 Succeeded 或包含 success,则设置为 ALLOW
p_id event.idm.read_only_udm.target.process.pid 直接映射。
pid event.idm.read_only_udm.target.process.pidevent.idm.read_only_udm.principal.process.pid 直接映射。
principal_hostname event.idm.read_only_udm.principal.hostnameevent.idm.read_only_udm.principal.asset.hostname 直接映射。
principal_ip event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 直接映射。
principal_present event.idm.read_only_udm.metadata.event_type 如果 truehas_targettrue,则将 event_type 设置为 NETWORK_UNCATEGORIZED。如果 trueuser_presenttrue,则将 event_type 设置为 USER_UNCATEGORIZED
process event.idm.read_only_udm.target.applicationevent.idm.read_only_udm.metadata.product_event_type 直接映射。如果 eventType 为空,则用作 target.application
ProcessID event.idm.read_only_udm.principal.process.pid 直接映射,转换为字符串。
ProcessName event.idm.read_only_udm.principal.resource.attribute.labels 键:ProcessName,值:ProcessName
prod_eve_type event.idm.read_only_udm.metadata.product_event_type 直接映射。
product_event_type event.idm.read_only_udm.metadata.product_event_type 直接映射。
Protocol event.idm.read_only_udm.network.ip_protocol 如果匹配 icmpudptcp(不区分大小写),则映射到相应的大写值。
proto event.idm.read_only_udm.network.application_protocol 如果为 sshssh2,则设置为 SSH
pwd event.idm.read_only_udm.target.file.full_path 直接映射。
reason security_result.summarysecurity_result.description actiondesc 结合使用,以创建 security_result.description。还映射到 security_result.summary
relayHostname event.idm.read_only_udm.intermediary.hostname 直接映射。
relayIp event.idm.read_only_udm.intermediary.ip 直接映射。
res security_result.summary 直接映射。
resource.labels.instance_id event.idm.read_only_udm.target.resource.product_object_id 直接映射。
resource.labels.project_id event.idm.read_only_udm.target.asset.attribute.cloud.project.id 直接映射。
resource.labels.zone event.idm.read_only_udm.target.asset.attribute.cloud.availability_zone 直接映射。
resource.type event.idm.read_only_udm.target.resource.resource_subtype 直接映射。
response_code event.idm.read_only_udm.network.http.response_code 直接映射,转换为整数。
ResponderBytes event.idm.read_only_udm.network.received_bytes 直接映射,转换为无符号整数。
ResponderPackets event.idm.read_only_udm.network.received_packets 直接映射,转换为整数。
rhost event.idm.read_only_udm.additional.fields 键:rhost,值:rhost
ruser srcUser 直接映射。
sec_action security_result.action 根据 actioneventType 进行映射。
sec_summary security_result.summary 直接映射。
security_action security_result.action 直接映射。
sent_bytes event.idm.read_only_udm.network.sent_bytes 直接映射,转换为无符号整数。
ses event.idm.read_only_udm.network.session_idevent.idm.read_only_udm.network.session_duration 如果为数值,则解析为 UNIX 时间戳并映射到 session_duration。否则,映射到 session_id
SeverityLevel security_result.severity 根据值映射到不同的严重程度(通知/信息 -> INFORMATIONAL,警告 -> HIGH,错误 -> ERROR,其他 -> UNKNOWN_SEVERITY)。
sessionId event.idm.read_only_udm.network.session_id 直接映射。
size event.idm.read_only_udm.network.received_bytes 直接映射,转换为无符号整数。
source event.idm.read_only_udm.principal.hostnameevent.idm.read_only_udm.principal.asset.hostname 移除开头的空格后的直接映射。
SourceSystem event.idm.read_only_udm.principal.resource.attribute.labelsevent.idm.read_only_udm.principal.platform 键:SourceSystem,值:SourceSystem。还映射到 platform(Linux -> LINUX,Window -> WINDOWS,Mac/iOS -> MAC)。
SrcIP event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 直接映射。
SrcPort event.idm.read_only_udm.principal.port 直接映射,转换为整数。
srcIp event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 直接映射。
srcPort event.idm.read_only_udm.principal.port 直接映射,转换为整数。
srcUser event.idm.read_only_udm.principal.user.userid 直接映射。
src_user event.idm.read_only_udm.principal.user.userid 直接映射。
src_user_display_name event.idm.read_only_udm.principal.user.user_display_name 直接映射。
status security_result.action 如果为 Deferred,则设置为 BLOCK。如果为 Sent,则设置为 ALLOW
summary security_result.summary 直接映射。
SyslogMessage security_result.description 直接映射。
targetEmail event.idm.read_only_udm.network.email.to 直接映射。
targetEmailfrom event.idm.read_only_udm.network.email.from 直接映射。
targetHostname event.idm.read_only_udm.target.hostnameevent.idm.read_only_udm.target.asset.hostname 直接映射。
target_hostname event.idm.read_only_udm.target.hostnameevent.idm.read_only_udm.target.asset.hostname 直接映射。
target_ip event.idm.read_only_udm.target.ipevent.idm.read_only_udm.target.asset.ip 直接映射。
target_mac event.idm.read_only_udm.target.mac 直接映射。
target_uri event.idm.read_only_udm.target.url 直接映射。
TenantId event.idm.read_only_udm.principal.user.product_object_id 直接映射。
terminal event.idm.read_only_udm.additional.fields 键:terminal,值:terminal(如果不为空)或 ?
TimeGenerated event.idm.read_only_udm.metadata.collected_timestamp 解析为时间戳。
timestamp @timestamp 解析为时间戳。
tls_cipher event.idm.read_only_udm.network.tls.cipher 直接映射。
Type event.idm.read_only_udm.principal.resource.attribute.labels 键:Type,值:Type
uid event.idm.read_only_udm.principal.user.userid 如果为 0,则设置为 root。否则,直接映射。
uid_2 event.idm.read_only_udm.target.user.userid 如果 uid 为空,则直接映射。
unit event.idm.read_only_udm.target.application 直接映射。
url event.idm.read_only_udm.target.url 直接映射。
user username 直接映射。
username event.idm.read_only_udm.target.user.useridevent.idm.read_only_udm.principal.user.userid 直接映射。
user_display_name event.idm.read_only_udm.target.user.user_display_name 直接映射。
user_present event.idm.read_only_udm.metadata.event_type 如果 trueprincipal_presenttrue,则将 event_type 设置为 USER_UNCATEGORIZED
_Internal_WorkspaceResourceId event.idm.read_only_udm.target.resource.attribute.labelsevent.idm.read_only_udm.target.resource.product_object_id 键:_Internal_WorkspaceResourceId,值:_Internal_WorkspaceResourceId。系统会提取订阅 ID 并将其映射到 product_object_id
_ItemId event.idm.read_only_udm.principal.resource.attribute.labels 键:_ItemId,值:_ItemId
_ResourceId event.idm.read_only_udm.principal.resource.attribute.labelsevent.idm.read_only_udm.principal.resource.product_object_id 键:_ResourceId,值:_ResourceId。系统会提取订阅 ID 并将其映射到 product_object_id
_timestamp @timestamp 解析为时间戳。
_timestamp_tz @timestamp 解析为时间戳。
  • event.idm.read_only_udm.metadata.event_type:最初设置为 GENERIC_EVENT,然后根据解析器逻辑进行覆盖。
  • event.idm.read_only_udm.metadata.product_name:硬编码为 Unix System
  • event.idm.read_only_udm.extensions.auth.type:对于某些事件类型,设置为 MACHINE
  • event.idm.read_only_udm.target.asset.attribute.cloud.environment:对于 Google Cloud 审核日志,请设置为 GOOGLE_CLOUD_PLATFORM
  • event.idm.read_only_udm.target.resource.resource_type:对于 Google Cloud 审核日志,请设置为 VIRTUAL_MACHINE
  • event.idm.read_only_udm.extensions.auth.mechanism:对于登录事件,设置为 USERNAME_PASSWORD
  • has_target_resource:如果存在 resource.labels.instance_id_Internal_WorkspaceResourceId,则设置为 true

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