收集 PowerShell 日志
支持的平台:
Google SecOps
SIEM
本文档介绍了如何使用 Bindplane 将 PowerShell 日志收集到 Google 安全运维团队。解析器会将原始 Microsoft PowerShell 日志转换为统一数据模型 (UDM)。它首先从原始日志消息中提取字段,将其标准化为 UDM 字段,然后根据特定事件 ID 使用其他上下文丰富数据,最终创建结构化 UDM 事件以进行安全分析。
准备工作
- 确保您拥有 Google SecOps 实例。
- 确保您使用的是 Windows 2016 或更高版本。
- 如果在代理后面运行,请确保防火墙端口处于打开状态。
获取 Google SecOps 提取身份验证文件
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载提取身份验证文件。将该文件安全地保存在将安装 BindPlane 的系统上。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 依次选择 SIEM 设置 > 配置文件。
- 复制并保存组织详细信息部分中的客户 ID。
在 Windows 上安装 Bindplane 代理
- 以管理员身份打开命令提示符或 PowerShell。
运行以下命令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
其他安装资源
- 如需了解其他安装选项,请参阅此安装指南。
配置 Bindplane 代理以注入 Syslog 并将其发送到 Google SecOps
- 在配置 YAML 文件之前,请在“服务”面板中停止
observIQ Distro for Open Telemetry Collector
服务。 访问配置文件:
- 找到
config.yaml
文件。通常,在 Linux 上,该目录位于/etc/bindplane-agent/
目录中;在 Windows 上,该目录位于安装目录中。 - 使用文本编辑器(例如
nano
、vi
或记事本)打开该文件。
- 找到
按如下方式修改
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]
将
<customer_id>
替换为实际的客户 ID。在获取 Google SecOps 提取身份验证文件部分中,将
/path/to/ingestion-authentication-file.json
更新为身份验证文件的保存路径。保存
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 名称 | security_result.detection_fields[0].value | 直接从原始日志中的 ContextInfo_Command Name 字段(如果有)映射而来。 |
ContextInfo_Command 类型 | security_result.detection_fields[1].value | 直接从原始日志中的 ContextInfo_Command Type 字段(如果有)映射而来。 |
ContextInfo_Host 应用 | 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_Host Name | target.hostname | 如果不存在 powershell.Host Name ,则直接从原始日志中的 ContextInfo_Host Name 字段映射。 |
ContextInfo_Script 名称 | target.process.file.full_path | 如果不存在 script_name ,则直接从原始日志中的 ContextInfo_Script Name 字段映射。 |
ContextInfo_Sequence 编号 | 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 字段映射而来。对于 security_result.rule_name 字段,值前面会带有 EventID: 前缀。 |
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.Command 名称 | security_result.detection_fields[0].value | 直接从 powershell.Command Name 字段(如果存在)映射。 |
powershell.Command 类型 | security_result.detection_fields[1].value | 直接从 powershell.Command Type 字段(如果存在)映射。 |
powershell.Host 应用 | 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.Script 名称 | target.process.file.full_path | 直接从原始日志中的 powershell.Script Name 字段(如果有)映射而来。 |
powershell.ScriptName | target.process.file.full_path | 直接从原始日志中的 powershell.ScriptName 字段(如果有)映射而来。 |
powershell.Sequence Number | 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 | 如果 ExecutionProcessID 和 ProcessID 不存在、为空或为 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 的值进行映射:- verbose 或 info 映射到 LOW 。- warn 或 err 映射到 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 | 如果 EventID 为 4104 且 _Path 存在于 Message 中,或者 EventID 为 4103 ,或者 EventID 在 [800 、600 、400 ] 中且存在 powershell.ScriptName 和 powershell.HostApplication ,则设置为 PROCESS_LAUNCH 。如果 EventID 为 403 且 _HostApplication 存在于 Message 中,或者 EventID 为 403 且 NewEngineState 为 Stopped ,则设置为 PROCESS_TERMINATION 。如果 EventID 为 4104 且 Message 中不存在 _Path ,或者 EventID 为 4103 且 no_value 、script_name 为空、script_name_not_found 和 host_application_not_found 均为 true,或者 EventID 为 53504 ,或者 EventID 为 40962 ,或者 EventID 为 40961 ,或者 EventID 为空且存在 MessageSourceAddress ,则设置为 STATUS_UPDATE 。如果 EventID 为空且存在 Username ,则设置为 USER_UNCATEGORIZED 。如果 EventID 为空且不存在 MessageSourceAddress 和 Username ,则设置为 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 | 如果 EventID 为 4104 且 Message 中存在 _Path ,则设置为 _Path 。如果 EventID 为 4104 且 Message 中存在 file_path ,则设置为 file_path 。如果 EventID 为 403 且 Message 中存在 _HostApplication ,则设置为 _HostApplication 。 |
变化
2025-01-29
增强功能:
- 将
ScriptBlockText
的映射从security_result.detection_fields
更改为了target.process.command_line
。
2025-01-28
增强功能:
- 添加了
gsub
,以支持新格式的 JSON 日志。
2025-01-09
增强功能:
- 将
Payload
映射到security_result.detection_fields
。 - 将
Script Name
映射到target.file.full_path
。
2024-11-28
增强功能:
- 添加了对新 SYSLOG 日志模式的支持。
2024-08-20
增强功能:
- 添加了
gsub
以移除多余字符,以便解析 JSON 日志。
2024-08-14
增强功能:
- 将
Version
映射到metadata.product_version
。 - 将
SystemTime
映射到metadata.event_timestamp
。 - 将
channel
、keywords
、MessageNumber
、MessageTotal
和ScriptBlockId
映射到security_result.detection_fields
。 - 将
Path
映射到target.process.file.full_path
。
2024-07-24
增强功能:
- 添加了对新 JSON 日志模式的支持。
2024-07-20
增强功能:
- 将
HostApplication
映射到principal.application
。 - 将
HostId
映射到principal.resource.product_object_id
。 - 将
System.Computer
映射到principal.hostname
和principal.asset.hostname
。 - 将
System.Version
映射到metadata.product_version
。 - 将
System.ProcessID
映射到principal.process.pid
。 - 将
System.ProviderName
映射到principal.resource.attribute.labels
。 - 将
HostVersion
、RunspaceId
、PipelineId
、EngineVersion
、DetailSequence
、DetailTotal
、SequenceNumber
和ScriptName
映射到additional.fields
。 - 将
System.EventRecordID
、System.Task
、System.Keywords
、System.Opcode
和System.ThreadID
映射到security.detection_fields
。
2023-12-05
增强功能:
- 添加了未解析的 JSON 日志的映射。
- 将
Computer
映射到principal.hostname
。 - 将
EventLevelName
映射到security_result.severity
。 - 将
ManagementGroupName
、Source
和TenantId
映射到additional_fields
。 - 将
RenderedDescription
映射到security_result.description
。 - 将
UserName
映射到principal.user.userid
。
2023-09-14
增强功能:
- 添加了未解析 JSON 日志的映射。
- 将“winlog.activity_id”映射到“security_result.detection_fields”。
- 将“winlog.api”映射到“additional.fields”。
- 将“winlog.channel”“winlog.process.thread.id”映射到“security_result.about.resource.attribute.labels”。
- 将“winlog.computer_name”映射到“principal.hostname”。
- 将“winlog.event_id”映射到“metadata.product_event_type”和“security_result.rule_name”。
- 将“winlog.opcode”映射到“metadata.description”。
- 将“winlog.process.pid”映射到“principal.process.pid”。
- 将“winlog.provider_guid”映射到“metadata.product_deployment_id”。
- 将“winlog.provider_name”映射到“metadata.product_name”。
- 将“winlog.record_id”映射到“metadata.product_log_id”。
- 将“winlog.user.domain”映射到“principal.administrative_domain”。
- 将“winlog.user.identifier”映射到“principal.user.windows_sid”。
- 将“winlog.user.name”映射到“principal.user.userid”。
2023-07-05
增强功能:
- 对于“EventID = 403”,如果“HostApplication”没有值,则将“metadata.event_type”映射到“STATUS_UPDATE”。
- 当“Path”为空时,使用 Grok 模式从日志中提取“target.file.full_path”的值。
- 添加了 gsub 函数,用于将“@timestamp”重命名为“EventTime”。
2022-11-09
增强功能:
- “ProviderGuid”字段会映射到“metadata.product_deployment_id”。
- “ExecutionProcessID”字段会映射到“principal.process.pid”。
- “ProcessID”或“进程 ID”字段会映射到“principal.process.pid”。
- 字段“SourceModuleType”映射到“principal.resource.resource_subtype”。
- 字段“SourceModuleName”映射到“principal.resource.name”。
- 字段“Machine”已映射到“principal.asset.asset_id”。
- 字段“MessageSourceAddress”会映射到“principal.ip”。
- 字段“File”已映射到“target.process.file.full_path”。
- “主机应用”或“命令”字段会映射到“target.process.command_line”。
- “输出”字段映射到“security_result.detection_fields”。
- “Message”字段已映射到“security_result.description”。
- 字段“ActivityID”已映射到“security_result.detection_fields”。
- 添加了以下映射(当 EventID 为“4103”时)
- “Host ID”(主机 ID)或“ContextInfo_Host ID”(ContextInfo_Host ID)字段会映射到“target.asset.asset_id”。
- “Host Name”(主机名)或“ContextInfo_Host Name”(ContextInfo_Host Name)字段会映射到“target.hostname”。
- “ContextInfo_Script Name”字段已映射到“target.process.file.full_path”。
- 将“ContextInfo_Host Application”字段映射到“target.process.command_line”。
- “ContextInfo_Command Name”字段已映射到“security_result.detection_fields”。
- 字段“ContextInfo_Command Type”已映射到“security_result.detection_fields”。
- 将“ContextInfo_Sequence Number”或“Sequence Number”字段映射到“security_result.detection_fields”。
- 添加了以下映射,以便在 EventID 为“800”“600”或“400”时使用
- “UserId”字段映射到“principal.user.userid”。
- “HostApplication”字段会映射到“target.process.command_line”。
- 字段“HostId”映射到“target.asset.asset_id”。
- “HostName”字段映射到“target.hostname”。
- 字段“ScriptName”已映射到“target.process.file.full_path”。
- 字段“SequenceNumber”已映射到“security_result.detection_fields”。
2022-10-13
bug 修复:
- 通过进行以下更改,解析了失败的日志。
- 针对在没有值的情况下解析失败的字段添加了
on_error
检查。例如“操作码”“主机应用”等字段。 - 在日志中不存在“Message”时,为 KV 解析添加了新来源“ContextInfo”。
- 增强功能:
- 将 event_type 从
GENERIC_EVENT
更改为了STATUS_UPDATE
。
需要更多帮助?向社区成员和 Google SecOps 专业人士寻求解答。