收集 Microsoft SQL Server 記錄

支援的國家/地區:

本文說明如何使用 Bindplane 將 Microsoft SQL Server 記錄擷取至 Google Security Operations。剖析器會處理結構化 (JSON、鍵/值組合) 和半結構化 (系統記錄) 的 Microsoft SQL Server 記錄。這項功能會擷取欄位、正規化時間戳記、根據 SourceModuleTypeMessage 內容 (包括稽核、登入和資料庫事件) 處理不同記錄格式,並將這些格式對應至 UDM。此外,這項服務也會針對稽核記錄、登入嘗試和資料庫作業執行特定剖析邏輯,並使用額外的背景資訊和嚴重程度資訊擴充資料。這項服務會使用 Syslog 轉送程式 (NXLog) 從 Windows 事件記錄檔收集 SQL Server 稽核和錯誤記錄,然後傳送至 BindPlane 代理程式,以便傳送至 Google SecOps。

事前準備

請確認您已完成下列事前準備事項:

  • Google SecOps 執行個體
  • 執行 Microsoft SQL Server 的 Windows Server 2016 以上版本主機
  • 具備管理員存取權,可安裝及設定 BindPlane 代理程式和 NXLog
  • 如果透過 Proxy 執行,請確保防火牆通訊埠已根據 Bindplane 代理程式需求開啟

取得 Google SecOps 擷取驗證檔案

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

取得 Google SecOps 客戶 ID

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

安裝 Bindplane 代理程式

請按照下列操作說明,在 Windows 或 Linux 作業系統上安裝 Bindplane 代理程式。

Windows 安裝

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

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    

其他安裝資源

如需其他安裝選項,請參閱安裝指南

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

  1. 存取設定檔:
    • 找出 config.yaml 檔案。在 Windows 上,通常位於 `C:\Program Files\observIQ\bindplane-agent` 目錄。
    • 使用文字編輯器 (例如 nanovi 或記事本) 開啟檔案。
  2. 按照下列方式編輯 config.yaml 檔案:

      receivers:
      udplog:
         # Replace the port and IP address as required
         listen_address: "0.0.0.0:1514"
    
      exporters:
      chronicle/chronicle_w_labels:
         compression: gzip
         # Adjust the path to the credentials file you downloaded in Step 1
         creds_file_path: '/path/to/ingestion-authentication-file.json'
         # Replace with your actual customer ID from Step 2
         customer_id: <YOUR_CUSTOMER_ID>
         endpoint: malachiteingestion-pa.googleapis.com
         # Add optional ingestion labels for better organization
         log_type: 'MICROSOFT_SQL'
         raw_log_field: body
         ingestion_labels:
    
      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 代理程式,以套用變更

  • 如要在 Windows 中重新啟動 Bindplane 代理程式,可以使用「服務」控制台,或輸入下列指令:

    net stop BindPlaneAgent && net start BindPlaneAgent
    

在 Windows 事件記錄中啟用 SQL Server 稽核

您可以使用 SQL Server Management Studio (SSMS) GUI 或 T-SQL 指令啟用 SQL Server 稽核功能。請選擇最適合您環境的選項。

選項 1:透過 SSMS GUI 啟用 SQL Server 稽核功能

在 SQL Server Management Studio UI 中建立伺服器稽核

  1. 開啟 SQL Server Management Studio (SSMS),然後連線至 SQL Server 執行個體。
  2. 在「物件總管」中,展開伺服器執行個體。
  3. 展開「安全性」資料夾。
  4. 以滑鼠右鍵按一下「稽核」,然後選取「新增稽核」
  5. 在「建立稽核」對話方塊中,提供下列設定詳細資料:
    • 稽核名稱:輸入 ChronicleAudit
    • 佇列延遲 (毫秒):輸入 1000
    • 稽核記錄失敗時:選取「繼續」
    • 稽核目的地:選取「應用程式記錄」
  6. 按一下「確定」即可建立稽核。
  7. 在「物件總管」中,以滑鼠右鍵按一下新建立的「ChronicleAudit」,然後選取「啟用稽核」

