收集 Linux auditd 和 AIX 系統記錄

支援以下發布途徑:

這個剖析器會處理採用 SYSLOG 格式的 Linux 稽核記錄,並將這些記錄轉換為 UDM。這項服務會處理 JSON 格式和純文字記錄訊息,並使用 grok、XML 剖析和 JSON 剖析技術擷取欄位,然後根據事件類型將這些欄位對應至適當的 UDM 欄位。剖析器也會處理 AIX 系統的特定稽核記錄格式,並透過 security_result 和中介詳細資料等額外欄位,豐富 UDM。

事前準備

  • 確認您有 Google Security Operations 執行個體。
  • 確認您具備受稽核主機的根存取權。
  • 請確認您已在 Auditd 主機上安裝 rsyslog。
  • 請確認您有 Windows 2012 SP2 以上版本或 Linux 主機 (含 systemd)。
  • 如果是透過 Proxy 執行,請確認防火牆通訊埠已開啟。

取得 Google SecOps 擷取驗證檔案

  1. 登入 Google SecOps 控制台。
  2. 依序前往「SIEM 設定」>「收集代理程式」
  3. 下載擷取驗證檔案

取得 Google SecOps 客戶 ID

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

安裝 Bindplane 代理程式

  1. 如要在 Windows 上安裝,請執行下列指令碼:
    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
  2. 針對Linux 安裝程序,請執行下列指令碼:
    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
  3. 如需其他安裝選項,請參閱這份安裝指南

設定 Bindplane Agent 擷取 Syslog 並傳送至 Google SecOps

  1. 存取已安裝 Bindplane 的電腦。
  2. 按照下列方式編輯 config.yaml 檔案:

    receivers:
      tcplog:
        # Replace the below port <54525> and IP <0.0.0.0> with your specific values
        listen_address: "0.0.0.0:54525" 
    
    exporters:
        chronicle/chronicle_w_labels:
            compression: gzip
            # Adjust the creds location below according the placement of the credentials file you downloaded
            creds: '{ json file for creds }'
            # Replace <customer_id> below with your actual ID that you copied
            customer_id: <customer_id>
            endpoint: malachiteingestion-pa.googleapis.com
            # You can apply ingestion labels below as preferred
            ingestion_labels:
            log_type: SYSLOG
            namespace: auditd
            raw_log_field: body
    service:
        pipelines:
            logs/source0__chronicle_w_labels-0:
                receivers:
                    - tcplog
                exporters:
                    - chronicle/chronicle_w_labels
    
  3. 重新啟動 Bindplane 代理程式,使用下列指令套用變更: sudo systemctl bindplane restart

從 Auditd 匯出 Syslog

  1. 存取要匯出稽核記錄的機器。
  2. 開啟 Auditd 設定檔 (通常位於 /etc/audit/auditd.conf)。

    sudo vi /etc/audit/auditd.conf
    
  3. 找出或新增下列行,設定 auditd:

    active = yes
    output = syslog
    log_format = ENRICHED
    dispatcher = /sbin/audispd
    

選用步驟:指定 Syslog Facility:在 auditd.conf 中新增或修改下列行:

```none
syslog_facility = LOG_AUTHPRIV
```
  1. 開啟 audispd 設定檔 (通常位於 /etc/audisp/plugins.d/syslog.conf):

    sudo vi /etc/audisp/plugins.d/syslog.conf
    
  2. 找出或新增下列指令列,以便設定 audispd:

    active = yes
    direction = out
    path = builtin_syslog
    type = builtin
    args = LOG_INFO
    format = string
    
  3. 重新啟動 Auditd 服務,套用變更:

    sudo systemctl restart auditd
    
  4. 使用 tail 等工具監控 syslog,並確認是否傳送稽核記錄:

    tail -f /var/log/syslog | grep auditd # Follow syslog and filter for auditd messages (path may vary depending on your system)
    
  5. 編輯 rsyslog.conf 或建立自訂設定:

    sudo vi /etc/rsyslog.d/50-audit-forwarding.conf
    
  6. 新增轉送記錄的規則:

    • if $programname == 'auditd' then @@<Bindplane_Agent>:<Bindplane_Port>
    • 使用 @ 適用於 UDP,或 @@ 適用於 TCP
    • <BindPlane_Agent> 替換為伺服器的 IP/主機名稱。
    • <BindPlane_Port> 替換為伺服器的通訊埠。
  7. 重新啟動 rsyslog 服務以套用變更:

    sudo systemctl restart rsyslog
    

UDM 對應表

