收集 Apache 記錄

支援的國家/地區:

本文說明如何使用 Bindplane,將 Apache 記錄擷取至 Google Security Operations。剖析器程式碼會先嘗試將原始記錄訊息剖析為 JSON。如果失敗,系統會使用規則運算式 (grok 模式) 根據常見的 Apache 記錄格式,從訊息中擷取欄位。

事前準備

  • 確認您擁有 Google SecOps 執行個體。
  • 確認您使用的是 Windows 2016 以上版本,或是搭載 systemd 的 Linux 主機。
  • 如果透過 Proxy 執行,請確認防火牆通訊埠已開啟。
  • 確認您具備 Apache 執行個體的特殊權限。

取得 Google SecOps 擷取驗證檔案

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

取得 Google SecOps 客戶 ID

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

安裝 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 代理程式,擷取系統記錄檔並傳送至 Google SecOps

  1. 存取設定檔:

    1. 找出 config.yaml 檔案。通常位於 Linux 的 /etc/bindplane-agent/ 目錄,或 Windows 的安裝目錄。
    2. 使用文字編輯器 (例如 nanovi 或記事本) 開啟檔案。
  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: '/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: 'APACHE'
                raw_log_field: body
    
    service:
        pipelines:
            logs/source0__chronicle_w_labels-0:
                receivers:
                    - udplog
                exporters:
                    - chronicle/chronicle_w_labels
    
  3. 視基礎架構需求,替換通訊埠和 IP 位址。

  4. <customer_id> 替換為實際的客戶 ID。

  5. /path/to/ingestion-authentication-file.json 更新為「取得 Google SecOps 擷取驗證檔案」一節中儲存驗證檔案的路徑。

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

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

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

    net stop BindPlaneAgent && net start BindPlaneAgent
    

