# GCP - API-Schlüssel Unauthentifizierte Enumeration {{#include ../../../banners/hacktricks-training.md}} ## API-Schlüssel Für weitere Informationen zu API-Schlüsseln siehe: {{#ref}} ../gcp-services/gcp-api-keys-enum.md {{#endref}} ### OSINT-Techniken **Google API-Schlüssel werden von allen Arten von Anwendungen verwendet**, die von der Client-Seite aus arbeiten. Es ist üblich, sie im Quellcode von Websites oder in Netzwerk-Anfragen, in mobilen Anwendungen oder einfach durch das Suchen nach Regex in Plattformen wie Github zu finden. Der Regex ist: **`AIza[0-9A-Za-z_-]{35}`** Suche ihn zum Beispiel in Github unter: [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) ### Überprüfen des Ursprungsprojekts in GCP - `apikeys.keys.lookup` Dies ist äußerst nützlich, um zu überprüfen, **zu welchem GCP-Projekt ein gefundener API-Schlüssel gehört**: ```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-Endpunkte Da Sie möglicherweise nicht wissen, welche APIs im Projekt aktiviert sind, wäre es interessant, das Tool [https://github.com/ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) auszuführen und zu überprüfen, **auf was Sie mit dem API-Schlüssel zugreifen können.** {{#include ../../../banners/hacktricks-training.md}}