收集 Windows AppLocker 記錄

支援:

本文說明如何使用 Bindplane 代理程式,將 Windows AppLocker 記錄檔擷取至 Google Security Operations。

Windows AppLocker 是 Windows 內建的應用程式控制功能,可產生政策強制執行、稽核和應用程式執行事件。AppLocker 會將這些事件寫入「應用程式及服務記錄檔」>「Microsoft」>「Windows」>「AppLocker」下的四個 Windows 事件記錄檔通道:EXE 和 DLL、MSI 和指令碼、封裝應用程式 - 部署,以及封裝應用程式 - 執行。

您可以透過下列兩種支援方法之一設定擷取作業:

  • 方法 1:NXLog 轉送至 Bindplane 代理程式 (建議)。NXLog 會讀取每個端點上的 AppLocker 管道,並將事件以 syslog 格式轉送至 Bindplane 代理程式,其中包含 JSON 酬載,代理程式會將事件以 WINDOWS_APPLOCKER 記錄類型傳送至 Google SecOps。這是 WINDOWS_APPLOCKER 剖析器預期的格式,可保留 AppLocker 規則和檔案欄位。
  • 方法 2:Bindplane 代理程式直接管道讀取。每個端點上的 Bindplane 代理程式會原生讀取 AppLocker 管道,並將原始 Windows 事件 XML 傳送至 Google SecOps,記錄類型為 WINEVTLOG。不需要匯出檔案或額外代理程式,但事件會由一般 Windows 事件記錄剖析器剖析。

事前準備

請確認您符合下列必要條件:

  • Google SecOps 執行個體
  • Windows Server 2016 以上版本或 Windows 10 以上版本,且已設定 AppLocker 政策
  • Windows 端點的管理員權限
  • 如果是在 Proxy 後方執行,請確認防火牆通訊埠已按照 Bindplane 代理程式規定開啟
  • 方法 1:Bindplane 代理程式的 Windows 或 Linux 主機,端點可透過 TCP 通訊埠 514 連線

取得 Bindplane 代理程式的 Google SecOps 憑證

如要向 Google SecOps 驗證 Bindplane 代理程式,請選擇下列其中一種方法:

  • 新部署作業:使用 Chronicle API (選項 1)。
  • 舊版部署作業:在 2027 年 7 月 20 日停用 Ingestion API 前,請繼續使用擷取驗證檔案 (選項 2)。
  1. 登入 Google Cloud 控制台,選取連結至 Google SecOps 執行個體的 Google Cloud 專案。
  2. 依序前往「IAM & Admin」(IAM 與管理) >「Service Accounts」(服務帳戶)。
  3. 按一下「建立服務帳戶」。
  4. 提供下列設定詳細資料:
    • 服務帳戶名稱:輸入帳戶名稱 (例如 bindplane-ingest)。
    • 「服務帳戶說明」:輸入說明 (例如 Bindplane agent log ingestion)。
  5. 點按「Create and continue」(建立並繼續)。
  6. 在「將專案存取權授予這個服務帳戶」部分,按一下「選取角色」,然後選取「Chronicle 編輯者」。
  7. 依序點選「繼續」和「完成」。
  8. 按一下您建立的服務帳戶,然後前往「金鑰」分頁。
  9. 依序點選「新增金鑰」>「建立新的金鑰」。
  10. 選取「JSON」,然後按一下「建立」。金鑰檔案會下載到電腦。
  11. 將金鑰檔案儲存為 Bindplane 收集器目錄中的 ingestion-auth.json (Linux 上的 /opt/observiq-otel-collector/ingestion-auth.json 或 Windows 上的 C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json),或更新 config.yaml 中的 creds_file_path,使其與儲存路徑相符。
  12. 依序前往「IAM & Admin」(IAM 與管理) >「Settings」(設定),然後複製「Project number」(專案編號)。匯出工具設定時會用到。

方法 2:下載擷取驗證檔案 (舊版)

  1. 登入 Google SecOps 控制台。
  2. 依序前往「SIEM Settings」 > 「Collection Agents」。
  3. 下載擷取驗證檔案。
  4. 將檔案安全地儲存在要安裝 Bindplane 代理程式的系統上。

取得 Google SecOps 客戶 ID

  1. 登入 Google SecOps 控制台。
  2. 依序前往「SIEM 設定」>「設定檔」。
  3. 複製並儲存「機構詳細資料」部分的客戶 ID。

安裝 Bindplane 代理程式

