Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az

This commit is contained in:
Translator
2024-12-31 18:57:14 +00:00
parent 7770a50092
commit 77a009d308
244 changed files with 8632 additions and 11470 deletions

View File

@@ -2,60 +2,60 @@
{{#include ../../banners/hacktricks-training.md}}
## Basic Information
## Grundinformationen
**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.
**Bevor Sie mit dem Pentesting** einer **GCP**-Umgebung beginnen, gibt es einige **grundlegende Dinge, die Sie wissen müssen**, wie es funktioniert, um zu verstehen, was Sie tun müssen, wie Sie Fehlkonfigurationen finden und wie Sie diese ausnutzen können.
Concepts such as **organization** hierarchy, **permissions** and other basic concepts are explained in:
Konzepte wie **Organisations**hierarchie, **Berechtigungen** und andere grundlegende Konzepte werden erklärt in:
{{#ref}}
gcp-basic-information/
{{#endref}}
## Labs to learn
## Labs zum Lernen
- [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
## GCP Pentester/Red Team Methodologie
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.
Um eine GCP-Umgebung zu auditieren, ist es sehr wichtig zu wissen: welche **Dienste verwendet werden**, was **exponiert** wird, wer **Zugriff** auf was hat und wie interne GCP-Dienste mit **externen Diensten** verbunden sind.
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:
Aus der Sicht eines Red Teams ist der **erste Schritt, um eine GCP-Umgebung zu kompromittieren**, das Erhalten von **Anmeldeinformationen**. Hier sind einige Ideen, wie Sie das tun können:
- **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
- **Leaks** in github (oder ähnlichem) - OSINT
- **Soziale** Ingenieurkunst (Überprüfen Sie die Seite [**Workspace Security**](../workspace-security/))
- **Passwort**-Wiederverwendung (Passwortlecks)
- Schwachstellen in GCP-gehosteten Anwendungen
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) mit Zugriff auf den Metadaten-Endpunkt
- **Lokales Datei Lesen**
- `/home/USERNAME/.config/gcloud/*`
- `C:\Users\USERNAME\.config\gcloud\*`
- 3rd Party **gehackt**
- **Interner** Mitarbeiter
Or by **compromising an unauthenticated service** exposed:
Oder durch **Kompromittierung eines nicht authentifizierten Dienstes**, der exponiert ist:
{{#ref}}
gcp-unauthenticated-enum-and-access/
{{#endref}}
Or if you are doing a **review** you could just **ask for credentials** with these roles:
Oder wenn Sie eine **Überprüfung** durchführen, könnten Sie einfach **nach Anmeldeinformationen** mit diesen Rollen fragen:
{{#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:
> Nachdem Sie es geschafft haben, Anmeldeinformationen zu erhalten, müssen Sie wissen, **wem diese Anmeldeinformationen gehören** und **auf was sie Zugriff haben**, daher müssen Sie einige grundlegende Aufzählungen durchführen:
## Basic Enumeration
## Grundlegende Aufzählung
### **SSRF**
For more information about how to **enumerate GCP metadata** check the following hacktricks page:
Für weitere Informationen darüber, wie man **GCP-Metadaten auflistet**, überprüfen Sie die folgende Hacktricks-Seite:
{{#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 können Sie mehrere Optionen ausprobieren, um zu erraten, wer Sie sind:
```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:
Sie können auch den API-Endpunkt `/userinfo` verwenden, um weitere Informationen über den Benutzer zu erhalten:
```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**.
Wenn Sie genügend Berechtigungen haben, wird das **Überprüfen der Berechtigungen jeder Entität im GCP-Konto** Ihnen helfen zu verstehen, was Sie und andere Identitäten tun können und wie Sie **Berechtigungen eskalieren** können.
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:
Wenn Sie nicht genügend Berechtigungen haben, um IAM zu enumerieren, können Sie sie **stehlen oder brute-forcen**, um sie herauszufinden.\
Überprüfen Sie **wie man die Enumeration und das Brute-Forcing durchführt** 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.**
> Jetzt, da Sie **einige Informationen über Ihre Anmeldeinformationen haben** (und wenn Sie ein Red Team sind, hoffen wir, dass Sie **nicht entdeckt wurden**). Es ist an der Zeit herauszufinden, welche Dienste in der Umgebung verwendet werden.\
> Im folgenden Abschnitt können Sie einige Möglichkeiten überprüfen, um **einige gängige Dienste zu enumerieren.**
## 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 hat eine erstaunliche Anzahl von Diensten, auf der folgenden Seite finden Sie **grundlegende Informationen, Enumeration** Cheatsheets, wie man **Erkennung vermeidet**, **Persistenz** erlangt und andere **Post-Exploitation** Tricks über einige von ihnen:
{{#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).
Beachten Sie, dass Sie **nicht** die gesamte Arbeit **manuell** durchführen müssen, weiter unten in diesem Beitrag finden Sie einen **Abschnitt über** [**automatische Tools**](./#automatic-tools).
Moreover, in this stage you might discovered **more services exposed to unauthenticated users,** you might be able to exploit them:
Darüber hinaus könnten Sie in dieser Phase **weitere Dienste entdeckt haben, die für nicht authentifizierte Benutzer exponiert sind**, die Sie möglicherweise ausnutzen können:
{{#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.
Der häufigste Weg, sobald Sie einige Cloud-Anmeldeinformationen erhalten oder einen Dienst, der in der Cloud läuft, kompromittiert haben, besteht darin, **fehlerhaft konfigurierte Berechtigungen** des kompromittierten Kontos auszunutzen. Daher sollten Sie als erstes Ihre Berechtigungen enumerieren.
Moreover, during this enumeration, remember that **permissions can be set at the highest level of "Organization"** as well.
Darüber hinaus denken Sie während dieser Enumeration daran, dass **Berechtigungen auch auf der höchsten Ebene der "Organisation"** festgelegt werden können.
{{#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**.
Während Sie GCP-Dienste enumerieren, haben Sie möglicherweise einige gefunden, die **Elemente ins Internet exponieren** (VM/Container-Ports, Datenbanken oder Warteschlangendienste, Snapshots oder Buckets...).\
Als Pentester/Red Teamer sollten Sie immer überprüfen, ob Sie **sensible Informationen / Schwachstellen** auf ihnen finden können, da sie Ihnen **weiteren Zugang zum AWS-Konto** verschaffen könnten.
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 diesem Buch sollten Sie **Informationen** darüber finden, wie man **exponierte GCP-Dienste findet und wie man sie überprüft**. Um **Schwachstellen in exponierten Netzwerkdiensten** zu finden, empfehle ich Ihnen, nach dem spezifischen **Dienst** zu **suchen** in:
{{#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:
Das **Kompromittieren** von Principals in **einer** Plattform könnte es einem Angreifer ermöglichen, die **andere** zu **kompromittieren**, überprüfen Sie es 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.
- In der **GCloud-Konsole**, unter [https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard) können Sie Ressourcen und IAMs sehen, die von Projekten verwendet werden.
- Hier können Sie die von dieser API unterstützten Assets sehen: [https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
- Überprüfen Sie **Tools**, die [**in mehreren Clouds hier verwendet werden können**](../pentesting-cloud-methodology.md).
- [**gcp_scanner**](https://github.com/google/gcp_scanner): Dies ist ein GCP-Ressourcenscanner, der helfen kann zu bestimmen, welches **Zugriffslevel bestimmte Anmeldeinformationen auf GCP besitzen**.
```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 couldnt 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-Skript zur Aufzählung einer GCP-Umgebung mit gcloud cli und zum Speichern der Ergebnisse in einer Datei.
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): Skripte zur Aufzählung hoher IAM-Berechtigungen und zur Eskalation von Berechtigungen in GCP durch deren Missbrauch (ich konnte das Aufzählungsskript nicht ausführen).
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): Skript zum Brute-Forcen Ihrer Berechtigungen.
## 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:
Denken Sie daran, dass Sie den **Parameter** **`--log-http`** mit der **`gcloud`** CLI verwenden können, um die **Anfragen** anzuzeigen, die das Tool ausführt. Wenn Sie nicht möchten, dass die Protokolle den Token-Wert redigieren, verwenden Sie `gcloud config set log_http_redact_token false`
Darüber hinaus, um die Kommunikation abzufangen:
```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-Token in gcloud konfigurieren
### OAuth token configure in gcloud
In order to **use an exfiltrated service account OAuth token from the metadata endpoint** you can just do:
Um ein **exfiltriertes Service-Account-OAuth-Token vom Metadaten-Endpunkt** zu verwenden, können Sie einfach Folgendes tun:
```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
## Referenzen
- [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}}