收集 PowerShell 日志

支持的语言:

本文档介绍了如何使用 Bindplane 将 PowerShell 日志收集到 Google Security Operations。解析器会将原始 Microsoft PowerShell 日志转换为统一数据模型 (UDM)。它首先从原始日志消息中提取字段,将这些字段标准化为 UDM 字段,然后根据特定事件 ID 使用其他上下文来扩充数据,最终创建用于安全分析的结构化 UDM 事件。

准备工作

  • 确保您拥有 Google SecOps 实例。
  • 确保您使用的是 Windows 2016 或更高版本。
  • 如果通过代理运行,请确保防火墙端口处于开放状态。

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

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

获取 Google SecOps 客户 ID

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

在 Windows 上安装 Bindplane 代理

  1. 以管理员身份打开命令提示符PowerShell
  2. 运行以下命令:

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    

其他安装资源

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

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

  1. 在配置 YAML 文件之前,请在“服务”面板中停止 observIQ Distro for Open Telemetry Collector 服务
  2. 访问配置文件:

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

    receivers:
      windowseventlog/powershell:
        channel: Microsoft-Windows-PowerShell/Operational
        max_reads: 100
        poll_interval: 5s
        raw: true
        start_at: end
    
    processors:
      batch:
    
    exporters:
      chronicle/powershell:
        endpoint: malachiteingestion-pa.googleapis.com
        # Adjust the path to the credentials file you downloaded in Step 1
        creds: '/path/to/ingestion-authentication-file.json'
        log_type: 'POWERSHELL'
        override_log_type: false
        raw_log_field: body
        customer_id: '<customer_id>'
    
    service:
      pipelines:
        logs/winpowershell:
          receivers:
            - windowseventlog/powershell
          processors: [batch]
          exporters: [chronicle/powershell] 
    
  4. <customer_id> 替换为实际的客户 ID。

  5. /path/to/ingestion-authentication-file.json 更新为获取 Google SecOps 提取身份验证文件部分中保存身份验证文件的路径。

  6. 保存 config.yaml 文件后,启动 observIQ Distro for Open Telemetry Collector 服务

重启 Bindplane 代理以应用更改

  • 如需在 Windows 中重启 Bindplane 代理,您可以使用服务控制台,也可以输入以下命令:

    net stop BindPlaneAgent && net start BindPlaneAgent
    

UDM 映射表