請按照下列操作說明安裝 Bindplane 代理程式。如果採用方法 1,請將外掛程式安裝在接收 NXLog 系統記錄的主機上。如果採用方法 2,請在要收集 AppLocker 事件的所有端點上安裝。

Windows 安裝

  1. 以管理員身分開啟「命令提示字元」或「PowerShell」。
  2. 執行下列指令:

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    
  3. 等待安裝完成。

  4. 執行下列指令,確認安裝成功:

    sc query observiq-otel-collector
    

    服務應顯示為「RUNNING」。

Linux 安裝

  1. 開啟具有 root 或 sudo 權限的終端機。
  2. 執行下列指令:

    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
    

其他安裝資源

如需其他安裝選項和疑難排解資訊,請參閱 Bindplane 代理程式安裝指南。

方法 1:將 NXLog 轉送至 Bindplane 代理程式

設定 Bindplane 代理程式,接收系統記錄檔並傳送至 Google SecOps

  1. 在 Bindplane 代理程式主機上開啟設定檔:

    Windows:

    notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
    

    Linux:

    sudo nano /opt/observiq-otel-collector/config.yaml
    
  2. 將 config.yaml 的全部內容替換為下列設定:

    receivers:
      tcplog/applocker:
        listen_address: "0.0.0.0:514"
    
    exporters:
      chronicle/windows_applocker:
        protocol: https
        # Region of your instance, for example us, europe, asia-southeast1
        location: <LOCATION>
        # Project number of the Google Cloud project linked to the instance
        project: '<PROJECT_NUMBER>'
        compression: gzip
        creds_file_path: '/path/to/ingestion-auth.json'
        customer_id: '<customer_id>'
        endpoint: chronicle.googleapis.com
        log_type: WINDOWS_APPLOCKER
        raw_log_field: body
        ingestion_labels:
          env: production
    
    service:
      pipelines:
        logs/applocker_to_chronicle:
          receivers:
            - tcplog/applocker
          exporters:
            - chronicle/windows_applocker
    
  3. 替換下列預留位置:

    • listen_address:代理程式接聽的 IP 位址和通訊埠。0.0.0.0:514 會在 TCP 通訊埠 514 的每個介面上接受系統記錄檔。如果代理程式不是以根身分執行,請在 Linux 上使用大於 1024 的通訊埠,並在主機防火牆中開啟該通訊埠。
    • creds_file_path:服務帳戶 JSON 金鑰檔案的完整路徑 (選項 1):
      • Windows:C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
      • Linux:/opt/observiq-otel-collector/ingestion-auth.json
    • <customer_id>:從「取得 Google SecOps 客戶 ID」一節取得的客戶 ID
    • location:將 <LOCATION> 替換為 Google SecOps 執行個體的區域 (例如 us、europe 或 asia-southeast1)。匯出工具會在這個值前面加上 chronicle.googleapis.com。如需完整清單,請參閱「區域性端點」。
    • project:將 <PROJECT_NUMBER> 替換為「IAM 與管理」>「設定」中的專案編號。
    • endpoint:請將此值設為 chronicle.googleapis.com。
    • ingestion_labels:YAML 格式的選用標籤 (例如 env: production)
  4. 儲存檔案。

  5. 重新啟動 Bindplane 代理程式:

    Windows:

    net stop observiq-otel-collector && net start observiq-otel-collector
    

    Linux:

    sudo systemctl restart observiq-otel-collector
    

舊版 Ingestion API 匯出工具

  • 如果您使用選項 2 的擷取驗證檔案,請將 exporters 區塊替換為下列內容。將 creds_file_path 設為擷取驗證檔案的路徑。如果執行個體位於美國境外,請將 malachiteingestion-pa.googleapis.com 替換為區域端點 (例如 europe-malachiteingestion-pa.googleapis.com)。

    exporters:
      chronicle/windows_applocker:
        compression: gzip
        creds_file_path: '/path/to/ingestion-auth.json'
        customer_id: '<customer_id>'
        endpoint: malachiteingestion-pa.googleapis.com
        log_type: WINDOWS_APPLOCKER
        raw_log_field: body
        ingestion_labels:
          env: production
    

在 Windows 端點上安裝 NXLog

  1. 從 NXLog 網站下載 Windows 適用的 NXLog Agent (原稱 NXLog Enterprise Edition)。
  2. 在要收集 AppLocker 事件的每個端點上執行安裝程式,並接受預設安裝目錄 (C:\Program Files\nxlog)。

