AWS - GuardDuty Enum

支持 HackTricks

GuardDuty

根据 文档: GuardDuty 结合了 机器学习、异常检测、网络监控和恶意文件发现,使用 AWS 和行业领先的第三方来源来帮助保护 AWS 上的工作负载和数据。GuardDuty 能够分析数十亿个事件,跨多个 AWS 数据源,如 AWS CloudTrail 事件日志、Amazon 虚拟私有云 (VPC) 流日志、Amazon 弹性 Kubernetes 服务 (EKS) 审计和系统级日志,以及 DNS 查询日志。

Amazon GuardDuty 识别您账户中的异常活动,分析该活动的 安全相关性,并提供其被调用的 上下文。这使得响应者能够判断是否应该花时间进行进一步调查。

警报 出现在 GuardDuty 控制台 (90 天) 和 CloudWatch 事件中。

当用户 禁用 GuardDuty 时,它将停止监控您的 AWS 环境,并且不会生成任何新的发现,现有发现将丢失。 如果您只是停止它,现有发现将保留。

发现示例

  • 侦察:表明攻击者进行侦察的活动,例如 异常的 API 活动、可疑的数据库 登录 尝试、VPC 内部 端口扫描、异常的失败登录请求模式,或来自已知恶意 IP 的未阻止端口探测。

  • 实例被攻破:表明实例被攻破的活动,例如 加密货币挖矿、后门命令与控制 (C&C) 活动、使用域生成算法 (DGA) 的恶意软件、出站拒绝服务活动、异常 高网络 流量、异常网络协议、与已知恶意 IP 的出站实例通信、外部 IP 地址使用的临时 Amazon EC2 凭证,以及使用 DNS 的数据外泄。

  • 账户被攻破:表明账户被攻破的常见模式包括来自异常地理位置或匿名代理的 API 调用、尝试禁用 AWS CloudTrail 日志、削弱账户密码策略的更改、异常的实例或基础设施启动、在异常区域的基础设施部署、凭证盗窃、可疑的数据库登录活动,以及来自已知恶意 IP 地址的 API 调用。

  • 存储桶被攻破:表明存储桶被攻破的活动,例如可疑的数据访问模式表明凭证滥用、来自远程主机的异常 Amazon S3 API 活动、来自已知恶意 IP 地址的未授权 S3 访问,以及从没有先前访问存储桶历史的用户或从异常位置调用的 API 调用以检索 S3 存储桶中的数据。Amazon GuardDuty 持续监控和分析 AWS CloudTrail S3 数据事件(例如 GetObject、ListObjects、DeleteObject),以检测您所有 Amazon S3 存储桶中的可疑活动。

发现信息

发现摘要:

  • 发现类型

  • 严重性:7-8.9 高,4-6.9 中,01-3.9 低

  • 区域

  • 账户 ID

  • 资源 ID

  • 检测时间

  • 使用了哪个威胁列表

主体包含以下信息:

  • 受影响的资源

  • 操作

  • 行为者:IP 地址、端口和域

  • 其他信息

所有发现

访问所有 GuardDuty 发现的列表: https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.html

多账户

通过邀请

您可以 邀请其他账户 到不同的 AWS GuardDuty 账户,以便 每个账户都从同一个 GuardDuty 进行监控。主账户必须邀请成员账户,然后成员账户的代表必须接受邀请。

通过组织

您可以指定组织内的任何账户为 GuardDuty 委派管理员。只有组织管理账户可以指定委派管理员。

被指定为委派管理员的账户成为 GuardDuty 管理员账户,在指定的 AWS 区域自动启用 GuardDuty,并且还具有 在该区域内为组织中的所有账户启用和管理 GuardDuty 的权限。组织中的其他账户可以被视为与该委派管理员账户关联的 GuardDuty 成员账户。

枚举

# Get Org config
aws guardduty list-organization-admin-accounts #Get Delegated Administrator
aws guardduty describe-organization-configuration --detector-id <id>

# Check external invitations
aws guardduty list-invitations
aws guardduty get-invitations-count

# Detector Information
aws guardduty list-detectors # 1 detector per account with GuardDuty
aws guardduty get-detector --detector-id <id> # Get detector info
aws guardduty get-master-account --detector-id <id>

# Get filters
aws guardduty list-filters --detector-id <id> # Check filters
aws guardduty get-filter --detector-id <id> --filter-name <name>

