mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-31 07:00:38 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
|
||||
## 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/
|
||||
@@ -21,41 +21,41 @@ gcp-basic-information/
|
||||
|
||||
## GCP Pentester/Red Team Methodology
|
||||
|
||||
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:
|
||||
З точки зору Red Team, **перший крок до компрометації середовища 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**](../workspace-security/))
|
||||
- Повторне використання **паролів** (витоки паролів)
|
||||
- Вразливості в GCP-розміщених додатках
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) з доступом до метаданих
|
||||
- **Читання локальних файлів**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- 3-ті сторони **зламані**
|
||||
- **Внутрішній** співробітник
|
||||
|
||||
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): Bash-скрипт для перерахунку середовища GCP за допомогою gcloud cli та збереження результатів у файл.
|
||||
- [**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:
|
||||
Пам'ятайте, що ви можете використовувати **параметр** **`--log-http`** з **`gcloud`** cli, щоб **друкувати** **запити**, які виконує інструмент. Якщо ви не хочете, щоб журнали редагували значення токена, використовуйте `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
|
||||
```
|
||||
### Налаштування токена OAuth у gcloud
|
||||
|
||||
### 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