Kubernetes Goat靶场搭建
categories: []
date: '2023-10-26T15:03:23.770147+08:00'
tags: []
title: Kubernetes Goat靶场搭建
updated: 2023-10-26T15:3:24.349+8:0
前提
- 前置条件:确保您拥有 Kubernetes 集群的管理员访问权限并安装了
kubectl
- k8s环境可参考:https://blog.putdown.top/archives/a31b6d49.html
介绍
- 靶场地址:https://github.com/madhuakula/kubernetes-goat
- 实验环境:安装
minikube
后的Ubuntu 22.04
的虚拟机
靶场内容
Sensitive keys in codebases
DIND (docker-in-docker) exploitation
SSRF in the Kubernetes (K8S) world
Container escape to the host system
Docker CIS benchmarks analysis
Kubernetes CIS benchmarks analysis
Attacking private registry
NodePort exposed services
Helm v2 tiller to PwN the cluster - [Deprecated]
Analyzing crypto miner container
Kubernetes namespaces bypass
Gaining environment information
DoS the Memory/CPU resources
Hacker container preview
Hidden in layers
RBAC least privileges misconfiguration
KubeAudit - Audit Kubernetes clusters
Falco - Runtime security monitoring & detection
Popeye - A Kubernetes cluster sanitizer
Secure network boundaries using NSP
Cilium Tetragon - eBPF-based Security Observability and Runtime Enforcement
Securing Kubernetes Clusters using Kyverno Policy Engine
搭建
- 参考
kubernetes-goat项目issues
安装helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- 验证
helm version
version.BuildInfo{Version:"v3.11.0", GitCommit:"472c5736ab01133de504a826bd9ee12cbe4e7904", GitTreeState:"clean", GoVersion:"go1.18.10"}
安装socat,用于端口转发
apt install -y socat
kubernetes-goat.git
- 下载项目
git clone https://github.com/madhuakula/kubernetes-goat.git
cd kubernetes-goat
- 修改
scenarios/internal-proxy/deployment.yaml
中CPU和内存值为300M。
spec:
selector:
matchLabels:
app: internal-proxy
template:
metadata:
labels:
app: internal-proxy
spec:
containers:
- name: internal-api
image: madhuakula/k8s-goat-internal-api
resources:
limits:
cpu: 300m
memory: 300Mi
requests:
cpu: 300m
memory: 300Mi
ports:
- 运行
chmod +x bash setup-kubernetes-goat.sh
chmod +x bash access-kubernetes-goat.sh
bash setup-kubernetes-goat.sh
bash access-kubernetes-goat.sh
- 访问1234端口,就可以看到全部的场景信息。
报错
- 个人遇到情况及解决
- 在执行
.sh
文件的时候出现的报错
root@ubuntu20:~/kubernetes-goat# bash setup-kubernetes-goat.sh
Error: Could not find kubectl or an other error happened, please check kubectl setup.
root@ubuntu20:~/kubernetes-goat# bash access-kubernetes-goat.sh
Please check kubectl setup.
- 根据https://github.com/madhuakula/kubernetes-goat/issues/134 这条issues解决问题
I fixed it using kubectl 1.23.0:
我使用 kubectl 1.23.0 修复了它:
curl -LO https://dl.k8s.io/release/v1.23.0/bin/linux/amd64/kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --short
- 执行上面三条命令后,能正常开启靶场
- 在执行安装
helm
的命令时下载不下来
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- 可手动去下载
helm
再添加环境变量
https://get.helm.sh/helm-v3.13.1-linux-amd64.tar.gz
mv helm /usr/local/bin/helm
搭建完成
- 在解决完各种问题后访问
ip:1234
即可打开靶场
- 后续会逐步完成靶场内容
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 putdown.top