analyzing-kubernetes-audit-logs
它能做什么
这个工具用来分析 Kubernetes 审计日志,帮你找出可疑行为。它会寻找未授权访问、权限提升和数据窃取的尝试,帮助你判断集群是否已经被入侵。
适用场景
- ✓当你怀疑 Kubernetes 集群遭到入侵时。
- ✓想调查攻击者通过 API 服务器做了什么时。
- ✓在编写检测规则、保护集群的时候。
技能链接
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-kubernetes-audit-logs/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“分析 Kubernetes 审计日志,告诉我是否有人尝试访问 secrets,或者创建特权 Pod。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会读取日志文件。日志文件就像是 Kubernetes 中所有操作的记录。工具会查找一些特定的模式,这些模式通常意味着危险操作,比如有人试图进入容器,或者访问敏感信息。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Analyzing Kubernetes Audit Logs
When to Use
- When investigating security incidents that require analyzing kubernetes audit logs
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
Prerequisites
- Familiarity with container security concepts and tools
- Access to a test or lab environment for safe execution
- Python 3.8+ with required dependencies installed
- Appropriate authorization for any testing activities
Instructions
Parse Kubernetes audit log files (JSON lines format) to detect security-relevant events including unauthorized access, privilege escalation, and data exfiltration.
import json
with open("/var/log/kubernetes/audit.log") as f:
for line in f:
event = json.loads(line)
verb = event.get("verb")
resource = event.get("objectRef", {}).get("resource")
user = event.get("user", {}).get("username")
if verb == "create" and resource == "pods/exec":
print(f"Pod exec by {user}")
Key events to detect:
- pods/exec and pods/attach (shell into containers)
- secrets access (get/list/watch)
- clusterrolebindings creation (RBAC escalation)
- Privileged pod creation
- Anonymous or system:unauthenticated access
Examples
# Detect secret enumeration
if verb in ("get", "list") and resource == "secrets":
print(f"Secret access: {user} -> {event['objectRef'].get('name')}")
常见问题
什么是 Kubernetes 审计日志?
这是详细记录集群中所有操作的文件,包括谁在什么时候对哪个资源做了什么。
什么是 “exec-into-pod”?
指有人通过命令进入集群中正在运行的容器,这可能是一种入侵行为。
什么是 SIEM 检测规则?
这是安全信息与事件管理(SIEM)系统中的配置,当从日志中识别出可疑活动时,系统就会发出告警。
详情
作者的原始描述
Parses Kubernetes API server audit logs (JSON lines) to detect exec-into-pod, secret access, RBAC modifications, privileged pod creation, and anonymous API access, and builds SIEM detection rules from the event patterns. Use when investigating a suspected cluster compromise, reconstructing what an attacker did through the API server, or writing Kubernetes-specific detection content. Keywords: audi
热度
- GitHub 星标
- 35k
- 排名
- #7618
- 许可证
- Apache-2.0
- 更新时间
- 2026/8/31
评论
- …
同一仓库的更多技能
abusing-dpapi-for-credential-access
35k为你的 AI 智能体提供针对特定任务的现成指令,让它完成得更好、更快。
abusing-shadow-credentials-for-privesc
35k教你的 AI 智能体写出清晰、结构良好的文本。
achieving-cmmc-level-2-compliance
35k帮助你的智能体搭建符合 CMMC Level 2 合规要求的环境。它会落实安全要求,并管理必要的文档。
acquiring-disk-image-with-dd-and-dcfldd
35k帮助你的智能体创建硬盘的精确副本。这能确保调查过程中信息不丢失、不被篡改。