收集 Linux Audit Daemon 日志

支持的语言:

本文档介绍了如何使用 Bindplane 将 Linux 审核守护程序 (auditd) 日志注入 Google Security Operations。

Linux 审核守护程序是 Linux 审核系统的用户空间组件。它会记录系统上与安全相关的事件,包括文件访问、系统调用、身份验证事件和 SELinux 拒绝。Auditd 日志对于 Linux 主机上的合规性监控、入侵检测和取证分析至关重要。

准备工作

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

  • Google SecOps 实例。
  • Windows Server 2016 或更高版本,或者具有 systemd 的 Linux 主机。
  • 如果在代理后面运行,请确保按照 Bindplane 代理要求打开防火墙端口。
  • 对运行 auditd 的 Linux 主机的根访问权限或 sudo 访问权限。
  • 已在源 Linux 主机上安装并运行的 auditd 软件包。
  • 源 Linux 主机上安装的 audispd-plugins 软件包(提供 audisp-syslog 插件)。

获取 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
    

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 代理安装指南。

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

  1. 访问配置文件:

    • Linux:/opt/observiq-otel-collector/config.yaml
    • Windows:C:\Program Files\observIQ OpenTelemetry Collector\config.yaml
  2. 按如下方式修改 config.yaml 文件:

    receivers:
      udplog:
        # Replace the port and IP address as required
        listen_address: "0.0.0.0:514"
    
    exporters:
      chronicle/chronicle_w_labels:
        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
        # Adjust the path to the credentials file you downloaded in Step 1
        creds_file_path: '/path/to/ingestion-authentication-file.json'
        # Replace with your actual customer ID from Step 2
        customer_id: '<your_customer_id>'
        endpoint: chronicle.googleapis.com
        # Add optional ingestion labels for better organization
        log_type: 'AUDITD'
        raw_log_field: body
        ingestion_labels:
    
    service:
      pipelines:
        logs/source0__chronicle_w_labels-0:
          receivers:
            - udplog
          exporters:
            - chronicle/chronicle_w_labels
    
  • 根据您基础设施的需要替换端口和 IP 地址。
  • 将 <LOCATION> 替换为 Google SecOps 实例所在的区域(例如 us、europe 或 asia-southeast1)。导出工具会为此值添加 chronicle.googleapis.com 前缀。
  • 将 <PROJECT_NUMBER> 替换为 IAM 和管理 > 设置中的项目编号。
  • 将 <your_customer_id> 替换为实际客户 ID。
  • 将 /path/to/ingestion-authentication-file.json 更新为获取 Bindplane 代理的 Google SecOps 凭据部分中保存服务账号密钥文件(选项 1)的文件路径。

旧版提取 API

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

    exporters:
      chronicle/chronicle_w_labels:
        compression: gzip
        # Adjust the path to the credentials file you downloaded in Step 1
        creds_file_path: '/path/to/ingestion-authentication-file.json'
        # Replace with your actual customer ID from Step 2
        customer_id: '<your_customer_id>'
        endpoint: malachiteingestion-pa.googleapis.com
        # Add optional ingestion labels for better organization
        log_type: 'AUDITD'
        raw_log_field: body
        ingestion_labels:
    

重启 Bindplane 代理以应用更改

如需在 Linux 中重启 Bindplane 代理,请执行以下操作:

  1. 运行以下命令:

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

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

    sudo journalctl -u observiq-otel-collector -f
    

如需在 Windows 中重启 Bindplane 代理,请执行以下操作:

  1. 请从下列选项中选择一项:

    • 以管理员身份运行命令提示符或 PowerShell:
    net stop observiq-otel-collector && net start observiq-otel-collector
    
    • 服务控制台:
      1. 按 Win+R,输入 services.msc,然后按 Enter 键。
      2. 找到 observIQ OpenTelemetry 收集器。
      3. 右键点击并选择重启。
  2. 验证服务是否正在运行:

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

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

将 auditd 配置为通过 syslog 转发日志

audisp syslog 插件会将审核事件转发到 syslog,然后 syslog 会将这些事件发送到 Bindplane 代理。这是转发 auditd 日志的推荐方法。

安装 audisp syslog 插件

  1. 使用 root 或 sudo 权限登录运行 auditd 的 Linux 主机。
  2. 安装 audispd-plugins 软件包。

    • RHEL/CentOS/Fedora:
    sudo yum install audispd-plugins
    
    • Debian/Ubuntu:
    sudo apt install audispd-plugins
    

