收集 ClamAV 記錄
本文說明如何使用 Bindplane 代理程式,將 ClamAV 記錄檔擷取至 Google Security Operations。
ClamAV 是一種開放原始碼防毒引擎,可偵測木馬程式、病毒、惡意軟體和其他惡意威脅。這項工具提供指令列掃描、自動更新簽章資料庫,並支援多種檔案格式,包括封存檔、可執行檔和文件。ClamAV 可在 Linux、Unix 和 Windows 系統上,以本機精靈 (clamd) 或指令列掃描器 (clamscan) 的形式運作。
事前準備
請確認您已完成下列事前準備事項:
- Google SecOps 執行個體
- Windows Server 2016 以上版本,或搭載
systemd的 Linux 主機 - Bindplane 代理程式主機與 ClamAV 伺服器之間的網路連線
- 如果透過 Proxy 執行,請確保防火牆通訊埠已根據 Bindplane 代理程式需求開啟
- 在 Linux 端點上安裝及執行 ClamAV
- ClamAV 伺服器和 Bindplane 代理程式主機的 root 或 sudo 存取權
取得 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: udplog: listen_address: "0.0.0.0:514" exporters: chronicle/clamav: compression: gzip creds_file_path: '/etc/bindplane-agent/ingestion-auth.json' customer_id: 'YOUR_CUSTOMER_ID' endpoint: malachiteingestion-pa.googleapis.com log_type: CLAM_AV raw_log_field: body ingestion_labels: env: production service: pipelines: logs/clamav_to_chronicle: receivers: - udplog exporters: - chronicle/clamav替換下列預留位置:
接收器設定:
listen_address:設為0.0.0.0:514,即可監聽 UDP 通訊埠 514 上的所有介面。如果通訊埠 514 需要 Linux 上的根權限,請使用0.0.0.0:1514並設定 rsyslog 轉送至通訊埠 1514。
匯出工具設定:
creds_file_path:擷取驗證檔案的完整路徑:- Linux:
/etc/bindplane-agent/ingestion-auth.json - Windows:
C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
- Linux:
customer_id:將YOUR_CUSTOMER_ID替換為先前取得的客戶 IDendpoint:區域端點網址:- 美國:
malachiteingestion-pa.googleapis.com - 歐洲:
europe-malachiteingestion-pa.googleapis.com - 亞洲:
asia-southeast1-malachiteingestion-pa.googleapis.com - 如需完整清單,請參閱「區域端點」。
- 美國:
log_type:設為CLAM_AV(Google SecOps 剖析器的完全比對)ingestion_labels:YAML 格式的選用標籤 (例如env: production)
儲存設定檔
編輯完成後,請儲存檔案:
- 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"
設定 ClamAV 系統記錄轉送
在 ClamAV 中啟用系統記錄記錄功能
- 使用 Root 或 sudo 權限登入執行 ClamAV 的 Linux 系統。
開啟 ClamAV 精靈設定檔:
sudo nano /etc/clamav/clamd.conf找出顯示
#LogSyslog yes或#LogSyslog true的行。移除
#註解字元,啟用系統記錄檔記錄:LogSyslog yes選用:設定系統記錄設施。找出
#LogFacility LOG_LOCAL6行並取消註解:LogFacility LOG_LOCAL6選用:啟用其他記錄選項,取得更詳細的記錄:
LogTime yes LogVerbose yes ExtendedDetectionInfo yesLogTime:在記錄訊息中加入時間戳記LogVerbose:啟用詳細記錄功能,並提供額外詳細資料ExtendedDetectionInfo:包含檔案大小和雜湊值,以及病毒偵測結果
儲存檔案並退出:
依序按下
Ctrl+O、Enter和Ctrl+X鍵重新啟動 ClamAV Daemon,套用變更:
sudo systemctl restart clamav-daemon確認 ClamAV 精靈正在執行:
sudo systemctl status clamav-daemon
設定 rsyslog 轉送 ClamAV 記錄
為 ClamAV 轉送建立新的 rsyslog 設定檔:
sudo nano /etc/rsyslog.d/30-clamav-forward.conf新增下列設定,將 ClamAV 記錄轉送至 Bindplane 代理程式:
# Forward ClamAV logs (LOG_LOCAL6 facility) to Bindplane agent if $syslogfacility-text == 'local6' then { action( type="omfwd" protocol="udp" target="BINDPLANE_AGENT_IP" port="514" queue.type="linkedList" queue.size="10000" action.resumeRetryCount="100" ) stop }將
BINDPLANE_AGENT_IP替換為 Bindplane 代理程式主機的 IP 位址:- 如果 Bindplane 與 ClamAV 安裝在同一部主機上,請使用
127.0.0.1 - 如果 Bindplane 位於其他主機,請使用該主機的 IP 位址 (例如
192.168.1.100)
- 如果 Bindplane 與 ClamAV 安裝在同一部主機上,請使用
如果您已設定 Bindplane 在其他通訊埠 (例如
1514) 上接聽,請據此更新port參數。儲存檔案並退出:
依序按下
Ctrl+O、Enter和Ctrl+X鍵驗證 rsyslog 設定語法:
sudo rsyslogd -N1重新啟動 rsyslog,以套用變更:
sudo systemctl restart rsyslog確認 rsyslog 正在執行:
sudo systemctl status rsyslog
測試設定
使用 EICAR 測試檔案產生測試病毒偵測:
cd /tmp echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > eicar.com使用 ClamAV 掃描測試檔案:
sudo clamdscan /tmp/eicar.com確認系統記錄中是否顯示偵測結果:
sudo tail -f /var/log/syslog | grep clamd您應該會看到類似下列內容的記錄項目:
Jan 15 10:30:45 hostname clamd[1234]: /tmp/eicar.com: Win.Test.EICAR_HDB-1(44d88612fea8a8f36de82e1278abb02f:68) FOUND檢查 Bindplane 代理程式記錄,確認記錄是否已轉送:
sudo journalctl -u observiq-otel-collector -f確認 Google SecOps 中顯示記錄:
- 登入 Google SecOps 控制台。
- 依序前往「搜尋」> UDM 搜尋。
針對 ClamAV 記錄執行搜尋查詢:
metadata.log_type = "CLAM_AV"
清除測試檔案:
sudo rm /tmp/eicar.com
替代設定:將所有系統記錄檔訊息轉送至 Bindplane
如要將所有系統記錄訊息 (不只是 ClamAV) 轉送至 Bindplane,請使用這個較簡單的設定:
編輯 rsyslog 設定:
sudo nano /etc/rsyslog.d/30-forward-all.conf新增下列設定:
# Forward all logs to Bindplane agent *.* action( type="omfwd" protocol="udp" target="BINDPLANE_AGENT_IP" port="514" queue.type="linkedList" queue.size="10000" action.resumeRetryCount="100" )將
BINDPLANE_AGENT_IP替換為適當的 IP 位址。按照上述步驟儲存、驗證及重新啟動 rsyslog。
UDM 對應表
| 記錄欄位 | UDM 對應 | 邏輯 |
|---|---|---|
| parsed_msg.resource.labels.instance_id | observer.resource.id | 直接複製值 |
| parsed_msg.labels.compute.googleapis.com/resource_name | observer.resource.name | 直接複製值 |
| parsed_msg.resource.type, parsed_msg.labels.container.googleapis.com/stream | observer.resource.type | 從 parsed_msg.resource.type 和 parsed_msg.labels.container.googleapis.com/stream 串連,並以「/」分隔 |
| parsed_msg.resource.labels.project_id、parsed_msg.resource.labels.cluster_name、parsed_msg.resource.labels.container_name | observer.hostname | 從 parsed_msg.resource.labels.project_id、parsed_msg.resource.labels.cluster_name 和 parsed_msg.resource.labels.container_name 串連而成,並以「/」分隔 |
| parsed_msg.resource.labels.container_name | observer.application | 直接複製值 |
| parsed_msg.labels.container.googleapis.com/namespace_name | observer.namespace | 直接複製值 |
| parsed_msg.resource.labels.zone | observer.location.country_or_region | 直接複製值 |
| parsed_msg.resource.labels.pod_id | observer.labels | 合併為鍵「pod_id」,值來自 parsed_msg.resource.labels.pod_id |
| parsed_msg.resource.labels.project_id、parsed_msg.resource.labels.cluster_name、parsed_msg.resource.labels.container_name | principal.hostname | 從 parsed_msg.resource.labels.project_id、parsed_msg.resource.labels.cluster_name 和 parsed_msg.resource.labels.container_name 串連而成,並以「/」分隔 |
| file, _file_path | target.file.full_path | 如果從 grok 模式擷取,則為檔案中的值;如果從替代 grok 模式擷取,則為 _file_path 中的值 |
| 威脅 | security_result.threat_name | 直接複製值 |
| total_files、_outcome、threat | security_result.summary | 如果已擷取 num_files,請設為「%{total_files} 個檔案遭到感染。」,否則請設為「已掃描檔案。(%{_outcome})」 (如果已擷取 _outcome),否則為「發現威脅 %{threat} 簽章。」(如果威脅不為空白) |
| category | security_result.category | 直接複製值 (如果威脅不為空,則設為「SOFTWARE_MALICIOUS」) |
| 動作 | security_result.action | 直接複製的值 (如果威脅不為空,則設為「BLOCK」;如果已擷取 _outcome,則設為「ALLOW」) |
| parsed_msg.insertId | metadata.product_log_id | 直接複製值 |
| parsed_msg.logName | metadata.description | 直接複製值 |
| metadata.event_type | 如果發現威脅或掃描檔案,請設為「SCAN_FILE」;如果擷取受感染的檔案數量,請設為「STATUS_UPDATE」 | |
| metadata.product_name | 設為「CLAMAV」 | |
| metadata.vendor_name | 設為「Cisco Systems」 |
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。