記錄欄位 UDM 對應 邏輯
acct target.user.user_display_name 原始記錄檔中的 acct 值會對應至 UDM 中的 target.user.user_display_name 欄位。代表與事件相關聯的帳戶。
addr principal.ip 原始記錄中的 addr 值會對應至 UDM 中的 principal.ip 欄位。代表事件中相關實體的 IP 位址。
additional.fields additional.fields 剖析的鍵/值組合或標籤所產生的其他欄位,會新增至 UDM 中的 additional.fields 陣列。
agent.googleapis.com/log_file_path (未對應) 這個標籤出現在部分原始記錄中,但未對應至 UDM 中的 IDM 物件。
algo (此範例未使用) 雖然這個欄位會出現在剖析器和部分原始記錄中,但在提供的範例中並未使用,也不會出現在最終的 UDM 中。
application principal.application 取自原始記錄檔中的 terminal 欄位,或 exe 等其他欄位 (視記錄類型而定)。代表相關應用程式。
arch security_result.about.platform_version 原始記錄的 arch 欄位架構會對應至 security_result.about.platform_version
auid about.user.useridsecurity_result.detection_fields.auid 稽核使用者 ID (auid) 會對應至 about.user.userid,並新增為 security_result 中的偵測欄位。
cmd target.process.command_line 原始記錄的 cmd 欄位指令會對應至 target.process.command_line
collection_time (未對應) 這個欄位是記錄收集時間,不會對應至 UDM 中的 IDM 物件。
comm principal.application 指令名稱 (comm) 會對應至 principal.application
compute.googleapis.com/resource_name principal.hostname 這個標籤的資源名稱會對應至 principal.hostname
create_time (未對應) 這個欄位未對應至 UDM 中的 IDM 物件。
cwd security_result.detection_fields.cwd 目前的工作目錄 (cwd) 會新增為 security_result 中的偵測欄位。
data (已處理) data 欄位包含主要記錄訊息,並由剖析器處理,以便擷取各種欄位。並未直接對應至單一 UDM 欄位。
exe principal.process.file.full_pathtarget.process.file.full_path 可執行路徑 (exe) 會根據情境對應至 principal.process.file.full_pathtarget.process.file.full_path
extensions.auth.type extensions.auth.type 剖析器邏輯會根據事件類型設定驗證類型。通常設為 MACHINEAUTHTYPE_UNSPECIFIED
fp network.tls.client.certificate.sha256 系統會剖析指紋 (fp),擷取 SHA256 雜湊並對應至 network.tls.client.certificate.sha256
insertId (未對應) 這個欄位未對應至 UDM 中的 IDM 物件。
jsonPayload.message (已處理) 這個欄位包含主要的記錄訊息,格式為 JSON,並由剖析器處理。
key security_result.about.registry.registry_key 鍵欄位會對應至 security_result.about.registry.registry_key
labels (已處理) 系統會處理原始記錄中的標籤,並將標籤對應至各種 UDM 欄位,或新增至 additional.fields
logName (未對應) 這個欄位未對應至 UDM 中的 IDM 物件。
msg security_result.summary 訊息 (msg) 通常用於填入 security_result.summary 欄位。
network.application_protocol network.application_protocol 由剖析器邏輯根據事件類型設定 (例如SSH、HTTP)。
network.direction network.direction 由剖析器邏輯根據事件類型設定 (例如INBOUND、OUTBOUND)。
network.ip_protocol network.ip_protocol 由剖析器邏輯設定,通常會將 SSH 事件設為 TCP。
network.session_id network.session_id ses 欄位對應或從其他欄位衍生。
network.tls.cipher network.tls.cipher 系統會從原始記錄中擷取加密資訊,並對應至這個欄位。
network.tls.curve network.tls.curve 系統會從原始記錄中擷取鍵交換曲線,並對應至這個欄位。
pid principal.process.pidtarget.process.pid 程序 ID (pid) 會根據情境對應至 principal.process.pidtarget.process.pid
ppid principal.process.parent_process.pidtarget.process.parent_process.pid 上層程序 ID (ppid) 會根據內容對應至 principal.process.parent_process.pidtarget.process.parent_process.pid
principal.asset.hostname principal.asset.hostname principal.hostname 複製的項目。
principal.asset.ip principal.asset.ip principal.ip 複製的項目。
principal.platform principal.platform 由剖析器邏輯依據作業系統設定 (例如 LINUX)。
principal.port principal.port 與主體相關聯的通訊埠編號。
principal.user.group_identifiers principal.user.group_identifiers 與主要使用者相關聯的群組 ID。
receiveTimestamp (未對應) 這個欄位是記錄接收時間戳記,不會對應至 UDM 中的 IDM 物件。
res security_result.action_details 結果 (res) 會對應至 security_result.action_details
resource.labels (未對應) 這些標籤會出現在部分原始記錄中,但不會對應至 UDM 中的 IDM 物件。
resource.type (未對應) 這個欄位會出現在部分原始記錄中,但不會對應至 UDM 中的 IDM 物件。
security_result.action security_result.action 由剖析器邏輯根據 res 欄位設定 (例如允許、封鎖)。
security_result.detection_fields security_result.detection_fields 原始記錄檔中的各個欄位會以鍵/值組合形式新增至這個陣列,以便提供背景資訊。
security_result.rule_id security_result.rule_id 由剖析器邏輯設定,通常會將 type_name 設為系統呼叫事件。
security_result.severity security_result.severity 由剖析器邏輯根據原始記錄中的嚴重性層級設定。
security_result.summary security_result.summary 事件摘要,通常是從 msg 欄位或其他相關欄位衍生而來。
ses network.session_id 工作階段 ID (ses) 會對應至 network.session_id
source (未對應) 這個欄位包含記錄來源的中繼資料,且不會對應至 UDM 中的 IDM 物件。
subj (已處理) 系統會處理主旨欄位 (subj),擷取使用者和安全性背景資訊。
syscall security_result.about.labels.Syscall 系統呼叫號碼會新增為 security_result.about 中的標籤。
target.administrative_domain target.administrative_domain 目標使用者的網域。
target.group.group_display_name target.group.group_display_name 指定目標群組的名稱。
target.ip target.ip 目標的 IP 位址。
target.port target.port 與目標相關聯的通訊埠編號。
target.process.command_line target.process.command_line 目標程序的指令列。
target.resource.type target.resource.type 目標資源的類型,由剖析器邏輯設定 (例如CREDENTIAL、SETTING)。
target.user.attribute.permissions target.user.attribute.permissions 與目標使用者相關的權限。
target.user.group_identifiers target.user.group_identifiers 與目標使用者相關聯的群組 ID。
target.user.userid target.user.userid 目標的使用者 ID。
textPayload (已處理) 解析器會處理記錄檔的文字酬載,以擷取各種欄位。
timestamp metadata.event_timestamp 事件的時間戳記。
tty security_result.about.labels.tty tty 會新增為 security_result.about 中的標籤。
type metadata.product_event_type 事件類型 (type) 會對應至 metadata.product_event_type
uid principal.user.useridtarget.user.userid 視環境而定,系統會將使用者 ID (uid) 對應至 principal.user.useridtarget.user.userid

