GCP - Cloud Functions Unauthenticated Enum

Soutenez HackTricks

Fonctions Cloud

Plus d'informations sur les fonctions Cloud peuvent être trouvées dans :

GCP - Cloud Functions Enum

Brute Force des URLs

Brute Force sur le format d'URL :

  • https://<region>-<nom-projet-gcp>.cloudfunctions.net/<nom_func>

C'est plus facile si vous connaissez les noms de projet.

Consultez cette page pour trouver des outils pour effectuer cette attaque par force brute :

GCP - Unauthenticated Enum & Access

Énumérer les fonctions Cloud ouvertes

Avec le code suivant pris à partir d'ici, vous pouvez trouver des fonctions Cloud qui permettent des invocations non authentifiées.

#!/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
Soutenez HackTricks

Last updated