Track changes to sensitive groups with Advanced Hunting in Microsoft 365 Defender

Published Apr 06 2022 09:00 AM 6,950 Views
Contributor

In my role working with Defender for Identity (MDI) customers, I'm often asked if MDI can help them answer questions about activities taking place within the environment. MDI does have a lot of information around the activities taking place in Active Directory and now combined with the power of Advanced Hunting in Microsoft 365 Defender, we can help customers answer some these questions with ease and efficiency.  

 

MDI tracks the changes made to Active Directory group memberships. These changes are recorded by MDI as an activity and are available in the Microsoft 365 Defender Advanced Hunting, IdentityDirectoryEvents. MDI records these changes from two different sources:

 

  1. Tracking changes made to an entity by the Active Directory Update Sequence Number (USN).  In the case of a group, MDI can see who has been added or removed from a group, but we don’t see the actor who made the change or which domain controller the change was made on.
  2. Tracking changes to a group, including who performed the action. MDI requires specific Windows events to be recorded on the domain controller.  For more information on the Windows events required by MDI, see https://docs.microsoft.com/en-us/defender-for-identity/configure-windows-event-collection.

In this blog we will show you how to build an Advanced Hunting query that captures group modification. Let’s start with a very basic script showing all the changes to a query that will show modifications to sensitive groups in your organization.

 

Step 1: Basic query that will show all group modifications.

The MDI group modification activities are in the “IdentityDirectoryEvents” table where ActionType equals “Group changed”

Here is a simple AH query you use to show you all the group changes in Active Directory.

 

 

 

 

 

IdentityDirectoryEvents 
| where Application == "Active Directory"
| where ActionType == "Group Membership changed"

 

 

 

 

 

Running this query yields the following result:

 

GersonLevitz_0-1649064568987.png

 

This shows some columns that are not relevant for the rest of our scenario, so we will use the “project” command to show only the columns of interest.

 

 

 

 

 

 

IdentityDirectoryEvents
| where Application == "Active Directory"
| where ActionType == "Group Membership changed"
| project Timestamp, ActionType, TargetAccountDisplayName, TargetAccountUpn, DestinationDeviceName, AccountName, AccountDomain, AdditionalFields

 

 

 

 

 

 

 

GersonLevitz_0-1649064708224.png

 

Step 2: Just show activities from Windows Events

As you can see there are some duplicate activities above. This is caused by MDI recording the group changes from two different sources.

  • Windows events
  • Active Directory sync changes via USN

The activities from the Windows events have more information such as which domain controller the change was initiated from and the user (actor) who performed the change. To simplify our query’s results, we want to exclude activities that are from Active Directory sync changes.

Additionally, we are going to use the “project” command again to show specific columns that are relevant here.

To include the activities from the Windows events only, run the following query:

 

 

 

 

 

 

 

IdentityDirectoryEvents
| where Application == "Active Directory"
| where ActionType == "Group Membership changed"
| where DestinationDeviceName != "" // Exclude activities coming from AD Sync changes. 
| project Timestamp, ActionType, TargetAccountDisplayName, TargetAccountUpn, DestinationDeviceName, AccountName, AccountDomain, AdditionalFields

 

 

 

 

 

 

 

GersonLevitz_1-1649064838159.png

 

Step 3: Group name and action type

The table is starting to take shape, but we are still missing some valuable pieces of information.

  • Group name that was modified
  • Whether the group change was an “Add” or a “Remove”

If you look closely, you can see a few lines that have no data for the TargetAccountDisplayName and TargetAccountUPN attributes. This is due to another group being added or removed to the queried group (group nesting).

To complete the missing data, we will be extracting it from the “AdditionalFields” column.  

 

 

 

 

 

 

 

IdentityDirectoryEvents
| where Application == "Active Directory"
| where ActionType == "Group Membership changed"
| where DestinationDeviceName != "" // Exclude activites coming AD Sync changes. 
| extend ToGroup = tostring(parse_json(AdditionalFields).["TO.GROUP"]) // Extracts the group name if action is add enity to a group.
| extend FromGroup = tostring(parse_json(AdditionalFields).["FROM.GROUP"]) // etracts the group name if action is remove entity from a group.
| extend Action = iff(isempty(ToGroup), "Remove", "Add") // calculates if the action is Remove or Add
| extend GroupModified = iff(isempty(ToGroup), FromGroup, ToGroup) // group name that the action was taken on 
| extend Target_Group = tostring(parse_json(AdditionalFields).["TARGET_OBJECT.GROUP"])
| project Timestamp, Action, GroupModified,  Target_Account = TargetAccountDisplayName, Target_UPN = TargetAccountUpn, Target_Group,  DC=DestinationDeviceName, Actor=AccountName, ActorDomain=AccountDomain, AdditionalFields
| sort by Timestamp desc 

 

 

 

 

 

 