透過 SSMS GUI 建立伺服器稽核規格

  1. 在「物件總管」中展開「安全性」
  2. 以滑鼠右鍵按一下「伺服器稽核規格」,然後選取「新增伺服器稽核規格」。
  3. 在「Create Server Audit Specification」(建立伺服器稽核規格) 對話方塊中,提供下列設定詳細資料:
    • 「Name」(名稱):輸入 ChronicleAuditSpec
    • 稽核:從選單中選取「ChronicleAudit」
  4. 在「稽核動作類型」部分,按一下「新增」,然後選取下列稽核動作群組 (選取每個群組後,請按一下「新增」逐一新增):
    • FAILED_LOGIN_GROUP
    • SUCCESSFUL_LOGIN_GROUP
    • LOGOUT_GROUP
    • SERVER_ROLE_MEMBER_CHANGE_GROUP
    • DATABASE_OBJECT_CHANGE_GROUP
    • DATABASE_PRINCIPAL_CHANGE_GROUP
    • SCHEMA_OBJECT_CHANGE_GROUP
    • DATABASE_PERMISSION_CHANGE_GROUP
  5. 按一下「確定」建立稽核規格。
  6. 在「物件總管」中,在新建的「ChronicleAuditSpec」上按一下滑鼠右鍵,然後選取「啟用伺服器稽核規格」

驗證稽核設定

  1. 在「物件總管」中,展開「安全性」> 稽核」
  2. 在「ChronicleAudit」上按一下滑鼠右鍵,然後選取「內容」
  3. 確認「狀態」顯示為「已啟動」或「已啟用」
  4. 展開「安全性」>「伺服器稽核規格」
  5. 在「ChronicleAuditSpec」上按一下滑鼠右鍵,然後選取「Properties」。
  6. 確認列出所有八個稽核動作群組,且規格已啟用。

選項 2:使用 T-SQL 啟用 SQL Server 稽核功能

  1. 開啟 SQL Server Management Studio (SSMS),然後連線至 SQL Server 執行個體。
  2. 執行下列 T-SQL 指令,建立寫入 Windows 應用程式記錄的伺服器稽核:

    USE master;
    GO
    
    CREATE SERVER AUDIT ChronicleAudit
    TO APPLICATION_LOG
    WITH (QUEUE_DELAY = 1000, ON_FAILURE = CONTINUE);
    GO
    
    ALTER SERVER AUDIT ChronicleAudit WITH (STATE = ON);
    GO
    
  3. 建立稽核規格,擷取相關安全性事件:

    CREATE SERVER AUDIT SPECIFICATION ChronicleAuditSpec
    FOR SERVER AUDIT ChronicleAudit
    ADD (FAILED_LOGIN_GROUP),
    ADD (SUCCESSFUL_LOGIN_GROUP),
    ADD (LOGOUT_GROUP),
    ADD (SERVER_ROLE_MEMBER_CHANGE_GROUP),
    ADD (DATABASE_OBJECT_CHANGE_GROUP),
    ADD (DATABASE_PRINCIPAL_CHANGE_GROUP),
    ADD (SCHEMA_OBJECT_CHANGE_GROUP),
    ADD (DATABASE_PERMISSION_CHANGE_GROUP);
    GO
    
    ALTER SERVER AUDIT SPECIFICATION ChronicleAuditSpec WITH (STATE = ON);
    GO
    

這項設定可確保系統將驗證事件、權限變更和物件修改記錄到 Windows 事件記錄檔。