異動

2024-05-08

  • 如果值不是「?」,則將「field」對應至「field33」,再對應至「security_result.detection_fields」。
  • 如果「type_name」是「CRYPTO_KEY_USER」,則將「exe」對應至「principal.process.file.full_path」。
  • 如果「type_name」是「CRYPTO_KEY_USER」,則會將「fp」對應至「network.tls.client.certificate.sha256」。
  • 如果「type_name」是「CRYPTO_KEY_USER」,則將「pid」對應至「principal.process.pid」。
  • 新增 Grok 模式,用於剖析新的日誌模式。
  • 將「syslog-tag」對應至「security_result.detection_fields」。
  • 已將「inter_ip」對應至「intermediary.ip」。
  • 已將「inter_hostname」對應至「intermediary.hostname」。

2024-05-02

  • 如果「type_name」是「USER_MGMT」,則將「grp」對應至「target.group.group_display_name」。
  • 如果「type_name」是「USER_MGMT」,則「uid」的對應項目會從「principal.user.userid」變更為「target.user.userid」。
  • 如果「type_name」是「USER_MGMT」,且「op」等於「deleting-user-from-group」,請將「metadata.event_type」設為「GROUP_MODIFICATION」。
  • 如果「type_name」是「USER_MGMT」,則將「exe」的對應項目從「target.process.file.full_path」變更為「principal.process.file.full_path」。
  • 如果「type_name」是「USER_MGMT」,則將「id」對應至「about.user.userid」。

2024-04-08

  • 如果「type_name」是「ADD_USER」、「principal_user_present」是「true」、「target_user_present」是「true」,且「has_principal」是「true」,請將「metadata.event_type」設為「USER_CREATION」。
  • 如果「type_name」是「USER_AUTH」,則將「acct」對應至「target.user.user_display_name」。
  • 如果「type_name」是「USER_AUTH」,則將「uid」對應至「principal.user.userid」。
  • 如果「type_name」不在「ADD_USER」、「USER_AUTH」、「CRED_ACQ」和「USER_MGMT」中,則將「auid」對應至「about.user.userid」。
  • 如果「type_name」是「ADD_USER」,則將「auid」對應至「target.user.userid」。
  • 如果「type_name」是「ADD_USER」或「USER_AUTH」,則會將「exe」對應至「principal.process.file.full_path」。
  • 如果「type_name」是「ADD_USER」,則將「op」和「id」對應至「security_result.summary」。
  • 如果「type_name」是「USER_AUTH」,則將「op」和「acct」對應至「security_result.summary」。

2024-03-22

  • 新增支援 JSON 記錄的新模式。
  • 將「labels.compute.googleapis.com/resource_name」、「jsonPayload._HOSTNAME」、「CollectorHostName」、「HOSTNAME」和「Computer」對應至「principal.hostname」。
  • 將「HostIP」對應至「principal.ip」。
  • 將「ProcessID」和「jsonPayload._PID」對應至「principal.process.pid」。
  • 將「SyslogMessage」對應至「metadata.description」。
  • 將「TenantId」、「_ItemId」、「_Internal_WorkspaceResourceId」、「_ResourceId」和「Facility」對應至「additional.fields」。
  • 將「SeverityLevel」對應至「security_result.severity」。
  • 將「SourceSystem」對應至「principal.platform」。
  • 將「jsonPayload._COMM」對應至「principal.application」。
  • 將「jsonPayload._EXE」對應至「target.process.file.full_path」。
  • 將「jsonPayload._AUDIT_FIELD_FILE」對應至「target.file.full_path」。
  • 已將「jsonPayload._AUDIT_FIELD_HASH」對應至「target.file.hash」。
  • 將「jsonPayload._AUDIT_SESSION」對應至「network.session_id」。
  • 將「jsonPayload._PPID」對應至「principal.process.parent_process.pid」。
  • 已將「jsonPayload._AUDIT_FIELD_A0」、「jsonPayload._AUDIT_FIELD_A1」、「jsonPayload._AUDIT_FIELD_A2」、「jsonPayload._AUDIT_FIELD_A3」、「jsonPayload._BOOT_ID」和「jsonPayload._AUDIT_FIELD_EXIT」對應至「security_result.detection_fields」。

2023-11-27

  • 新增驗證檢查,確保在將「metadata.event_type」設為「USER_LOGIN」前,"principal_user_present"、"target_user_present" 或 "has_principal" 為「是」。
  • 新增驗證檢查,確保在將「metadata.event_type」設為「USER_LOGOUT」前,"principal_user_present"、"target_user_present" 或 "has_principal" 為「是」。
  • 新增驗證檢查,確保在將「metadata.event_type」設為「USER_CREATION」前,確保「principal_user_present」、「target_user_present」或「has_principal」為「是」。
  • 新增驗證檢查,確保在將「metadata.event_type」設為「USER_DELETION」前,"principal_user_present"、"target_user_present" 或 "has_principal" 為 true。
  • 新增驗證檢查,確保在將「metadata.event_type」設為「USER_UNCATEGORIZED」前,"principal_user_present"、"target_user_present" 或 "has_principal" 為 true。
  • 新增驗證檢查,確保在將「metadata.event_type」設為「USER_RESOURCE_ACCESS」前,"principal_user_present"、"target_user_present" 或 "has_principal" 為「是」。
  • 新增驗證檢查,確保在將「metadata.event_type」設為「USER_CHANGE_PERMISSIONS」前,"principal_user_present"、"target_user_present" 或 "has_principal" 為「是」。
  • 如果使用者詳細資料存在,但主要機器詳細資料不存在,則將「metadata.event_type」的對應項目從「USER_CREATION」變更為「USER_UNCATEGORIZED」。
  • 如果使用者詳細資料存在,但主要機器詳細資料不存在,則將「metadata.event_type」的對應項目從「USER_DELETION」變更為「USER_UNCATEGORIZED」。

2023-09-06

  • 針對「cron daemon(CROND)」新增了「CMD」與「target.process.command_line」的對應項目。

2023-06-20

  • 改善功能:當 type 為「ADD_USER」和「DEL_USER」時,新增或修改下列對應項目:
  • 將「uid」的對應項目從「target.user.userid」修改為「principal.user.userid」。
  • 將「id」對應至「target.user.userid」。
  • 將「ID」對應至「target.user.user_display_name」。
  • 將「UID」的對應項目從「principal.user.userid」修改為「principal.user.user_display_name」。
  • 將「acct」的對應項目從「principal.user.user_display_name」修改為「target.user.user_display_name」和「target.user.userid」。

