关于 performing-cloud-native-threat-hunting-with-aws-detective
面向 AWS 安全分析人员的云原生威胁狩猎技能,利用 AWS Detective 的行为图和调查结果分析实体活动、异常 API 调用及攻击关联。
主要功能
- 01列出可用行为图
- 02调查 IAM 用户等实体
- 03通过 AWS CLI 和 boto3 搜索实体
- 04分析关联的 GuardDuty 发现
- 05检查调查指标
适用场景
- 01调查可疑 IAM 用户或角色的活动
- 02分析高严重级别调查和攻击关联
- 03核对 Detective 结果与 CloudTrail 日志
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill performing-cloud-native-threat-hunting-with-aws-detective安装后在 Claude Code 中输入/performing-cloud-native-threat-hunting-with-aws-detective确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
assets/template.mdreferences/api-reference.mdstandards.mdworkflows.mdscripts/process.py详细介绍
使用 AWS Detective 执行云原生威胁狩猎
概述
AWS Detective 会自动收集并分析来自 AWS CloudTrail、VPC Flow Logs、GuardDuty 发现结果和 EKS 审计日志的日志数据,以构建交互式行为图。这些图使安全分析师能够跨时间调查实体(IAM 用户、角色、IP 地址、EC2 实例),识别异常的 API 调用,检测账户之间的横向移动,并将 GuardDuty 发现结果关联为连贯的攻击叙述 — 这一切都无需手动解析日志。
先决条件
- 已启用 Detective 的 AWS 账户(需要 GuardDuty 处于活动状态 48+ 小时)
- 已配置适当 IAM 权限(
detective:*、guardduty:List*)的 AWS CLI v2 - Python 3.9+ 以及 boto3
- IAM 策略:
AmazonDetectiveFullAccess或包含detective:SearchGraph、detective:GetInvestigation、detective:ListIndicators的自定义策略
关键概念
| 概念 | 描述 |
|---|---|
| 行为图 | 链接某个账户/区域的 CloudTrail、VPC Flow、GuardDuty 和 EKS 日志的数据结构 |
| 实体 | 可调查对象:IAM 用户、IAM 角色、EC2 实例、IP 地址、S3 存储桶、EKS 集群 |
| 发现结果组 | 与同一攻击活动相关联的一组 GuardDuty 发现结果 |
| 实体配置文件 | 某个实体的 API 调用、网络连接和资源访问的时间线 |
| 作用域时间 | 用于行为分析调查的时间窗口(默认 24 小时,最长 1 年) |
步骤
步骤 1:列出可用的行为图
aws detective list-graphs --output table
步骤 2:调查可疑的 IAM 用户
# Get entity profile for an IAM user
aws detective get-investigation \
--graph-arn arn:aws:detective:us-east-1:123456789012:graph:a1b2c3d4 \
--investigation-id 000000000000000000001
步骤 3:以编程方式搜索实体
#!/usr/bin/env python3
"""Search AWS Detective for suspicious entities."""
import boto3
import json
from datetime import datetime, timedelta
detective = boto3.client('detective')
def list_behavior_graphs():
"""List all Detective behavior graphs."""
response = detective.list_graphs()
return response.get('GraphList', [])
def get_investigation_indicators(graph_arn, investigation_id, max_results=50):
"""Get indicators for a specific investigation."""
response = detective.list_indicators(
GraphArn=graph_arn,
InvestigationId=investigation_id,
MaxResults=max_results
)
return response.get('Indicators', [])
def investigate_guardduty_findings(graph_arn):
"""List high-severity investigations correlated by Detective."""
response = detective.list_investigations(
GraphArn=graph_arn,
FilterCriteria={
'Severity': {'Value': 'CRITICAL'},
'Status': {'Value': 'RUNNING'}
},
MaxResults=20
)
for investigation in response.get('InvestigationDetails', []):
print(f"Investigation: {investigation['InvestigationId']}")
print(f" Entity: {investigation['EntityArn']}")
print(f" Status: {investigation['Status']}")
print(f" Severity: {investigation['Severity']}")
print(f" Created: {investigation['CreatedTime']}")
print()
if __name__ == "__main__":
graphs = list_behavior_graphs()
for graph in graphs:
print(f"Graph: {graph['Arn']}")
investigate_guardduty_findings(graph['Arn'])
步骤 4:分析攻击活动的发现结果组
# List investigations with high severity
aws detective list-investigations \
--graph-arn arn:aws:detective:us-east-1:123456789012:graph:a1b2c3d4 \
--filter-criteria '{"Severity":{"Value":"HIGH"}}' \
--max-results 10
步骤 5:检查实体指标
# Get indicators for a specific investigation
aws detective list-indicators \
--graph-arn arn:aws:detective:us-east-1:123456789012:graph:a1b2c3d4 \
--investigation-id 000000000000000000001 \
--max-results 50
预期输出
list-investigations 命令返回调查元数据:
{
"InvestigationDetails": [
{
"InvestigationId": "000000000000000000001",
"Severity": "CRITICAL",
"Status": "RUNNING",
"State": "ACTIVE",
"EntityArn": "arn:aws:iam::123456789012:user/suspicious-user",
"EntityType": "IAM_USER",
"CreatedTime": "2026-03-15T14:30:00Z"
}
]
}
指标通过 list-indicators 单独检索,并包括诸如 TTP_OBSERVED、IMPOSSIBLE_TRAVEL、FLAGGED_IP_ADDRESS、NEW_GEOLOCATION、NEW_ASO、NEW_USER_AGENT、RELATED_FINDING 和 RELATED_FINDING_GROUP 等类型。
验证
- 确认行为图有数据:
aws detective list-graphs返回非空列表 - 验证调查结果包含带有 API 调用序列的实体时间线
- 将 Detective 发现结果与原始 CloudTrail 日志交叉核对以确保准确性
- 验证发现结果组关联与手动调查结论一致
- 确认针对 HIGH/CRITICAL 严重性调查的自动警报会触发
评论
支持 Markdown