配置 syslog 插件

  1. 修改 syslog 插件配置文件:

    sudo nano /etc/audit/plugins.d/syslog.conf
    
  2. 在文件中设置以下值:

    active = yes
    direction = out
    path = /sbin/audisp-syslog
    type = always
    args = LOG_LOCAL6
    format = string
    
    • active:设置为 yes 以启用插件。
    • path:audisp-syslog 二进制文件的路径。
    • type:设置为 always,以将插件作为外部程序运行。
    • args:要使用的 syslog 设施。建议使用 LOG_LOCAL6 将审核日志与其他 syslog 消息分开。
    • format:设置为 string,以适合 syslog 的文本格式传递事件。

配置审核规则(可选)

  1. 修改审核规则文件,以定义要捕获的事件:

    sudo nano /etc/audit/rules.d/audit.rules
    
  2. 根据您的监控要求添加规则。例如:

    ## Delete all existing rules
    -D
    
    ## Set buffer size (increase for high-volume systems)
    -b 8192
    
    ## Set failure mode (1 = printk, 2 = panic)
    -f 1
    
    ## Monitor authentication-related files
    -w /etc/passwd -p wa -k identity
    -w /etc/group -p wa -k identity
    -w /etc/shadow -p wa -k identity
    -w /etc/sudoers -p wa -k sudoers
    
    ## Monitor login events
    -w /var/log/faillog -p wa -k logins
    -w /var/log/lastlog -p wa -k logins
    
    ## Monitor process execution
    -a always,exit -F arch=b64 -S execve -k exec
    
    ## Monitor network configuration changes
    -a always,exit -F arch=b64 -S sethostname -S setdomainname -k network
    
    ## Make the configuration immutable (must be the last rule)
    -e 2
    
  3. 加载新的审核规则:

    sudo augenrules --load
    

重启 auditd

  1. 重启 auditd 服务以应用插件和规则更改:

    sudo service auditd restart
    

配置 rsyslog 以将审核日志转发到 Bindplane

  1. 为审核日志转发创建新的 rsyslog 配置文件:

    sudo nano /etc/rsyslog.d/audit-forward.conf
    
  2. 添加以下代码行,以通过 UDP 将日志转发到 Bindplane 代理:

    local6.* @<BINDPLANE_IP>:514
    
  3. 重启 rsyslog 以应用更改:

    sudo systemctl restart rsyslog
    

验证日志转发

  1. 在源 Linux 主机上,生成测试审核事件:

    sudo auditctl -w /tmp/test_audit -p wa -k test_chronicle
    
  2. 通过触摸文件触发手表:

    touch /tmp/test_audit
    
  3. 在 Bindplane 代理主机上,验证是否正在接收日志:

    sudo journalctl -u observiq-otel-collector -f
    

UDM 映射表

