收集 Linux Audit Daemon 記錄

支援的國家/地區:

本文說明如何使用 Bindplane,將 Linux Audit Daemon (auditd) 記錄擷取至 Google Security Operations。

Linux Audit Daemon 是 Linux 稽核系統的 Userspace 元件。這項服務會記錄系統上與安全性相關的事件,包括檔案存取、系統呼叫、驗證事件和 SELinux 拒絕。稽核記錄對於法規遵循監控、入侵偵測和 Linux 主機的鑑識分析至關重要。

事前準備

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

  • Google SecOps 執行個體。
  • Windows Server 2016 以上版本,或搭載 systemd 的 Linux 主機。
  • 如果透過 Proxy 執行,請確保防火牆通訊埠已根據 Bindplane 代理程式需求開啟。
  • 在執行 auditd 的 Linux 主機上,擁有 root 或 sudo 存取權。
  • 在來源 Linux 主機上安裝並執行 auditd 套件。
  • 安裝在來源 Linux 主機上的 audispd-plugins 套件 (提供 audisp-syslog 外掛程式)。

取得 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
    

Linux 安裝

  1. 開啟具有根層級或 sudo 權限的終端機。
  2. 執行下列指令:

    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
    

其他安裝資源

如需其他安裝選項,請參閱 Bindplane 代理程式安裝指南

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

  1. 存取設定檔:

    • Linux/status observiq-otel-collector/config.yaml
    • WindowsC:\Program Files\observIQ OpenTelemetry Collector\config.yaml
  2. 按照下列方式編輯 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_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: 'AUDITD'
            raw_log_field: body
            ingestion_labels:
    
    service:
        pipelines:
            logs/source0__chronicle_w_labels-0:
                receivers:
                    - udplog
                exporters:
                    - chronicle/chronicle_w_labels
    
  • 視基礎架構需求,替換通訊埠和 IP 位址。
  • <your_customer_id> 替換為實際的客戶 ID。
  • /path/to/ingestion-authentication-file.json 更新為檔案路徑,也就是在「取得擷取驗證檔案」步驟中儲存驗證檔案的路徑。

重新啟動 Bindplane 代理程式,以套用變更

如要在 Linux 中重新啟動 Bindplane 代理程式,請執行下列步驟:

  1. 執行下列指令:

    sudo systemctl restart observiq-otel-collector
    
  2. 確認服務正在執行:

    sudo systemctl status observiq-otel-collector
    
  3. 檢查記錄中是否有錯誤:

    sudo journalctl -u observiq-otel-collector -f
    

如要在 Windows 中重新啟動 Bindplane 代理程式,請按照下列步驟操作:

  1. 您可以選擇下列其中一個選項:

    • 以管理員身分開啟命令提示字元或 PowerShell:
    net stop observiq-otel-collector && net start observiq-otel-collector
    
    • 服務控制台:
      1. 按下 Win+R,輸入 services.msc,然後按下 Enter 鍵。
      2. 找出 observIQ OpenTelemetry Collector
      3. 按一下滑鼠右鍵,然後選取「重新啟動」
  2. 確認服務正在執行:

    sc query observiq-otel-collector
    
  3. 檢查記錄中是否有錯誤:

    type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
    

設定 auditd 透過系統記錄檔轉送記錄

audisp syslog 外掛程式會將稽核事件轉送至 syslog,然後 syslog 會將事件傳送至 Bindplane 代理程式。建議使用這個方法轉送 auditd 記錄。

安裝 audisp syslog 外掛程式

  1. 使用 Root 或 sudo 權限登入執行 auditd 的 Linux 主機。
  2. 安裝 audispd-plugins 套件:

    • RHEL/CentOS/Fedora
    sudo yum install audispd-plugins
    
    • Debian/Ubuntu
    sudo apt install audispd-plugins
    

設定 Syslog 外掛程式

  1. 編輯 syslog 外掛程式設定檔:

    sudo nano /etc/audit/plugins.d/syslog.conf
    
  2. 在檔案中設定下列值:

    active = yes
    direction = out
    path = /sbin/audisp-syslog
    type = always
    args = LOG_LOCAL6
    format = string
    
    • active:設為 yes 即可啟用外掛程式。
    • pathaudisp-syslog 二進位檔的路徑。
    • type:設為 always,將外掛程式做為外部程式執行。
    • args:要使用的系統記錄設施。建議您將稽核記錄與其他系統記錄訊息分開。LOG_LOCAL6
    • format:設為 string,以傳遞適合系統記錄的文字格式事件。

