收集 ClamAV 日志
解析器版本:3.0
本文档介绍了如何使用 Bindplane 代理将 ClamAV 日志注入 Google Security Operations。
ClamAV 是一款开源防病毒引擎,旨在检测特洛伊木马、病毒、恶意软件和其他恶意威胁。它提供命令行扫描、自动签名数据库更新,并支持多种文件格式,包括归档文件、可执行文件和文档。ClamAV 在 Linux、Unix 和 Windows 系统上以本地守护程序 (clamd) 或命令行扫描器 (clamscan) 的形式运行。
准备工作
请确保满足以下前提条件:
- Google SecOps 实例
- Windows Server 2016 或更高版本,或者具有
systemd的 Linux 主机 - Bindplane 代理主机与 ClamAV 服务器之间的网络连接
- 如果在代理后面运行,请确保根据 Bindplane 代理要求打开防火墙端口
- 在 Linux 端点上安装并运行 ClamAV
- 对 ClamAV 服务器和 Bindplane 代理主机的根访问权限或 sudo 访问权限
获取 Bindplane 代理的 Google SecOps 凭据
如需向 Google SecOps 验证 Bindplane 代理,请选择以下方法之一:
- 新部署:使用 Chronicle API(选项 1)。
- 旧版部署:继续使用提取身份验证文件(方法 2),直到提取 API 于 2027 年 7 月 20 日停用。
方法 1:为 Chronicle API 创建服务账号(推荐)
- 登录 Google Cloud 控制台,然后选择与您的 Google SecOps 实例关联的 Google Cloud 项目。
- 前往 IAM 和管理 > 服务账号。
- 点击创建服务账号。
- 提供以下配置详细信息:
- 服务账号名称:输入账号的名称(例如
bindplane-ingest)。 - 服务账号说明:输入说明(例如
Bindplane agent log ingestion)。
- 服务账号名称:输入账号的名称(例如
- 点击创建并继续。
- 在向此服务账号授予对项目的访问权限部分,点击选择角色,然后选择 Chronicle Editor。
- 点击继续,然后点击完成。
- 点击您创建的服务账号,然后前往密钥标签页。
- 依次点击添加密钥 > 创建新密钥。
- 选择 JSON,然后点击创建。密钥文件会下载到您的计算机上。
- 将密钥文件另存为 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以与您保存密钥文件的路径相匹配。 - 前往 IAM 和管理 > 设置,然后复制项目编号。您在配置导出器时需要用到该名称。
方法 2:下载数据注入身份验证文件(旧版)
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载数据注入身份验证文件。
- 将文件安全地保存在将安装 Bindplane 代理的系统上。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 前往 SIEM 设置 > 个人资料。
从组织详细信息部分复制并保存客户 ID。
安装 Bindplane 代理
根据以下说明,在 Windows 或 Linux 操作系统上安装 Bindplane 代理。
Windows 安装
- 以管理员身份打开命令提示符或 PowerShell。
运行以下命令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet等待安装完成。
运行以下命令,验证安装是否成功:
sc query observiq-otel-collector服务状态应为 RUNNING。
Linux 安装
- 打开具有 root 或 sudo 权限的终端。
运行以下命令:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh等待安装完成。
运行以下命令,验证安装是否成功:
sudo systemctl status observiq-otel-collector服务状态应为有效(正在运行)。
其他安装资源
如需了解其他安装选项和问题排查信息,请参阅 Bindplane 代理安装指南。
配置 Bindplane 代理以注入 syslog 并将日志发送到 Google SecOps
找到配置文件
Linux:
sudo nano /opt/observiq-otel-collector/config.yamlWindows:
notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
修改配置文件
将
config.yaml的全部内容替换为以下配置:receivers: udplog: listen_address: "0.0.0.0:514" exporters: chronicle/clamav: 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: 'YOUR_CUSTOMER_ID' endpoint: chronicle.googleapis.com log_type: CLAM_AV raw_log_field: body ingestion_labels: env: production service: pipelines: logs/clamav_to_chronicle: receivers: - udplog exporters: - chronicle/clamav替换以下占位符:
接收器配置:
listen_address:设置为0.0.0.0:514可在 UDP 端口 514 上监听所有接口。如果端口 514 在 Linux 上需要 root 权限,请使用0.0.0.0:1514并将 rsyslog 配置为转发到端口 1514。
导出器配置:
creds_file_path:服务账号 JSON 密钥文件的完整路径(选项 1):- Linux:
/opt/observiq-otel-collector/ingestion-auth.json - Windows:
C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
- Linux:
customer_id:将YOUR_CUSTOMER_ID替换为之前获得的客户 IDlocation:将<LOCATION>替换为 Google SecOps 实例所在的区域(例如us、europe或asia-southeast1)。导出工具会在此值前面加上chronicle.googleapis.com。如需查看完整列表,请参阅区域级端点。project:将<PROJECT_NUMBER>替换为“IAM 和管理”>“设置”中的项目编号。endpoint:保持设置为chronicle.googleapis.com。log_type:设置为CLAM_AV(与 Google SecOps 解析器完全匹配)ingestion_labels:YAML 格式的可选标签(例如env: production)
旧版提取 API
如果您使用选项 2 中的数据注入身份验证文件,请将
exporters代码块替换为以下内容。将creds_file_path设置为数据注入身份验证文件的路径,如果您的实例位于美国境外,请将malachiteingestion-pa.googleapis.com替换为您的区域端点(例如europe-malachiteingestion-pa.googleapis.com)。exporters: chronicle/clamav: compression: gzip creds_file_path: '/opt/observiq-otel-collector/ingestion-auth.json' customer_id: 'YOUR_CUSTOMER_ID' endpoint: malachiteingestion-pa.googleapis.com log_type: CLAM_AV raw_log_field: body ingestion_labels: env: production
保存配置文件
修改后,保存文件:
- Linux:依次按
Ctrl+O、Enter和Ctrl+X - Windows:依次点击文件 > 保存
重启 Bindplane 代理以应用更改
如需在 Linux 中重启 Bindplane 代理,请执行以下操作:
运行以下命令:
sudo systemctl restart observiq-otel-collector验证服务是否正在运行:
sudo systemctl status observiq-otel-collector检查日志中的错误:
sudo journalctl -u observiq-otel-collector -f
如需在 Windows 中重启 Bindplane 代理,请执行以下操作:
请从下列选项中选择一项:
以管理员身份运行命令提示符或 PowerShell:
net stop observiq-otel-collector && net start observiq-otel-collector服务控制台:
- 按
Win+R,输入services.msc,然后按 Enter 键。 - 找到 observIQ OpenTelemetry 收集器。
- 右键点击并选择重启。
- 按
验证服务是否正在运行:
sc query observiq-otel-collector检查日志中的错误:
type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
配置 ClamAV syslog 转发
在 ClamAV 中启用 syslog 日志记录
- 使用 root 或 sudo 权限登录运行 ClamAV 的 Linux 系统。
打开 ClamAV 守护程序配置文件:
sudo nano /etc/clamav/clamd.conf找到包含
#LogSyslog yes或#LogSyslog true的行。移除
#注释字符以启用 syslog 日志记录:LogSyslog yes可选:配置 syslog 设施。找到
#LogFacility LOG_LOCAL6这行代码并取消注释:LogFacility LOG_LOCAL6可选:启用其他日志记录选项以获取更详细的日志:
LogTime yes LogVerbose yes ExtendedDetectionInfo yesLogTime:为日志消息添加时间戳LogVerbose:启用详细日志记录,提供更多细节ExtendedDetectionInfo:包含文件大小和哈希值,以及病毒检测结果
保存文件并退出:
依次按
Ctrl+O、Enter、Ctrl+X重启 ClamAV 守护程序以应用更改:
sudo systemctl restart clamav-daemon验证 ClamAV 守护程序是否正在运行:
sudo systemctl status clamav-daemon
配置 rsyslog 以转发 ClamAV 日志
为 ClamAV 转发创建新的 rsyslog 配置文件:
sudo nano /etc/rsyslog.d/30-clamav-forward.conf添加以下配置,以将 ClamAV 日志转发到 Bindplane 代理:
# Forward ClamAV logs (LOG_LOCAL6 facility) to Bindplane agent if $syslogfacility-text == 'local6' then { action( type="omfwd" protocol="udp" target="BINDPLANE_AGENT_IP" port="514" queue.type="linkedList" queue.size="10000" action.resumeRetryCount="100" ) stop }将
BINDPLANE_AGENT_IP替换为 Bindplane 代理主机的 IP 地址:- 如果 Bindplane 与 ClamAV 安装在同一主机上,请使用
127.0.0.1 - 如果 Bindplane 位于其他主机上,请使用该主机的 IP 地址(例如
192.168.1.100)
- 如果 Bindplane 与 ClamAV 安装在同一主机上,请使用
如果您将 Bindplane 配置为监听其他端口(例如
1514),请相应地更新port参数。保存文件并退出:
依次按
Ctrl+O、Enter和Ctrl+X验证 rsyslog 配置语法:
sudo rsyslogd -N1重启 rsyslog 以应用更改:
sudo systemctl restart rsyslog验证 rsyslog 是否正在运行:
sudo systemctl status rsyslog
测试配置
使用 EICAR 测试文件生成测试病毒检测:
cd /tmp echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > eicar.com使用 ClamAV 扫描测试文件:
sudo clamdscan /tmp/eicar.com验证检测结果是否显示在系统日志中:
sudo tail -f /var/log/syslog | grep clamd您应该会看到类似如下的日志条目:
Jan 15 10:30:45 hostname clamd[1234]: /tmp/eicar.com: Win.Test.EICAR_HDB-1(44d88612fea8a8f36de82e1278abb02f:68) FOUND检查 Bindplane 代理日志,验证日志是否正在转发:
sudo journalctl -u observiq-otel-collector -f验证日志是否显示在 Google SecOps 中:
- 登录 Google SecOps 控制台。
- 依次前往搜索 > UDM 搜索。
运行搜索查询以查找 ClamAV 日志:
metadata.log_type = "CLAM_AV"
清理测试文件:
sudo rm /tmp/eicar.com
替代配置:将所有 syslog 消息转发到 Bindplane
如果您想将所有 syslog 消息(而不仅仅是 ClamAV)转发到 Bindplane,请使用以下更简单的配置:
修改 rsyslog 配置:
sudo nano /etc/rsyslog.d/30-forward-all.conf添加以下配置:
# Forward all logs to Bindplane agent *.* action( type="omfwd" protocol="udp" target="BINDPLANE_AGENT_IP" port="514" queue.type="linkedList" queue.size="10000" action.resumeRetryCount="100" )将
BINDPLANE_AGENT_IP替换为适当的 IP 地址。按照上述步骤保存、验证并重启 rsyslog。
UDM 映射表
| 日志字段 | UDM 映射 | 逻辑 |
|---|---|---|
| parsed_msg.resource.labels.instance_id | observer.resource.id | 直接复制的值 |
| parsed_msg.labels.compute.googleapis.com/resource_name | observer.resource.name | 直接复制的值 |
| parsed_msg.resource.type, parsed_msg.labels.container.googleapis.com/stream | observer.resource.type | 由 parsed_msg.resource.type 和 parsed_msg.labels.container.googleapis.com/stream 串联而成,中间用“/”分隔 |
| parsed_msg.resource.labels.project_id, parsed_msg.resource.labels.cluster_name, parsed_msg.resource.labels.container_name | observer.hostname | 由 parsed_msg.resource.labels.project_id、parsed_msg.resource.labels.cluster_name 和 parsed_msg.resource.labels.container_name 串联而成,并使用“/”分隔符 |
| parsed_msg.resource.labels.container_name | observer.application | 直接复制的值 |
| parsed_msg.labels.container.googleapis.com/namespace_name | observer.namespace | 直接复制的值 |
| parsed_msg.resource.labels.zone | observer.location.country_or_region | 直接复制的值 |
| parsed_msg.resource.labels.pod_id | observer.labels | 合并为键“pod_id”,其值来自 parsed_msg.resource.labels.pod_id |
| parsed_msg.resource.labels.project_id, parsed_msg.resource.labels.cluster_name, parsed_msg.resource.labels.container_name | principal.hostname | 由 parsed_msg.resource.labels.project_id、parsed_msg.resource.labels.cluster_name 和 parsed_msg.resource.labels.container_name 串联而成,并使用“/”分隔符 |
| file, _file_path | target.file.full_path | 如果从 Grok 模式提取,则为文件中的值;如果从替代 Grok 模式提取,则为 _file_path 中的值 |
| 威胁 | security_result.threat_name | 直接复制的值 |
| total_files, _outcome, threat | security_result.summary | 如果提取了 num_files,则设置为“发现 %{total_files} 个受感染的文件”。否则,设置为“已扫描文件。(%{_outcome})" if _outcome extracted, else "Threat %{threat} signature found." if threat not empty |
| 类别 | security_result.category | 直接复制的值(如果威胁不为空,则设置为“SOFTWARE_MALICIOUS”) |
| 操作 | security_result.action | 直接复制的值(如果威胁不为空,则设置为“BLOCK”;否则,如果提取了 _outcome,则设置为“ALLOW”) |
| parsed_msg.insertId | metadata.product_log_id | 直接复制值 |
| parsed_msg.logName | metadata.description | 直接复制的值 |
| metadata.event_type | 如果发现威胁或扫描了文件,则设置为“SCAN_FILE”;如果提取了受感染文件数量,则设置为“STATUS_UPDATE” | |
| metadata.product_name | 设置为“CLAMAV” | |
| metadata.vendor_name | 设置为“Cisco Systems” |
需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。