收集 PowerShell 記錄

支援的國家/地區:

本文說明如何使用 Bindplane 收集 PowerShell 記錄,並傳送至 Google Security Operations。剖析器會將原始 Microsoft PowerShell 記錄轉換為統一資料模型 (UDM)。系統會先從原始記錄訊息中擷取欄位,將其正規化為 UDM 欄位,然後根據特定事件 ID 透過額外內容擴充資料,最終建立用於安全分析的結構化 UDM 事件。

事前準備

  • 確認您擁有 Google SecOps 執行個體。
  • 確認您使用的是 Windows 2016 以上版本。
  • 如果透過 Proxy 執行,請確認防火牆通訊埠已開啟。

取得 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 代理程式,擷取系統記錄檔並傳送至 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_Host Application 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 Name target.process.file.full_path 如果沒有 script_name,則直接從原始記錄中的 ContextInfo_Script Name 欄位對應。
ContextInfo_Sequence Number 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 欄位對應。
項目 未對應至 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 位於 [40341034104] 和 message_message_not_found 中,則直接從原始記錄的 Message.Message 欄位對應。換行符和 Tab 鍵會替換為半形逗號。
訊息 security_result.description 如有,則直接從原始記錄中的 Message 欄位對應。
MessageNumber 未對應至 IDM 物件。
MessageSourceAddress principal.ip 如有,則直接從原始記錄中的 MessageSourceAddress 欄位對應。
MessageTotal 未對應至 IDM 物件。
MG 未對應至 IDM 物件。
Opcode metadata.description 直接從原始記錄中的 Opcode 欄位對應。
OpcodeValue 未對應至 IDM 物件。
輸出 security_result.detection_fields[0].value 如有,則直接從原始記錄中的 Output 欄位對應。
powershell.Command Name 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.Script Name 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 如果 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 如果 EventID4104,且 Message 中有 _Path,或 EventID4103,或 EventID 位於 [800600400] 中,且有 powershell.ScriptNamepowershell.HostApplication,則設為 PROCESS_LAUNCH。如果 EventID403,且 Message 中有 _HostApplication,或如果 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,且 Message 中有 _Path,則設為 _Path。如果 EventID4104,且 Message 中有 file_path,則設為 file_path。如果 EventID403,且 Message 中有 _HostApplication,則設為 _HostApplication

還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。