mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-18 07:35:41 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -2,99 +2,94 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
This service allows users to store, search, analyze, monitor, and alert on **log data and events** from GCP.
|
||||
Dieser Dienst ermöglicht es Benutzern, **Protokolldaten und Ereignisse** von GCP zu speichern, zu durchsuchen, zu analysieren, zu überwachen und Alarme auszulösen.
|
||||
|
||||
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 ist vollständig in andere GCP-Dienste integriert und bietet ein zentrales Repository für Protokolle aller Ihrer GCP-Ressourcen. Es **sammelt automatisch Protokolle von verschiedenen GCP-Diensten** wie App Engine, Compute Engine und Cloud Functions. Sie können Cloud Logging auch für Anwendungen verwenden, die lokal oder in anderen Clouds ausgeführt werden, indem Sie den Cloud Logging-Agenten oder die API verwenden.
|
||||
|
||||
Key Features:
|
||||
Hauptmerkmale:
|
||||
|
||||
- **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.
|
||||
- **Zentralisierung von Protokolldaten:** Aggregieren Sie Protokolldaten aus verschiedenen Quellen, um einen ganzheitlichen Überblick über Ihre Anwendungen und Infrastruktur zu erhalten.
|
||||
- **Echtzeit-Protokollverwaltung:** Streamen Sie Protokolle in Echtzeit für sofortige Analyse und Reaktion.
|
||||
- **Leistungsstarke Datenanalyse:** Verwenden Sie erweiterte Filter- und Suchfunktionen, um große Mengen an Protokolldaten schnell zu durchsuchen.
|
||||
- **Integration mit BigQuery:** Exportieren Sie Protokolle nach BigQuery für detaillierte Analysen und Abfragen.
|
||||
- **Protokollbasierte Metriken:** Erstellen Sie benutzerdefinierte Metriken aus Ihren Protokolldaten zur Überwachung und Alarmierung.
|
||||
|
||||
### Logs flow
|
||||
### Protokollfluss
|
||||
|
||||
<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.
|
||||
Grundsätzlich bestimmen die Senken und protokollbasierten Metriken, wo ein Protokoll gespeichert werden soll.
|
||||
|
||||
### Configurations Supported by GCP Logging
|
||||
### Von GCP Logging unterstützte Konfigurationen
|
||||
|
||||
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 ist hochgradig konfigurierbar, um unterschiedlichen Betriebsbedürfnissen gerecht zu werden:
|
||||
|
||||
1. **Protokoll-Buckets (Protokollspeicherung im Web):** Definieren Sie Buckets in Cloud Logging, um **Protokollaufbewahrung** zu verwalten und Kontrolle darüber zu haben, wie lange Ihre Protokolleinträge aufbewahrt werden.
|
||||
- Standardmäßig werden die Buckets `_Default` und `_Required` erstellt (einer protokolliert, was der andere nicht tut).
|
||||
- **\_Required** ist:
|
||||
````
|
||||
```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")
|
||||
```
|
||||
|
||||
### Default Logs
|
||||
````
|
||||
- **Die Aufbewahrungsfrist** der Daten ist pro Bucket konfiguriert und muss **mindestens 1 Tag** betragen. Die **Aufbewahrungsfrist von \_Required beträgt 400 Tage** und kann nicht geändert werden.
|
||||
- Beachten Sie, dass Log-Buckets **nicht in Cloud Storage sichtbar sind.**
|
||||
|
||||
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**.
|
||||
2. **Log Sinks (Log-Router im Web):** Erstellen Sie Sinks, um **Protokolleinträge** an verschiedene Ziele wie Pub/Sub, BigQuery oder Cloud Storage basierend auf einem **Filter** zu exportieren.
|
||||
- Standardmäßig werden Sinks für die Buckets `_Default` und `_Required` erstellt:
|
||||
- ```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")
|
||||
```
|
||||
- **Ausschlussfilter:** Es ist möglich, **Ausschlüsse einzurichten, um bestimmte Protokolleinträge** von der Erfassung auszuschließen, um Kosten zu sparen und unnötigen Lärm zu reduzieren.
|
||||
3. **Log-basierte Metriken:** Konfigurieren Sie **benutzerdefinierte Metriken** basierend auf dem Inhalt von Protokollen, die Alarmierung und Überwachung basierend auf Protokolldaten ermöglichen.
|
||||
4. **Logansichten:** Logansichten bieten eine erweiterte und **detaillierte Kontrolle darüber, wer Zugriff** auf die Protokolle innerhalb Ihrer Log-Buckets hat.
|
||||
- Cloud Logging **erstellt automatisch die `_AllLogs`-Ansicht für jeden Bucket**, die alle Protokolle anzeigt. Cloud Logging erstellt auch eine Ansicht für den `_Default`-Bucket namens `_Default`. Die `_Default`-Ansicht für den `_Default`-Bucket zeigt alle Protokolle außer den Datenzugriffs-Auditprotokollen an. Die Ansichten `_AllLogs` und `_Default` sind nicht bearbeitbar.
|
||||
|
||||
Then, the user can enable **Data Access audit logs**, these are **Admin Read, Data Write and Data Write**.
|
||||
Es ist möglich, einem Principal **nur die Verwendung einer bestimmten Logansicht** mit einer IAM-Richtlinie zu erlauben wie:
|
||||
```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
|
||||
}
|
||||
```
|
||||
### Standardprotokolle
|
||||
|
||||
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)
|
||||
Standardmäßig werden **Admin Write**-Operationen (auch als Admin Activity-Auditprotokolle bezeichnet) protokolliert (Metadaten oder Konfigurationsinformationen schreiben) und **können nicht deaktiviert** werden.
|
||||
|
||||
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.
|
||||
Der Benutzer kann dann **Data Access-Auditprotokolle** aktivieren, dies sind **Admin Read, Data Write und Data Write**.
|
||||
|
||||
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:
|
||||
Weitere Informationen zu jedem Protokolltyp finden Sie in den Dokumenten: [https://cloud.google.com/iam/docs/audit-logging](https://cloud.google.com/iam/docs/audit-logging)
|
||||
|
||||
- **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:
|
||||
Beachten Sie jedoch, dass dies bedeutet, dass standardmäßig **`GetIamPolicy`**-Aktionen und andere Leseaktionen **nicht protokolliert** werden. Ein Angreifer, der versucht, die Umgebung zu enumerieren, wird also standardmäßig nicht erfasst, wenn der Systemadministrator nicht konfiguriert hat, um mehr Protokolle zu generieren.
|
||||
|
||||
Um mehr Protokolle in der Konsole zu aktivieren, muss der Systemadministrator zu [https://console.cloud.google.com/iam-admin/audit](https://console.cloud.google.com/iam-admin/audit) gehen und sie aktivieren. Es gibt 2 verschiedene Optionen:
|
||||
|
||||
- **Standardkonfiguration**: Es ist möglich, eine Standardkonfiguration zu erstellen und alle Admin Read und/oder Data Read und/oder Data Write-Protokolle zu protokollieren und sogar befreite Prinzipale hinzuzufügen:
|
||||
|
||||
<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.
|
||||
- **Wählen Sie die Dienste aus**: Oder einfach **die Dienste auswählen**, für die Sie Protokolle generieren möchten, sowie die Art der Protokolle und den befreiten Prinzipal für diesen speziellen Dienst.
|
||||
|
||||
Also note that by default only those logs are being generated because generating more logs will increase the costs.
|
||||
Beachten Sie auch, dass standardmäßig nur diese Protokolle generiert werden, da die Generierung weiterer Protokolle die Kosten erhöhen würde.
|
||||
|
||||
### 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.
|
||||
|
||||
Das `gcloud`-Befehlszeilenwerkzeug ist ein integraler Bestandteil des GCP-Ökosystems und ermöglicht es Ihnen, Ihre Ressourcen und Dienste zu verwalten. So können Sie `gcloud` verwenden, um Ihre Protokollkonfigurationen zu verwalten und auf Protokolle zuzugreifen.
|
||||
```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
|
||||
```
|
||||
Beispiel, um die Protokolle von **`cloudresourcemanager`** (dem, der verwendet wird, um Berechtigungen zu BF) zu überprüfen: [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`**:
|
||||
Es gibt keine Protokolle von **`testIamPermissions`**:
|
||||
|
||||
<figure><img src="../../../images/image (2) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Post Exploitation
|
||||
### Post-Exploitation
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-logging-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### Persistenz
|
||||
|
||||
{{#ref}}
|
||||
../gcp-persistence/gcp-logging-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [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}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user