mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-27 07:14:20 -08:00
4.1 KiB
4.1 KiB
GCP - API Keys Unauthenticated Enum
{{#include ../../../banners/hacktricks-training.md}}
API Keys
APIキーに関する詳細情報は、以下を確認してください:
{{#ref}} ../gcp-services/gcp-api-keys-enum.md {{#endref}}
OSINT技術
Google APIキーは、クライアント側から使用されるあらゆる種類のアプリケーションで広く使用されています。ウェブサイトのソースコードやネットワークリクエスト、モバイルアプリケーション、またはGithubのようなプラットフォームで正規表現を検索することで見つけることが一般的です。
正規表現は次のとおりです:AIza[0-9A-Za-z_-]{35}
例えば、Githubで次のように検索します:https://github.com/search?q=%2FAIza%5B0-9A-Za-z_-%5D%7B35%7D%2F&type=code&ref=advsearch
元のGCPプロジェクトを確認
これは、見つけたAPIキーがどのGCPプロジェクトに属しているかを確認するのに非常に便利です。いくつかのオプションがあります:
https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>に連絡します。
簡潔さのために出力は切り捨てられましたが、完全な出力ではプロジェクトIDが5回以上表示されます。
curl -s "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=AIzaSyD[...]uE8Y"
{
"error": {
"code": 403,
"message": "Identity Toolkit API has not been used in project 943955951114 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=943955951114 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
[...]
https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>に連絡します。
簡潔さのために出力は切り捨てられましたが、完全な出力にはプロジェクトIDが5回以上表示されます。
curl -s "https://identitytoolkit.googleapis.com/v1/projects?key=AIzaSyD[...]uE8Y"
{
"error": {
"code": 403,
"message": "Identity Toolkit API has not been used in project 943955951114 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=943955951114 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
[...]
- [この方法はもう機能しません!]
apikeys.keys.lookup
# If you have permissions
gcloud services api-keys lookup AIzaSyD[...]uE8Y
name: projects/5[...]6/locations/global/keys/28d[...]e0e
parent: projects/5[...]6/locations/global
# If you don't, you can still see the project ID in the error msg
gcloud services api-keys lookup AIzaSy[...]Qbkd_oYE
ERROR: (gcloud.services.api-keys.lookup) PERMISSION_DENIED: Permission 'apikeys.keys.lookup' denied on resource project.
Help Token: ARD_zUaNgNilGTg9oYUnMhfa3foMvL7qspRpBJ-YZog8RLbTjCTBolt_WjQQ3myTaOqu4VnPc5IbA6JrQN83CkGH6nNLum6wS4j1HF_7HiCUBHVN
- '@type': type.googleapis.com/google.rpc.PreconditionFailure
violations:
- subject: ?error_code=110002&service=cloudresourcemanager.googleapis.com&permission=serviceusage.apiKeys.getProjectForKey&resource=projects/89123452509
type: googleapis.com
- '@type': type.googleapis.com/google.rpc.ErrorInfo
domain: apikeys.googleapis.com
metadata:
permission: serviceusage.apiKeys.getProjectForKey
resource: projects/89123452509
service: cloudresourcemanager.googleapis.com
reason: AUTH_PERMISSION_DENIED
ブルートフォースAPIエンドポイント
プロジェクトでどのAPIが有効になっているかわからない場合、ツールhttps://github.com/ozguralp/gmapsapiscannerを実行し、APIキーで何にアクセスできるかを確認するのは興味深いでしょう。
{{#include ../../../banners/hacktricks-training.md}}