設定 NXLog 轉送 AppLocker 事件

  1. 開啟「檔案總管」,然後前往 C:\Program Files\nxlog\conf。
  2. 以管理員權限在記事本或文字編輯器中開啟 nxlog.conf 檔案。
  3. 將全部內容替換為下列設定:

    define ROOT C:\Program Files\nxlog
    define LOGDIR %ROOT%\data
    define LOGFILE %LOGDIR%\nxlog.log
    
    Moduledir %ROOT%\modules
    CacheDir %ROOT%\data
    Pidfile %ROOT%\data\nxlog.pid
    SpoolDir %ROOT%\data
    LogFile %LOGFILE%
    
    <Extension json>
        Module      xm_json
    </Extension>
    
    <Extension xml>
        Module      xm_xml
    </Extension>
    
    <Extension syslog>
        Module      xm_syslog
    </Extension>
    
    <Input applocker_events>
        Module      im_msvistalog
        <QueryXML>
            <QueryList>
                <Query Id="0">
                    <Select Path="Microsoft-Windows-AppLocker/EXE and DLL">*</Select>
                    <Select Path="Microsoft-Windows-AppLocker/MSI and Script">*</Select>
                    <Select Path="Microsoft-Windows-AppLocker/Packaged app-Deployment">*</Select>
                    <Select Path="Microsoft-Windows-AppLocker/Packaged app-Execution">*</Select>
                </Query>
            </QueryList>
        </QueryXML>
        <Exec>
            # AppLocker keeps the rule and file details in the UserData part of the
            # event. parse_xml() turns them into RuleAndFileData.* fields, which
            # the parser expects.
            if $UserData parse_xml($UserData);
            $Message = to_json();
            to_syslog_bsd();
        </Exec>
    </Input>
    
    <Output bindplane_syslog>
        Module      om_tcp
        Host        <BINDPLANE_AGENT_IP>
        Port        514
    </Output>
    
    <Route applocker_to_bindplane>
        Path        applocker_events => bindplane_syslog
    </Route>
    
  4. 將 <BINDPLANE_AGENT_IP> 替換為 Bindplane 代理程式主機的 IP 位址,並將 514 替換為 listen_address 的通訊埠 (如有變更)。

  5. 儲存 nxlog.conf 檔案。

重新啟動 NXLog 服務

  1. 按下 Win+R 鍵,輸入 services.msc,然後按下 Enter 鍵,開啟「服務」。
  2. 在服務清單中找到「nxlog」nxlog。
  3. 在「nxlog」上按一下滑鼠右鍵,然後選取「Restart」。
  4. 確認服務狀態顯示為「執行中」。
  • 或者,您也可以以管理員身分從命令提示字元重新啟動 NXLog:

    net stop nxlog && net start nxlog
    

確認 AppLocker 事件已轉送

  1. 在 Windows 端點上開啟「事件檢視器」。
  2. 依序前往「Applications and Services Logs」 >「Microsoft」 >「Windows」 >「AppLocker」 >「EXE and DLL」。
  3. 確認 AppLocker 事件 (例如事件 ID 8002、8003 或 8004) 是否存在。如果記錄空白,請確認已套用 AppLocker 政策,且「應用程式識別」服務正在執行。
  4. 檢查 C:\Program Files\nxlog\data\nxlog.log 中的 NXLog 記錄檔是否有錯誤或警告。
  5. 在 Bindplane 代理程式主機上,檢查代理記錄是否有錯誤:

    Windows:

    type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
    

    Linux:

    sudo tail -f /opt/observiq-otel-collector/log/collector.log
    

方法 2:Bindplane 代理直接管道讀取

如果不想部署 NXLog,請使用這個方法。安裝在各端點的 Bindplane 代理程式會直接從 Windows 事件記錄讀取 AppLocker 管道,並將原始事件 XML 傳送至 Google SecOps,記錄類型為 WINEVTLOG。

