GCP - API Keys Unauthenticated Enum

Reading time: 4 minutes

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें

API Keys

API Keys के बारे में अधिक जानकारी के लिए देखें:

GCP - API Keys Enum

OSINT techniques

Google API Keys का उपयोग किसी भी प्रकार के अनुप्रयोगों द्वारा किया जाता है जो क्लाइंट साइड से उपयोग करते हैं। इन्हें वेबसाइट के स्रोत कोड या नेटवर्क अनुरोधों में, मोबाइल अनुप्रयोगों में या Github जैसे प्लेटफार्मों पर regex खोजते समय आमतौर पर पाया जाता है।

Regex है: 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

Check origin GCP project

यह जांचने के लिए अत्यंत उपयोगी है कि आपके द्वारा पाए गए API key किस GCP प्रोजेक्ट से संबंधित है। हमारे पास विभिन्न विकल्प हैं:

  • संपर्क करें https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>

संक्षिप्तता के लिए आउटपुट को संक्षिप्त किया गया था, लेकिन पूर्ण आउटपुट में प्रोजेक्ट ID 5 से अधिक बार दिखाई देता है।

bash
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>

संक्षिप्तता के लिए आउटपुट को काट दिया गया था, लेकिन पूर्ण आउटपुट में प्रोजेक्ट आईडी 5 से अधिक बार दिखाई देता है।

bash
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
bash
# 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

Brute Force API endspoints

जैसा कि आप नहीं जानते होंगे कि प्रोजेक्ट में कौन से APIs सक्षम हैं, यह दिलचस्प होगा कि आप टूल https://github.com/ozguralp/gmapsapiscanner चलाएं और जांचें कि आप API कुंजी के साथ क्या एक्सेस कर सकते हैं।

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें