Best practices for leveraging Microsoft 365 Defender API's - Episode One

Published Jan 27 2021 12:12 PM 5,345 Views
Microsoft

We are strong supporters of automation, and fully acknowledge the value of automating repetitive actions and being able to adjust technology to the specific security practices and processes used by our customers and partners. This is what motivates us in developing and enriching our API layer. But as we all know, with great scale comes great responsibility, and here efficiency is the name of the game 

 

This blog series will provide you best practices and recommendations on how to best use the different Microsoft 365 Defender features and APIs, in the most efficient way to power your automation to achieve the outcome you desire. 

 

In this first blog we will focus on two aspects: 

  • Don’t automatically default to the Advanced hunting API 
  • If you do need to use the Advanced hunting API for your scenario, how to use it in the most optimal way.

 

When to use the Advanced hunting API and when to use other APIs / features?  

The Advanced hunting API is a very robust capability that enables retrieving raw data from all Microsoft 365 Defender products (covering endpoints, identities, applications docs and email), and can also be leveraged to generate statistics on entities, translating identifierse.g. to which machine IP X.X.X.X belongs to. While this is a great feature with broad reach across your data, it can also be challenging to maintain, because;

 

  • More team members need to know the internals of KQL to leverage itand; 
  • Consuming the hunting resource pool where there is no real need for that  

Below are a few examples of how we have developed a dedicated API to provide you with the intended answer in a single API call: 

 

1.   You have a 3rd party alert on an IP address. You would like to see which device this IP was assigned to at that time and to get more information on this device. Easy ! You can do it by :

a.   Using Find devices by internal IP API  - Find devices seen with the requested internal IP in the time range of 15 minutes prior and after a given timestamp.  It will return details on the device including its OS Platform, MDE groups, tags, and exposure level. 

 

2.   You have a malicious domain IOC and you would like to see its prevalence in your organization.

Easy! You can use Get domain statistics API for that, it retrieves the organization statistics on the given domain for the lookback time you configured, by default the last 30 days, based on Microsoft Defender for Endpoint (MDE) including: 

a.   Prevalence

b.   First seen

c.   Last seen

For example: https://api.securitycenter.microsoft.com/api/domains/microsoft.com/stats?lookBackHours=24

 

3.   You have a list of IOCs, and you would like to make sure you are alerted if there is any activity associated with this URL in your organization.

To implement this scenario you can use Indicators:

a.   Add IOCs to MDE indicators via Indicators API and set the required action (“Alert” or “Alert and Block”).

b.   To check if any of the IOCs was observed in the organization in the last 30 days, you can run a single Advanced hunting query:

 

// See if any process created a file matching a hash on the list 
let covidIndicators = (externaldata(TimeGenerated:datetime, FileHashValue:string, FileHashType: string )
[@"https://raw.githubusercontent.com/Azure/Azure-Sentinel/master/Sample%20Data/Feeds/Microsoft.Covid19.Indicators.csv"]
with (format="csv"))
| where FileHashType == 'sha256'; //and TimeGenerated > ago(1d);
covidIndicators
| join (DeviceFileEvents
| where ActionType == 'FileCreated'
| take 100) on $left.FileHashValue  == $right.SHA256

 

How to optimize your Advanced hunting queries

Once you determine that the only way to resolve your scenario is using Advanced hunting queries, you should write efficient optimized queries so your queries will execute faster and will consume less resources. Queries may be throttled or limited based on how they're written, to limit impact to other sessions. You can read all our best practices recommendations, and also watch this webcast to learn more. In this section we will highlight a few recommendations to improve query performance.

 

  1. Always use time filters as your first query condition. Most of the time you will use Advanced hunting to get more information on an entity following an incident, so make sure to insert the time of the incident, and narrow your lookback time. The shorter the lookback time is, the faster the query will be executed.

  There are multiple ways to insert time filters to your query.

  Scenario example – get all logon activities of the Finance departments users in Office 365.

 