日志字段 UDM 映射 逻辑
AccountName principal.user.userid 直接从原始日志中的 AccountName 字段映射。
ActivityID security_result.detection_fields[0].value 直接从原始日志中的 ActivityID 字段映射。移除了大括号。
渠道 未映射到 IDM 对象。
collection_time.nanos 未映射到 IDM 对象。
collection_time.seconds 未映射到 IDM 对象。
命令 未映射到 IDM 对象。
CommandLine 未映射到 IDM 对象。
计算机 principal.hostname 如果存在,则直接从原始日志中的 Computer 字段映射。
ContextInfo 未映射到 IDM 对象。
ContextInfo_Command Name security_result.detection_fields[0].value 如果存在,则直接从原始日志中的 ContextInfo_Command Name 字段映射。
ContextInfo_Command 类型 security_result.detection_fields[1].value 如果存在,则直接从原始日志中的 ContextInfo_Command Type 字段映射。
ContextInfo_宿主应用 target.process.command_line 如果不存在 powershell.Host Application,则直接从原始日志中的 ContextInfo_Host Application 字段映射。
ContextInfo_Host ID target.asset.asset_id 如果不存在 powershell.Host ID,则直接从原始日志中的 ContextInfo_Host ID 字段映射。该值带有 Host ID: 前缀。
ContextInfo_主机名 target.hostname 如果不存在 powershell.Host Name,则直接从原始日志中的 ContextInfo_Host Name 字段映射。
ContextInfo_脚本名称 target.process.file.full_path 如果不存在 script_name,则直接从原始日志中的 ContextInfo_Script Name 字段映射。
ContextInfo_序列号 security_result.detection_fields[2].value 如果存在,则直接从原始日志中的 ContextInfo_Sequence Number 字段映射。转换为字符串。
ContextInfo_Severity 未映射到 IDM 对象。
create_time.nanos 未映射到 IDM 对象。
create_time.seconds 未映射到 IDM 对象。
customer_id 未映射到 IDM 对象。
数据 未映射到 IDM 对象。
数据 security_result.detection_fields[0].value 如果存在,则直接从原始日志中的 Data 字段映射。
Data_1 security_result.detection_fields[1].value 如果存在,则直接从原始日志中的 Data_1 字段映射。
Data_2 security_result.detection_fields[2].value 如果存在,则直接从原始日志中的 Data_2 字段映射。
网域 principal.administrative_domain 直接从原始日志中的 Domain 字段映射。
entries 未映射到 IDM 对象。
ERROR_EVT_UNRESOLVED 未映射到 IDM 对象。
EventCategory 未映射到 IDM 对象。
EventData 未映射到 IDM 对象。
EventID metadata.product_event_type、security_result.rule_name 直接从原始日志中的 EventID 字段映射。该值以 EventID: 为前缀,用于 security_result.rule_name 字段。
EventLevel 未映射到 IDM 对象。
EventLevelName security_result.severity 根据 EventLevelName 的值进行映射:
- Information 映射到 INFORMATIONAL
- Verbose 映射到 LOW
EventLog 未映射到 IDM 对象。
EventReceivedTime 未映射到 IDM 对象。
EventType 未映射到 IDM 对象。
EventTime metadata.event_timestamp 用于提取时间戳(如果存在)。
ExecutionProcessID principal.process.pid 如果原始日志中存在 ExecutionProcessID 字段且该字段不为空或不为 0,则直接从该字段映射。转换为字符串。
ExecutionThreadID security_result.detection_fields[2].value 如果原始日志中存在 ExecutionThreadID 字段且该字段不为空或不为 0,则直接从该字段映射。转换为字符串。
文件 target.process.file.full_path 如果存在,则直接从原始日志中的 File 字段映射。
宿主应用 未映射到 IDM 对象。
HostApplication 未映射到 IDM 对象。
主机名 principal.hostname 直接从原始日志中的 Hostname 字段映射。
id 未映射到 IDM 对象。
关键字 未映射到 IDM 对象。
log_type metadata.log_type 直接从原始日志中的 log_type 字段映射。
机器 principal.asset.asset_id, principal.asset.platform_software.platform_version 系统会解析 Machine 字段,以提取机器 ID 和平台信息。机器 ID 的前缀为 Machine ID:。平台会根据值映射到 UDM 枚举:
- win 映射到 WINDOWS
- mac 映射到 MAC
- lin 映射到 LINUX
- 其他值映射到 UNKNOWN_PLATFORM
ManagementGroupName additional.fields[0].value.string_value 如果存在,则直接从原始日志中的 ManagementGroupName 字段映射。
Message.EventTime metadata.event_timestamp 用于提取时间戳(如果存在)。转换为字符串。
Message.Message security_result.description 如果 EventID 位于 [403, 4103, 4104] 中且为 message_message_not_found,则直接从原始日志中的 Message.Message 字段映射。将回车符和制表符替换为英文逗号。
消息 security_result.description 如果存在,则直接从原始日志中的 Message 字段映射。
MessageNumber 未映射到 IDM 对象。
MessageSourceAddress principal.ip 如果存在,则直接从原始日志中的 MessageSourceAddress 字段映射。
MessageTotal 未映射到 IDM 对象。
MG 未映射到 IDM 对象。
操作码 metadata.description 直接从原始日志中的 Opcode 字段映射。
OpcodeValue 未映射到 IDM 对象。
输出 security_result.detection_fields[0].value 如果存在,则直接从原始日志中的 Output 字段映射。
powershell.命令名称 security_result.detection_fields[0].value 如果存在,则直接从 powershell.Command Name 字段映射。
powershell.Command Type security_result.detection_fields[1].value 如果存在,则直接从 powershell.Command Type 字段映射。
powershell.Host Application target.process.command_line 如果存在,则直接从原始日志中的 powershell.Host Application 字段映射。
powershell.Host ID target.asset.asset_id 如果存在,则直接从原始日志中的 powershell.Host ID 字段映射。该值带有 Host ID: 前缀。
powershell.Host Name target.hostname 如果存在,则直接从原始日志中的 powershell.Host Name 字段映射。
powershell.HostApplication target.process.command_line 如果存在,则直接从原始日志中的 powershell.HostApplication 字段映射。
powershell.HostId target.asset.asset_id 如果存在,则直接从原始日志中的 powershell.HostId 字段映射。该值带有 Host ID: 前缀。
powershell.HostName target.hostname 如果存在,则直接从原始日志中的 powershell.HostName 字段映射。
powershell.脚本名称 target.process.file.full_path 如果存在,则直接从原始日志中的 powershell.Script Name 字段映射。
powershell.ScriptName target.process.file.full_path 如果存在,则直接从原始日志中的 powershell.ScriptName 字段映射。
powershell.序列号 security_result.detection_fields[2].value 如果存在,则直接从原始日志中的 powershell.Sequence Number 字段映射。
powershell.SequenceNumber security_result.detection_fields[0].value 如果存在,则直接从原始日志中的 powershell.SequenceNumber 字段映射。
powershell.UserId principal.user.userid 如果存在,则直接从原始日志中的 powershell.UserId 字段映射。
进程 ID principal.process.pid 如果原始日志中存在 Process ID 字段,且 ExecutionProcessIDProcessID 不存在、为空或为 0,则直接从 Process ID 字段映射。转换为字符串。
ProcessID principal.process.pid 如果 ExecutionProcessID 不存在、为空或为 0,则直接从原始日志中的 ProcessID 字段映射。转换为字符串。
ProviderGuid metadata.product_deployment_id 直接从原始日志中的 ProviderGuid 字段映射。移除了大括号。
PSEdition 未映射到 IDM 对象。
PSRemotingProtocolVersion 未映射到 IDM 对象。
PSVersion 未映射到 IDM 对象。
RecordNumber metadata.product_log_id 直接从原始日志中的 RecordNumber 字段映射。转换为字符串。
RenderedDescription security_result.description 如果存在,则直接从原始日志中的 RenderedDescription 字段映射。
RunAs 用户 未映射到 IDM 对象。
ScriptBlockId 未映射到 IDM 对象。
ScriptBlockText security_result.detection_fields[0].value 如果存在,则直接从原始日志中的 ScriptBlockText 字段映射。
ScriptBlock ID 未映射到 IDM 对象。
严重程度 security_result.severity、security_result.severity_details 根据 Severity 的值进行映射:
-verboseinfo 映射到 LOW
- warnerr 映射到 MEDIUM
- crit 映射到 HIGH
原始值也会映射到 security_result.severity_details
source.collector_id 未映射到 IDM 对象。
source.customer_id 未映射到 IDM 对象。
来源 additional.fields[1].value.string_value 如果存在,则直接从原始日志中的 Source 字段映射。
SourceModuleName principal.resource.name 直接从原始日志中的 SourceModuleName 字段映射。
SourceModuleType principal.resource.resource_subtype 直接从原始日志中的 SourceModuleType 字段映射。
SourceName metadata.product_name 直接从原始日志中的 SourceName 字段映射。
start_time.nanos 未映射到 IDM 对象。
start_time.seconds 未映射到 IDM 对象。
TenantId additional.fields[2].value.string_value 如果存在,则直接从原始日志中的 TenantId 字段映射。
ThreadID 未映射到 IDM 对象。
timestamp.nanos 未映射到 IDM 对象。
timestamp.seconds 未映射到 IDM 对象。
类型 未映射到 IDM 对象。
UserID principal.user.windows_sid 直接从原始日志中的 UserID 字段映射。
用户名 principal.user.userid 如果不存在 AccountName,则直接从原始日志中的 Username 字段映射。
metadata.vendor_name 设置为 Microsoft
metadata.event_type 如果 EventID4104Message 中存在 _Path,或者 EventID4103,或者 EventID 位于 [800, 600, 400] 中且存在 powershell.ScriptNamepowershell.HostApplication,则设置为 PROCESS_LAUNCH。如果 EventID403_HostApplication 存在于 Message 中,或者如果 EventID403NewEngineStateStopped,则设置为 PROCESS_TERMINATION。如果 EventID4104Message 中不存在 _Path,或者如果 EventID4103no_valuescript_name 为空、script_name_not_foundhost_application_not_found 均为 true,或者如果 EventID53504,或者如果 EventID40962,或者如果 EventID40961,或者如果 EventID 为空且存在 MessageSourceAddress,则设置为 STATUS_UPDATE。如果 EventID 为空且 Username 存在,则设置为 USER_UNCATEGORIZED。如果 EventID 为空且 MessageSourceAddressUsername 不存在,则设置为 GENERIC_EVENT
metadata.product_name 如果 SourceName 不存在,则设置为 Powershell
security_result.action 设置为 ALLOW
security_result.detection_fields[0].key 设置为 Activity ID
security_result.detection_fields[1].key 设置为 Sequence Number
security_result.detection_fields[2].key 设置为 ExecutionThreadID
additional.fields[0].key 设置为 Management Group Name
additional.fields[1].key 设置为 Source
additional.fields[2].key 设置为 TenantId
principal.asset.platform_software.platform 如果 platform_software 包含 win,则设置为 WINDOWS;如果包含 mac,则设置为 MAC;如果包含 lin,则设置为 LINUX;否则设置为 UNKNOWN_PLATFORM
target.process.file.full_path 如果 EventID4104_Path 存在于 Message 中,则设置为 _Path。如果 EventID4104file_path 存在于 Message 中,则设置为 file_path。如果 EventID403Message 中存在 _HostApplication,则设置为 _HostApplication

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