GersonLevitz_0-1649064974705.png

The information is now presented in a more concise manner. You can now sort the data as needed and export the data to a CSV file.

 

Step 4: See changes for sensitive groups

You might not want to see every group change that has occurred, as some groups may have many changes but might not be of interest from a security standpoint, like an all company group, for example.

From a security standpoint, we want to focus on changes that have been made to “sensitive” groups. By default, MDI considers specific groups to be sensitive. You can see the list of groups that are by default sensitive here - https://docs.microsoft.com/en-us/defender-for-identity/manage-sensitive-honeytoken-accounts#sensitiv....

If you have nested other groups to one of these predefined groups or if you have manually tagged group as sensitive, you should add the group name to the list in the query below.

An array is created with the list of the default sensitive groups as defined by MDI.

We will then query to only show groups that have been modified based on the array defined. The new or changed lines in the query are highlighted to help you keep track of the query evolution:   

Note: If your operating system is in a different language than English validate the spelling of the group names. 

 

 

 

 

 

 

 

let SensitiveGroupName = pack_array(  // Declare Sensitive Group names. Add any groups that you manually tagged as sensitive
    'Account Operators',
    'Administrators',
    'Domain Admins', 
    'Backup Operators',
    'Domain Controllers',
    'Enterprise Admins',
    'Enterprise Read-only Domain Controllers',
    'Group Policy Creator Owners',
    'Incoming Forest Trust Builders',
    'Microsoft Exchange Servers',
    'Network Configuration Operators',
    'Microsoft Exchange Servers',
    'Print Operators',
    'Read-only Domain Controllers',
    'Replicator',
    'Schema Admins',
    'Server Operators'
);
IdentityDirectoryEvents
| where Application == "Active Directory"
| where ActionType == "Group Membership changed"
| where DestinationDeviceName != "" // Exclude activites coming AD Sync changes. 
| extend ToGroup = tostring(parse_json(AdditionalFields).["TO.GROUP"]) // Extracts the group name if action is add enity to a group.
| extend FromGroup = tostring(parse_json(AdditionalFields).["FROM.GROUP"]) // etracts the group name if action is remove entity from a group.
| extend Action = iff(isempty(ToGroup), "Remove", "Add") // calculates if the action is Remove or Add
| extend GroupModified = iff(isempty(ToGroup), FromGroup, ToGroup) // group name that the action was taken on
| extend Target_Group = tostring(parse_json(AdditionalFields).["TARGET_OBJECT.GROUP"])
| where GroupModified in~ (SensitiveGroupName)
| project Timestamp, Action, GroupModified,  Target_Account = TargetAccountDisplayName, Target_UPN = TargetAccountUpn, Target_Group,  DC=DestinationDeviceName, Actor=AccountName, ActorDomain=AccountDomain, AdditionalFields
| sort by Timestamp desc

 

 

 

 

 

 

GersonLevitz_1-1649065556856.png

 

We can now review all changes made to sensitive groups. Feel free to save this query, then customize it further to suit your organization’s needs.

 

If you find the query helpful, please leave a comment, or use the comment space to tell us what you’ve done to make this query even more powerful in your organization. Please let us know what areas you want to see us tackle next in Advanced Hunting. We can’t wait to hear your ideas.

 

 

 

 