// Filter timestamp in the query using “ago”
IdentityInfo
| where Department == "Finance"
| distinct AccountObjectId
| join (IdentityLogonEvents | where Timestamp > ago(10d)) on AccountObjectId
| where Application == "Office 365"
// Filter timestamp in the query using “between”
let selectedTimestamp = datetime(2020-11-12T19:35:03.9859771Z);
IdentityInfo
| where Department == "Finance"
| distinct AccountObjectId
| join (IdentityLogonEvents | where Timestamp between ((selectedTimestamp - 2h) .. (selectedTimestamp + 2h))) on AccountObjectId
| where Application == "Office 365"

  In general, always filter your query by adding Where conditions, so it will be accurate and will query for the exact data you are looking for.

 

2.   Only use “join” when it is necessary for your scenario.

a.   If you are using a join, try to reduce the dataset before joining to limit the join size. Filter the table on the left side, to reduce its size as much as you can.

b.   Use an accurate key for the join.

c.   Choose the join flavor(kind) according to your scenario.

 

  In the following example we want to see all details of emails and their attachments.

 

  The following example is an inefficient query, because:

a.   EmailEvents table is the largest table, it should never be on the left side of the join, without substantial filtering on it.

b.   Join kind=leftouter returns all emails, including ones without attachments, which make the result set very large. We don’t need to see emails without attachments therefore this kind of join is not the right kind for this scenario.

c.   The Key of the join is not accurate , NetworkMessageId. This is an email identifier, but the same email can be set to multiple recipients.

 

EmailEvents
| project NetworkMessageId, Subject, Timestamp, SenderFromAddress , SenderIPv4 , RecipientEmailAddress , AttachmentCount
| join kind=leftouter(EmailAttachmentInfo
| project NetworkMessageId,FileName, FileType, MalwareFilterVerdict, SHA256, RecipientEmailAddress )
on NetworkMessageId

 

  This query should be changed and improved to the following query by:

a.   Putting the smaller table, EmailAttachmentInfo, on the left.

b.   Increasing join accuracy using join kind=inner

c.   Using an accurate key for the join (NetworkMessageId, RecipientEmailAddress)

d.   Filtering the EmailEvents table to only include emails with attachments before the join.

 

// Smaller table on the left side, with kind = inner, as default join (innerunique)
// will remove left side duplications, so if a single email has more than one attachments we will miss it
EmailAttachmentInfo
| project NetworkMessageId, FileName, FileType, MalwareFilterVerdict, SHA256, RecipientEmailAddress
| join kind=inner
(EmailEvents
| where AttachmentCount > 0
|project NetworkMessageId, Subject, Timestamp, SenderFromAddress , SenderIPv4 , RecipientEmailAddress , AttachmentCount)
on NetworkMessageId, RecipientEmailAddress

 

 3.   When you want to search for an attribute/entity in multiple tables, use the search in operator instead of using union. For example, if you want to search for list of Urls, use the following query:

 

let ListOfIoc = dynamic(["t20saudiarabia@outlook.sa", "t20saudiarabia@hotmail.com", "t20saudiarabia@gmail.com", "munichconference@outlook.com",
"munichconference@outlook.de", "munichconference1962@gmail.com", "ctldl.windowsupdate.com"]);
search in (DeviceNetworkEvents, DeviceFileEvents, DeviceEvents, EmailUrlInfo )
Timestamp > ago(1d) and
RemoteUrl in (ListOfIoc) or FileOriginUrl in (ListOfIoc) or FileOriginReferrerUrl in (ListOfIoc)

 

4.   Using “Has” is better than “contains”: When looking for full tokens, “has” is more efficient,

      since it doesn't look for substrings.

 

     Instead of using “contains”:

DeviceNetworkEvents
| where RemoteUrl contains "microsoft.com"
| take 50

            Use “has”:

DeviceNetworkEvents
| where RemoteUrl has "microsoft.com"
| take 50

     If possible, Use case-sensitive operators

DeviceNetworkEvents
| where RemoteUrl has_cs "microsoft.com"
| take 50

 

