GWS - Google Platforms Phishing
Tip
学んで実践する AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学んで実践する GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学んで実践する Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks をサポートする
- subscription plans を確認してください!
- 参加する 💬 Discord group または telegram group に参加するか、Twitter 🐦 @hacktricks_live をフォローしてください。
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
一般的な Phishing の方法論
Phishing Methodology - HackTricks
Google Groups Phishing
デフォルトでは、workspace のメンバーは can create groups and invite people to them ことができるようです。送信されるメールを編集して リンクを追加 することができます。メールは google のアドレスから送られてくるため見た目が legit になり、リンクをクリックする可能性があります。
また、FROM アドレスを Google group email に設定して、グループ内のユーザへより多くのメールを送信することも可能です。以下の画像ではグループ google--support@googlegroups.com を作成し、グループのメンバー(同意なしに追加された)が 全員にメールを送られた 状況が示されています。
 (1).png)
Google Chat Phishing
相手のメールアドレスさえあれば、その人と start a chat したり、invitation to talk を送ることができるかもしれません。さらに、任意の名前(例:“Google Support”)を付けられる Space を create してメンバーを invite することが可能です。相手が承諾すると、Google Support とやり取りしていると思い込む可能性があります:
.png)
Tip
私のテストでは、招待されたメンバーは招待を受け取らないことすらありました。
過去の動作は次で確認できます: https://www.youtube.com/watch?v=KTVHLolz6cE&t=904s
Google Doc Phishing
以前は apparently legitimate document を作成し、コメントで mention some email (like @user@gmail.com) することで、Google がそのメールアドレスに sent an email to that email address と通知していました。
現在はこれが機能しませんが、被害者のメールにドキュメントへのアクセス権を give すると Google はその旨を通知するメールを送ります。誰かをメンションしたときに表示されるメッセージは次の通りです:
.png)
Tip
被害者側には、外部ドキュメントが共有されたことを示すメールが届かないようにする保護機構がある場合があります。
Google Calendar Phishing
calendar event を create し、攻撃対象の会社のメールアドレスを持っているだけ入れられるだけ追加します。カレンダーイベントを現在時刻から 5 or 15 min にスケジュールします。イベントをそれらしく見せ、put a comment and a title indicating that they need to read something(phishing link を含める)とします。
ブラウザに “Firing People” という会議タイトルで表示されるアラートの例があり、より phishing 的なタイトルに設定することも(メールに紐づく名前も変更できます)できます。
.png)
疑わしく見えないようにするために:
- receivers cannot see the other people invited ように設定する
- イベントに関する通知メールを NOT send しない。そうすると、参加者は 5 分後の会議の警告だけを見て、そのリンクを読む必要があると思う
- API を使うと、True に設定して people がイベントを accepted したと見せかけたり、comments on their behalf を作成することもできるようです
App Scripts Redirect Phishing
https://script.google.com/ でスクリプトを作成し、expose it as a web application accessible by everyone として公開することが可能で、正当なドメイン script.google.com を使用します。
次のようなコードを使うと、攻撃者はこのページに任意のコンテンツをロードさせ、ドメインにアクセスし続けることができます。
function doGet() {
return HtmlService.createHtmlOutput(
'<meta http-equiv="refresh" content="0;url=https://cloud.hacktricks.wiki/en/pentesting-cloud/workspace-security/gws-google-platforms-phishing/index.html#app-scripts-redirect-phishing">'
).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
}
For example accessing https://script.google.com/macros/s/AKfycbwuLlzo0PUaT63G33MtE6TbGUNmTKXCK12o59RKC7WLkgBTyltaS3gYuH_ZscKQTJDC/exec you will see:
 (1).png)