設定稽核規則 (選用)

  1. 編輯稽核規則檔案,定義要擷取的事件:

    sudo nano /etc/audit/rules.d/audit.rules
    
  2. 根據監控需求新增規則。例如:

    ## Delete all existing rules
    -D
    
    ## Set buffer size (increase for high-volume systems)
    -b 8192
    
    ## Set failure mode (1 = printk, 2 = panic)
    -f 1
    
    ## Monitor authentication-related files
    -w /etc/passwd -p wa -k identity
    -w /etc/group -p wa -k identity
    -w /etc/shadow -p wa -k identity
    -w /etc/sudoers -p wa -k sudoers
    
    ## Monitor login events
    -w /var/log/faillog -p wa -k logins
    -w /var/log/lastlog -p wa -k logins
    
    ## Monitor process execution
    -a always,exit -F arch=b64 -S execve -k exec
    
    ## Monitor network configuration changes
    -a always,exit -F arch=b64 -S sethostname -S setdomainname -k network
    
    ## Make the configuration immutable (must be the last rule)
    -e 2
    
  3. 載入新的稽核規則:

    sudo augenrules --load
    

重新啟動 auditd

  1. 重新啟動 auditd 服務,套用外掛程式和規則變更:

    sudo service auditd restart
    

設定 rsyslog,將稽核記錄轉送至 Bindplane

  1. 建立新的 rsyslog 設定檔,用於轉送稽核記錄:

    sudo nano /etc/rsyslog.d/audit-forward.conf
    
  2. 新增下列指令行,透過 UDP 將記錄轉送至 Bindplane 代理程式:

    local6.* @<BINDPLANE_IP>:514
    
  3. 重新啟動 rsyslog,以套用變更:

    sudo systemctl restart rsyslog
    

確認記錄轉送

  1. 在來源 Linux 主機上,產生測試稽核事件:

    sudo auditctl -w /tmp/test_audit -p wa -k test_chronicle
    
  2. 輕觸檔案即可觸發手錶:

    touch /tmp/test_audit
    
  3. 在 Bindplane 代理程式主機上,確認是否收到記錄:

    sudo journalctl -u observiq-otel-collector -f
    

UDM 對應表

