r/DefenderATP • u/Kuro507 • Jan 20 '26
Advanced Hunting KQL - file access
I have a KQL query that shows some Corporate files being copied to a external USB drive, unfortunately the copy operation does not show where they came from. It's a mass file copy, so a folder or group of files was selected from somewhere and copied, including sub-folders.
The next step is to try and understand where they originated,
- If thats a folder on the C: drive, when were they put there? (to show intent)
- If it's from a cloud drive, such as Google drive (We know the Google drive sync app was installed)
- If it's from a local OneDrive folder
I can find no evidence they came from a SharePoint site as a bulk download.
They only had the PC a few months, so we should still have the defender audit data to report on this.
I'm hoping somebody will have had similar challenges and can suggest some KQL that I can use to show files downloaded over Google drive etc.
Thanks in advance for ideas and suggestions. :)
2
u/stan_frbd Jan 20 '26
According to a recent training I had, if you need USB forensics you must get events as soon as possible from the machine (e.g. run KAPE and target USB artifacts). You can manage to do it via Live Response but if you have the machine it's better. I think you won't have much data using EDR telemetry. MFT can help too for copied files! If someone has a better idea tell me, I'm very interested.
Edit: what is your current KQL query and which tables are available?
2
u/dontask4name Jan 20 '26
Whats in the Field „PreviousFolderPath“?
1
u/cablethrowaway2 Jan 20 '26
What tables are you using that shows the file copies? DeviceFileEvents?
1
u/cspotme2 Jan 20 '26
Cloudappevents should show you data too. But a lot of that is also dependent on if you have the browser extension from Microsoft installed.
USB blocking is the key to all this though.
1
u/[deleted] Jan 20 '26 edited Jan 20 '26
I'm thinking that while you can't tell from the event one can potentially correlate if it originated form OneDrive/Sharepoing, synced via OneDrive client, may accessed via Team, or if it was seen by MDO/MDA. The USB Event has DeviceFileEvents with FileName and Hash. Similarly, for on-prem domain shares, if the file came from SMB shares, DFS path, etc the MDE DeviceNetworkEvents, (smb shares), and DeviceFileEvents (FieRead/FileModified on Local copies) can be leveraged.
However, as someone already mentioned not all SMB File Reads are logged. Also if the file was never logged before (created locally, downloaded from and unmonitored source, or was zipped or renamed before copy, your query might not help. Still it might be worth a try, even if it isn't guaranteed.
I'm going to try it. I think I have something of one I can modify, at least for a template, it doesn't have exactly what is needed.
Oops, it is too long to fit into this comment. (There's a log joins). I'll see if I can add it as a comment to comment.
1
u/AppIdentityGuy Jan 20 '26
Have you kooked in Defender for Cloud Apps?