# Findings
aws guardduty list-findings --detector-id <id> # List findings
aws guardduty get-findings --detector-id <id> --finding-ids <id> # Get details about the finding
aws guardduty get-findings-statistics --detector-id <id> --finding-statistic-types <types>

# Get trusted IP addresses
aws guardduty list-ip-sets --detector-id <id>
aws guardduty get-ip-set --detector-id <id>

# Member accounts of the current AWS GuardDuty master account
aws guardduty list-members --detector-id <id>
aws guardduty get-members --detector-id <id> --account-ids <id>
aws guardduty get-member-detectors --detector-id <id> --account-ids <id>

# Continuously export its findings to an Amazon S3 bucket
aws guardduty list-publishing-destinations --detector-id <id>

# Intelligence sets that you have uploaded to GuardDuty
aws guardduty list-threat-intel-sets --detector-id <id>
aws guardduty get-threat-intel-set --detector-id <id> --threat-intel-set-id <id>

GuardDuty 绕过

一般指导

尽量多了解你将要使用的凭证的行为:

  • 使用时间

  • 位置

  • 用户代理 / 服务(可以通过 awscli、webconsole、lambda 等使用)

  • 定期使用的权限

根据这些信息,尽可能重现相同的场景以使用访问权限:

  • 如果是 用户或用户访问的角色,尽量在相同的时间、相同的地理位置(如果可能,甚至相同的 ISP 和 IP)使用它

  • 如果是 服务使用的角色,在相同区域创建相同的服务,并在相同的时间范围内从那里使用

  • 始终尝试使用该主体使用的 相同权限

  • 如果需要 使用其他权限或滥用权限(例如,下载 1.000.000 个 cloudtrail 日志文件),请 缓慢 进行,并与 AWS 的 最小交互量(awscli 有时在写入之前会调用多个读取 API)

破解 GuardDuty

guardduty:UpdateDetector

通过此权限,你可以禁用 GuardDuty 以避免触发警报。

aws guardduty update-detector --detector-id <detector-id> --no-enable
aws guardduty update-detector --detector-id <detector-id> --data-sources S3Logs={Enable=false}

guardduty:CreateFilter

拥有此权限的攻击者可以使用过滤器自动归档发现:

aws guardduty create-filter  --detector-id <detector-id> --name <filter-name> --finding-criteria file:///tmp/criteria.json --action ARCHIVE

iam:PutRolePolicy, (guardduty:CreateIPSet|guardduty:UpdateIPSet)

具有先前权限的攻击者可以通过将其 IP 地址添加到 GuardDuty 的 受信任 IP 列表 中来修改该列表,从而避免生成警报。

aws guardduty update-ip-set --detector-id <detector-id> --activate --ip-set-id <ip-set-id> --location https://some-bucket.s3-eu-west-1.amazonaws.com/attacker.csv

guardduty:DeletePublishingDestination

攻击者可以删除目标以防止警报:

aws guardduty delete-publishing-destination --detector-id <detector-id> --destination-id <dest-id>

删除此发布目标将不会影响GuardDuty控制台中发现的生成或可见性。GuardDuty将继续分析您AWS环境中的事件,识别可疑或意外行为,并生成发现。

特定发现绕过示例

请注意,GuardDuty有数十种发现,然而,作为红队成员,并非所有发现都会影响您,更好的是,您可以在https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.html中找到每个发现的完整文档,因此在采取任何行动之前请查看,以免被抓。

以下是几个特定GuardDuty发现绕过的示例:

GuardDuty检测来自常见渗透测试工具的AWS API请求,并触发PenTest Finding。 它是通过在API请求中传递的用户代理名称检测到的。 因此,修改用户代理可以防止GuardDuty检测到攻击。

为防止这种情况,您可以在botocore包中的脚本session.py中搜索并修改用户代理,或将Burp Suite设置为AWS CLI代理,并使用MitM更改用户代理,或者只需使用Ubuntu、Mac或Windows等操作系统将防止此警报触发。

UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration

从元数据服务提取EC2凭证并在AWS环境外部使用将激活UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS警报。相反,从您的EC2实例使用这些凭证将触发UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.InsideAWS警报。然而,在同一账户内的另一台被攻陷的EC2实例上使用这些凭证不会被检测到,不会引发警报。

因此,在您找到凭证的机器内部使用提取的凭证以避免触发此警报。

参考文献

支持HackTricks

Last updated