Last active
January 14, 2023 14:46
-
-
Save yaya2devops/1d15dd3d36f40b5fd0a38183c2e56c5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id: 119d9e1c-afcc-4d23-b239-cdb4e7bf851c | |
name: External user added and removed in a short timeframe - Hunt Version | |
description: | | |
'This hunting query identifies external user accounts that are added to a Team and then removed within one hour.' | |
requiredDataConnectors: | |
- connectorId: Office365 | |
dataTypes: | |
- OfficeActivity (Teams) | |
tactics: | |
- Persistence | |
relevantTechniques: | |
- T1136 | |
query: | | |
// If you want to look at user added further than 7 days ago adjust this value | |
// If you want to change the timeframe of how quickly accounts need to be added and removed change this value | |
let time_delta = 1h; | |
OfficeActivity | |
| where OfficeWorkload =~ "MicrosoftTeams" | |
| where Operation =~ "MemberAdded" | |
| extend UPN = tostring(parse_json(Members)[0].UPN) | |
| where UPN contains ("#EXT#") | |
| project TimeAdded=TimeGenerated, Operation, UPN, UserWhoAdded = UserId, TeamName, TeamGuid | |
| join ( | |
OfficeActivity | |
| where OfficeWorkload =~ "MicrosoftTeams" | |
| where Operation =~ "MemberRemoved" | |
| extend UPN = tostring(parse_json(Members)[0].UPN) | |
| where UPN contains ("#EXT#") | |
| project TimeDeleted=TimeGenerated, Operation, UPN, UserWhoDeleted = UserId, TeamName, TeamGuid) on UPN, TeamGuid | |
| where TimeDeleted < (TimeAdded + time_delta) | |
| project TimeAdded, TimeDeleted, UPN, UserWhoAdded, UserWhoDeleted, TeamName, TeamGuid | |
| extend timestamp = TimeAdded, AccountCustomEntity = UPN | |
entityMappings: | |
- entityType: Account | |
fieldMappings: | |
- identifier: FullName | |
columnName: AccountCustomEntity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment