收集 Apache 日志
支持的语言:
Google SecOps
SIEM
本文档介绍了如何使用 Bindplane 将 Apache 日志注入到 Google Security Operations。解析器代码首先尝试将原始日志消息解析为 JSON。如果失败,则使用正则表达式(grok 模式)根据常见的 Apache 日志格式从消息中提取字段。
准备工作
- 确保您拥有 Google SecOps 实例。
- 确保您使用的是 Windows 2016 或更高版本,或者具有
systemd的 Linux 主机。 - 如果通过代理运行,请确保防火墙端口处于开放状态。
- 确保您对 Apache 实例拥有特权访问权限。
获取 Google SecOps 注入身份验证文件
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载注入身份验证文件。将文件安全地保存在将要安装 Bindplane 的系统上。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 配置文件。
- 复制并保存组织详细信息部分中的客户 ID。
安装 Bindplane 代理
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: 'APACHE' 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
在 Apache 中配置 Syslog
- 使用 SSH 登录 Ubuntu 服务器。
在
/etc/rsyslog.d/下创建一个名为02-apache2.conf的文件:vim /etc/rsyslog.d/02-apache2.conf在文件中添加以下代码:
module(load="imfile" PollingInterval="10" statefile.directory="/var/spool/rsyslog") input(type="imfile" File="/var/log/apache2/access.log" Tag="http_access" Severity="info" Facility="local6") Local6.info @<bindplane-agnet-ip>:<vindplane-agent-port> module(load="imfile" PollingInterval="10" statefile.directory="/var/spool/rsyslog") input(type="imfile" File="/var/log/apache2/error.log" Tag="http_error"- 将
bindplane-agent-ip>和bindplane-agent-port替换为为 Bindplane 代理配置的 IP 地址和端口 - 如果您使用的是 TCP 协议,请在主机行中附加一个额外的
@,使其看起来像这样:@@<bindplane-agnet-ip>:<vindplane-agent-port>。
- 将
重启 RSyslog 服务:
sudo service rsyslog restart
UDM 映射表
| 日志字段 | UDM 映射 | 逻辑 |
|---|---|---|
| 字节 | network.received_bytes | 从客户端接收的字节数。 |
| 字节 | network.sent_bytes | 发送到客户端的字节数。 |
| bytes_out | network.sent_bytes | 发送到客户端的字节数。 |
| bytes_received | network.received_bytes | 从客户端接收的字节数。 |
| 内容 | network.http.method | 从“Content”字段中提取的 HTTP 方法。 |
| 内容 | target.url | 从“内容”字段中提取的目标网址。 |
| 饼干 | additional.fields.value.string_value | “cookie”字段的值。 |
| dest_ip | target.ip | 目标的 IP 地址。 |
| dest_name | target.hostname | 目标的 hostname。 |
| dest_port | target.port | 目标端口。 |
| 说明 | metadata.description | 活动说明。 |
| duration_microseconds | additional.fields.value.string_value | “duration_microseconds”字段的值。 |
| file_full_path | target.file.full_path | 目标文件的完整路径。 |
| 主机名 | target.hostname | 目标的 hostname。 |
| http_content_type | additional.fields.value.string_value | “http_content_type”字段的值。 |
| http_host | principal.hostname | 正文的主机名。 |
| http_method | network.http.method | HTTP 方法。 |
| http_referrer | network.http.referral_url | HTTP 引荐来源网址。 |
| http_user_agent | network.http.user_agent | HTTP 用户代理。 |
| ID | metadata.id | 活动的 ID。 |
| insertId | metadata.product_log_id | 商品日志 ID。 |
| ip | principal.ip | 主账号的 IP 地址。 |
| jsonPayload.cIP | target.ip | 目标的 IP 地址。 |
| jsonPayload.cPort | target.port | 目标端口。 |
| jsonPayload.csBytes | network.sent_bytes | 发送到客户端的字节数。 |
| jsonPayload.csMethod | network.http.method | HTTP 方法。 |
| jsonPayload.csMimeType | target.file.mime_type | 目标文件的 MIME 类型。 |
| jsonPayload.csReferer | network.http.referral_url | HTTP 引荐来源网址。 |
| jsonPayload.csURL | target.url | 目标网址。 |
| jsonPayload.csUserAgent | network.http.user_agent | HTTP 用户代理。 |
| jsonPayload.sHierarchy | additional.fields.value.string_value | “sHierarchy”字段的值。 |
| jsonPayload.sHostname | principal.hostname | 正文的主机名。 |
| jsonPayload.sIP | principal.ip | 主账号的 IP 地址。 |
| jsonPayload.scBytes | network.received_bytes | 从客户端接收的字节数。 |
| jsonPayload.scHTTPStatus | network.http.response_code | HTTP 响应代码。 |
| jsonPayload.scResultCode | additional.fields.value.string_value | “scResultCode”字段的值。 |
| LastStatus | network.http.response_code | HTTP 响应代码。 |
| log_level | security_result.severity | 安全结果的严重程度。 |
| logName | security_result.category_details | 安全结果的类别详细信息。 |
| 方法 | network.http.method | HTTP 方法。 |
| pid | principal.process.pid | 主账号的进程 ID。 |
| 端口 | target.port | 目标端口。 |
| proto | network.application_protocol | 应用协议。 |
| 引荐来源网址 | network.http.referral_url | HTTP 引荐来源网址。 |
| RemoteHost | principal.ip | 主账号的 IP 地址。 |
| RemoteUser | principal.user.userid | 主账号的用户 ID。 |
| resource.labels.instance_id | target.resource.product_object_id | 目标资源的商品对象 ID。 |
| resource.labels.project_id | target.resource.attribute.labels.value | “project_id”标签的值。 |
| resource.labels.zone | target.resource.attribute.cloud.availability_zone | 目标资源的可用区。 |
| resource.type | target.resource.resource_type | 目标的资源类型。 |
| 回答 | network.http.response_code | HTTP 响应代码。 |
| SizeBytes | network.received_bytes | 从客户端接收的字节数。 |
| src_ip | principal.ip | 主账号的 IP 地址。 |
| src_port | principal.port | 主账号的端口。 |
| ssl_cipher | network.tls.cipher | TLS 加密算法。 |
| ssl_version | network.tls.version_protocol | TLS 版本协议。 |
| 状态 | network.http.response_code | HTTP 响应代码。 |
| 目标 | target.url | 目标网址。 |
| target_ip | target.ip | 目标的 IP 地址。 |
| target_port | target.port | 目标端口。 |
| 时间 | metadata.event_timestamp | 活动时间戳。 |
| uri_path | target.process.file.full_path | 目标文件的完整路径。 |
| 用户 | principal.user.userid | 主账号的用户 ID。 |
| 用户代理 | network.http.user_agent | HTTP 用户代理。 |
| version_protocol | network.tls.version_protocol | TLS 版本协议。 |
| workername | principal.hostname | 正文的主机名。 |
| x_forwarded_for | “X-Forwarded-For”标头的值。 | |
| metadata.log_type | 该值在解析器代码中设置为“APACHE”。 | |
| metadata.product_name | 在解析器代码中,该值设置为“Apache Web Server”。 | |
| metadata.vendor_name | 该值在解析器代码中设置为“Apache”。 | |
| metadata.event_type | 该值根据委托人和目标信息是否存在来确定。如果主账号和目标都存在,则事件类型设置为“NETWORK_HTTP”。如果仅存在主账号,则事件类型设置为“STATUS_UPDATE”。否则,该值会设置为“GENERIC_EVENT”。 | |
| additional.fields.key | 在解析器代码中,根据相应字段将键设置为“keep_alive”“duration_microseconds”“cookie”“http_content_type”“sHierarchy”“scResultCode”。 | |
| target.port | 如果“proto”字段为“HTTP”,则端口设置为 80。如果“proto”字段为“HTTPS”,则端口设置为 443。如果“proto”字段为“FTP”,则端口设置为 21。 | |
| target.resource.attribute.labels.key | 在解析器代码中,该键设置为“project_id”。 |
需要更多帮助?从社区成员和 Google SecOps 专业人士那里获得解答。