在 Apache 中設定 Syslog

  1. 使用 SSH 登入 Ubuntu 伺服器。
  2. /etc/rsyslog.d/ 下建立名為 02-apache2.conf 的檔案:

    vim /etc/rsyslog.d/02-apache2.conf
    
  3. 在檔案新增下列程式碼:

    module(load="imfile" PollingInterval="10" statefile.directory="/var/spool/rsyslog")
    input(type="imfile"
            File="/var/log/apache2/access.log"
            Tag="http_access"
            Severity="info"
            Facility="local6")
    Local6.info        @<bindplane-agnet-ip>:<vindplane-agent-port>
    module(load="imfile" PollingInterval="10" statefile.directory="/var/spool/rsyslog")
    input(type="imfile"
            File="/var/log/apache2/error.log"
            Tag="http_error"
    
    • bindplane-agent-ip>bindplane-agent-port 替換為為 Bindplane Agent 設定的 IP 位址和連接埠
    • 如果您使用 TCP 協定,請在主機行中附加額外的 @,如下所示:@@<bindplane-agnet-ip>:<vindplane-agent-port>
  4. 重新啟動 RSyslog 服務:

    sudo service rsyslog restart
    

UDM 對應表

記錄欄位 UDM 對應 邏輯
位元組 network.received_bytes 從用戶端收到的位元組數。
位元組 network.sent_bytes 傳送給用戶端的位元組數。
bytes_out network.sent_bytes 傳送給用戶端的位元組數。
bytes_received network.received_bytes 從用戶端收到的位元組數。
內容 network.http.method 從「Content」欄位擷取的 HTTP 方法。
內容 target.url 從「內容」欄位擷取的目標網址。
餅乾 additional.fields.value.string_value 「cookie」欄位的值。
dest_ip target.ip 目標的 IP 位址。
dest_name target.hostname 目標的主機名稱。
dest_port target.port 目標的通訊埠。
說明 metadata.description 活動說明。
duration_microseconds additional.fields.value.string_value 「duration_microseconds」欄位的值。
file_full_path target.file.full_path 目標檔案的完整路徑。
主機名稱 target.hostname 目標的主機名稱。
http_content_type additional.fields.value.string_value 「http_content_type」欄位的值。
http_host principal.hostname 主體的主機名稱。
http_method network.http.method HTTP 方法。
http_referrer network.http.referral_url HTTP 參照網址。
http_user_agent network.http.user_agent HTTP 使用者代理程式。
ID metadata.id 活動的 ID。
insertId metadata.product_log_id 產品記錄 ID。
ip principal.ip 主體的 IP 位址。
jsonPayload.cIP target.ip 目標的 IP 位址。
jsonPayload.cPort target.port 目標的通訊埠。
jsonPayload.csBytes network.sent_bytes 傳送給用戶端的位元組數。
jsonPayload.csMethod network.http.method HTTP 方法。
jsonPayload.csMimeType target.file.mime_type 目標檔案的 MIME 類型。
jsonPayload.csReferer network.http.referral_url HTTP 參照網址。
jsonPayload.csURL target.url 目標網址。
jsonPayload.csUserAgent network.http.user_agent HTTP 使用者代理程式。
jsonPayload.sHierarchy additional.fields.value.string_value 「sHierarchy」欄位的值。
jsonPayload.sHostname principal.hostname 主體的主機名稱。
jsonPayload.sIP principal.ip 主體的 IP 位址。
jsonPayload.scBytes network.received_bytes 從用戶端收到的位元組數。
jsonPayload.scHTTPStatus network.http.response_code HTTP 回應代碼。
jsonPayload.scResultCode additional.fields.value.string_value 「scResultCode」欄位的值。
LastStatus network.http.response_code HTTP 回應代碼。
log_level security_result.severity 安全性結果的嚴重程度。
logName security_result.category_details 安全結果的類別詳細資料。
方法 network.http.method HTTP 方法。
pid principal.process.pid 主體的程序 ID。
通訊埠 target.port 目標的通訊埠。
proto network.application_protocol 應用程式通訊協定。
參照網址 network.http.referral_url HTTP 參照網址。
RemoteHost principal.ip 主體的 IP 位址。
RemoteUser principal.user.userid 主體的使用者 ID。
resource.labels.instance_id target.resource.product_object_id 目標資源的產品物件 ID。
resource.labels.project_id target.resource.attribute.labels.value 「project_id」標籤的值。
resource.labels.zone target.resource.attribute.cloud.availability_zone 目標資源的可用區。
resource.type target.resource.resource_type 目標的資源類型。
回應 network.http.response_code HTTP 回應代碼。
SizeBytes network.received_bytes 從用戶端收到的位元組數。
src_ip principal.ip 主體的 IP 位址。
src_port principal.port 主體的通訊埠。
ssl_cipher network.tls.cipher 傳輸層安全標準 (TLS) 加密。
ssl_version network.tls.version_protocol TLS 版本通訊協定。
狀態 network.http.response_code HTTP 回應代碼。
目標 target.url 目標網址。
target_ip target.ip 目標的 IP 位址。
target_port target.port 目標的通訊埠。
時間 metadata.event_timestamp 事件時間戳記。
uri_path target.process.file.full_path 目標檔案的完整路徑。
使用者 principal.user.userid 主體的使用者 ID。
使用者代理程式 network.http.user_agent HTTP 使用者代理程式。
version_protocol network.tls.version_protocol TLS 版本通訊協定。
工作站名稱 principal.hostname 主體的主機名稱。
x_forwarded_for 「X-Forwarded-For」標頭的值。
metadata.log_type 剖析器程式碼中的值會設為「APACHE」。
metadata.product_name 剖析器程式碼中的值會設為「Apache Web Server」。
metadata.vendor_name 剖析器程式碼中的值會設為「Apache」。
metadata.event_type 系統會根據主體和目標資訊是否存在來判斷值。如果主體和目標都存在,事件類型會設為「NETWORK_HTTP」。如果只有主體存在,事件類型會設為「STATUS_UPDATE」。否則會設為「GENERIC_EVENT」。
additional.fields.key 根據欄位,剖析器程式碼中的鍵會設為「keep_alive」、「duration_microseconds」、「cookie」、「http_content_type」、「sHierarchy」、「scResultCode」。
target.port 如果「proto」欄位為「HTTP」,通訊埠會設為 80。如果「proto」欄位為「HTTPS」,通訊埠會設為 443。如果「proto」欄位為「FTP」,則通訊埠會設為 21。
target.resource.attribute.labels.key 剖析器程式碼中的鍵會設為「project_id」。

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