For more information about Advanced hunting and the features discussed in this article, read:

 

As always, we’d love to know what you think. Leave us feedback directly on Microsoft 365 security center or start a discussion in Microsoft 365 Defender community.

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2102893%22%20slang%3D%22en-US%22%3EBest%20practices%20for%20leveraging%20Microsoft%20365%20Defender%20API's%20-%20Episode%20One%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102893%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWe%20are%20strong%20supporters%20of%20automation%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efully%20acknowledg%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ee%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Evalue%20of%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bautomating%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Erepetitive%20actions%20and%20be%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eing%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bable%20to%20adjust%20technology%20to%20the%20specific%20security%20practices%20and%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eprocesses%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eused%20by%20our%20customers%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%20partners%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20This%20is%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewhat%20motivates%20us%20in%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edeveloping%20and%20enriching%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eour%20API%20layer.%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EBut%20as%20we%20all%20know%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewith%20great%20scale%20comes%20great%20responsibility%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%20here%20efficiency%20is%20the%20name%20of%20the%20game%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETh%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eis%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eblog%20series%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewill%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eprovide%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Byou%20best%20practices%20and%20recommendations%20on%20how%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ebest%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Euse%20the%20different%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMicrosoft%20365%20Defender%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efeature%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Es%20and%20APIs%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%20in%20the%20most%20efficient%20way%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Epower%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eyour%20automation%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%20achiev%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ee%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthe%20outcome%20you%20%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edesire%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIn%20this%20first%20blog%20we%20will%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efocus%20on%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Etwo%20aspects%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EDon%E2%80%99t%20automatically%20default%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAdvanced%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehunting%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAPI%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EI%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ef%20you%20do%20need%20to%20use%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAdvanced%20hunting%20API%20for%20you%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Er%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bscenario%2C%20how%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Buse%20it%20in%20the%20most%20optim%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eal%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bway.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1969121748%22%20id%3D%22toc-hId-1969121748%22%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3EWhen%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3Eto%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3E%26nbsp%3Buse%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3Ethe%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3EAdvanced%20hunting%20API%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3Eand%20when%20to%20use%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW186190282%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW186190282%20BCX8%22%20data-ccp-parastyle%3D%22heading%202%22%3Eother%20APIs%20%2F%20features%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22EOP%20SCXW186190282%20BCX8%22%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAdvanced%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eh%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eunting%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3BAPI%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eis%20a%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Every%20robust%20capability%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthat%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eenabl%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ees%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eretriev%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eing%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Braw%20data%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efrom%20all%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMicrosoft%20365%20Defender%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bproducts%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ecovering%20endpoints%2C%20identities%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eapplications%20docs%20and%20email)%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%20and%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ecan%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ealso%20be%20leveraged%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Egenerat%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ee%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bstatistics%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eon%20entities%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Etranslating%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bidentifiers%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ee.g.%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bto%20which%20machine%20IP%20X.X.X.X%20belongs%20to%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWhile%20this%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eis%20a%20great%20featu%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ere%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bwith%20broad%20re%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Each%20across%20your%20data%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eit%20can%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ealso%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ebe%20challenging%20to%20maintain%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ebecause%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EM%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eore%20team%20members%20need%20to%20know%20the%20internal%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Es%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bof%20KQL%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bto%20leverage%20it%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EC%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eonsuming%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%20hunting%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eresource%20pool%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewhere%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethere%20is%20no%20real%20need%20for%20that%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EBelow%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eare%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Ba%20few%20examples%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eof%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehow%20we%20have%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edeveloped%20a%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ededicated%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3BAPI%20to%20provide%20you%20with%20the%20intended%20answer%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ein%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ea%20single%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3BAPI%20call%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E1.%26nbsp%3B%20%26nbsp%3BYou%20have%20a%203%3CSUP%3Erd%3C%2FSUP%3E%20party%20alert%20on%20an%20IP%20address.%20You%20would%20like%20to%20see%20which%20device%20this%20IP%20was%20assigned%20to%20at%20that%20time%20and%20to%20get%20more%20information%20on%20this%20device.%20Easy%20!%20You%20can%20do%20it%20by%20%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ea.%26nbsp%3B%20%26nbsp%3B%3CSPAN%20class%3D%22TrackChangeTextInsertion%20TrackedChange%20SCXW190255819%20BCX8%22%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3EU%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3Esing%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CA%20class%3D%22Hyperlink%20SCXW190255819%20BCX8%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fsecurity%2Fthreat-protection%2Fmicrosoft-defender-atp%2Ffind-machines-by-ip%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%22%3E%3CSPAN%20class%3D%22TextRun%20Underlined%20SCXW190255819%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%20data-ccp-charstyle%3D%22Hyperlink%22%3EFind%20devices%20by%20internal%20IP%20API%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E%26nbsp%3B-%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3EFind%E2%80%AF%3C%2FSPAN%3E%3C%2FSPAN%3E%3CA%20class%3D%22Hyperlink%20SCXW190255819%20BCX8%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fsecurity%2Fthreat-protection%2Fmicrosoft-defender-atp%2Fmachine%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%22%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3Edevices%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E%E2%80%AFseen%20with%20the%20requested%20internal%20IP%20in%20the%20time%20range%20of%2015%20minutes%20prior%20and%20after%20a%20given%20timestamp.%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TrackChangeTextInsertion%20TrackedChange%20SCXW190255819%20BCX8%22%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3EIt%20will%20return%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TrackChangeTextInsertion%20TrackedChange%20SCXW190255819%20BCX8%22%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3Edetails%20on%20the%20device%20including%20its%20OS%20Platform%2C%20MDE%20groups%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E%2C%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Etags%2C%20and%20exposure%20level%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW190255819%20BCX8%22%20data-contrast%3D%22none%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW190255819%20BCX8%22%3E.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22EOP%20TrackedChange%20SCXW190255819%20BCX8%22%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E2.%26nbsp%3B%20%26nbsp%3BYou%20have%20a%20malicious%20domain%20IOC%20and%20you%20would%20like%20to%20see%20its%20prevalence%20in%20your%20organization.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EEasy!%20You%20can%20use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fsecurity%2Fthreat-protection%2Fmicrosoft-defender-atp%2Fget-domain-statistics%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGet%20domain%20statistics%20API%20for%3C%2FA%3E%20that%2C%20it%20retrieves%20the%20organization%20statistics%20on%20the%20given%20domain%20for%20the%20lookback%20time%20you%20configured%2C%20by%20default%20the%20last%2030%20days%2C%20based%20on%20Microsoft%20Defender%20for%20Endpoint%20(MDE)%20including%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ea.%26nbsp%3B%20%26nbsp%3BPrevalence%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Eb.%26nbsp%3B%20%26nbsp%3BFirst%20seen%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ec.%26nbsp%3B%20%26nbsp%3BLast%20seen%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EFor%20example%3A%20%3CA%20href%3D%22https%3A%2F%2Fapi.securitycenter.microsoft.com%2Fapi%2Fdomains%2Fmicrosoft.com%2Fstats%3FlookBackHours%3D24%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fapi.securitycenter.microsoft.com%2Fapi%2Fdomains%2Fmicrosoft.com%2Fstats%3FlookBackHours%3D24%3C%2FA%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E3.%26nbsp%3B%20%26nbsp%3BYou%20have%20a%20list%20of%20IOCs%2C%20and%20you%20would%20like%20to%20make%20sure%20you%20are%20alerted%20if%20there%20is%20any%20activity%20associated%20with%20this%20URL%20in%20your%20organization.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3ETo%20implement%20this%20scenario%20you%20can%20use%20Indicators%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ea.%26nbsp%3B%20%26nbsp%3BAdd%20IOCs%20to%20MDE%20indicators%20via%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fsecurity%2Fthreat-protection%2Fmicrosoft-defender-atp%2Fpost-ti-indicator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EIndicators%20API%3C%2FA%3E%20and%20set%20the%20required%20action%20(%E2%80%9CAlert%E2%80%9D%20or%20%E2%80%9CAlert%20and%20Block%E2%80%9D).%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Eb.%26nbsp%3B%20%26nbsp%3BTo%20check%20if%20any%20of%20the%20IOCs%20was%20observed%20in%20the%20organization%20in%20the%20last%2030%20days%2C%20you%20can%20run%20a%20%3CU%3Esingle%3C%2FU%3E%20Advanced%20hunting%20query%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-60px%22%3E%2F%2F%20See%20if%20any%20process%20created%20a%20file%20matching%20a%20hash%20on%20the%20list%20%3CBR%20%2F%3Elet%20covidIndicators%20%3D%20(externaldata(TimeGenerated%3Adatetime%2C%20FileHashValue%3Astring%2C%20FileHashType%3A%20string%20)%3CBR%20%2F%3E%5B%40%22https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FSample%2520Data%2FFeeds%2FMicrosoft.Covid19.Indicators.csv%22%5D%3CBR%20%2F%3Ewith%20(format%3D%22csv%22))%3CBR%20%2F%3E%7C%20where%20FileHashType%20%3D%3D%20'sha256'%3B%20%2F%2Fand%20TimeGenerated%20%26gt%3B%20ago(1d)%3B%3CBR%20%2F%3EcovidIndicators%3CBR%20%2F%3E%7C%20join%20(DeviceFileEvents%3CBR%20%2F%3E%7C%20where%20ActionType%20%3D%3D%20'FileCreated'%3CBR%20%2F%3E%7C%20take%20100)%20on%20%24left.FileHashValue%26nbsp%3B%20%3D%3D%20%24right.SHA256%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1958618644%22%20id%3D%22toc-hId-1958618644%22%3EHow%20to%20optimize%20your%20Advanced%20hunting%20queries%3C%2FH2%3E%0A%3CP%3EOnce%20you%20determine%20that%20the%20only%20way%20to%20resolve%20your%20scenario%20is%20using%20Advanced%20hunting%20queries%2C%20you%20should%20write%20efficient%20optimized%20queries%20so%20your%20queries%20will%20execute%20faster%20and%20will%20consume%20less%20resources.%20Queries%20may%20be%20throttled%20or%20limited%20based%20on%20how%20they're%20written%2C%20to%20limit%20impact%20to%20other%20sessions.%20You%20can%20read%20all%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fsecurity%2Fmtp%2Fadvanced-hunting-best-practices%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eour%20best%20practices%20recommendations%3C%2FA%3E%2C%20and%20also%20watch%20this%20%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnMGbK-ALaVg%26amp%3Bfeature%3Dyoutu.be%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewebcast%3C%2FA%3E%3CSPAN%3E%20to%20learn%20more%3C%2FSPAN%3E.%20In%20this%20section%20we%20will%20highlight%20a%20few%20recommendations%20to%20improve%20query%20performance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3EAlways%20use%20time%20filters%20%3C%2FSTRONG%3Eas%20your%20first%20query%20condition.%20Most%20of%20the%20time%20you%20will%20use%20Advanced%20hunting%20to%20get%20more%20information%20on%20an%20entity%20following%20an%20incident%2C%20so%20make%20sure%20to%20insert%20the%20time%20of%20the%20incident%2C%20and%20narrow%20your%20lookback%20time.%20The%20shorter%20the%20lookback%20time%20is%2C%20the%20faster%20the%20query%20will%20be%20executed.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20There%20are%20multiple%20ways%20to%20insert%20time%20filters%20to%20your%20query.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20Scenario%20example%20%E2%80%93%20get%20all%20logon%20activities%20of%20the%20Finance%20departments%20users%20in%20Office%20365.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-30px%22%3E%2F%2F%20Filter%20timestamp%20in%20the%20query%20using%20%E2%80%9Cago%E2%80%9D%3CBR%20%2F%3EIdentityInfo%3CBR%20%2F%3E%7C%20where%20Department%20%3D%3D%20%22Finance%22%3CBR%20%2F%3E%7C%20distinct%20AccountObjectId%3CBR%20%2F%3E%7C%20join%20(IdentityLogonEvents%20%7C%20where%20Timestamp%20%26gt%3B%20ago(10d))%20on%20AccountObjectId%3CBR%20%2F%3E%7C%20where%20Application%20%3D%3D%20%22Office%20365%22%3C%2FPRE%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-30px%22%3E%2F%2F%20Filter%20timestamp%20in%20the%20query%20using%20%E2%80%9Cbetween%E2%80%9D%3CBR%20%2F%3Elet%20selectedTimestamp%20%3D%20datetime(2020-11-12T19%3A35%3A03.9859771Z)%3B%3CBR%20%2F%3EIdentityInfo%3CBR%20%2F%3E%7C%20where%20Department%20%3D%3D%20%22Finance%22%3CBR%20%2F%3E%7C%20distinct%20AccountObjectId%3CBR%20%2F%3E%7C%20join%20(IdentityLogonEvents%20%7C%20where%20Timestamp%20between%20((selectedTimestamp%20-%202h)%20..%20(selectedTimestamp%20%2B%202h)))%20on%20AccountObjectId%3CBR%20%2F%3E%7C%20where%20Application%20%3D%3D%20%22Office%20365%22%3C%2FPRE%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20In%20general%2C%20always%20filter%20your%20query%20by%20adding%20%3CSTRONG%3EWhere%3C%2FSTRONG%3E%20conditions%2C%20so%20it%20will%20be%20accurate%20and%20will%20query%20for%20the%20exact%20data%20you%20are%20looking%20for.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E2.%26nbsp%3B%20%26nbsp%3BOnly%20use%20%E2%80%9Cjoin%E2%80%9D%20when%20it%20is%20%3CU%3Enecessary%3C%2FU%3E%20for%20your%20scenario.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ea.%26nbsp%3B%20%26nbsp%3BIf%20you%20are%20using%20a%20join%2C%20try%20to%20%3CSTRONG%3Ereduce%20the%20dataset%20before%20joining%3C%2FSTRONG%3E%20to%20limit%20the%20join%20size.%20%3CSTRONG%3EFilter%3C%2FSTRONG%3E%20%3CSTRONG%3Ethe%20table%20on%20the%20left%20side%3C%2FSTRONG%3E%2C%20to%20reduce%20its%20size%20as%20much%20as%20you%20can.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Eb.%26nbsp%3B%20%26nbsp%3B%3CSTRONG%3EUse%20an%20accurate%20key%3C%2FSTRONG%3E%20for%20the%20join.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ec.%26nbsp%3B%20%26nbsp%3BChoose%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fjoinoperator%3Fpivots%3Dazuredataexplorer%23join-flavors%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethe%20join%20flavor(kind)%3C%2FA%3E%20according%20to%20your%20scenario.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20In%20the%20following%20example%20we%20want%20to%20see%20all%20details%20of%20emails%20and%20their%20attachments.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20The%20following%20example%20is%20an%20inefficient%20query%2C%20because%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ea.%26nbsp%3B%20%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3EEmailEvents%3C%2FFONT%3E%20table%20is%20the%20largest%20table%2C%20it%20should%20never%20be%20on%20the%20left%20side%20of%20the%20join%2C%20without%20substantial%20filtering%20on%20it.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Eb.%26nbsp%3B%20%26nbsp%3B%3CFONT%20color%3D%22%233366FF%22%3EJoin%20kind%3Dleftouter%3C%2FFONT%3E%20returns%20all%20emails%2C%20including%20ones%20without%20attachments%2C%20which%20make%20the%20result%20set%20very%20large.%20We%20don%E2%80%99t%20need%20to%20see%20emails%20without%20attachments%20therefore%20this%20kind%20of%20join%20is%20not%20the%20right%20kind%20for%20this%20scenario.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ec.%26nbsp%3B%20%26nbsp%3BThe%20Key%20of%20the%20join%20is%20not%20accurate%20%2C%20NetworkMessageId.%20This%20is%20an%20email%20identifier%2C%20but%20the%20same%20email%20can%20be%20set%20to%20multiple%20recipients.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-60px%22%3E%3CFONT%20color%3D%22%23FF0000%22%3EEmailEvents%3C%2FFONT%3E%3CBR%20%2F%3E%7C%20project%20NetworkMessageId%2C%20Subject%2C%20Timestamp%2C%20SenderFromAddress%20%2C%20SenderIPv4%20%2C%20RecipientEmailAddress%20%2C%20AttachmentCount%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%233366FF%22%3Ejoin%20kind%3Dleftouter%3C%2FFONT%3E(EmailAttachmentInfo%3CBR%20%2F%3E%7C%20project%20NetworkMessageId%2CFileName%2C%20FileType%2C%20MalwareFilterVerdict%2C%20SHA256%2C%20RecipientEmailAddress%20)%3CBR%20%2F%3Eon%20NetworkMessageId%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20This%20query%20should%20be%20changed%20and%20improved%20to%20the%20following%20query%20by%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ea.%26nbsp%3B%20%26nbsp%3BPutting%20the%20smaller%20table%2C%20EmailAttachmentInfo%2C%20on%20the%20left.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Eb.%26nbsp%3B%20%26nbsp%3BIncreasing%20join%20accuracy%20using%20join%20kind%3Dinner%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ec.%26nbsp%3B%20%26nbsp%3BUsing%20an%20accurate%20key%20for%20the%20join%20(NetworkMessageId%2C%20RecipientEmailAddress)%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3Ed.%26nbsp%3B%20%26nbsp%3BFiltering%20the%20EmailEvents%20table%20to%20only%20include%20emails%20with%20attachments%20before%20the%20join.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-60px%22%3E%2F%2F%20Smaller%20table%20on%20the%20left%20side%2C%20with%20kind%20%3D%20inner%2C%20as%20default%20join%20(innerunique)%3CBR%20%2F%3E%2F%2F%20will%20remove%20left%20side%20duplications%2C%20so%20if%20a%20single%20email%20has%20more%20than%20one%20attachments%20we%20will%20miss%20it%3CBR%20%2F%3EEmailAttachmentInfo%3CBR%20%2F%3E%7C%20project%20NetworkMessageId%2C%20FileName%2C%20FileType%2C%20MalwareFilterVerdict%2C%20SHA256%2C%20RecipientEmailAddress%3CBR%20%2F%3E%7C%20join%20kind%3Dinner%3CBR%20%2F%3E(EmailEvents%3CBR%20%2F%3E%7C%20where%20AttachmentCount%20%26gt%3B%200%3CBR%20%2F%3E%7Cproject%20NetworkMessageId%2C%20Subject%2C%20Timestamp%2C%20SenderFromAddress%20%2C%20SenderIPv4%20%2C%20RecipientEmailAddress%20%2C%20AttachmentCount)%3CBR%20%2F%3Eon%20NetworkMessageId%2C%20RecipientEmailAddress%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B3.%26nbsp%3B%20%26nbsp%3BWhen%20you%20want%20to%20search%20for%20an%20attribute%2Fentity%20in%20multiple%20tables%2C%20use%20the%20%3CSTRONG%3Esearch%20in%3C%2FSTRONG%3E%20operator%20instead%20of%20using%20union.%20For%20example%2C%20if%20you%20want%20to%20search%20for%20list%20of%20Urls%2C%20use%20the%20following%20query%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-30px%22%3Elet%20ListOfIoc%20%3D%20dynamic(%5B%22t20saudiarabia%40outlook.sa%22%2C%20%22t20saudiarabia%40hotmail.com%22%2C%20%22t20saudiarabia%40gmail.com%22%2C%20%22munichconference%40outlook.com%22%2C%3CBR%20%2F%3E%22munichconference%40outlook.de%22%2C%20%22munichconference1962%40gmail.com%22%2C%20%22ctldl.windowsupdate.com%22%5D)%3B%3CBR%20%2F%3Esearch%20in%20(DeviceNetworkEvents%2C%20DeviceFileEvents%2C%20DeviceEvents%2C%20EmailUrlInfo%20)%3CBR%20%2F%3ETimestamp%20%26gt%3B%20ago(1d)%20and%3CBR%20%2F%3ERemoteUrl%20in%20(ListOfIoc)%20or%20FileOriginUrl%20in%20(ListOfIoc)%20or%20FileOriginReferrerUrl%20in%20(ListOfIoc)%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E4.%26nbsp%3B%20%26nbsp%3B%3CSTRONG%3EUsing%20%E2%80%9CHas%E2%80%9D%20is%20better%20than%20%E2%80%9Ccontains%E2%80%9D%3C%2FSTRONG%3E%3A%20When%20looking%20for%20full%20tokens%2C%20%E2%80%9Chas%E2%80%9D%20is%20more%20efficient%2C%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20since%20it%20doesn't%20look%20for%20substrings.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BInstead%20of%20using%20%E2%80%9Ccontains%E2%80%9D%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-60px%22%3EDeviceNetworkEvents%3CBR%20%2F%3E%7C%20where%20RemoteUrl%20contains%20%22microsoft.com%22%3CBR%20%2F%3E%7C%20take%2050%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Use%20%E2%80%9Chas%E2%80%9D%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-60px%22%3EDeviceNetworkEvents%3CBR%20%2F%3E%7C%20where%20RemoteUrl%20has%20%22microsoft.com%22%3CBR%20%2F%3E%7C%20take%2050%3C%2FPRE%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BIf%20possible%2C%20%3CSTRONG%3EUse%20case-sensitive%20operators%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-indent-padding-left-60px%22%3EDeviceNetworkEvents%3CBR%20%2F%3E%7C%20where%20RemoteUrl%20has_cs%20%22microsoft.com%22%3CBR%20%2F%3E%7C%20take%2050%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20more%20information%20about%20Advanced%20hunting%20and%20the%20features%20discussed%20in%20this%20article%2C%20read%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fsecurity%2Fmtp%2Fadvanced-hunting-overview%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAdvanced%20hunting%20overview%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fsecurity%2Fmtp%2Fadvanced-hunting-best-practices%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAdvanced%20hunting%20best%20practices%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fsecurity%2Fmtp%2Fapi-advanced-hunting%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAdvanced%20hunting%20APIs%20-%20Microsoft%20365%20security%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fsecurity%2Fmtp%2Fadvanced-hunting-limits%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAdvanced%20hunting%20quota%20and%20resources%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fsecurity%2Fmtp%2Fapi-overview%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20365%20Defender%20APIs%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fsecurity%2Fthreat-protection%2Fmicrosoft-defender-atp%2Fmanagement-apis%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Defender%20for%20Endpoint%20APIs%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20always%2C%20we%E2%80%99d%20love%20to%20know%20what%20you%20think.%20Leave%20us%20feedback%20directly%20on%20Microsoft%20365%20security%20center%20or%20start%20a%20discussion%20in%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-365-defender%2Fbd-p%2FMicrosoftThreatProtection%22%20target%3D%22_blank%22%3EMicrosoft%20365%20Defender%20community.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2102893%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWe%20are%20strong%20supporters%20of%20automation%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efully%20acknowledg%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ee%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Evalue%20of%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bautomating%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Erepetitive%20actions%20and%20be%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eing%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bable%20to%20adjust%20technology%20to%20the%20specific%20security%20practices%20and%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eprocesses%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eused%20by%20our%20customers%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%20partners%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20This%20is%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewhat%20motivates%20us%20in%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edeveloping%20and%20enriching%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eour%20API%20layer.%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EBut%20as%20we%20all%20know%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewith%20great%20scale%20comes%20great%20responsibility%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%20here%20efficiency%20is%20the%20name%20of%20the%20game%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎Jan 28 2021 02:37 AM
Updated by:
www.000webhost.com