收集 MySQL 記錄
本文說明如何使用 Bindplane 將 MySQL 記錄擷取至 Google Security Operations。剖析器會先使用 grok 從 MySQL SYSLOG 訊息中擷取常見欄位。然後,它會使用條件分支 (if、else if) 和規則運算式比對,找出記錄訊息中的特定事件類型,並將相關資訊擷取及對應至 Unified Data Model (UDM) 結構定義。
事前準備
請確認您已完成下列事前準備事項:
- Google SecOps 執行個體
- Windows 2016 以上版本,或搭載
systemd的 Linux 主機 - 如果透過 Proxy 執行,防火牆通訊埠已開啟
- MySQL 主機的特殊存取權
- 已安裝 MySQL 資料庫和 Rsyslog
取得 Google SecOps 擷取驗證檔案
- 登入 Google SecOps 控制台。
- 依序前往「SIEM 設定」>「收集代理程式」。
- 下載擷取驗證檔案。將檔案安全地儲存在要安裝 Bindplane 的系統上。
取得 Google SecOps 客戶 ID
- 登入 Google SecOps 控制台。
- 依序前往「SIEM 設定」>「設定檔」。
- 複製並儲存「機構詳細資料」專區中的客戶 ID。
安裝 Bindlane 代理程式
Windows 安裝
- 以系統管理員身分開啟「命令提示字元」或「PowerShell」。
執行下列指令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
Linux 安裝
- 開啟具有根層級或 sudo 權限的終端機。
執行下列指令:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
其他安裝資源
如需其他安裝選項,請參閱安裝指南。
設定 Bindplane 代理程式,擷取系統記錄檔並傳送至 Google SecOps
- 存取設定檔:
- 找出
config.yaml檔案。通常位於 Linux 的/etc/bindplane-agent/目錄,或 Windows 的安裝目錄。 - 使用文字編輯器 (例如
nano、vi或記事本) 開啟檔案。
- 找出
按照下列方式編輯
config.yaml檔案:receivers: udplog: # Replace the port and IP address as required listen_address: "0.0.0.0:514" exporters: chronicle/chronicle_w_labels: compression: gzip # Adjust the path to the credentials file you downloaded in Step 1 creds: '/path/to/ingestion-authentication-file.json' # Replace with your actual customer ID from Step 2 customer_id: <customer_id> endpoint: malachiteingestion-pa.googleapis.com # Add optional ingestion labels for better organization ingestion_labels: log_type: 'MYSQL' raw_log_field: body service: pipelines: logs/source0__chronicle_w_labels-0: receivers: - udplog exporters: - chronicle/chronicle_w_labels視基礎架構需求,替換通訊埠和 IP 位址。
將
<customer_id>替換為實際的客戶 ID。將
/path/to/ingestion-authentication-file.json更新為「取得 Google SecOps 擷取驗證檔案」一節中驗證檔案的儲存路徑。
重新啟動 Bindplane 代理程式,以套用變更
如要在 Linux 中重新啟動 Bindplane 代理程式,請執行下列指令:
sudo systemctl restart bindplane-agent如要在 Windows 中重新啟動 Bindplane 代理程式,可以使用「服務」控制台,或輸入下列指令:
net stop BindPlaneAgent && net start BindPlaneAgent
在 MySQL 中設定 Syslog
使用 SSH 登入 MySQL 主機。
連線至 MySQL 資料庫:
mysql -u root -p驗證
server_audit.so稽核外掛程式:show variables like 'plugin_dir';如果外掛程式目錄中沒有外掛程式檔案,請使用下列指令安裝外掛程式:
install plugin server_audit soname 'server_audit.so';確認外掛程式已安裝並啟用:
show plugins;使用
vi編輯/etc/my.cnf檔案,啟用下列項目並儲存檔案:server_audit_events='CONNECT,QUERY,TABLE' server_audit_file_path=server_audit.log server_audit_logging=ON server_audit_output_type=SYSLOG server_audit_syslog_facility=LOG_LOCAL6使用下列指令驗證稽核變數:
show global variables like "server_audit%";執行下列指令,確認稽核功能已啟用:
Show global status like 'server_audit%';使用
vi編輯/etc/rsyslog.conf檔案,啟用 UDP 並儲存檔案:*.* @@<bindplane-agent-ip>:<bindplane-agent-port>將
<bindplane-agent-ip>和<bindplane-agent-port>替換為您的 Bindplane 代理程式設定。重新啟動 MySQL 服務,並連線至 MySQL 資料庫。
/etc/init.d/mysqld restart
UDM 對應表
| 記錄欄位 | UDM 對應 | 邏輯 |
|---|---|---|
| 動作 | read_only_udm.metadata.event_type | 如果值為 Created,則為 FILE_CREATION;如果值為 Deleted,則為 FILE_DELETION;否則沒有變更。 |
| 資料庫 | read_only_udm.target.resource.parent | |
| db_hostname | read_only_udm.target.hostname | |
| db_user | read_only_udm.target.user.userid | |
| 說明 | read_only_udm.security_result.description | |
| error_details | 這是暫時性變數,請忽略 | |
| error_level | read_only_udm.security_result.severity | 如果值為 error,則為「ERROR」;如果值為 warning,則為「MEDIUM」;如果值為 note,則為「INFORMATIONAL」;否則不變。 |
| error_message | read_only_udm.security_result.summary | |
| file_path | read_only_udm.target.file.full_path | |
| file_size | read_only_udm.target.file.size | |
| 主機名稱 | read_only_udm.principal.hostname | |
| inner_message | read_only_udm.security_result.description | |
| 摘要 | read_only_udm.metadata.product_event_type | |
| 資料表 | read_only_udm.target.resource.name | |
| table_not_found | 這是暫時性變數,請忽略 | |
| 時間戳記 | read_only_udm.metadata.event_timestamp | |
| read_only_udm.extensions.auth.type | 靜態值 - MACHINE |
|
| read_only_udm.metadata.event_type | 靜態值 - USER_LOGIN、GENERIC_EVENT、STATUS_UPDATE、FILE_CREATION、FILE_DELETION |
|
| read_only_udm.metadata.log_type | 靜態值 - MYSQL |
|
| read_only_udm.metadata.product_name | 靜態值 - MySQL |
|
| read_only_udm.metadata.vendor_name | 靜態值 - Oracle Corporation |
|
| read_only_udm.security_result.action | 靜態值 - BLOCK |
|
| read_only_udm.target.resource.resource_type | 靜態值 - DATABASE、TABLE |
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。