mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-08 19:30:51 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -2,60 +2,60 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Before start pentesting** a **GCP** environment, there are a few **basics things you need to know** about how it works to help you understand what you need to do, how to find misconfigurations and how to exploit them.
|
||||
**GCP** 環境の **ペンテスト** を開始する前に、どのように機能するかについて知っておくべき **基本的なこと** がいくつかあります。これにより、何をすべきか、誤設定を見つける方法、そしてそれをどのように悪用するかを理解するのに役立ちます。
|
||||
|
||||
Concepts such as **organization** hierarchy, **permissions** and other basic concepts are explained in:
|
||||
**組織** 階層、**権限**、およびその他の基本的な概念については、以下で説明されています:
|
||||
|
||||
{{#ref}}
|
||||
gcp-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
## Labs to learn
|
||||
## 学習用ラボ
|
||||
|
||||
- [https://gcpgoat.joshuajebaraj.com/](https://gcpgoat.joshuajebaraj.com/)
|
||||
- [https://github.com/ine-labs/GCPGoat](https://github.com/ine-labs/GCPGoat)
|
||||
- [https://github.com/lacioffi/GCP-pentest-lab/](https://github.com/lacioffi/GCP-pentest-lab/)
|
||||
- [https://github.com/carlospolop/gcp_privesc_scripts](https://github.com/carlospolop/gcp_privesc_scripts)
|
||||
|
||||
## GCP Pentester/Red Team Methodology
|
||||
## GCP ペンテスター/レッドチームの方法論
|
||||
|
||||
In order to audit a GCP environment it's very important to know: which **services are being used**, what is **being exposed**, who has **access** to what, and how are internal GCP services an **external services** connected.
|
||||
GCP 環境を監査するためには、どの **サービスが使用されているか**、何が **公開されているか**、誰が **何にアクセスできるか**、および内部 GCP サービスと **外部サービス** がどのように接続されているかを知ることが非常に重要です。
|
||||
|
||||
From a Red Team point of view, the **first step to compromise a GCP environment** is to manage to obtain some **credentials**. Here you have some ideas on how to do that:
|
||||
レッドチームの観点から、GCP 環境を侵害するための **最初のステップ** は、いくつかの **資格情報** を取得することです。以下はその方法に関するいくつかのアイデアです:
|
||||
|
||||
- **Leaks** in github (or similar) - OSINT
|
||||
- **Social** Engineering (Check the page [**Workspace Security**](../workspace-security/))
|
||||
- **Password** reuse (password leaks)
|
||||
- Vulnerabilities in GCP-Hosted Applications
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) with access to metadata endpoint
|
||||
- **Local File Read**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- 3rd parties **breached**
|
||||
- **Internal** Employee
|
||||
- github(または類似のもの)での **漏洩** - OSINT
|
||||
- **ソーシャル** エンジニアリング(ページ [**Workspace Security**](../workspace-security/) を確認)
|
||||
- **パスワード** 再利用(パスワード漏洩)
|
||||
- GCP ホストアプリケーションの脆弱性
|
||||
- [**サーバーサイドリクエストフォージェリ**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) メタデータエンドポイントへのアクセス
|
||||
- **ローカルファイル読み取り**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- 第三者の **侵害**
|
||||
- **内部** 従業員
|
||||
|
||||
Or by **compromising an unauthenticated service** exposed:
|
||||
または、**認証されていないサービス** を侵害することによって:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
{{#endref}}
|
||||
|
||||
Or if you are doing a **review** you could just **ask for credentials** with these roles:
|
||||
または、**レビュー** を行っている場合は、これらの役割で **資格情報を要求** することができます:
|
||||
|
||||
{{#ref}}
|
||||
gcp-permissions-for-a-pentest.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> After you have managed to obtain credentials, you need to know **to who do those creds belong**, and **what they have access to**, so you need to perform some basic enumeration:
|
||||
> 資格情報を取得した後は、それらの資格情報が **誰に属しているか**、および **何にアクセスできるか** を知る必要があります。そのため、いくつかの基本的な列挙を実行する必要があります:
|
||||
|
||||
## Basic Enumeration
|
||||
## 基本的な列挙
|
||||
|
||||
### **SSRF**
|
||||
|
||||
For more information about how to **enumerate GCP metadata** check the following hacktricks page:
|
||||
GCP メタデータを **列挙** する方法についての詳細は、以下の hacktricks ページを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#6440
|
||||
@@ -63,8 +63,7 @@ https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/clou
|
||||
|
||||
### Whoami
|
||||
|
||||
In GCP you can try several options to try to guess who you are:
|
||||
|
||||
GCP では、自分が誰であるかを推測するためにいくつかのオプションを試すことができます:
|
||||
```bash
|
||||
#If you are inside a compromise machine
|
||||
gcloud auth list
|
||||
@@ -74,60 +73,55 @@ gcloud auth print-identity-token #Get info from the token
|
||||
#If you compromised a metadata token or somehow found an OAuth token
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -d "access_token=<token>" https://www.googleapis.com/oauth2/v1/tokeninfo
|
||||
```
|
||||
|
||||
You can also use the API endpoint `/userinfo` to get more info about the user:
|
||||
|
||||
ユーザーに関する詳細情報を取得するには、APIエンドポイント `/userinfo` を使用することもできます:
|
||||
```bash
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth $(gcloud auth print-access-token)" https://www.googleapis.com/oauth2/v1/userinfo
|
||||
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth <access_token>" https://www.googleapis.com/oauth2/v1/userinfo
|
||||
```
|
||||
|
||||
### Org Enumeration
|
||||
|
||||
### 組織の列挙
|
||||
```bash
|
||||
# Get organizations
|
||||
gcloud organizations list #The DIRECTORY_CUSTOMER_ID is the Workspace ID
|
||||
gcloud resource-manager folders list --organization <org_number> # Get folders
|
||||
gcloud projects list # Get projects
|
||||
```
|
||||
### プリンシパルとIAM列挙
|
||||
|
||||
### Principals & IAM Enumeration
|
||||
十分な権限がある場合、**GCPアカウント内の各エンティティの権限を確認すること**は、あなたや他のアイデンティティが何をできるか、また**権限を昇格させる方法**を理解するのに役立ちます。
|
||||
|
||||
If you have enough permissions, **checking the privileges of each entity inside the GCP account** will help you understand what you and other identities can do and how to **escalate privileges**.
|
||||
|
||||
If you don't have enough permissions to enumerate IAM, you can **steal brute-force them** to figure them out.\
|
||||
Check **how to do the numeration and brute-forcing** in:
|
||||
IAMを列挙するための十分な権限がない場合は、**ブルートフォースで盗む**ことでそれを把握できます。\
|
||||
**列挙とブルートフォースの方法**については、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
gcp-services/gcp-iam-and-org-policies-enum.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> Now that you **have some information about your credentials** (and if you are a red team hopefully you **haven't been detected**). It's time to figure out which services are being used in the environment.\
|
||||
> In the following section you can check some ways to **enumerate some common services.**
|
||||
> 現在、**あなたの資格情報に関する情報を持っている**(そして、もしあなたがレッドチームであれば、希望的には**検出されていない**)ので、環境で使用されているサービスを特定する時が来ました。\
|
||||
> 次のセクションでは、**一般的なサービスを列挙する方法**をいくつか確認できます。
|
||||
|
||||
## Services Enumeration
|
||||
## サービス列挙
|
||||
|
||||
GCP has an astonishing amount of services, in the following page you will find **basic information, enumeration** cheatsheets, how to **avoid detection**, obtain **persistence**, and other **post-exploitation** tricks about some of them:
|
||||
GCPには驚くべき数のサービスがあります。以下のページでは、**基本情報、列挙**のチートシート、**検出を回避する方法**、**持続性**を得る方法、その他の**ポストエクスプロイト**のトリックについての情報を見つけることができます:
|
||||
|
||||
{{#ref}}
|
||||
gcp-services/
|
||||
{{#endref}}
|
||||
|
||||
Note that you **don't** need to perform all the work **manually**, below in this post you can find a **section about** [**automatic tools**](./#automatic-tools).
|
||||
すべての作業を**手動で**行う必要はないことに注意してください。この投稿の下部には、[**自動ツール**](./#automatic-tools)に関する**セクション**があります。
|
||||
|
||||
Moreover, in this stage you might discovered **more services exposed to unauthenticated users,** you might be able to exploit them:
|
||||
さらに、この段階で**認証されていないユーザーに公開されているサービスを**発見するかもしれません。それらを悪用できるかもしれません:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
{{#endref}}
|
||||
|
||||
## Privilege Escalation, Post Exploitation & Persistence
|
||||
## 権限昇格、ポストエクスプロイト&持続性
|
||||
|
||||
The most common way once you have obtained some cloud credentials or have compromised some service running inside a cloud is to **abuse misconfigured privileges** the compromised account may have. So, the first thing you should do is to enumerate your privileges.
|
||||
クラウドの資格情報を取得したり、クラウド内で実行されているサービスを侵害した後の最も一般的な方法は、**侵害されたアカウントが持つ誤設定された権限を悪用すること**です。したがって、最初に行うべきことは、自分の権限を列挙することです。
|
||||
|
||||
Moreover, during this enumeration, remember that **permissions can be set at the highest level of "Organization"** as well.
|
||||
さらに、この列挙中に、**権限は「組織」の最高レベルで設定できる**ことを忘れないでください。
|
||||
|
||||
{{#ref}}
|
||||
gcp-privilege-escalation/
|
||||
@@ -141,32 +135,31 @@ gcp-post-exploitation/
|
||||
gcp-persistence/
|
||||
{{#endref}}
|
||||
|
||||
### Publicly Exposed Services
|
||||
### 公開されたサービス
|
||||
|
||||
While enumerating GCP services you might have found some of them **exposing elements to the Internet** (VM/Containers ports, databases or queue services, snapshots or buckets...).\
|
||||
As pentester/red teamer you should always check if you can find **sensitive information / vulnerabilities** on them as they might provide you **further access into the AWS account**.
|
||||
GCPサービスを列挙していると、いくつかのサービスが**インターネットに要素を公開している**ことに気付くかもしれません(VM/コンテナのポート、データベースやキューサービス、スナップショットやバケットなど)。\
|
||||
ペンテスター/レッドチームのメンバーとして、常にそれらに**機密情報/脆弱性**がないか確認すべきです。これにより、**AWSアカウントへのさらなるアクセス**を得られるかもしれません。
|
||||
|
||||
In this book you should find **information** about how to find **exposed GCP services and how to check them**. About how to find **vulnerabilities in exposed network services** I would recommend you to **search** for the specific **service** in:
|
||||
この本では、**公開されたGCPサービスを見つける方法とそれを確認する方法**に関する**情報**を見つけることができるはずです。**公開されたネットワークサービスの脆弱性を見つける方法**については、特定の**サービス**を以下で**検索**することをお勧めします:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/
|
||||
{{#endref}}
|
||||
|
||||
## GCP <--> Workspace Pivoting
|
||||
## GCP <--> Workspace ピボッティング
|
||||
|
||||
**Compromising** principals in **one** platform might allow an attacker to **compromise the other one**, check it in:
|
||||
**一つの**プラットフォームでプリンシパルを**侵害すること**は、攻撃者が**他のプラットフォームを侵害する**ことを可能にするかもしれません。以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
gcp-to-workspace-pivoting/
|
||||
{{#endref}}
|
||||
|
||||
## Automatic Tools
|
||||
|
||||
- In the **GCloud console**, in [https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard) you can see resources and IAMs being used by project.
|
||||
- Here you can see the assets supported by this API: [https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
|
||||
- Check **tools** that can be [**used in several clouds here**](../pentesting-cloud-methodology.md).
|
||||
- [**gcp_scanner**](https://github.com/google/gcp_scanner): This is a GCP resource scanner that can help determine what **level of access certain credentials posses** on GCP.
|
||||
## 自動ツール
|
||||
|
||||
- **GCloudコンソール**では、[https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard)でプロジェクトによって使用されているリソースとIAMを確認できます。
|
||||
- このAPIでサポートされている資産を確認できます:[https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
|
||||
- [**複数のクラウドで使用できるツール**](../pentesting-cloud-methodology.md)を確認してください。
|
||||
- [**gcp_scanner**](https://github.com/google/gcp_scanner):これは、GCP上で**特定の資格情報が持つアクセスレベル**を判断するのに役立つGCPリソーススキャナーです。
|
||||
```bash
|
||||
# Install
|
||||
git clone https://github.com/google/gcp_scanner.git
|
||||
@@ -177,13 +170,11 @@ pip install -r requirements.txt
|
||||
# Execute with gcloud creds
|
||||
python3 __main__.py -o /tmp/output/ -g "$HOME/.config/gcloud"
|
||||
```
|
||||
|
||||
- [**gcp_enum**](https://gitlab.com/gitlab-com/gl-security/threatmanagement/redteam/redteam-public/gcp_enum): Bash script to enumerate a GCP environment using gcloud cli and saving the results in a file.
|
||||
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): Scripts to enumerate high IAM privileges and to escalate privileges in GCP abusing them (I couldn’t make run the enumerate script).
|
||||
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): Script to bruteforce your permissions.
|
||||
- [**gcp_enum**](https://gitlab.com/gitlab-com/gl-security/threatmanagement/redteam/redteam-public/gcp_enum): gcloud cliを使用してGCP環境を列挙し、結果をファイルに保存するBashスクリプト。
|
||||
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): 高いIAM権限を列挙し、それを悪用してGCPで権限を昇格させるスクリプト(列挙スクリプトを実行できませんでした)。
|
||||
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): あなたの権限をブルートフォースするスクリプト。
|
||||
|
||||
## gcloud config & debug
|
||||
|
||||
```bash
|
||||
# Login so gcloud can use your credentials
|
||||
gcloud auth login
|
||||
@@ -198,13 +189,11 @@ gcloud auth application-default print-access-token
|
||||
# Update gcloud
|
||||
gcloud components update
|
||||
```
|
||||
|
||||
### Capture gcloud, gsutil... network
|
||||
|
||||
Remember that you can use the **parameter** **`--log-http`** with the **`gcloud`** cli to **print** the **requests** the tool is performing. If you don't want the logs to redact the token value use `gcloud config set log_http_redact_token false`
|
||||
|
||||
Moreover, to intercept the communication:
|
||||
**`gcloud`** CLIで**リクエスト**を**表示**するために、**パラメータ** **`--log-http`**を使用できることを忘れないでください。ログがトークン値を隠さないようにするには、`gcloud config set log_http_redact_token false`を使用します。
|
||||
|
||||
さらに、通信を傍受するには:
|
||||
```bash
|
||||
gcloud config set proxy/address 127.0.0.1
|
||||
gcloud config set proxy/port 8080
|
||||
@@ -221,11 +210,9 @@ gcloud config unset proxy/type
|
||||
gcloud config unset auth/disable_ssl_validation
|
||||
gcloud config unset core/custom_ca_certs_file
|
||||
```
|
||||
### gcloudでのOAuthトークンの設定
|
||||
|
||||
### OAuth token configure in gcloud
|
||||
|
||||
In order to **use an exfiltrated service account OAuth token from the metadata endpoint** you can just do:
|
||||
|
||||
**メタデータエンドポイントからの流出したサービスアカウントOAuthトークンを使用するためには**、次のようにするだけです:
|
||||
```bash
|
||||
# Via env vars
|
||||
export CLOUDSDK_AUTH_ACCESS_TOKEN=<token>
|
||||
@@ -237,13 +224,8 @@ gcloud config set auth/access_token_file /some/path/to/token
|
||||
gcloud projects list
|
||||
gcloud config unset auth/access_token_file
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user