2023-06-09

  • 改善項目:當「type=ADD_USER」時,將「event_type」從「USER_LOGIN」修改為「USER_CREATION」。

2023-04-17

  • 強化
  • 新增 gsub 函式,用來取代會破壞 JSON 結構的「GS - 群組分隔符」字元。

2023-04-10

  • 強化
  • 新增「gid」、「euid」、「egid」、「suid」、「fsuid」、「sgid」、「fsgid」、「tty」、「items」欄位至 security_result.detection_fields。
  • 此外,我們也將「gid」對應至「principal.user.group_identifiers」。
  • 將「euid」對應至「target.user.userid」。
  • 已將「egid」對應至「target.user.group_identifiers」。

2023-03-27

  • 改善功能:新增對含有記錄的「jsonPayload」支援。

2023-02-28

  • 錯誤修正:強化剖析器,將十六進位編碼字串轉換為 ASCII。

2023-02-09

  • 改善項目:針對含有「type=PATH」的記錄修改 grok,以便從記錄中擷取正確的主機名稱。

2023-01-24

  • 改善項目:
  • 剖析的記錄中,eventType 為「tac_plus」。
  • 新增對應不同 event_type 的條件:「NETWORK_CONNECTION」、「NETWORK_HTTP」、「USER_LOGIN」。

2022-12-02

  • 改善項目:
  • 將「user_name」對應至「principal.user.userid」。
  • 新增「dst_ip」和「dst_port」的條件檢查。

2022-10-31

  • 改善項目:
  • 強化剖析器,以便剖析 type=ADD_USER、USER_MGMT、DEL_USER 的記錄。
  • 新增「principal_hostname」的空值檢查。
  • 已為「principal.process.file.full_path」、「type_syscall_props.key」、「type_syscall_props.arch」、「msg2」新增 on_error 檢查。
  • 新增條件檢查,對應至 event_type="FILE_OPEN"、"USER_UNCATEGORIZED"、"STATUS_UPDATE" 和 "USER_DELETION"。
  • 將「principal_user_userid」對應至「principal.user.userid」。

2022-11-16

  • 改善項目:
  • 針對包含「存取記錄」的記錄類型,將「GENERIC_EVENT」改為「STATUS_UPDATE」。

2022-10-14

  • 改善項目:
  • 將客戶剖析器遷移至預設剖析器。

2022-10-13

  • 改善項目:將「vendor_name」對應至「Linux」。
  • 已將「product_name」對應至「AuditD」。
  • 剖析含有「ProxySG」的記錄,並盡可能將「ip」對應至「target.ip」,將「port」對應至「target.port」。
  • 已將「event_type」從「GENERIC_EVENT」修改為「STATUS_UPDATE」。
  • 將「intermediary.hostname」的對應項目修改為「principal.hostname」。

2022-07-28

  • 改善項目:
  • 將「auid」欄位對應至「about.user.userid」。
  • 將「AUID」欄位對應至「about.user.user_display_name」。
  • 將「proctitle」欄位對應至「target.process.file.full_path」。
  • 強化剖析器,以便剖析 type=DAEMON_END、CRYPTO_SESSION、CONFIG_CHANGE、PROCTITLE、USER_ERR、CRYPTO_KEY_USER 的記錄。
  • 新增 laddr、addr、cipher、pfs、direction、acct、pid、ppid、cmd、exe、ses 的條件式檢查。

2022-06-17

  • 改善功能 - 對應/修改下列欄位:
  • 將「auid」的對應項目從「security_result.about.user.userid」變更為「about.user.userid」。
  • 將 type=SYSCALL 的「event_type」從「SYSTEM_AUDIT_LOG_UNCATEGORIZED」變更為「USER_UNCATEGORIZED」。
  • 已將「success」對應至「security_result.summary」。
  • 已將「syscall」、「exit」、「tty」、「a0」、「a1」、「a2」、「a3」對應至「security_result.about.labels」。
  • 以 ASCII 格式放置記錄。

2022-06-14

  • 增強
  • 強化剖析器,以便剖析 USER_CMD 類型的記錄。
  • 將「cmd」欄位對應至「principal.process.command_line」。
  • 將「ses」欄位對應至「network.session_id」。
  • 將「res」欄位對應至「security_result.action」和「security_result.action_details」。
  • 將欄位「auid」和「cwd」對應至「security_result.detection_fields」。

2022-04-26

  • 增強
  • 剖析所有未剖析的記錄,提高剖析百分比。

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