安裝及設定 NXLog,將事件轉送至 Bindplane

  1. nxlog.co/downloads 下載 NXLog Community Edition
  2. 執行安裝程式,並完成安裝精靈。
  3. 開啟位於下列位置的 NXLog 設定檔:

    C:\Program Files\nxlog\conf\nxlog.conf
    
  4. 將內容替換成下列設定:

    define ROOT C:\Program Files\nxlog
    Moduledir %ROOT%\modules
    CacheDir %ROOT%\data
    Pidfile %ROOT%\data\nxlog.pid
    SpoolDir %ROOT%\data
    LogFile %ROOT%\data\nxlog.log
    
    <Extension _json>
       Module      xm_json
    </Extension>
    
    <Input in_eventlog>
       Module      im_msvistalog
       Query       <QueryList>\
                      <Query Id="0">\
                            <Select Path="Application">*[System[Provider[@Name='MSSQLSERVER']]]</Select>\
                      </Query>\
                   </QueryList>
    </Input>
    
    <Output out_syslog>
       Module      om_udp
       Host        127.0.0.1
       Port        1514
       Exec        to_json();
    </Output>
    
    <Route r1>
       Path        in_eventlog => out_syslog
    </Route>
    
    • 將「Host」(主機) 的目前值 127.0.0.1 替換為 Bindplane 代理程式 IP 位址。
    • 確認「Port」值與先前設定的 Bindplane udplog 接收器通訊埠相符。
  5. 儲存檔案並重新啟動 NXLog 服務:

    net stop nxlog && net start nxlog
    

UDM 對應表

