Skip to content

Instantly share code, notes, and snippets.

@dxflatline
Last active January 18, 2024 15:59
Show Gist options
  • Save dxflatline/acde39ab675e19220f3773a896eb6e9b to your computer and use it in GitHub Desktop.
Save dxflatline/acde39ab675e19220f3773a896eb6e9b to your computer and use it in GitHub Desktop.
Descriptor:
Name: EmailHuntingCustomKQL
DisplayName: Defender KQL for email discovery
Description: Skills to query email logs in M365 Advanced Hunting
SkillGroups:
- Format: KQL
Skills:
- Name: GetLatestEmailsByRecipientSender
DisplayName: Get Latest Emails By Recipient or Sender
Description: Fetches the latest emails received or send by the user with the specified email address
Inputs:
- Name: email
Description: The email address of the recipient or sender
Required: true
Settings:
Target: Defender
Template: |-
EmailEvents
| where RecipientEmailAddress =~ '{{email}}' or SenderMailFromAddress =~ '{{email}}'
| project Timestamp, NetworkMessageId, SenderFromAddress, SenderDisplayName, Subject, DeliveryLocation
| top 100 by Timestamp desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment