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 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
API Keys
API 키에 대한 자세한 정보는 다음을 확인하세요:
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.",
[...]
- Contact
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
Brute Force API endspoints
프로젝트에서 어떤 API가 활성화되어 있는지 모를 수 있으므로, 도구 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 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.