mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-06 17:53:37 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -2,60 +2,60 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Informazioni di base
|
||||
|
||||
**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.
|
||||
**Prima di iniziare il pentesting** di un **ambiente GCP**, ci sono alcune **cose di base che devi sapere** su come funziona per aiutarti a capire cosa devi fare, come trovare misconfigurazioni e come sfruttarle.
|
||||
|
||||
Concepts such as **organization** hierarchy, **permissions** and other basic concepts are explained in:
|
||||
Concetti come **gerarchia** dell'**organizzazione**, **permessi** e altri concetti di base sono spiegati in:
|
||||
|
||||
{{#ref}}
|
||||
gcp-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
## Labs to learn
|
||||
## Laboratori per imparare
|
||||
|
||||
- [https://gcpgoat.joshuajebaraj.com/](https://gcpgoat.joshuajebaraj.com/)
|
||||
- [https://github.com/ine-labs/GCPGoat](https://github.com/ine-labs/GCPGoat)
|
||||
- [https://github.com/lacioffi/GCP-pentest-lab/](https://github.com/lacioffi/GCP-pentest-lab/)
|
||||
- [https://github.com/carlospolop/gcp_privesc_scripts](https://github.com/carlospolop/gcp_privesc_scripts)
|
||||
|
||||
## GCP Pentester/Red Team Methodology
|
||||
## Metodologia GCP Pentester/Red Team
|
||||
|
||||
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.
|
||||
Per auditare un ambiente GCP è molto importante sapere: quali **servizi vengono utilizzati**, cosa è **esposto**, chi ha **accesso** a cosa e come sono connessi i servizi GCP interni e i **servizi esterni**.
|
||||
|
||||
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:
|
||||
Dal punto di vista di un Red Team, il **primo passo per compromettere un ambiente GCP** è riuscire a ottenere alcune **credenziali**. Qui hai alcune idee su come farlo:
|
||||
|
||||
- **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
|
||||
- **Leak** su github (o simili) - OSINT
|
||||
- **Ingegneria** Sociale (Controlla la pagina [**Sicurezza di Workspace**](../workspace-security/))
|
||||
- Riutilizzo della **Password** (leak di password)
|
||||
- Vulnerabilità nelle Applicazioni Ospitate su GCP
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) con accesso all'endpoint dei metadati
|
||||
- **Lettura di File Locali**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- **breach** di terze parti
|
||||
- **Dipendente** Interno
|
||||
|
||||
Or by **compromising an unauthenticated service** exposed:
|
||||
Oppure compromettendo un **servizio non autenticato** esposto:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
{{#endref}}
|
||||
|
||||
Or if you are doing a **review** you could just **ask for credentials** with these roles:
|
||||
O se stai facendo una **revisione** potresti semplicemente **chiedere le credenziali** con questi ruoli:
|
||||
|
||||
{{#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:
|
||||
> Dopo aver ottenuto le credenziali, devi sapere **a chi appartengono quelle credenziali**, e **a cosa hanno accesso**, quindi devi eseguire alcune enumerazioni di base:
|
||||
|
||||
## Basic Enumeration
|
||||
## Enumerazione di Base
|
||||
|
||||
### **SSRF**
|
||||
|
||||
For more information about how to **enumerate GCP metadata** check the following hacktricks page:
|
||||
Per ulteriori informazioni su come **enumerare i metadati GCP** controlla la seguente pagina di hacktricks:
|
||||
|
||||
{{#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:
|
||||
|
||||
In GCP puoi provare diverse opzioni per cercare di indovinare chi sei:
|
||||
```bash
|
||||
#If you are inside a compromise machine
|
||||
gcloud auth list
|
||||
@@ -74,60 +73,55 @@ 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:
|
||||
|
||||
Puoi anche utilizzare l'endpoint API `/userinfo` per ottenere ulteriori informazioni sull'utente:
|
||||
```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
|
||||
|
||||
### Enumerazione dell'Org
|
||||
```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
|
||||
```
|
||||
### Principali e Enumerazione IAM
|
||||
|
||||
### Principals & IAM Enumeration
|
||||
Se hai abbastanza permessi, **controllare i privilegi di ciascuna entità all'interno dell'account GCP** ti aiuterà a capire cosa puoi fare tu e altre identità e come **escalare i privilegi**.
|
||||
|
||||
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**.
|
||||
|
||||
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:
|
||||
Se non hai abbastanza permessi per enumerare IAM, puoi **rubare e forzare** per scoprirli.\
|
||||
Controlla **come fare l'enumerazione e il brute-forcing** in:
|
||||
|
||||
{{#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.**
|
||||
> Ora che **hai alcune informazioni sulle tue credenziali** (e se sei un red team speriamo che **non sei stato rilevato**). È tempo di scoprire quali servizi vengono utilizzati nell'ambiente.\
|
||||
> Nella sezione seguente puoi controllare alcuni modi per **enumerare alcuni servizi comuni.**
|
||||
|
||||
## Services Enumeration
|
||||
## Enumerazione dei Servizi
|
||||
|
||||
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 ha un'ammirevole quantità di servizi, nella pagina seguente troverai **informazioni di base, cheatsheet di enumerazione**, come **evitare il rilevamento**, ottenere **persistenza** e altri trucchi di **post-exploitation** su alcuni di essi:
|
||||
|
||||
{{#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).
|
||||
Nota che **non** è necessario eseguire tutto il lavoro **manualmente**, qui sotto in questo post puoi trovare una **sezione su** [**strumenti automatici**](./#automatic-tools).
|
||||
|
||||
Moreover, in this stage you might discovered **more services exposed to unauthenticated users,** you might be able to exploit them:
|
||||
Inoltre, in questa fase potresti aver scoperto **più servizi esposti a utenti non autenticati**, potresti essere in grado di sfruttarli:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
{{#endref}}
|
||||
|
||||
## Privilege Escalation, Post Exploitation & Persistence
|
||||
## Escalation dei Privilegi, Post Exploitation e Persistenza
|
||||
|
||||
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.
|
||||
Il modo più comune una volta ottenute alcune credenziali cloud o compromesso un servizio in esecuzione all'interno di un cloud è **abusare dei privilegi mal configurati** che l'account compromesso potrebbe avere. Quindi, la prima cosa che dovresti fare è enumerare i tuoi privilegi.
|
||||
|
||||
Moreover, during this enumeration, remember that **permissions can be set at the highest level of "Organization"** as well.
|
||||
Inoltre, durante questa enumerazione, ricorda che **i permessi possono essere impostati al livello più alto di "Organizzazione"**.
|
||||
|
||||
{{#ref}}
|
||||
gcp-privilege-escalation/
|
||||
@@ -141,12 +135,12 @@ gcp-post-exploitation/
|
||||
gcp-persistence/
|
||||
{{#endref}}
|
||||
|
||||
### Publicly Exposed Services
|
||||
### Servizi Esposti Pubblicamente
|
||||
|
||||
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**.
|
||||
Durante l'enumerazione dei servizi GCP potresti aver trovato alcuni di essi **esponendo elementi a Internet** (porte VM/Container, database o servizi di coda, snapshot o bucket...).\
|
||||
Come pentester/red teamer dovresti sempre controllare se puoi trovare **informazioni sensibili / vulnerabilità** su di essi poiché potrebbero fornirti **ulteriore accesso all'account 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:
|
||||
In questo libro dovresti trovare **informazioni** su come trovare **servizi GCP esposti e come controllarli**. Per quanto riguarda come trovare **vulnerabilità nei servizi di rete esposti**, ti consiglio di **cercare** il **servizio** specifico in:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/
|
||||
@@ -154,19 +148,18 @@ https://book.hacktricks.xyz/
|
||||
|
||||
## GCP <--> Workspace Pivoting
|
||||
|
||||
**Compromising** principals in **one** platform might allow an attacker to **compromise the other one**, check it in:
|
||||
**Compromettere** i principi in **una** piattaforma potrebbe consentire a un attaccante di **compromettere l'altra**, controllalo in:
|
||||
|
||||
{{#ref}}
|
||||
gcp-to-workspace-pivoting/
|
||||
{{#endref}}
|
||||
|
||||
## 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.
|
||||
## Strumenti Automatici
|
||||
|
||||
- Nella **console GCloud**, in [https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard) puoi vedere le risorse e gli IAM utilizzati dal progetto.
|
||||
- Qui puoi vedere gli asset supportati da questa API: [https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
|
||||
- Controlla **strumenti** che possono essere [**utilizzati in diversi cloud qui**](../pentesting-cloud-methodology.md).
|
||||
- [**gcp_scanner**](https://github.com/google/gcp_scanner): Questo è uno scanner di risorse GCP che può aiutare a determinare quale **livello di accesso possiedono certe credenziali** su 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): Script Bash per enumerare un ambiente GCP utilizzando gcloud cli e salvando i risultati in un file.
|
||||
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): Script per enumerare privilegi IAM elevati e per escalare privilegi in GCP abusandone (non sono riuscito a far funzionare lo script di enumerazione).
|
||||
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): Script per forzare le tue autorizzazioni.
|
||||
|
||||
## 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
|
||||
```
|
||||
### Cattura gcloud, gsutil... rete
|
||||
|
||||
### 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:
|
||||
Ricorda che puoi usare il **parametro** **`--log-http`** con il **`gcloud`** cli per **stampare** le **richieste** che lo strumento sta eseguendo. Se non vuoi che i log oscurino il valore del token, usa `gcloud config set log_http_redact_token false`
|
||||
|
||||
Inoltre, per intercettare la comunicazione:
|
||||
```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
|
||||
```
|
||||
### Configurazione del token OAuth in gcloud
|
||||
|
||||
### OAuth token configure in gcloud
|
||||
|
||||
In order to **use an exfiltrated service account OAuth token from the metadata endpoint** you can just do:
|
||||
|
||||
Per **utilizzare un token OAuth di un account di servizio esfiltrato dall'endpoint dei metadati** puoi semplicemente fare:
|
||||
```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
|
||||
## Riferimenti
|
||||
|
||||
- [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}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user