GCP - Cloud Functions Unauthenticated Enum

Support HackTricks

Cloud Functions

Cloud Functions에 대한 더 많은 정보는 다음에서 확인할 수 있습니다:

GCP - Cloud Functions Enum

Brute Force URls

URL 형식의 Brute Force:

  • https://<region>-<project-gcp-name>.cloudfunctions.net/<func_name>

프로젝트 이름을 알고 있으면 더 쉽습니다.

이 Brute Force를 수행할 도구에 대한 정보는 이 페이지를 확인하세요:

GCP - Unauthenticated Enum & Access

Enumerate Open Cloud Functions

다음 코드를 사용하여 여기에서 가져온 Cloud Functions를 찾을 수 있습니다. 이 함수는 인증되지 않은 호출을 허용합니다.

#!/bin/bash

############################
# Run this tool to find Cloud Functions that permit unauthenticated invocations
# anywhere in your GCP organization.
# Enjoy!
############################

for proj in $(gcloud projects list --format="get(projectId)"); do
echo "[*] scraping project $proj"

enabled=$(gcloud services list --project "$proj" | grep "Cloud Functions API")

if [ -z "$enabled" ]; then
continue
fi


for func_region in $(gcloud functions list --quiet --project "$proj" --format="value[separator=','](NAME,REGION)"); do
# drop substring from first occurence of "," to end of string.
func="${func_region%%,*}"
# drop substring from start of string up to last occurence of ","
region="${func_region##*,}"
ACL="$(gcloud functions get-iam-policy "$func" --project "$proj" --region "$region")"

all_users="$(echo "$ACL" | grep allUsers)"
all_auth="$(echo "$ACL" | grep allAuthenticatedUsers)"

if [ -z "$all_users" ]
then
:
else
echo "[!] Open to all users: $proj: $func"
fi

if [ -z "$all_auth" ]
then
:
else
echo "[!] Open to all authenticated users: $proj: $func"
fi
done
done
HackTricks 지원하기

Last updated