AWS - GuardDuty Enum
Reading time: 15 minutes
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をサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
GuardDuty
According to the docs: GuardDutyは、機械学習、異常検知、ネットワーク監視、悪意のあるファイル発見を組み合わせて、AWS上のワークロードとデータを保護するために、AWSおよび業界をリードするサードパーティのソースを使用します。GuardDutyは、AWS CloudTrailイベントログ、Amazon Virtual Private Cloud (VPC)フローログ、Amazon Elastic Kubernetes Service (EKS)の監査およびシステムレベルのログ、DNSクエリログなど、複数のAWSデータソースにわたる数十億のイベントを分析することができます。
Amazon GuardDutyは、アカウント内の異常な活動を特定し、その活動のセキュリティ関連性を分析し、活動が発生したコンテキストを提供します。これにより、応答者はさらなる調査に時間を費やすべきかどうかを判断できます。
アラートは**GuardDutyコンソール(90日間)**およびCloudWatch Eventsに表示されます。
warning
ユーザーがGuardDutyを無効にすると、AWS環境の監視が停止し、新しい発見は一切生成されず、既存の発見は失われます。
ただ停止するだけの場合、既存の発見は残ります。
Findings Example
- 偵察: 攻撃者による偵察を示唆する活動、例えば異常なAPI活動、疑わしいデータベースログイン試行、VPC内のポートスキャン、異常な失敗したログインリクエストパターン、または既知の悪意のあるIPからのブロックされていないポートのプロービング。
- インスタンスの侵害: インスタンスの侵害を示す活動、例えば暗号通貨マイニング、バックドアコマンドおよびコントロール(C&C)活動、ドメイン生成アルゴリズム(DGA)を使用するマルウェア、外向きのサービス拒否活動、異常に高いネットワークトラフィック量、異常なネットワークプロトコル、既知の悪意のあるIPとの外向きインスタンス通信、外部IPアドレスによって使用される一時的なAmazon EC2資格情報、DNSを使用したデータの流出。
- アカウントの侵害: アカウントの侵害を示す一般的なパターンには、異常な地理的位置または匿名プロキシからのAPI呼び出し、AWS CloudTrailログの無効化の試み、アカウントパスワードポリシーを弱める変更、異常なインスタンスまたはインフラの起動、異常な地域でのインフラ展開、資格情報の盗難、疑わしいデータベースログイン活動、既知の悪意のあるIPアドレスからのAPI呼び出しが含まれます。
- バケットの侵害: バケットの侵害を示す活動、例えば資格情報の誤用を示す疑わしいデータアクセスパターン、リモートホストからの異常なAmazon S3 API活動、既知の悪意のあるIPアドレスからの不正なS3アクセス、またはバケットにアクセスしたことのないユーザーからのS3バケット内のデータを取得するためのAPI呼び出し、または異常な場所からの呼び出し。Amazon GuardDutyは、すべてのAmazon S3バケットにわたる疑わしい活動を検出するために、AWS CloudTrail S3データイベント(例:GetObject、ListObjects、DeleteObject)を継続的に監視および分析します。
Finding Information
Finding summary:
- Finding type
- Severity: 7-8.9 高, 4-6.9 中, 01-3.9 低
- Region
- Account ID
- Resource ID
- Time of detection
- Which threat list was used
The body has this information:
- Resource affected
- Action
- Actor: Ip address, port and domain
- Additional Information
All Findings
Access a list of all the GuardDuty findings in: https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.html
Multi Accounts
By Invitation
他のアカウントを異なるAWS GuardDutyアカウントに招待することができ、すべてのアカウントが同じGuardDutyから監視されます。マスターアカウントがメンバーアカウントを招待し、メンバーアカウントの代表者が招待を受け入れる必要があります。
Via Organization
組織内の任意のアカウントをGuardDutyの委任管理者として指定できます。委任管理者を指定できるのは、組織の管理アカウントのみです。
委任管理者として指定されたアカウントは、GuardDuty管理者アカウントとなり、指定されたAWSリージョンでGuardDutyが自動的に有効になり、そのリージョン内の組織内のすべてのアカウントに対してGuardDutyを有効にし、管理する権限を持ちます。組織内の他のアカウントは、この委任管理者アカウントに関連付けられたGuardDutyメンバーアカウントとして表示および追加できます。
Enumeration
# Get Org config
aws guardduty list-organization-admin-accounts #Get Delegated Administrator
aws guardduty describe-organization-configuration --detector-id <id>
# Check external invitations
aws guardduty list-invitations
aws guardduty get-invitations-count
# Detector Information
aws guardduty list-detectors # 1 detector per account with GuardDuty
aws guardduty get-detector --detector-id <id> # Get detector info
aws guardduty get-master-account --detector-id <id>
# Get filters
aws guardduty list-filters --detector-id <id> # Check filters
aws guardduty get-filter --detector-id <id> --filter-name <name>
# Findings
aws guardduty list-findings --detector-id <id> # List findings
aws guardduty get-findings --detector-id <id> --finding-ids <id> # Get details about the finding
aws guardduty get-findings-statistics --detector-id <id> --finding-statistic-types <types>
# Get trusted IP addresses
aws guardduty list-ip-sets --detector-id <id>
aws guardduty get-ip-set --detector-id <id>
# Member accounts of the current AWS GuardDuty master account
aws guardduty list-members --detector-id <id>
aws guardduty get-members --detector-id <id> --account-ids <id>
aws guardduty get-member-detectors --detector-id <id> --account-ids <id>
# Continuously export its findings to an Amazon S3 bucket
aws guardduty list-publishing-destinations --detector-id <id>
# Intelligence sets that you have uploaded to GuardDuty
aws guardduty list-threat-intel-sets --detector-id <id>
aws guardduty get-threat-intel-set --detector-id <id> --threat-intel-set-id <id>
GuardDuty バイパス
一般的なガイダンス
使用する資格情報の動作についてできるだけ多くの情報を収集してください:
- 使用される時間
- 場所
- ユーザーエージェント / サービス(awscli、webconsole、lambda などから使用される可能性があります)
- 定期的に使用される権限
この情報をもとに、アクセスを使用するためにできるだけ同じシナリオを再現してください:
- ユーザーによってアクセスされるユーザーまたはロールの場合、同じ時間帯、同じ地理的位置(可能であれば同じISPとIPから)で使用してください
- サービスによって使用されるロールの場合、同じリージョンに同じサービスを作成し、同じ時間範囲でそこから使用してください
- このプリンシパルが使用した同じ権限を常に使用するようにしてください
- 他の権限を使用する必要がある場合や権限を悪用する必要がある場合(例えば、1,000,000のcloudtrailログファイルをダウンロードするなど)、ゆっくり行い、AWSとの最小限のインタラクションで行ってください(awscliは時々、書き込みの前に複数の読み取りAPIを呼び出します)
GuardDutyの破壊
guardduty:UpdateDetector
この権限を使用すると、アラートをトリガーしないようにGuardDutyを無効にすることができます。
aws guardduty update-detector --detector-id <detector-id> --no-enable
aws guardduty update-detector --detector-id <detector-id> --data-sources S3Logs={Enable=false}
guardduty:CreateFilter
この権限を持つ攻撃者は、発見の自動アーカイブのためのフィルターを使用する能力があります:
aws guardduty create-filter --detector-id <detector-id> --name <filter-name> --finding-criteria file:///tmp/criteria.json --action ARCHIVE
iam:PutRolePolicy
, (guardduty:CreateIPSet
|guardduty:UpdateIPSet
)
以前の権限を持つ攻撃者は、GuardDutyの信頼されたIPリストを変更し、自分のIPアドレスを追加することでアラートの生成を回避することができます。
aws guardduty update-ip-set --detector-id <detector-id> --activate --ip-set-id <ip-set-id> --location https://some-bucket.s3-eu-west-1.amazonaws.com/attacker.csv
guardduty:DeletePublishingDestination
攻撃者はアラートを防ぐために宛先を削除する可能性があります:
aws guardduty delete-publishing-destination --detector-id <detector-id> --destination-id <dest-id>
caution
この公開先を削除しても、GuardDutyコンソール内の発見の生成や可視性には影響しません。GuardDutyは引き続き、AWS環境内のイベントを分析し、疑わしいまたは予期しない動作を特定し、発見を生成します。
特定の発見バイパスの例
GuardDutyの発見は数十種類ありますが、Red Teamerとしてはすべてがあなたに影響を与えるわけではありません。さらに良いことに、各発見の完全なドキュメントがhttps://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.htmlにあるので、行動を起こす前に確認して捕まらないようにしてください。
ここに特定のGuardDuty発見のバイパスの例がいくつかあります:
PenTest:IAMUser/KaliLinux
GuardDutyは一般的なペネトレーションテストツールからのAWS APIリクエストを検出し、PenTest Findingをトリガーします。
これはAPIリクエストに渡されるユーザーエージェント名によって検出されます。
したがって、ユーザーエージェントを変更することでGuardDutyが攻撃を検出するのを防ぐことが可能です。
これを防ぐためには、botocore
パッケージ内のsession.py
スクリプトを検索してユーザーエージェントを変更するか、Burp SuiteをAWS CLIプロキシとして設定し、MitMでユーザーエージェントを変更するか、またはUbuntu、Mac、WindowsのようなOSを使用することでこのアラートのトリガーを防ぐことができます。
UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration
EC2のメタデータサービスからEC2の資格情報を抽出し、AWS環境外で利用すると、UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS
アラートが発動します。逆に、これらの資格情報をEC2インスタンスから使用すると、UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.InsideAWS
アラートがトリガーされます。しかし、同じアカウント内の別の侵害されたEC2インスタンスで資格情報を使用すると、検出されず、アラートは発生しません。
tip
したがって、見つけたマシンの内部から抽出された資格情報を使用することで、このアラートをトリガーしないようにしてください。
参考文献
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.html
- https://docs.aws.amazon.com/guardduty/latest/ug/findings_suppression-rule.html
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_upload-lists.html
- https://docs.aws.amazon.com/cli/latest/reference/guardduty/delete-publishing-destination.html
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-ec2.html#unauthorizedaccess-ec2-torclient
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-iam.html#unauthorizedaccess-iam-instancecredentialexfiltrationoutsideaws
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-iam.html#unauthorizedaccess-iam-instancecredentialexfiltrationinsideaws
- https://docs.aws.amazon.com/whitepapers/latest/aws-privatelink/what-are-vpc-endpoints.html
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をサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。