記錄欄位 UDM 對應 邏輯
acct target.user.userid 取自 acct 欄位的值。
addr principal.ip 如果 addr 欄位是有效的 IP 位址,則會採用該欄位的值。
arch additional.fields 以鍵/值組合形式新增,鍵為「arch」。
auid principal.user.userid 取自 auid 欄位的值。做為稽核使用者 ID。
comm target.process.command_line 取自 comm 欄位的值。
cwd additional.fields 以鍵/值組合形式新增,鍵為「cwd」。
exe target.process.file.full_path 取自 exe 欄位的值。
exit additional.fields 以鍵/值組合形式新增,鍵為「exit」。
gid principal.user.group_identifiers 取自 gid 欄位的值。
hostname principal.hostname 取自 hostname 欄位的值。
key security_result.detection_fields 以鍵/值組合形式新增,鍵為「audit_key」。
msg metadata.description msg 欄位剖析。包含稽核事件訊息。
name target.file.full_path 適用時,取自 name 欄位的值。
node principal.hostname 如果沒有 hostname,則會從 node 欄位取得值。
op metadata.product_event_type 取自 op 欄位 (作業類型) 的值。
pid principal.process.pid 取自 pid 欄位的值。
ppid principal.process.parent_process.pid 取自 ppid 欄位的值。
res security_result.action 如果 res 為「success」或「1」,請設為「ALLOW」。如果 res 為「failed」或「0」,請設為「BLOCK」。
ses network.session_id 取自 ses 欄位的值 (工作階段 ID)。
subj principal.process.file.full_path 取自 subj 欄位的值 (SELinux 主體內容)。
syscall additional.fields 以鍵/值組合形式新增,鍵為「syscall」。
terminal additional.fields 以鍵/值組合形式新增,鍵為「terminal」。
type metadata.product_event_type 取自 type 欄位的值 (稽核記錄類型,例如 SYSCALL、USER_LOGIN、EXECVE)。
uid principal.user.userid 取自 uid 欄位的值。
metadata.event_type 衍生自稽核記錄類型。登入事件請設為「USER_LOGIN」,登出事件請設為「USER_LOGOUT」,執行事件請設為「PROCESS_LAUNCH」,檔案事件請設為「FILE_MODIFICATION」。預設值為「GENERIC_EVENT」。
metadata.product_name 設為「auditd」。
metadata.vendor_name 設為「Linux」。
home event.idm.read_only_udm.additional.fields 從變更記錄對應
shell event.idm.read_only_udm.additional.fields 從變更記錄對應
name event.idm.read_only_udm.target.user.userid 從變更記錄對應
name event.idm.read_only_udm.target.group.group_display_name 從變更記錄對應
UID event.idm.read_only_udm.target.user.product_object_id 從變更記錄對應
GID event.idm.read_only_udm.target.user.group_identifiers 從變更記錄對應
GID event.idm.read_only_udm.target.group.product_object_id 從變更記錄對應
key_type event.idm.read_only_udm.additional.fields 從變更記錄對應
hash event.idm.read_only_udm.additional.fields 從變更記錄對應
key_fingerprint event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
user event.idm.read_only_udm.target.user.userid 從變更記錄對應
error_detail1 event.idm.read_only_udm.security_result.summary 從變更記錄對應
service_name event.idm.read_only_udm.additional.fields 從變更記錄對應
ssh_disconnect_code event.idm.read_only_udm.additional.fields 從變更記錄對應
labels.bp_csoc event.idm.read_only_udm.additional.fields 從變更記錄對應
labels.bp_env_id event.idm.read_only_udm.additional.fields 從變更記錄對應
labels.log.file.name event.idm.read_only_udm.additional.fields 從變更記錄對應
resource.labels.node_id event.idm.read_only_udm.additional.fields 從變更記錄對應
intermediary_host event.idm.read_only_udm.intermediary.hostname 從變更記錄對應
PWD event.idm.read_only_udm.target.file.full_path 從變更記錄對應
log_details event.idm.read_only_udm.additional.fields 從變更記錄對應
indicator.SUID event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.UID event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.AUID event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
type_crypto_props.msg event.idm.read_only_udm.additional.fields 從變更記錄對應
usr event.idm.read_only_udm.principal.user.userid 從變更記錄對應
pi event.idm.read_only_udm.principal.process.pid 從變更記錄對應
cmnd event.idm.read_only_udm.target.process.command_line 從變更記錄對應
proctitle_value event.idm.read_only_udm.principal.process.file.full_path 從變更記錄對應
filename event.idm.read_only_udm.principal.process.file.names 從變更記錄對應
filepath event.idm.read_only_udm.target.file.full_path 從變更記錄對應
uid event.idm.read_only_udm.principal.user.userid 從變更記錄對應
acct event.idm.read_only_udm.principal.user.user_display_name 從變更記錄對應
exe event.idm.read_only_udm.target.process.file.full_path 從變更記錄對應
pid event.idm.read_only_udm.principal.process.pid 從變更記錄對應
auid event.idm.read_only_udm.about.user.userid 從變更記錄對應
ses event.idm.read_only_udm.network.session_id 從變更記錄對應
addr event.idm.read_only_udm.principal.ipevent.idm.read_only_udm.principal.asset.ip 從變更記錄對應
subj event.idm.read_only_udm.additional.fields 從變更記錄對應
res event.idm.read_only_udm.security_result.summary 從變更記錄對應
op event.idm.read_only_udm.security_result.summary 從變更記錄對應
msg_value event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
grantors_value event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.msg event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.grantors event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
terminal event.idm.read_only_udm.principal.application 從變更記錄對應
sec_result event.idm.read_only_udm.security_result 從變更記錄對應
hostname event.idm.read_only_udm.principal.hostname 從變更記錄對應
indicator.mode event.idm.read_only_udm.src.user.attribute.permissions 從變更記錄對應
indicator.nametype event.idm.read_only_udm.security_result.rule_name 從變更記錄對應
indicator.cap_frootid event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.cap_fver event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.cap_fi event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.cap_fp event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
indicator.cap_fe event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
OUID event.idm.read_only_udm.principal.user.userid 從變更記錄對應
OGID event.idm.read_only_udm.principal.group.group_display_name 從變更記錄對應
action_data event.idm.read_only_udm.security_result.action_details 從變更記錄對應
target_email event.idm.ready_only_udm.target.user.email_addresses 從變更記錄對應
target_port event.idm.ready_only_udm.target.port 從變更記錄對應
status event.idm.ready_only_udm.security_result.action_details 從變更記錄對應
to_email event.idm.ready_only_udm.network.email.to 從變更記錄對應
target_hostname event.idm.ready_only_udm.target.hostname 從變更記錄對應
"relay_data" event.idm.ready_only_udm.additional.fields 從變更記錄對應
"delays_data" event.idm.ready_only_udm.additional.fields 從變更記錄對應
"delay_data" event.idm.ready_only_udm.additional.fields 從變更記錄對應
and "dns_data" event.idm.ready_only_udm.additional.fields 從變更記錄對應
bytes_sent event.idm.ready_only_udm.network.sent_bytes 從變更記錄對應
bytes_received event.idm.ready_only_udm.network.received_bytes 從變更記錄對應
response_code event.idm.ready_only_udm.network.http.response_code 從變更記錄對應
principal_user_name principal.user.userid 從變更記錄對應
remote principal.ip 從變更記錄對應
method network.http.method 從變更記錄對應
path principal.file.full_path 從變更記錄對應
code additional.fields 從變更記錄對應
size principal.file.size 從變更記錄對應
agent network.http.user_agent 從變更記錄對應
az principal.location.name 從變更記錄對應
ec2_instance_id principal.asset.product_object_id 從變更記錄對應
private_ip principal.ip 從變更記錄對應
ProviderName additional.fields 從變更記錄對應
Version additional.fields 從變更記錄對應
Task additional.fields 從變更記錄對應
EventRecordID additional.fields 從變更記錄對應
ThreadID additional.fields 從變更記錄對應
messageType target.resource.attribute.labels 從變更記錄對應
owner principal.user.userid 從變更記錄對應
logevent.id metadata.product_log_id 從變更記錄對應
logGroup secu_result.about.resource.name 從變更記錄對應
logStream secu_result.about.resource.attribute.labels 從變更記錄對應
ip_addr principal.ip 從變更記錄對應
gd secu_result.description 從變更記錄對應
process target.application 從變更記錄對應
pid target.process.pid 從變更記錄對應
status_code network.http.response_code 從變更記錄對應
url network.http.referral_url 從變更記錄對應
useragent network.http.user_agent 從變更記錄對應
request additional.fields 從變更記錄對應
tls_version network.tls.version 從變更記錄對應
hostname_is principal.hostname 從變更記錄對應
referrer network.http.referral_url 從變更記錄對應
metadata.event_type USER_LOGIN 從變更記錄對應
metadata.event_type PROCESS_UNCATEGORIZED 從變更記錄對應
srcIP principal.ip 從變更記錄對應
username principal.user.user_display_name 從變更記錄對應
type_syscall_props.msg additional.fields 從變更記錄對應
sw", "sw_type", and "subj security_result.detection_fields 從變更記錄對應
indicator.SYSCALL security_result.detection_fields 從變更記錄對應
exe principal.process.file.full_path 從變更記錄對應
target.user.userid principal.user.userid 從變更記錄對應
target_user_name target.user.userid 從變更記錄對應
field field33 從變更記錄對應
fp network.tls.client.certificate.sha256 從變更記錄對應
pid principal.process.pid 從變更記錄對應
syslog-tag security_result.detection_fields 從變更記錄對應
inter_ip intermediary.ip 從變更記錄對應
inter_hostname intermediary.hostname 從變更記錄對應
grp target.group.group_display_name 從變更記錄對應
id about.user.userid 從變更記錄對應
acct target.user.user_display_name 從變更記錄對應
uid principal.user.userid 從變更記錄對應
auid about.user.userid 從變更記錄對應
auid target.user.userid 從變更記錄對應
op" and "id security_result.summary 從變更記錄對應
op" and "acct security_result.summary 從變更記錄對應
labels.compute.googleapis.com/resource_name","jsonPayload._HOSTNAME" , "CollectorHostName", "HOSTNAME", and "Computer principal.hostname 從變更記錄對應
HostIP principal.ip 從變更記錄對應
ProcessID" and "jsonPayload._PID principal.process.pid 從變更記錄對應
SyslogMessage metadata.description 從變更記錄對應
TenantId", "_ItemId", "_Internal_WorkspaceResourceId", "_ResourceId", and "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", and "jsonPayload._AUDIT_FIELD_EXIT security_result.detection_fields 從變更記錄對應
id target.user.userid 從變更記錄對應
ID target.user.user_display_name 從變更記錄對應
user_name principal.user.userid 從變更記錄對應
principal_user_userid principal.user.userid 從變更記錄對應
vendor_name Linux 從變更記錄對應
product_name AuditD 從變更記錄對應
ip target.ip 從變更記錄對應
success security_result.summary 從變更記錄對應
syscall", "exit", "tty", "a0", "a1", "a2", "a3 security_result.about.labels 從變更記錄對應

變更記錄

查看這個剖析器的變更記錄

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