forked from SEVENP/Sentinel-Queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDevice-FileDownloadedfromO365thenCopiedtoUSB.kql
36 lines (36 loc) · 1.32 KB
/
Device-FileDownloadedfromO365thenCopiedtoUSB.kql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//Detects a user that downloaded a file from O365 and then wrote the same file to USB, matches on both filename and the user
let filedownloads=
OfficeActivity
| where TimeGenerated > ago(1d)
| extend DownloadTime = TimeGenerated
| where Operation in ('FileSyncDownloadedFull', 'FileDownloaded')
| project DownloadTime, UserId, SourceFileName
| join kind=inner
(
IdentityInfo
| where TimeGenerated > ago (21d)
| summarize arg_max(TimeGenerated, *) by AccountUPN)
on $left.UserId == $right.AccountUPN
| project DownloadTime, SourceFileName, UserId, AccountName
;
DeviceEvents
| where TimeGenerated > ago(1d)
| where ActionType == "UsbDriveMounted"
| extend DriveLetter = tostring(todynamic(AdditionalFields).DriveLetter)
| join kind=inner
(
DeviceFileEvents
| where TimeGenerated > ago(1d)
| extend FileCopyTime = TimeGenerated
| where ActionType == "FileCreated"
| join kind=inner filedownloads
on
$left.FileName == $right.SourceFileName,
$left.RequestAccountName == $right.AccountName
| parse FolderPath with DriveLetter '\\' *
| extend DriveLetter = tostring(DriveLetter)
)
on DeviceId, DriveLetter
| extend FileCopied = FileName1
| extend User = AccountName1
| distinct DeviceName, DriveLetter, FileCopied, User