Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/test/kubernetes/README.md
Views: 11766
Kubernetes
A collection of Helm charts have been created to aid both Metasploit developers and pentesters explore Metasploit's Kubernetes support. These charts can help provision your local Kubernetes environment with intentionally vulnerable applications, which can be exploited using Metasploit modules.
Usage
Requirements
Kubernetes is installed on your host machine with either kind, Minikube, Docker Desktop, or alternatives.
If you are using Kind, you will need to create a cluster ahead of time:
Kubectl and Helm will also need to be available on your path, an example of installing these tools can be found within the example Dockerfile.
Installing
The provided Makefile
will have all of the required commands available for setting up your environment:
Next install the vulnerable charts and configuration:
If you are on a Mac environment, you can optionally use the docker-compose
setup:
It is also possible to enter into an interactive environment with the required Helm/Kubectl tools available:
Available Charts
secrets
Create multiple Kubernetes Secrets to test Metasploit's enumeration capabilities:
thinkphp
Run an intentionally vulnerable thinkphp
application with full cluster access:
Forwarding to host on port 9001:
Exploitation will result in a Meterpreter session with full cluster access:
lucee
Run an intentionally vulnerable lucee
application with a default service account with minimal access:
Forwarding to host on port 9002:
Exploitation will result in a cmd shell session with a default service account with minimal access:
Workflow Example
First configure the Kubernetes environment:
Now expose the exploitable thinkphp application to your host machine. In the real world this step would not be required as the application would be most likely already be publicly accessible:
Open Metasploit and exploit the thinkphp container to open a Metarpreter session:
The auxiliary/cloud/kubernetes/enum_kubernetes
module can now be used to pivot through the compromised container to reach the previously inaccessible Kubernetes API. In this scenario the container's Kubernetes service token will be read from the file system, and used to authenticate with the Kubernetes API:
If the compromised service token has the required permissions to create new pods, it is possible to open additional Metasploit sessions and run one-of tasks with the exploit/multi/kubernetes/exec
module. This newly created pod will also attempt to mount the Kubernetes Node's root filesystem to /host_mnt
, which may lead to additional attack vectors:
See the corresponding documentation for each module for more detail.
Kubernetes Dashboard
To access the Kubernetes dashboard:
Now visit https://localhost:9443, and select the token option. To generate an admin token will full access to the cluster: