GCP - Cloud Functions 인증되지 않은 열거

Reading time: 3 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 지원하기

Cloud Functions

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

GCP - Cloud Functions Enum

브루트 포스 URL

URL 형식 브루트 포스:

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

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

이 페이지에서 이 브루트 포스를 수행할 도구를 확인하세요:

GCP - Unauthenticated Enum & Access

열린 Cloud Functions 열거

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

bash
#!/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

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 지원하기