K8S
Some useful command during a Kubernetes engagement.
kubectl get pods -A -o json | jq -r '.items[] |{namespace: .metadata.namespace,name: .metadata.name,seccomp: (.spec.securityContext.seccompProfile.type // .metadata.annotations["seccomp.security.alpha.kubernetes.io/pod"] // "not set")}'kubectl get pods -A -o json | jq -r '.items[] as $pod |$pod.spec.containers[]? as $c |"\($pod.metadata.name)\t\($c.name)\t\($c.securityContext.allowPrivilegeEscalation // "not set (defaults to true)")"' kubectl get pods -A -o json | jq -r '.items[] |select(any(.spec.containers[]?; .securityContext.readOnlyRootFilesystem != true)) |"\(.metadata.namespace)\t\(.metadata.name)"' kubectl get pods -A -o json | jq -r '.items[] as $pod|$pod.spec.containers[]? as $c|select($c.securityContext.privileged == true)|"\($pod.metadata.namespace)\t\($pod.metadata.name)\t\($c.name)"'kubectl get networkpolicies -A# First gather API servers
kubectl get pods -A -l component=kube-apiserver
# Check for each returned Pod if it outputs anything
kubectl -n kube-system get pod <POD_NAME> -o json | jq -r '.spec.containers[0].command[]' | grep encryption-provider-configapiVersion: v1
kind: Pod
metadata:
name: pentest
spec:
containers:
- name: pentest
image: ubuntu:latest
command: ["/bin/sh", "-c", "sleep 3600"]
volumeMounts:
- mountPath: /host-root
name: root-mount
volumes:
- name: root-mount
hostPath:
path: /
type: Directory Last updated