Microsoft Sentinel に取り込んだ AWS CloudTrail ログを検索してみた

2023.11.25

Microsoft Sentinel に取り込んだ AWS CloudTrail を検索するクエリをいくつか試したため、自信の備忘録も兼ねてブログにします。下記ブログと同様の手順で取り込んだ AWS CloudTrail ログを検索してみます。

AWS CloudTrail ログを検索

Microsoft Setinel のデータコネクタで AWS CloudTrail に関する宛先テーブルはAWSCloudTrialを指定しています。 AWSCloudTrailのテーブル情報は次のドキュメントに記載されています。この情報を参考にクエリを検討します。

Azure Monitor ログ リファレンス - AWSCloudTrail | Microsoft Learn


Microsoft Sentinel の「ログ」メニューからクエリが実行でき、クエリ実行画面からもテーブル情報を確認できます。

いくつかクエリを試してみます。なお、今回の環境は AWS CloudTrail ログを転送していた期間が 2023.11.13 までの環境となります。


始めに、最新 5 件の取得です。

AWSCloudTrail
| take 5


出力内容を指定してみます。結果のマスキング部分は AWS アカウント ID となります。

AWSCloudTrail
| project TimeGenerated, RecipientAccountId, AWSRegion, EventName, EventSource
| take 5


時間指定で検索してみます。

AWSCloudTrail
| project TimeGenerated, RecipientAccountId, AWSRegion, EventName, EventSource
| where TimeGenerated between (datetime(2023-11-12T00:00:00) .. datetime(2023-11-13T00:00:00))
| order by TimeGenerated asc
| take 5


AWS アカウントを指定し、読み取り専用ではないログの検索です。

AWSCloudTrail
| project TimeGenerated, RecipientAccountId, AWSRegion, EventName, EventSource, ReadOnly, Resources
| where RecipientAccountId == '111122223333'
| where ReadOnly == 'false'
| take 5


イベントソースとイベント名の指定です。出力にはユーザー名も追加しています。

AWSCloudTrail
| project TimeGenerated, RecipientAccountId, AWSRegion, SessionIssuerUserName, EventName, EventSource, ReadOnly, RequestParameters
| where RecipientAccountId == '111122223333'
| where EventSource == 'cloudtrail.amazonaws.com'
| where EventName  == 'StopLogging'


IAM ユーザー名/ロール名を指定した検索です。UserIdentityArn の一部に、指定した IAM ユーザー名/ロール名が含まれることを条件に検索してみました。

AWSCloudTrail
| project TimeGenerated, RecipientAccountId, AWSRegion, EventName, EventSource, UserIdentityArn
| where RecipientAccountId == '111122223333'
| where UserIdentityArn contains 'ms-sentinel-role'
| take 5


最後に、リソース名(EC2 インスタンス ID)を指定した検索です。RequestParameters または ResponseElements の中に指定したインスタンス ID が含まれることを条件として検索しています。EC2 インスタンスを作成する RunInstances イベントなどでは、RequestParameters にはインスタンス ID が含まれないこともあるため、ResponseElements も含める条件としてみました。

AWSCloudTrail
| project TimeGenerated, RecipientAccountId, AWSRegion, SessionIssuerUserName, EventName, EventSource, ReadOnly, RequestParameters, ResponseElements
| where RecipientAccountId == '111122223333'
| where EventSource == 'ec2.amazonaws.com'
| where RequestParameters contains 'i-0f87a72c26d0a9ad0' or ResponseElements contains 'i-0f87a72c26d0a9ad0'
| where ReadOnly == 'false'
| take 5

以上で AWS CloudTrail ログの検索のお試しは終わりです。

さいごに

Microsoft Sentinel に取り込んだ AWS CloudTrail ログを検索してみました。

Microsoft Sentinel でのクエリは次のトレーニングに含まれており、参考になりました。

以上、このブログがどなたかのご参考になれば幸いです。