# GCP - Cloud Functions 認証なし列挙 {{#include ../../../banners/hacktricks-training.md}} ## Cloud Functions Cloud Functionsに関する詳細情報は以下で確認できます: {{#ref}} ../gcp-services/gcp-cloud-functions-enum.md {{#endref}} ### ブルートフォースURL **URL形式をブルートフォースする**: - `https://-.cloudfunctions.net/` プロジェクト名を知っていると簡単です。 このページをチェックして、ブルートフォースを実行するためのツールをいくつか確認してください: {{#ref}} ./ {{#endref}} ### オープンなCloud Functionsの列挙 以下のコードを使用すると、認証なしの呼び出しを許可するCloud Functionsを見つけることができます [こちらから取得](https://gitlab.com/gitlab-com/gl-security/security-operations/gl-redteam/gcp_misc/-/blob/master/find_open_functions.sh)。 ```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 ``` {{#include ../../../banners/hacktricks-training.md}}