收集 MySQL 日志
本文档介绍了如何使用 Bindplane 将 MySQL 日志注入到 Google Security Operations。解析器首先使用 grok 从 MySQL SYSLOG 消息中提取通用字段。然后,它使用条件分支(if、else if)和正则表达式匹配来识别日志消息中的特定事件类型,并将相关信息提取并映射到统一数据模型 (UDM) 架构中。
准备工作
请确保满足以下前提条件:
- Google SecOps 实例
- Windows 2016 或更高版本,或者具有
systemd的 Linux 主机 - 如果在代理后运行,防火墙端口处于开放状态
- 对 MySQL 主机的特权访问权限
- 安装了 MySQL 数据库和 Rsyslog
获取 Google SecOps 注入身份验证文件
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载注入身份验证文件。将该文件安全地保存在将要安装 Bindplane 的系统上。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 配置文件。
- 复制并保存组织详细信息部分中的客户 ID。
安装 Bindlane 代理
Windows 安装
- 以管理员身份打开命令提示符或 PowerShell。
运行以下命令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
Linux 安装
- 打开具有 root 或 sudo 权限的终端。
运行以下命令:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
其他安装资源
如需了解其他安装选项,请参阅安装指南。
配置 Bindplane 代理以注入 Syslog 并将其发送到 Google SecOps
- 访问配置文件:
- 找到
config.yaml文件。通常,它位于 Linux 上的/etc/bindplane-agent/目录中或 Windows 上的安装目录中。 - 使用文本编辑器(例如
nano、vi或记事本)打开该文件。
- 找到
按如下方式修改
config.yaml文件:receivers: udplog: # Replace the port and IP address as required listen_address: "0.0.0.0:514" exporters: chronicle/chronicle_w_labels: compression: gzip # 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 ingestion_labels: log_type: 'MYSQL' raw_log_field: body service: pipelines: logs/source0__chronicle_w_labels-0: receivers: - udplog exporters: - chronicle/chronicle_w_labels根据基础架构的需要替换端口和 IP 地址。
将
<customer_id>替换为实际的客户 ID。将
/path/to/ingestion-authentication-file.json更新为获取 Google SecOps 提取身份验证文件部分中保存身份验证文件的路径。
重启 Bindplane 代理以应用更改
如需在 Linux 中重启 Bindplane 代理,请运行以下命令:
sudo systemctl restart bindplane-agent如需在 Windows 中重启 Bindplane 代理,您可以使用服务控制台,也可以输入以下命令:
net stop BindPlaneAgent && net start BindPlaneAgent
在 MySQL 中配置 Syslog
使用 SSH 登录 MySQL 主机。
连接到 MySQL 数据库:
mysql -u root -p验证
server_audit.so审核插件:show variables like 'plugin_dir';如果您在插件目录中找不到插件文件,请使用以下命令安装插件:
install plugin server_audit soname 'server_audit.so';确认插件已安装并已启用:
show plugins;使用
vi修改文件/etc/my.cnf,启用以下内容并保存文件:server_audit_events='CONNECT,QUERY,TABLE' server_audit_file_path=server_audit.log server_audit_logging=ON server_audit_output_type=SYSLOG server_audit_syslog_facility=LOG_LOCAL6使用以下命令验证审核变量:
show global variables like "server_audit%";使用以下命令验证是否已启用审核:
Show global status like 'server_audit%';使用
vi修改文件/etc/rsyslog.conf,以启用 UDP 并保存文件:*.* @@<bindplane-agent-ip>:<bindplane-agent-port>将
<bindplane-agent-ip>和<bindplane-agent-port>替换为您的 Bindplane 代理配置。重启 MySQL 服务并连接到 MySQL 数据库。
/etc/init.d/mysqld restart
UDM 映射表
| 日志字段 | UDM 映射 | 逻辑 |
|---|---|---|
| 操作 | read_only_udm.metadata.event_type | 如果值为 Created,则为 FILE_CREATION;如果值为 Deleted,则为 FILE_DELETION;否则为无变化。 |
| 数据库 | read_only_udm.target.resource.parent | |
| db_hostname | read_only_udm.target.hostname | |
| db_user | read_only_udm.target.user.userid | |
| 说明 | read_only_udm.security_result.description | |
| error_details | 这是一个临时变量,请忽略它 | |
| error_level | read_only_udm.security_result.severity | 如果值为 error,则为 ERROR;如果值为 warning,则为 MEDIUM;如果值为 note,则为 INFORMATIONAL;否则不进行更改。 |
| error_message | read_only_udm.security_result.summary | |
| file_path | read_only_udm.target.file.full_path | |
| file_size | read_only_udm.target.file.size | |
| 主机名 | read_only_udm.principal.hostname | |
| inner_message | read_only_udm.security_result.description | |
| 摘要 | read_only_udm.metadata.product_event_type | |
| 表 | read_only_udm.target.resource.name | |
| table_not_found | 这是一个临时变量,请忽略它 | |
| 时间戳 | read_only_udm.metadata.event_timestamp | |
| read_only_udm.extensions.auth.type | 静态价值 - MACHINE |
|
| read_only_udm.metadata.event_type | 静态值 - USER_LOGIN、GENERIC_EVENT、STATUS_UPDATE、FILE_CREATION、FILE_DELETION |
|
| read_only_udm.metadata.log_type | 静态价值 - MYSQL |
|
| read_only_udm.metadata.product_name | 静态价值 - MySQL |
|
| read_only_udm.metadata.vendor_name | 静态价值 - Oracle Corporation |
|
| read_only_udm.security_result.action | 静态价值 - BLOCK |
|
| read_only_udm.target.resource.resource_type | 静态值 - DATABASE、TABLE |
需要更多帮助?从社区成员和 Google SecOps 专业人士那里获得解答。