記錄欄位 UDM 對應 邏輯
AccountName principal.user.userid 如果記錄中出現「Starting up database」或「Log was backed up」等訊息,則會使用 principal.user.userid
AgentDevice additional.fields 以鍵/值組合的形式新增至 additional.fields,鍵為「AgentDevice」。
AgentLogFile additional.fields 以鍵/值組合的形式新增至 additional.fields,鍵為「AgentLogFile」。
agent.hostname observer.asset.hostname 對應至觀察者主機名稱。
agent.id observer.asset_id agent.type 串連,形成 observer.asset_id
agent.type observer.asset_id agent.id 串連,形成 observer.asset_id
agent.version observer.platform_version 對應至觀察員平台版本。
ApplicationName principal.application 對應至主要應用程式。
application_name target.application 對應至目標應用程式。
client_address principal.ip 如果與主機不同,且不是本機或具名管道,則用於主體 IP。
client_ip principal.ip 對應至主體 IP。
computer_name about.hostname 對應至主機名稱。
correlationId security_result.detection_fields 以鍵/值組合的形式新增至 security_result.detection_fields,並使用「correlationId」做為鍵。
Date metadata.event_timestamp Time 結合,即可建立事件時間戳記。
database_name target.resource_ancestors.name 如果稽核記錄中存在目標資源的祖先名稱,則會使用此名稱。
durationMs network.session_duration.seconds 從毫秒轉換為秒,並對應。
ecs.version metadata.product_version 對應至產品版本。
error security_result.detection_fields 以鍵/值組合的形式新增至 security_result.detection_fields,鍵為「error」。
err_msg security_result.description 對應至安全性結果說明的地圖。
EventID metadata.product_event_type 如果沒有其他欄位,可用於建構產品事件類型,並以「EventID: 」為前置字元。
event.action Source 如果存在,則做為來源。
event.code metadata.product_event_type event.provider 結合形成 metadata.product_event_type
event.provider metadata.product_event_type event.code 結合形成 metadata.product_event_type
EventReceivedTime metadata.ingested_timestamp 系統會剖析並做為擷取時間戳記使用。
event_time metadata.event_timestamp 系統會剖析並做為事件時間戳記使用。
file_name principal.process.file.full_path 對應至主程序檔案的完整路徑。
file_path target.file.full_path 如果備份記錄中找到目標檔案,則用於目標檔案完整路徑。
first_lsn target.resource.attribute.labels 以鍵/值組合的形式新增至 target.resource.attribute.labels,鍵為「First LSN」。
host principal.hostnameobserver.hostname 如果不是 IP,則用於主體或觀察者主機名稱。視是否為 IP 而定,也可用於目標主機名稱或 IP。
host.ip principal.ip 已併入主要 IP。
host.name host 如有,則做為主機使用。
Hostname principal.hostnametarget.hostname 如果存在,則用於主機或目標主機名稱。
hostinfo.architecture principal.asset.hardware.cpu_platform 對應至主要資產硬體 CPU 平台。
hostinfo.os.build additional.fields 以鍵/值組合的形式新增至 additional.fields,鍵為「os_build」。
hostinfo.os.kernel principal.platform_patch_level 對應至主要平台修補程式層級。
hostinfo.os.name additional.fields 以鍵/值組合的形式新增至 additional.fields,並使用「os_name」鍵。
hostinfo.os.platform principal.platform 大寫,並對應至主要平台。
hostinfo.os.version principal.platform_version 對應至主要平台版本。
last_lsn target.resource.attribute.labels 以鍵/值組合的形式新增至 target.resource.attribute.labels,鍵為「Last LSN」。
level security_result.severity 如果為「Informational」,則將 security_result.severity 設為「INFORMATIONAL」。
log.level security_result.severity_details 對應至安全結果嚴重程度詳細資料。
LoginName principal.user.userid 如果 KV 記錄中存在主體使用者 ID,則會使用該 ID。
login_result security_result.action 決定安全結果動作 (允許或封鎖)。
logon_user principal.user.userid 如果登入記錄中存在主體使用者 ID,則會使用該 ID。
logstash.process.host intermediary.hostname 對應至中介主機名稱。
Message metadata.descriptionsecurity_result.description 視記錄類型而定,可用於事件說明或安全性結果說明。
msg metadata.description 如果有的話,用於活動說明。
ObjectName target.resource.name 對應至目標資源名稱。
object_name target.resource.name 如果稽核記錄中存在目標資源名稱,則會使用此名稱。
ObjectType target.resource.type 對應至目標資源類型。
operationId security_result.detection_fields 以鍵/值組合的形式新增至 security_result.detection_fields,並使用「operationId」鍵。
operationName metadata.product_event_type 對應至產品事件類型。
operationVersion additional.fields 以鍵/值組合形式新增至 additional.fields,鍵為「operationVersion」。
ProcessInfo additional.fields 以鍵/值組合的形式新增至 additional.fields,並使用「ProcessInfo」鍵。
properties.apiVersion metadata.product_version 對應至產品版本。
properties.appId target.resource.product_object_id 對應至目標資源產品物件 ID。
properties.clientAuthMethod extensions.auth.auth_details 用於判斷驗證詳細資料。
properties.clientRequestId additional.fields 以鍵/值組合的形式新增至 additional.fields,並使用「clientRequestId」鍵。
properties.durationMs network.session_duration.seconds 已轉換為秒數並對應。
properties.identityProvider security_result.detection_fields 以鍵/值組合的形式新增至 security_result.detection_fields,鍵為「identityProvider」。
properties.ipAddress principal.ipprincipal.asset.ip 剖析 IP,並合併至主要 IP 和主要資產 IP。
properties.location principal.location.name 對應至主要位置名稱。
properties.operationId security_result.detection_fields 以鍵/值組合的形式新增至 security_result.detection_fields,並使用「operationId」鍵。
properties.requestId metadata.product_log_id 對應至產品記錄 ID。
properties.requestMethod network.http.method 對應至網路 HTTP 方法。
properties.requestUri target.url 對應至目標網址。
properties.responseSizeBytes network.received_bytes 轉換為無正負號整數並對應。
properties.responseStatusCode network.http.response_code 已轉換為整數並對應。
properties.roles additional.fields 以鍵/值組合的形式新增至 additional.fields,鍵為「roles」。
properties.servicePrincipalId principal.user.userid 如果沒有 properties.userId,則用於主要使用者 ID。
properties.signInActivityId network.session_id 對應至網路工作階段 ID。
properties.tenantId metadata.product_deployment_id 對應至產品部署 ID。
properties.tokenIssuedAt additional.fields 以鍵/值組合的形式新增至 additional.fields,並使用「tokenIssuedAt」鍵。
properties.userAgent network.http.user_agent 對應至網路 HTTP 使用者代理程式。
properties.userId principal.user.userid 如果存在,則用於主體使用者 ID。
properties.wids security_result.detection_fields 以鍵/值組合的形式新增至 security_result.detection_fields,鍵為「wids」。
reason security_result.summary 用於登入事件中的安全性結果摘要。
resourceId target.resource.attribute.labels 以鍵/值組合的形式新增至 target.resource.attribute.labels,鍵為「資源 ID」。
schema_name target.resource_ancestors.resource_subtype 如果稽核記錄中存在目標資源上層子類型,則會使用此類型。
security_result.description metadata.description 如果不是稽核事件,則用於事件說明。
security_result.severity security_result.severity 如果存在,則直接對應。KV 記錄設為「LOW」,特定錯誤訊息設為「INFORMATIONAL」,並衍生自 levelSeverity 欄位。
security_result.severity_details security_result.severity_details 如果存在,則直接對應。
security_result.summary security_result.summary 如果存在,則直接對應。針對登入事件,請設為「使用 Windows 驗證建立連線」或登入事件中的特定原因;針對稽核事件,請設為「SQL Server 稽核記錄」。
security_result_action security_result.action 已合併至「security_result.action」。大部分事件都設為「ALLOW」,登入事件則衍生自 login_result
server_instance_name target.hostname 如果稽核記錄中存在目標主機名稱,則會使用此名稱。
server_principal_name principal.user.userid 如果稽核記錄中存在主體使用者 ID,則會使用該 ID。
server_principal_sid principal.asset_id 用於建構主體資產 ID,並加上「server SID:」前置字元。
session_id network.session_id 如果稽核記錄中存在網路工作階段 ID,則會使用該 ID。
sev security_result.severity 用於判斷安全性結果的嚴重程度。
Severity security_result.severity 用於判斷安全性結果的嚴重程度。
Source additional.fields 以鍵/值組合的形式新增至 additional.fields,鍵為「來源」。
source principal.resource.attribute.labels 以鍵/值組合的形式新增至 principal.resource.attribute.labels,鍵為「source」。
SourceModuleType observer.application 對應至觀察者應用程式。
SourceModuleName additional.fields 以鍵/值組合的形式新增至 additional.fields,並使用「SourceModuleName」鍵。
source_module_name observer.labels 以鍵/值組合的形式新增至 observer.labels,並使用「SourceModuleName」鍵。
source_module_type observer.application 對應至觀察者應用程式。
SPID network.session_id 對應至網路工作階段 ID。
statement target.process.command_line 如果稽核記錄中存在目標程序指令列,則會使用此指令列。
TextData security_result.descriptionmetadata.description 如果不是登入事件,則用於安全性結果說明;如果是登入事件,則用於事件說明。
time metadata.event_timestamp 系統會剖析並做為事件時間戳記使用。
Time metadata.event_timestamp Date 結合,即可建立事件時間戳記。
transaction_id target.resource.attribute.labels 以鍵/值組合的形式新增至 target.resource.attribute.labels,並使用「transaction_id」鍵。
UserID principal.user.windows_sid 如果主要使用者 Windows SID 存在且格式正確,則會使用該 SID。
user_id principal.user.userid 如果存在,則用於主體使用者 ID。
metadata.log_type metadata.log_type 硬式編碼為「MICROSOFT_SQL」。
metadata.vendor_name metadata.vendor_name 硬式編碼為「Microsoft」。
metadata.product_name metadata.product_name 硬式編碼為「SQL Server」。
metadata.event_type metadata.event_type 根據記錄內容設定各種值,包括「USER_LOGIN」、「USER_LOGOUT」、「STATUS_STARTUP」、「STATUS_SHUTDOWN」、「NETWORK_HTTP」、「GENERIC_EVENT」和預設的「STATUS_UNCATEGORIZED」。
extensions.auth.type extensions.auth.type 登入和登出事件請設為「MACHINE」。

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