日志字段 UDM 映射 逻辑
acct target.user.userid 从 acct 字段获取的值。
addr principal.ip 从 addr 字段获取的值(如果它是有效的 IP 地址)。
arch additional.fields 作为键值对添加,键为“arch”。
auid principal.user.userid 从 auid 字段获取的值。用作审核用户 ID。
comm target.process.command_line 从 comm 字段获取的值。
cwd additional.fields 以键值对的形式添加,键为“cwd”。
exe target.process.file.full_path 从 exe 字段获取的值。
exit additional.fields 以键值对的形式添加,键为“exit”。
gid principal.user.group_identifiers 从 gid 字段获取的值。
hostname principal.hostname 从 hostname 字段获取的值。
key security_result.detection_fields 以键值对的形式添加,键为“audit_key”。
msg metadata.description 从 msg 字段解析。包含审核事件消息。
name target.file.full_path 值取自 name 字段(如果适用)。
node principal.hostname 如果 hostname 不存在,则从 node 字段中获取值。
op metadata.product_event_type 从 op 字段(操作类型)获取的值。
pid principal.process.pid 从 pid 字段获取的值。
ppid principal.process.parent_process.pid 从 ppid 字段获取的值。
res security_result.action 如果 res 为“success”或“1”,则设置为“ALLOW”。如果 res 为“failed”或“0”,则设置为“BLOCK”。
ses network.session_id 从 ses 字段(会话 ID)获取的值。
subj principal.process.file.full_path 从 subj 字段(SELinux 主体上下文)获取的值。
syscall additional.fields 以键值对的形式添加,键为“syscall”。
terminal additional.fields 作为键值对添加,键为“terminal”。
type metadata.product_event_type 从 type 字段(审核记录类型,例如 SYSCALL、USER_LOGIN、EXECVE)获取的值。
uid principal.user.userid 从 uid 字段获取的值。
metadata.event_type 派生自审核记录类型。对于登录事件,设置为“USER_LOGIN”;对于退出事件,设置为“USER_LOGOUT”;对于执行事件,设置为“PROCESS_LAUNCH”;对于文件事件,设置为“FILE_MODIFICATION”。默认值为“GENERIC_EVENT”。
metadata.product_name 设置为“auditd”。
metadata.vendor_name 设置为“Linux”。
home event.idm.read_only_udm.additional.fields 从更新日志映射
shell event.idm.read_only_udm.additional.fields 从更新日志映射
name event.idm.read_only_udm.target.user.userid 从更新日志映射
name event.idm.read_only_udm.target.group.group_display_name 从更新日志映射
UID event.idm.read_only_udm.target.user.product_object_id 从更新日志映射
GID event.idm.read_only_udm.target.user.group_identifiers 从更新日志映射
GID event.idm.read_only_udm.target.group.product_object_id 从更新日志映射
key_type event.idm.read_only_udm.additional.fields 从更新日志映射
hash event.idm.read_only_udm.additional.fields 从更新日志映射
key_fingerprint event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
user event.idm.read_only_udm.target.user.userid 从更新日志映射
error_detail1 event.idm.read_only_udm.security_result.summary 从更新日志映射
service_name event.idm.read_only_udm.additional.fields 从更新日志映射
ssh_disconnect_code event.idm.read_only_udm.additional.fields 从更新日志映射
labels.bp_csoc event.idm.read_only_udm.additional.fields 从更新日志映射
labels.bp_env_id event.idm.read_only_udm.additional.fields 从更新日志映射
labels.log.file.name event.idm.read_only_udm.additional.fields 从更新日志映射
resource.labels.node_id event.idm.read_only_udm.additional.fields 从更新日志映射
intermediary_host event.idm.read_only_udm.intermediary.hostname 从更新日志映射
PWD event.idm.read_only_udm.target.file.full_path 从更新日志映射
log_details event.idm.read_only_udm.additional.fields 从更新日志映射
indicator.SUID event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.UID event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.AUID event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
type_crypto_props.msg event.idm.read_only_udm.additional.fields 从更新日志映射
usr event.idm.read_only_udm.principal.user.userid 从更新日志映射
pi event.idm.read_only_udm.principal.process.pid 从更新日志映射
cmnd event.idm.read_only_udm.target.process.command_line 从更新日志映射
proctitle_value event.idm.read_only_udm.principal.process.file.full_path 从更新日志映射
filename event.idm.read_only_udm.principal.process.file.names 从更新日志映射
filepath event.idm.read_only_udm.target.file.full_path 从更新日志映射
uid event.idm.read_only_udm.principal.user.userid 从更新日志映射
acct event.idm.read_only_udm.principal.user.user_display_name 从更新日志映射
exe event.idm.read_only_udm.target.process.file.full_path 从更新日志映射
pid event.idm.read_only_udm.principal.process.pid 从更新日志映射
auid event.idm.read_only_udm.about.user.userid 从更新日志映射
ses event.idm.read_only_udm.network.session_id 从更新日志映射
addr event.idm.read_only_udm.principal.ip和event.idm.read_only_udm.principal.asset.ip之间 从更新日志映射
subj event.idm.read_only_udm.additional.fields 从更新日志映射
res event.idm.read_only_udm.security_result.summary 从更新日志映射
op event.idm.read_only_udm.security_result.summary 从更新日志映射
msg_value event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
grantors_value event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.msg event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.grantors event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
terminal event.idm.read_only_udm.principal.application 从更新日志映射
sec_result event.idm.read_only_udm.security_result 从更新日志映射
hostname event.idm.read_only_udm.principal.hostname 从更新日志映射
indicator.mode event.idm.read_only_udm.src.user.attribute.permissions 从更新日志映射
indicator.nametype event.idm.read_only_udm.security_result.rule_name 从更新日志映射
indicator.cap_frootid event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.cap_fver event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.cap_fi event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.cap_fp event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
indicator.cap_fe event.idm.read_only_udm.security_result.detection_fields 从更新日志映射
OUID event.idm.read_only_udm.principal.user.userid 从更新日志映射
OGID event.idm.read_only_udm.principal.group.group_display_name 从更新日志映射
action_data event.idm.read_only_udm.security_result.action_details 从更新日志映射
target_email event.idm.ready_only_udm.target.user.email_addresses 从更新日志映射
target_port event.idm.ready_only_udm.target.port 从更新日志映射
status event.idm.ready_only_udm.security_result.action_details 从更新日志映射
to_email event.idm.ready_only_udm.network.email.to 从更新日志映射
target_hostname event.idm.ready_only_udm.target.hostname 从更新日志映射
"relay_data" event.idm.ready_only_udm.additional.fields 从更新日志映射
"delays_data" event.idm.ready_only_udm.additional.fields 从更新日志映射
"delay_data" event.idm.ready_only_udm.additional.fields 从更新日志映射
and "dns_data" event.idm.ready_only_udm.additional.fields 从更新日志映射
bytes_sent event.idm.ready_only_udm.network.sent_bytes 从更新日志映射
bytes_received event.idm.ready_only_udm.network.received_bytes 从更新日志映射
response_code event.idm.ready_only_udm.network.http.response_code 从更新日志映射
principal_user_name principal.user.userid 从更新日志映射
remote principal.ip 从更新日志映射
method network.http.method 从更新日志映射
path principal.file.full_path 从更新日志映射
code additional.fields 从更新日志映射
size principal.file.size 从更新日志映射
agent network.http.user_agent 从更新日志映射
az principal.location.name 从更新日志映射
ec2_instance_id principal.asset.product_object_id 从更新日志映射
private_ip principal.ip 从更新日志映射
ProviderName additional.fields 从更新日志映射
Version additional.fields 从更新日志映射
Task additional.fields 从更新日志映射
EventRecordID additional.fields 从更新日志映射
ThreadID additional.fields 从更新日志映射
messageType target.resource.attribute.labels 从更新日志映射
owner principal.user.userid 从更新日志映射
logevent.id metadata.product_log_id 从更新日志映射
logGroup secu_result.about.resource.name 从更新日志映射
logStream secu_result.about.resource.attribute.labels 从更新日志映射
ip_addr principal.ip 从更新日志映射
gd secu_result.description 从更新日志映射
process target.application 从更新日志映射
pid target.process.pid 从更新日志映射
status_code network.http.response_code 从更新日志映射
url network.http.referral_url 从更新日志映射
useragent network.http.user_agent 从更新日志映射
request additional.fields 从更新日志映射
tls_version network.tls.version 从更新日志映射
hostname_is principal.hostname 从更新日志映射
referrer network.http.referral_url 从更新日志映射
metadata.event_type USER_LOGIN 从更新日志映射
metadata.event_type PROCESS_UNCATEGORIZED 从更新日志映射
srcIP principal.ip 从更新日志映射
username principal.user.user_display_name 从更新日志映射
type_syscall_props.msg additional.fields 从更新日志映射
sw", "sw_type", and "subj security_result.detection_fields 从更新日志映射
indicator.SYSCALL security_result.detection_fields 从更新日志映射
exe principal.process.file.full_path 从更新日志映射
target.user.userid principal.user.userid 从更新日志映射
target_user_name target.user.userid 从更新日志映射
field field33 从更新日志映射
fp network.tls.client.certificate.sha256 从更新日志映射
pid principal.process.pid 从更新日志映射
syslog-tag security_result.detection_fields 从更新日志映射
inter_ip intermediary.ip 从更新日志映射
inter_hostname intermediary.hostname 从更新日志映射
grp target.group.group_display_name 从更新日志映射
id about.user.userid 从更新日志映射
acct target.user.user_display_name 从更新日志映射
uid principal.user.userid 从更新日志映射
auid about.user.userid 从更新日志映射
auid target.user.userid 从更新日志映射
op" and "id security_result.summary 从更新日志映射
op" and "acct security_result.summary 从更新日志映射
labels.compute.googleapis.com/resource_name","jsonPayload._HOSTNAME" , "CollectorHostName", "HOSTNAME", and "Computer principal.hostname 从更新日志映射
HostIP principal.ip 从更新日志映射
ProcessID" and "jsonPayload._PID principal.process.pid 从更新日志映射
SyslogMessage metadata.description 从更新日志映射
TenantId", "_ItemId", "_Internal_WorkspaceResourceId", "_ResourceId", and "Facility additional.fields 从更新日志映射
SeverityLevel security_result.severity 从更新日志映射
SourceSystem principal.platform 从更新日志映射
jsonPayload._COMM principal.application 从更新日志映射
jsonPayload._EXE target.process.file.full_path 从更新日志映射
jsonPayload._AUDIT_FIELD_FILE target.file.full_path 从更新日志映射
jsonPayload._AUDIT_FIELD_HASH target.file.hash 从更新日志映射
jsonPayload._AUDIT_SESSION network.session_id 从更新日志映射
jsonPayload._PPID principal.process.parent_process.pid 从更新日志映射
jsonPayload._AUDIT_FIELD_A0", "jsonPayload._AUDIT_FIELD_A1", "jsonPayload._AUDIT_FIELD_A2", "jsonPayload._AUDIT_FIELD_A3", "jsonPayload._BOOT_ID", and "jsonPayload._AUDIT_FIELD_EXIT security_result.detection_fields 从更新日志映射
id target.user.userid 从更新日志映射
ID target.user.user_display_name 从更新日志映射
user_name principal.user.userid 从更新日志映射
principal_user_userid principal.user.userid 从更新日志映射
vendor_name Linux 从更新日志映射
product_name AuditD 从更新日志映射
ip target.ip 从更新日志映射
success security_result.summary 从更新日志映射
syscall", "exit", "tty", "a0", "a1", "a2", "a3 security_result.about.labels 从更新日志映射

更新日志

查看此解析器的更新日志

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