madhuakula / kubernetes-goat

Kubernetes Goat is a "Vulnerable by Design" cluster environment to learn and practice Kubernetes security using an interactive hands-on playground 🚀

Home Page:https://madhuakula.com/kubernetes-goat

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting "invalid port" message when accessing http://127.0.0.1:1234

SaurabhSinghDev opened this issue · comments

All the steps completed but getting following message when accessing the local cloud address.

Following message received post completion :
kubectl setup looks good. Creating port forward for all the Kubernetes Goat resources to locally. We will be using 1230 to 1236 ports locally! Visit http://127.0.0.1:1234 to get started with your Kuberenetes Goat hacking!

Please see...
When accessed the URL
image

Hey @SaurabhSinghDev if you can give more details about your setup that would be useful. Also try to check all the pods running before running the bash access-kubernetes-goat.sh script. Because this script basically port-forward all the pods required to locally.

Hi @madhuakula , have followed all the steps as mentioned in your guide, no major changes. Also, have checked all pods are running as required. I wonder if the ports are not accessible or issue with port forwarding.

Can you check if any firewall/ufw in your system which is blocking these ports. Apart from the above steps, it should work out of the box and there shouldn't be any issues. As this is just doing kubectl port forwarding to local system.

Closing this task. Let me know if you still facing some issue.

The firewall rules are set to default. Can you just post what ideal rule should be.

Thanks

Closing this task. Let me know if you still facing some issue.

Yes, Still facing the issue. Tried everything.

@SaurabhSinghDev could you please explain about your setup?

Thanks

@SaurabhSinghDev could you please explain about your setup?

Thanks

I made a fresh new account with GCloud.
And, Started with the setup as mentioned by your blog. And followed each step, everything worked fine but when I access the address finally. I am not able to.

Also, PODS are running.

Can you check and paste the netstat result for the ports which exposed for kubernetes goat

Hope this helps

image

Looks like it's properly exposed. Here is the screeshot from the Katacoda as well. I am not sure if anything missing at your system side. As till here we can see the ports exposed means, it looks like everything works with Kubernetes Goat.

Selection_001

So, what must be causing the issue ?

Can you help !!

Hello

If you work in a VM and you are using a browser on the host, you need to specify --address 0.0.0.0

When I am using Docker and similar applications, I never map anything to 127.0.0.1, always 0.0.0.0

http://vm-ip-address:1234 on host is not working
http://localhost:1234 inside the vm works

Then, you use 0.0.0.0 in the expose script:
http://vm-ip-address:1234 on host now works.

@madhuakula I suggest you update your script since this does not break http://localhost:1234 or http://127.0.0.1:1234 inside the VM.

CMD="kubectl port-forward --address 0.0.0.0"
echo 'Creating port forward for all the Kubernetes Goat resources to locally. We will be using 1230 to 1236 ports locally!'

# Exposing Sensitive keys in code bases Scenario
export POD_NAME=$(kubectl get pods --namespace default -l "app=build-code" -o jsonpath="{.items[0].metadata.name}")
$CMD $POD_NAME 1230:3000 > /dev/null 2>&1 &

# Exposing DIND (docker-in-docker) exploitation Scenario
export POD_NAME=$(kubectl get pods --namespace default -l "app=health-check" -o jsonpath="{.items[0].metadata.name}")
$CMD $POD_NAME 1231:80 > /dev/null 2>&1 &

# Exposing SSRF in K8S world Scenario
export POD_NAME=$(kubectl get pods --namespace default -l "app=internal-proxy" -o jsonpath="{.items[0].metadata.name}")
$CMD $POD_NAME 1232:3000 > /dev/null 2>&1 &

# Exposing Container escape to access host system Scenario
export POD_NAME=$(kubectl get pods --namespace default -l "app=system-monitor" -o jsonpath="{.items[0].metadata.name}")
$CMD $POD_NAME 1233:8080 > /dev/null 2>&1 &

# Exposing Kubernetes Goat Home
export POD_NAME=$(kubectl get pods --namespace default -l "app=kubernetes-goat-home" -o jsonpath="{.items[0].metadata.name}")
$CMD $POD_NAME 1234:80 > /dev/null 2>&1 &

# Exposing Attacking private registry Scenario
export POD_NAME=$(kubectl get pods --namespace default -l "app=poor-registry" -o jsonpath="{.items[0].metadata.name}")
$CMD $POD_NAME 1235:5000 > /dev/null 2>&1 &

# Exposing Attacking private registry Scenario
export POD_NAME=$(kubectl get pods --namespace default -l "app=hunger-check" -o jsonpath="{.items[0].metadata.name}")
$CMD $POD_NAME 1236:8080 > /dev/null 2>&1 &

Hello @alains-trend

You are correct. I use --address 0.0.0.0 in the Katacoda environment to expose as the port binds to the localhost.

I will update the script and push the latest changes.

Thank you so much once again!