設定 Bindplane 代理程式,讀取 AppLocker 管道

  1. 在 Windows 端點上開啟設定檔:

    notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
    
  2. 將 config.yaml 的全部內容替換為下列設定:

    receivers:
      windowseventlog/applocker_exe_dll:
        channel: Microsoft-Windows-AppLocker/EXE and DLL
        raw: true
        max_reads: 100
        poll_interval: 5s
        start_at: end
    
      windowseventlog/applocker_msi_script:
        channel: Microsoft-Windows-AppLocker/MSI and Script
        raw: true
        max_reads: 100
        poll_interval: 5s
        start_at: end
    
      windowseventlog/applocker_packaged_deployment:
        channel: Microsoft-Windows-AppLocker/Packaged app-Deployment
        raw: true
        max_reads: 100
        poll_interval: 5s
        start_at: end
    
      windowseventlog/applocker_packaged_execution:
        channel: Microsoft-Windows-AppLocker/Packaged app-Execution
        raw: true
        max_reads: 100
        poll_interval: 5s
        start_at: end
    
    exporters:
      chronicle/winevtlog:
        protocol: https
        # Region of your instance, for example us, europe, asia-southeast1
        location: <LOCATION>
        # Project number of the Google Cloud project linked to the instance
        project: '<PROJECT_NUMBER>'
        compression: gzip
        creds_file_path: 'C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json'
        customer_id: '<customer_id>'
        endpoint: chronicle.googleapis.com
        log_type: WINEVTLOG
        raw_log_field: body
        ingestion_labels:
          env: production
    
    service:
      pipelines:
        logs/applocker_to_chronicle:
          receivers:
            - windowseventlog/applocker_exe_dll
            - windowseventlog/applocker_msi_script
            - windowseventlog/applocker_packaged_deployment
            - windowseventlog/applocker_packaged_execution
          exporters:
            - chronicle/winevtlog
    
  3. 替換下列預留位置:

    • <customer_id>:從「取得 Google SecOps 客戶 ID」一節取得的客戶 ID
    • endpoint:區域端點網址,如方法 1 所示
    • ingestion_labels:YAML 格式的選用標籤 (例如 env: production)
    • start_at:設為 end,只收集新事件;或設為 beginning,同時收集管道中已有的事件
  4. 儲存檔案。

  5. 重新啟動 Bindplane 代理程式:

    net stop observiq-otel-collector && net start observiq-otel-collector
    
  6. 確認服務正在執行,並檢查代理記錄是否有錯誤:

    sc query observiq-otel-collector
    type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
    

舊版擷取 API 匯出工具

  • 如果您使用選項 2 的擷取驗證檔案,請將 exporters 區塊替換為下列內容。將 creds_file_path 設為擷取驗證檔案的路徑,如果您的執行個體位於美國境外,請將 malachiteingestion-pa.googleapis.com 替換為區域端點 (例如 europe-malachiteingestion-pa.googleapis.com)。

    exporters:
      chronicle/winevtlog:
        compression: gzip
        creds_file_path: 'C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json'
        customer_id: '<customer_id>'
        endpoint: malachiteingestion-pa.googleapis.com
        log_type: WINEVTLOG
        raw_log_field: body
        ingestion_labels:
          env: production
    

UDM 對應表

記錄欄位 UDM 對應 邏輯
syslog_ts metadata.event_timestamp 已剖析為 yyyy-MM-ddTHH:mm:ss Z
event_type metadata.event_type 直接對應
EventID metadata.product_event_type 直接對應
sourceName metadata.product_name 直接對應
SourceModuleType observer.application 已重新命名/對應
Domain principal.administrative_domain 已重新命名/對應
Hostname principal.hostname 已重新命名/對應
principal_ip1 principal.ip 已合併
roles principal.user.attribute.roles 已合併
AccountName principal.user.userid 已重新命名/對應
EventID security_result.about.labels 已對應:8002,8005, 8006, 8020 → ssdl
ssdl security_result.about.labels 已合併
message1 security_result.action 已對應:allowed to run → security_action
security_action security_result.action 已合併
message1 security_result.description 直接對應
RuleAndFileData.RuleId security_result.rule_id 已重新命名/對應
EventID security_result.rule_name 直接對應
RuleAndFileData.RuleName security_result.rule_name 已重新命名/對應
EventType security_result.severity 對應:INFO → INFORMATIONAL,WARNING → LOW
RuleAndFileData.PolicyName security_result.summary 已重新命名/對應
ThreadID security_result.threat_id 已重新命名/對應
RuleAndFileData.FullFilePath target.process.file.full_path 已重新命名/對應
filePath target.process.file.full_path 已重新命名/對應
ProcessID target.process.pid 直接對應
RuleAndFileData.TargetProcessId target.process.pid 已重新命名/對應
ProviderGuid target.resource.product_object_id 已重新命名/對應
UserID target.user.userid 已重新命名/對應
不適用 metadata.vendor_name 常數:Microsoft
不適用 security_result.severity 常數:INFORMATIONAL

變更記錄

查看這個剖析器的變更記錄

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