2 Comments
%3CLINGO-SUB%20id%3D%22lingo-sub-3275198%22%20slang%3D%22en-US%22%3ETrack%20changes%20to%20sensitive%20groups%20with%20Advanced%20Hunting%20in%20Microsoft%20365%20Defender%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3275198%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20my%20role%20working%20with%20Defender%20for%20Identity%20(MDI)%20customers%2C%20I'm%20often%20asked%20if%20MDI%20can%20help%20them%20answer%20questions%20about%20activities%20taking%20place%20within%20the%20environment.%26nbsp%3BMDI%20does%20have%20a%20lot%20of%20information%20around%20the%20activities%20taking%20place%20in%20Active%20Directory%20and%20now%20combined%20with%20the%20power%20of%20Advanced%20Hunting%20in%20Microsoft%20365%20Defender%2C%20we%20can%20help%20customers%20answer%20some%20these%20questions%20with%20ease%20and%20efficiency.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMDI%20tracks%20the%20changes%20made%20to%20Active%20Directory%20group%20memberships.%20These%20changes%20are%20recorded%20by%20MDI%20as%20an%20activity%20and%20are%20available%20in%20the%20Microsoft%20365%20Defender%20Advanced%20Hunting%2C%20IdentityDirectoryEvents.%20MDI%20records%20these%20changes%20from%20two%20different%20sources%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ETracking%20changes%20made%20to%20an%20entity%20by%20the%20Active%20Directory%20Update%20Sequence%20Number%20(USN).%20%26nbsp%3BIn%20the%20case%20of%20a%20group%2C%20MDI%20can%20see%20who%20has%20been%20added%20or%20removed%20from%20a%20group%2C%20but%20we%20don%E2%80%99t%20see%20the%20actor%20who%20made%20the%20change%20or%20which%20domain%20controller%20the%20change%20was%20made%20on.%3C%2FLI%3E%0A%3CLI%3ETracking%20changes%20to%20a%20group%2C%20including%20who%20performed%20the%20action.%20MDI%20requires%20specific%26nbsp%3BWindows%20events%20to%20be%20recorded%20on%20the%20domain%20controller.%20%26nbsp%3BFor%20more%20information%20on%20the%20Windows%20events%20required%20by%20MDI%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdefender-for-identity%2Fconfigure-windows-event-collection%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdefender-for-identity%2Fconfigure-windows-event-collection%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EIn%20this%20blog%20we%20will%20show%20you%20how%20to%20build%20an%20Advanced%20Hunting%20query%20that%20captures%20group%20modification.%20Let%E2%80%99s%20start%20with%20a%20very%20basic%20script%20showing%20all%20the%20changes%20to%20a%20query%20that%20will%20show%20modifications%20to%20sensitive%20groups%20in%20your%20organization.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-393784979%22%20id%3D%22toc-hId-416813358%22%3EStep%201%3A%20Basic%20query%20that%20will%20show%20all%20group%20modifications.%3C%2FH2%3E%0A%3CP%3EThe%20MDI%20group%20modification%20activities%20are%20in%20the%20%E2%80%9CIdentityDirectoryEvents%E2%80%9D%20table%20where%20ActionType%20equals%20%E2%80%9CGroup%20changed%E2%80%9D%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20simple%20AH%20query%20you%20use%20to%20show%20you%20all%20the%20group%20changes%20in%20Active%20Directory.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3EIdentityDirectoryEvents%20%0A%7C%20where%20Application%20%3D%3D%20%22Active%20Directory%22%0A%7C%20where%20ActionType%20%3D%3D%20%22Group%20Membership%20changed%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERunning%20this%20query%20yields%20the%20following%20result%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22GersonLevitz_0-1649064568987.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361063i98074CC52D8B08CD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22GersonLevitz_0-1649064568987.png%22%20alt%3D%22GersonLevitz_0-1649064568987.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20shows%20some%20columns%20that%20are%20not%20relevant%20for%20the%20rest%20of%20our%20scenario%2C%20so%20we%20will%20use%20the%20%E2%80%9Cproject%E2%80%9D%20command%20to%20show%20only%20the%20columns%20of%20interest.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3EIdentityDirectoryEvents%0A%7C%20where%20Application%20%3D%3D%20%22Active%20Directory%22%0A%7C%20where%20ActionType%20%3D%3D%20%22Group%20Membership%20changed%22%0A%7C%20project%20Timestamp%2C%20ActionType%2C%20TargetAccountDisplayName%2C%20TargetAccountUpn%2C%20DestinationDeviceName%2C%20AccountName%2C%20AccountDomain%2C%20AdditionalFields%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GersonLevitz_0-1649064708224.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361065i3EDA1F82382C70F9%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22GersonLevitz_0-1649064708224.png%22%20alt%3D%22GersonLevitz_0-1649064708224.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1413669484%22%20id%3D%22toc-hId--1390641105%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1073843349%22%20id%3D%22toc-hId-1096871728%22%3EStep%202%3A%20Just%20show%20activities%20from%20Windows%20Events%3C%2FH2%3E%0A%3CP%3EAs%20you%20can%20see%20there%20are%20some%20duplicate%20activities%20above.%20This%20is%20caused%20by%20MDI%20recording%20the%20group%20changes%20from%20two%20different%20sources.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWindows%20events%3C%2FLI%3E%0A%3CLI%3EActive%20Directory%20sync%20changes%20via%20USN%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20activities%20from%20the%20Windows%20events%20have%20more%20information%20such%20as%20which%20domain%20controller%20the%20change%20was%20initiated%20from%20and%20the%20user%20(actor)%20who%20performed%20the%20change.%20To%20simplify%20our%20query%E2%80%99s%20results%2C%20we%20want%20to%20exclude%20activities%20that%20are%20from%20Active%20Directory%20sync%20changes.%3C%2FP%3E%0A%3CP%3EAdditionally%2C%20we%20are%20going%20to%20use%20the%20%E2%80%9Cproject%E2%80%9D%20command%20again%20to%20show%20specific%20columns%20that%20are%20relevant%20here.%3C%2FP%3E%0A%3CP%3ETo%20include%20the%20activities%20from%20the%20Windows%20events%20only%2C%20run%20the%20following%20query%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3EIdentityDirectoryEvents%0A%7C%20where%20Application%20%3D%3D%20%22Active%20Directory%22%0A%7C%20where%20ActionType%20%3D%3D%20%22Group%20Membership%20changed%22%0A%7C%20where%20DestinationDeviceName%20!%3D%20%22%22%20%2F%2F%20Exclude%20activities%20coming%20from%20AD%20Sync%20changes.%20%0A%7C%20project%20Timestamp%2C%20ActionType%2C%20TargetAccountDisplayName%2C%20TargetAccountUpn%2C%20DestinationDeviceName%2C%20AccountName%2C%20AccountDomain%2C%20AdditionalFields%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GersonLevitz_1-1649064838159.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361067iB3CF0B5064BF83A2%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22GersonLevitz_1-1649064838159.png%22%20alt%3D%22GersonLevitz_1-1649064838159.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--733611114%22%20id%3D%22toc-hId--710582735%22%3EStep%203%3A%20Group%20name%20and%20action%20type%3C%2FH2%3E%0A%3CP%3EThe%20table%20is%20starting%20to%20take%20shape%2C%20but%20we%20are%20still%20missing%20some%20valuable%20pieces%20of%20information.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGroup%20name%20that%20was%20modified%3C%2FLI%3E%0A%3CLI%3EWhether%20the%20group%20change%20was%20an%20%E2%80%9CAdd%E2%80%9D%20or%20a%20%E2%80%9CRemove%E2%80%9D%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIf%20you%20look%20closely%2C%20you%20can%20see%20a%20few%20lines%20that%20have%20no%20data%20for%20the%20TargetAccountDisplayName%20and%20TargetAccountUPN%20attributes.%20This%20is%20due%20to%20another%20group%20being%20added%20or%20removed%20to%20the%20queried%20group%20(group%20nesting).%3C%2FP%3E%0A%3CP%3ETo%20complete%20the%20missing%20data%2C%20we%20will%20be%20extracting%20it%20from%20the%20%E2%80%9CAdditionalFields%E2%80%9D%20column.%20%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3EIdentityDirectoryEvents%0A%7C%20where%20Application%20%3D%3D%20%22Active%20Directory%22%0A%7C%20where%20ActionType%20%3D%3D%20%22Group%20Membership%20changed%22%0A%7C%20where%20DestinationDeviceName%20!%3D%20%22%22%20%2F%2F%20Exclude%20activites%20coming%20AD%20Sync%20changes.%20%0A%7C%20extend%20ToGroup%20%3D%20tostring(parse_json(AdditionalFields).%5B%22TO.GROUP%22%5D)%20%2F%2F%20Extracts%20the%20group%20name%20if%20action%20is%20add%20enity%20to%20a%20group.%0A%7C%20extend%20FromGroup%20%3D%20tostring(parse_json(AdditionalFields).%5B%22FROM.GROUP%22%5D)%20%2F%2F%20etracts%20the%20group%20name%20if%20action%20is%20remove%20entity%20from%20a%20group.%0A%7C%20extend%20Action%20%3D%20iff(isempty(ToGroup)%2C%20%22Remove%22%2C%20%22Add%22)%20%2F%2F%20calculates%20if%20the%20action%20is%20Remove%20or%20Add%0A%7C%20extend%20GroupModified%20%3D%20iff(isempty(ToGroup)%2C%20FromGroup%2C%20ToGroup)%20%2F%2F%20group%20name%20that%20the%20action%20was%20taken%20on%20%0A%7C%20extend%20Target_Group%20%3D%20tostring(parse_json(AdditionalFields).%5B%22TARGET_OBJECT.GROUP%22%5D)%0A%7C%20project%20Timestamp%2C%20Action%2C%20GroupModified%2C%20%20Target_Account%20%3D%20TargetAccountDisplayName%2C%20Target_UPN%20%3D%20TargetAccountUpn%2C%20Target_Group%2C%20%20DC%3DDestinationDeviceName%2C%20Actor%3DAccountName%2C%20ActorDomain%3DAccountDomain%2C%20AdditionalFields%0A%7C%20sort%20by%20Timestamp%20desc%20%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GersonLevitz_0-1649064974705.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361068i5037C20AC02EF68A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22GersonLevitz_0-1649064974705.png%22%20alt%3D%22GersonLevitz_0-1649064974705.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20information%20is%20now%20presented%20in%20a%20more%20concise%20manner.%20You%20can%20now%20sort%20the%20data%20as%20needed%20and%20export%20the%20data%20to%20a%20CSV%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1753901719%22%20id%3D%22toc-hId-1776930098%22%3E%3CSTRONG%3EStep%204%3A%20See%20changes%20for%20sensitive%20groups%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3EYou%20might%20not%20want%20to%20see%20every%20group%20change%20that%20has%20occurred%2C%20as%20some%20groups%20may%20have%20many%20changes%20but%20might%20not%20be%20of%20interest%20from%20a%20security%20standpoint%2C%20like%20an%20all%20company%20group%2C%20for%20example.%3C%2FP%3E%0A%3CP%3EFrom%20a%20security%20standpoint%2C%20we%20want%20to%20focus%20on%20changes%20that%20have%20been%20made%20to%20%E2%80%9Csensitive%E2%80%9D%20groups.%20By%20default%2C%20MDI%20considers%20specific%20groups%20to%20be%20sensitive.%20You%20can%20see%20the%20list%20of%20groups%20that%20are%20by%20default%20sensitive%20here%20-%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdefender-for-identity%2Fmanage-sensitive-honeytoken-accounts%23sensitive-entities%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdefender-for-identity%2Fmanage-sensitive-honeytoken-accounts%23sensitive-entities%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20nested%20other%20groups%20to%20one%20of%20these%20predefined%20groups%20or%20if%20you%20have%20manually%20tagged%20group%20as%20sensitive%2C%20you%20should%20add%20the%20group%20name%20to%20the%20list%20in%20the%20query%20below.%3C%2FP%3E%0A%3CP%3EAn%20array%20is%20created%20with%20the%20list%20of%20the%20default%20sensitive%20groups%20as%20defined%20by%20MDI.%3C%2FP%3E%0A%3CP%3EWe%20will%20then%20query%20to%20only%20show%20groups%20that%20have%20been%20modified%20based%20on%20the%20array%20defined.%20The%20new%20or%20changed%20lines%20in%20the%20query%20are%20highlighted%20to%20help%20you%20keep%20track%20of%20the%20query%20evolution%3A%20%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENote%3A%20If%20your%20operating%20system%20is%20in%20a%20different%20language%20than%20English%20validate%20the%20spelling%20of%20the%20group%20names.%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3Elet%20SensitiveGroupName%20%3D%20pack_array(%20%20%2F%2F%20Declare%20Sensitive%20Group%20names.%20Add%20any%20groups%20that%20you%20manually%20tagged%20as%20sensitive%0A%20%20%20%20'Account%20Operators'%2C%0A%20%20%20%20'Administrators'%2C%0A%20%20%20%20'Domain%20Admins'%2C%20%0A%20%20%20%20'Backup%20Operators'%2C%0A%20%20%20%20'Domain%20Controllers'%2C%0A%20%20%20%20'Enterprise%20Admins'%2C%0A%20%20%20%20'Enterprise%20Read-only%20Domain%20Controllers'%2C%0A%20%20%20%20'Group%20Policy%20Creator%20Owners'%2C%0A%20%20%20%20'Incoming%20Forest%20Trust%20Builders'%2C%0A%20%20%20%20'Microsoft%20Exchange%20Servers'%2C%0A%20%20%20%20'Network%20Configuration%20Operators'%2C%0A%20%20%20%20'Microsoft%20Exchange%20Servers'%2C%0A%20%20%20%20'Print%20Operators'%2C%0A%20%20%20%20'Read-only%20Domain%20Controllers'%2C%0A%20%20%20%20'Replicator'%2C%0A%20%20%20%20'Schema%20Admins'%2C%0A%20%20%20%20'Server%20Operators'%0A)%3B%0AIdentityDirectoryEvents%0A%7C%20where%20Application%20%3D%3D%20%22Active%20Directory%22%0A%7C%20where%20ActionType%20%3D%3D%20%22Group%20Membership%20changed%22%0A%7C%20where%20DestinationDeviceName%20!%3D%20%22%22%20%2F%2F%20Exclude%20activites%20coming%20AD%20Sync%20changes.%20%0A%7C%20extend%20ToGroup%20%3D%20tostring(parse_json(AdditionalFields).%5B%22TO.GROUP%22%5D)%20%2F%2F%20Extracts%20the%20group%20name%20if%20action%20is%20add%20enity%20to%20a%20group.%0A%7C%20extend%20FromGroup%20%3D%20tostring(parse_json(AdditionalFields).%5B%22FROM.GROUP%22%5D)%20%2F%2F%20etracts%20the%20group%20name%20if%20action%20is%20remove%20entity%20from%20a%20group.%0A%7C%20extend%20Action%20%3D%20iff(isempty(ToGroup)%2C%20%22Remove%22%2C%20%22Add%22)%20%2F%2F%20calculates%20if%20the%20action%20is%20Remove%20or%20Add%0A%7C%20extend%20GroupModified%20%3D%20iff(isempty(ToGroup)%2C%20FromGroup%2C%20ToGroup)%20%2F%2F%20group%20name%20that%20the%20action%20was%20taken%20on%0A%7C%20extend%20Target_Group%20%3D%20tostring(parse_json(AdditionalFields).%5B%22TARGET_OBJECT.GROUP%22%5D)%0A%7C%20where%20GroupModified%20in~%20(SensitiveGroupName)%0A%7C%20project%20Timestamp%2C%20Action%2C%20GroupModified%2C%20%20Target_Account%20%3D%20TargetAccountDisplayName%2C%20Target_UPN%20%3D%20TargetAccountUpn%2C%20Target_Group%2C%20%20DC%3DDestinationDeviceName%2C%20Actor%3DAccountName%2C%20ActorDomain%3DAccountDomain%2C%20AdditionalFields%0A%7C%20sort%20by%20Timestamp%20desc%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GersonLevitz_1-1649065556856.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361071iD6687539C50B7886%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22GersonLevitz_1-1649065556856.png%22%20alt%3D%22GersonLevitz_1-1649065556856.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20now%20review%20all%20changes%20made%20to%20sensitive%20groups.%20Feel%20free%20to%20save%20this%20query%2C%20then%20customize%20it%20further%20to%20suit%20your%20organization%E2%80%99s%20needs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20find%20the%20query%20helpful%2C%20please%20leave%20a%20comment%2C%20or%20use%20the%20comment%20space%20to%20tell%20us%20what%20you%E2%80%99ve%20done%20to%20make%20this%20query%20even%20more%20powerful%20in%20your%20organization.%20Please%20let%20us%20know%20what%20areas%20you%20want%20to%20see%20us%20tackle%20next%20in%20Advanced%20Hunting.%20We%20can%E2%80%99t%20wait%20to%20hear%20your%20ideas.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%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-3275198%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20this%20blog%20we%20will%20show%20you%20how%20to%20build%20an%20Advanced%20Hunting%20query%20that%20captures%20group%20modification.%20Let%E2%80%99s%20start%20with%20a%20very%20basic%20script%20showing%20all%20the%20changes%20to%20a%20query%20that%20will%20show%20modifications%20to%20sensitive%20groups%20in%20your%20organization.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3275198%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20365%20Defender%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Defender%20for%20Identity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3278613%22%20slang%3D%22en-US%22%3ERe%3A%20Track%20changes%20to%20sensitive%20groups%20with%20Advanced%20Hunting%20in%20Microsoft%20365%20Defender%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3278613%22%20slang%3D%22en-US%22%3E%3CP%3EShould%20definitely%20be%20part%20of%20a%20workbook.%20Thanks%20for%20sharing%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3278408%22%20slang%3D%22en-US%22%3ERe%3A%20Track%20changes%20to%20sensitive%20groups%20with%20Advanced%20Hunting%20in%20Microsoft%20365%20Defender%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3278408%22%20slang%3D%22en-US%22%3E%3CP%3EGreat%20article.%20Queries%20on%20this%20article%20should%20be%20included%20in%20the%20sample.%20Also%20wondering%20if%20you%20could%20add%20a%20query%20for%20user%20account%20add%20%26amp%3B%20remove%20to%20AD%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Co-Authors
Version history
Last update:
‎Apr 07 2022 11:22 PM
Updated by: