收集 Elastic Windows Event Log Beats 記錄
本文說明如何使用 Bindplane 代理程式,將 Elastic Windows Event Log Beats 記錄檔擷取至 Google Security Operations。
Winlogbeat 是 Elastic 的 Windows 專用事件記錄檔傳送代理程式,可收集 Windows 事件記錄檔並轉送至不同目的地。這項服務會在 Windows 系統上以 Windows 服務的形式執行,並從「應用程式」、「安全性」、「系統」和其他 Windows 事件記錄通道收集事件。
事前準備
請確認您已完成下列事前準備事項:
- Google SecOps 執行個體
- Windows Server 2016 以上版本,或搭載
systemd的 Linux 主機,用於執行 Bindplane 代理程式 - Bindplane 代理程式與 Logstash 伺服器之間的網路連線
- Logstash 與 Bindplane 代理程式之間的網路連線
- 如果透過 Proxy 執行,請確保防火牆通訊埠已根據 Bindplane 代理程式需求開啟
- 要安裝 Winlogbeat 來收集事件記錄的 Windows 系統
- 具備 Windows 系統的管理員存取權,可安裝 Winlogbeat
- 用於中介處理的 Logstash 伺服器 (7.x 或 8.x 版)
取得 Google SecOps 擷取驗證檔案
- 登入 Google SecOps 控制台。
- 依序前往「SIEM 設定」>「收集代理程式」。
下載擷取驗證檔案。將檔案安全地儲存在要安裝 Bindplane 的系統上。
取得 Google SecOps 客戶 ID
- 登入 Google SecOps 控制台。
- 依序前往「SIEM 設定」>「設定檔」。
複製並儲存「機構詳細資料」專區中的客戶 ID。
安裝 Bindplane 代理程式
請按照下列操作說明,在 Windows 或 Linux 作業系統上安裝 Bindplane 代理程式。
Windows 安裝
- 以管理員身分開啟「命令提示字元」或「PowerShell」。
執行下列指令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet等待安裝完成。
執行下列指令來驗證安裝:
sc query observiq-otel-collector服務狀態應為「RUNNING」。
Linux 安裝
- 開啟具有根層級或 sudo 權限的終端機。
執行下列指令:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh等待安裝完成。
執行下列指令來驗證安裝:
sudo systemctl status observiq-otel-collector服務狀態應為「active (running)」。
其他安裝資源
如需其他安裝選項和疑難排解資訊,請參閱 Bindplane 代理程式安裝指南。
設定 Bindplane 代理程式,擷取系統記錄檔並傳送至 Google SecOps
找出設定檔
Linux:
sudo nano /etc/bindplane-agent/config.yamlWindows:
notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
編輯設定檔
將
config.yaml的所有內容替換為下列設定:receivers: tcplog: listen_address: "0.0.0.0:1514" exporters: chronicle/winlogbeat: compression: gzip creds_file_path: '<CREDS_FILE_PATH>' customer_id: '<CUSTOMER_ID>' endpoint: <REGION_ENDPOINT> log_type: ELASTIC_WINLOGBEAT raw_log_field: body ingestion_labels: env: production source: winlogbeat service: pipelines: logs/winlogbeat_to_chronicle: receivers: - tcplog exporters: - chronicle/winlogbeat替換下列預留位置:
接收器設定:
listen_address:設為0.0.0.0:1514,即可在通訊埠 1514 (TCP) 的所有介面上接聽。您可以視需要變更通訊埠號碼,但請確保與 Logstash syslog 輸出設定一致。
匯出工具設定:
<CREDS_FILE_PATH>:擷取驗證檔案的完整路徑:- Linux:
/etc/bindplane-agent/ingestion-auth.json - Windows:
C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
- Linux:
<CUSTOMER_ID>:上一步中的客戶 ID<REGION_ENDPOINT>:區域端點網址:- 美國:
malachiteingestion-pa.googleapis.com - 歐洲:
europe-malachiteingestion-pa.googleapis.com - 亞洲:
asia-southeast1-malachiteingestion-pa.googleapis.com - 如需完整清單,請參閱「區域端點」
- 美國:
設定範例:
receivers: tcplog: listen_address: "0.0.0.0:1514" exporters: chronicle/winlogbeat: compression: gzip creds_file_path: '/etc/bindplane-agent/ingestion-auth.json' customer_id: 'a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6' endpoint: malachiteingestion-pa.googleapis.com log_type: ELASTIC_WINLOGBEAT raw_log_field: body ingestion_labels: env: production source: winlogbeat service: pipelines: logs/winlogbeat_to_chronicle: receivers: - tcplog exporters: - chronicle/winlogbeat
儲存設定檔
編輯完成後,請儲存檔案:
- Linux:依序按下
Ctrl+O、Enter和Ctrl+X - Windows:依序點選「檔案」>「儲存」
重新啟動 Bindplane 代理程式,以套用變更
如要在 Linux 中重新啟動 Bindplane 代理程式,請執行下列步驟:
執行下列指令:
sudo systemctl restart observiq-otel-collector確認服務正在執行:
sudo systemctl status observiq-otel-collector檢查記錄中是否有錯誤:
sudo journalctl -u observiq-otel-collector -f
如要在 Windows 中重新啟動 Bindplane 代理程式,請按照下列步驟操作:
您可以選擇下列其中一個選項:
以管理員身分開啟命令提示字元或 PowerShell:
net stop observiq-otel-collector && net start observiq-otel-collector服務控制台:
- 按下
Win+R鍵,輸入services.msc,然後按下 Enter 鍵。 - 找出 observIQ OpenTelemetry Collector。
- 按一下滑鼠右鍵,然後選取「重新啟動」。
- 按下
確認服務正在執行:
sc query observiq-otel-collector檢查記錄中是否有錯誤:
type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
安裝及設定 Logstash
您必須使用 Logstash 做為中介,才能接收 Winlogbeat 的事件,並透過 syslog 將事件轉送至 Bindplane 代理程式。Winlogbeat 沒有原生 syslog 輸出功能。
安裝 Logstash
- 從 Elastic 下載頁面下載 Logstash。
- 在 Windows 或 Linux 伺服器上安裝 Logstash:
Linux (Debian/Ubuntu):
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - sudo apt-get install apt-transport-https echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list sudo apt-get update && sudo apt-get install logstashLinux (RHEL/CentOS):
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch sudo tee /etc/yum.repos.d/logstash.repo <<EOF [logstash-8.x] name=Elastic repository for 8.x packages baseurl=https://artifacts.elastic.co/packages/8.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md EOF sudo yum install logstashWindows:
- 從 Elastic 下載頁面下載 ZIP 檔案。
- 擷取至
C:\logstash。
設定 Logstash 管道
建立新的管道設定檔:
Linux:
sudo nano /etc/logstash/conf.d/winlogbeat-to-syslog.confWindows:
notepad "C:\logstash\config\winlogbeat-to-syslog.conf"
新增下列設定:
input { beats { port => 5044 } } output { syslog { host => "<BINDPLANE_AGENT_IP>" port => 1514 protocol => "tcp" rfc => "rfc5424" appname => "winlogbeat" facility => "user-level" severity => "informational" } }將
<BINDPLANE_AGENT_IP>替換為執行 Bindplane 代理程式的伺服器 IP 位址。
Logstash 設定範例
input { beats { port => 5044 } } output { syslog { host => "192.168.1.100" port => 1514 protocol => "tcp" rfc => "rfc5424" appname => "winlogbeat" facility => "user-level" severity => "informational" } }
啟動 Logstash
Linux:
啟動 Logstash:
sudo systemctl start logstash sudo systemctl enable logstash確認 Logstash 是否正在執行:
sudo systemctl status logstash檢查 Logstash 記錄:
sudo tail -f /var/log/logstash/logstash-plain.log
Windows:
cd C:\logstash\bin logstash.bat -f C:\logstash\config\winlogbeat-to-syslog.conf如要在正式環境中使用,請使用 NSSM 或類似工具,將 Logstash 安裝為 Windows 服務。
在 Windows 系統上安裝 Winlogbeat
下載 Winlogbeat
- 從 Elastic 下載頁面下載 Winlogbeat。
- 選擇 Windows 適用的 ZIP 或 MSI 安裝程式。
安裝 Winlogbeat
使用 MSI 安裝程式:
- 執行 MSI 安裝程式。
- 按照安裝精靈的指示操作。
- 安裝至預設位置:
C:\Program Files\Winlogbeat。
使用 ZIP 檔案:
- 將 ZIP 檔案解壓縮至
C:\Program Files\Winlogbeat。 - 以管理員身分開啟 PowerShell。
前往 Winlogbeat 目錄:
cd 'C:\Program Files\Winlogbeat'執行安裝指令碼:
.\install-service-winlogbeat.ps1
- 將 ZIP 檔案解壓縮至
設定 Winlogbeat,將記錄傳送至 Logstash
開啟 Winlogbeat 設定檔:
notepad "C:\Program Files\Winlogbeat\winlogbeat.yml"設定要收集的事件記錄。找出
winlogbeat.event_logs區段,然後按照下列方式設定:winlogbeat.event_logs: - name: Application ignore_older: 72h - name: System - name: Security - name: Microsoft-Windows-Sysmon/Operational ignore_older: 72h - name: Windows PowerShell event_id: 400, 403, 600, 800 - name: Microsoft-Windows-PowerShell/Operational event_id: 4103, 4104, 4105, 4106 - name: ForwardedEvents tags: [forwarded]在每一行的開頭加上
#,註解排除 Elasticsearch 輸出部分:#output.elasticsearch: # hosts: ["localhost:9200"]取消註解並設定 Logstash 輸出區段:
output.logstash: hosts: ["<LOGSTASH_SERVER_IP>:5044"]將
<LOGSTASH_SERVER_IP>替換為 Logstash 伺服器的 IP 位址。
Winlogbeat 設定範例
winlogbeat.event_logs: - name: Application ignore_older: 72h - name: System - name: Security - name: Microsoft-Windows-Sysmon/Operational ignore_older: 72h output.logstash: hosts: ["192.168.1.50:5044"]
儲存設定檔
儲存並關閉檔案。
啟動 Winlogbeat 服務
- 以管理員身分開啟 PowerShell。
啟動 Winlogbeat 服務:
Start-Service winlogbeat確認服務正在執行:
Get-Service winlogbeat狀態應顯示為「Running」(執行中)。
檢查 Winlogbeat 記錄是否有錯誤:
Get-Content "C:\ProgramData\winlogbeat\Logs\winlogbeat" -Tail 50
驗證記錄流程
驗證 Winlogbeat 與 Logstash 的連線
在 Logstash 伺服器上,檢查 Logstash 記錄:
Linux:
sudo tail -f /var/log/logstash/logstash-plain.logWindows:
type C:\logstash\logs\logstash-plain.log
尋找顯示 Beats 連線的訊息:
[INFO ][logstash.inputs.beats] Beats inputs: Starting input listener {:address=>"0.0.0.0:5044"}
驗證 Logstash 與 Bindplane 代理程式的連線
在 Bindplane 代理程式伺服器上,檢查代理程式記錄:
Linux:
sudo journalctl -u observiq-otel-collector -fWindows:
type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
找出顯示記錄擷取成功的訊息。
在 Google SecOps 中驗證記錄
- 登入 Google SecOps 控制台。
- 前往「搜尋」。
執行搜尋查詢,確認 Winlogbeat 記錄是否已擷取:
metadata.log_type = "ELASTIC_WINLOGBEAT"確認搜尋結果中顯示 Windows 事件記錄。
疑難排解
Winlogbeat 無法連線至 Logstash
確認 Winlogbeat 與 Logstash 之間的網路連線:
Test-NetConnection -ComputerName <LOGSTASH_IP> -Port 5044檢查 Windows 防火牆規則是否允許透過 5044 連接埠建立連出連線。
確認 Logstash 正在監聽通訊埠 5044:
Linux:
sudo netstat -tulpn | grep 5044Windows:
netstat -an | findstr 5044
Logstash 未轉送至 Bindplane 代理程式
確認 Logstash 與 Bindplane 代理程式之間的網路連線:
Linux:
telnet <BINDPLANE_IP> 1514Windows:
Test-NetConnection -ComputerName <BINDPLANE_IP> -Port 1514
檢查防火牆規則,確認是否允許通訊埠 1514 的 TCP 連線。
確認 Bindplane 代理程式正在接聽通訊埠 1514:
Linux:
sudo netstat -tulpn | grep 1514Windows:
netstat -an | findstr 1514
Google SecOps 未顯示記錄
- 確認客戶 ID 和匯入驗證檔案正確無誤。
- 檢查 Bindplane 代理程式記錄,瞭解是否有驗證錯誤。
- 確認區域端點與 Google SecOps 執行個體區域相符。
- 確認
log_type設為ELASTIC_WINLOGBEAT,如圖所示。
UDM 對應表
這個剖析器沒有欄位對應資訊。
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。