Tip
コンテンツが iframe 内に読み込まれるため、警告が表示される点に注意してください。
App Scripts OAuth Phishing
It’s possible to create App Scripts attached to documents to try to get access over a victims OAuth token, for more information check:
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).
Note
Google は多くの場合、アプリケーションが信頼されていない旨の警告プロンプトを表示し、Workspace 管理者は OAuth アプリの承認を禁止できる場合があることに注意してください。
Google allows to create applications that can interact on behalf users with several Google services: 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.
This is a very juicy way to phish non-technical users into using applications that access sensitive information because they might not understand the consequences. However, in organizations accounts, there are ways to prevent this from happening.
Unverified App prompt
As it was mentioned, google will always present a prompt to the user to accept the permissions they are giving the application on their behalf. However, if the application is considered dangerous, google will show first a prompt indicating that it’s dangerous and making it more difficult for the user to grant the permissions to the app.
This prompt appears in apps that:
- Use any scope that can access private data (Gmail, Drive, GCP, BigQuery…)
- Apps with less than 100 users (apps > 100 a review process is also needed to stop showing the unverified prompt)
Interesting Scopes
Here you can find a list of all the 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.
Create an OAuth App
Start creating an OAuth Client ID
- Go to https://console.cloud.google.com/apis/credentials/oauthclient and click on configure the consent screen.
- 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.
- 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.
- 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.readonlyandcloud-platformare sensitive permissions.
- 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.
Now let’s get credentials for a web application using the previously created OAuth Client ID:
- Go back to https://console.cloud.google.com/apis/credentials/oauthclient, a different option will appear this time.
- Select to create credentials for a Web application
- Set needed Javascript origins and redirect URIs
- You can set in both something like
http://localhost:8000/callbackfor testing
- 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.
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 プロンプトが表示されます with a message like this one:
.png)
アプリケーションは、簡単に使用できるaccess and refresh tokenを表示します。これらの token の使い方については次を参照してください:
glcoud を使う
web コンソールの代わりに gcloud を使って操作することも可能です。詳しくは次を参照してください:
GCP - ClientAuthConfig Privesc
OAuth app の保護
デフォルトでは、Workspace 組織内の任意のユーザーがどんな権限の OAuth app でも承認できるように設定されていますが、これらを Sign in with Google に必要な基本情報のみを要求するアプリに限定したり、外部のサードパーティアプリをまったく許可しないように制限することが可能です。
さらに、外部のサードパーティアプリを信頼しない設定にしていても、組織内で作成されたアプリ(apps created inside the organization)を信頼することを許可できます。この信頼はデフォルトで設定されています。

OAuth 同意付与の悪用:検出と対応 (Admin Reports)
ユーザーが OAuth app を承認すると、Google Workspace はそれを Admin Reports OAuth Token Audit Activity(application name token)に記録し、events.name は authorize に設定されます。これらのイベントは、consent phishing を検出し、付与された client ID と scopes を追跡するための最良のテレメトリです。
監査イベントから抽出すべき主なフィールド:
id.time,id.customerIdactor.email,actor.profileIdipAddress,networkInfo.regionCode,networkInfo.subdivisionCodeevents[0]['parameters']values forclient_id,app_name,scope,scope_data
Baseline first (reduce noise): 既存の client IDs と scopes のインベントリを作成し、新規または稀な同意があった場合にアラートを出すようにします。
gam all users print tokens todrive
検出アイデア(新規/希少なアプリ + 危険な scopes):
client_idがapproved allowlistに含まれておらず、かつ過去X日間に確認されていない場合(例: 90日)にアラートを出す。- 付与された
scopeに、特に大量データアクセスやサプライチェーンへの影響を与えうる、ハイリスクまたは希少なscopeが含まれている場合にアラートを出す。例えば: https://mail.google.com/https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.readonlyhttps://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chromewebstore
client_id NOT IN approved_client_ids
AND client_id NOT IN last_seen_90d
AND scope CONTAINS any(high_risk_scopes OR rare_scopes)
対応 / 封じ込め:
- 悪意のある OAuth client ID の tokens を取り消す:
gam all users delete tokens clientId <client_id>
- Admin ConsoleでOAuth client IDをブロックし、アプリケーションのGoogleデータへのアクセスを取り消します。
Threat hunting pivots:
- 利用者がN未満のユーザーに同意された外部アプリをリストする(採用が稀)。
- アプリ名、発行者、permissions/scopes、および固有のapplication IDを確認する。
- 突如リスクの高いpermissionsを使用し始めた休眠中のアプリを探す(内部 phishing やデータ窃盗のような追随行為の可能性)。
緩和策:
- すべてのサードパーティアプリのアクセスを制限する(管理者承認のみ)。
- ユーザーが同意できるのを基本的な “Sign in with Google” のプロフィール情報のみとするよう、アクセスを限定する。
参考資料
- 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 - Mike Felch and Beau Bullock - OK Google, How do I Red Team GSuite?
- https://redcanary.com/blog/threat-detection/google-workspace-oauth-attack/
- https://github.com/GAM-team/GAM
Tip
学んで実践する AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学んで実践する GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学んで実践する Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks をサポートする
- subscription plans を確認してください!
- 参加する 💬 Discord group または telegram group に参加するか、Twitter 🐦 @hacktricks_live をフォローしてください。
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
HackTricks Cloud

