Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit d407644

Browse files
authored
Update Open email link.txt
Add the same query to be executed also with the MTP schema
1 parent be30287 commit d407644

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Delivery/Open email link.txt

+35
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,38 @@ alerts | join kind=inner (outlookLinks) on DeviceId | where FirstDetectedActivit
3434
// Note: bin(Timestamp, 1tick) is used because when summarizing by a datetime field, the default "bin" used is 1-hour.
3535
| summarize FirstDetectedActivity=min(FirstDetectedActivity), AlertTitles=makeset(Title) by OpenedLink, InitiatingProcessFileName, Timestamp=bin(Timestamp, 1tick), DeviceName, DeviceId, WasOutlookSafeLink
3636

37+
// Query for links opened from mail apps – if a detection occurred right afterwards. - MTP Schema
38+
// As there are many links opened from mails, to have a successful hunt we should have some filter or join with some other signal,
39+
// such as suspicious processes, network connections, etc.
40+
// Therefore, in this example, we query for alerts that might be related to links sent via email.
41+
// This could be indicative of a phishing or spear-phishing attacks.
42+
// Tags: #EmailLink, #Phishing, #GetNearbyAlerts
43+
// Explaining the underlying data:
44+
// This query uses the BrowserLaunchedToOpenUrl event, that includes clicks on http:// or https:// links (clicks outside of browsers), or on .lnk files
45+
// For this event, RemoteUrl contains the opened URL.
46+
let minTimeRange = ago(7d);
47+
let outlookLinks =
48+
DeviceEvents
49+
// Filter on click on links from outlook
50+
| where Timestamp > minTimeRange and ActionType == "BrowserLaunchedToOpenUrl" and isnotempty(RemoteUrl)
51+
| where
52+
// outlook.exe is the Office Outlook app
53+
InitiatingProcessFileName =~ "outlook.exe"
54+
// RuntimeBroker.exe opens links for all apps from the Windows store, including the Windows Mail app (HxOutlook.exe).
55+
// However, it will also include some links opened from other apps.
56+
or InitiatingProcessFileName =~ "runtimebroker.exe"
57+
| project Timestamp, DeviceId, DeviceName, RemoteUrl, InitiatingProcessFileName, ParsedUrl=parse_url(RemoteUrl)
58+
// When applicable, parse the link sent via email from the clicked O365 ATP SafeLink
59+
| extend WasOutlookSafeLink=(tostring(ParsedUrl.Host) endswith "safelinks.protection.outlook.com")
60+
| project Timestamp, DeviceId, DeviceName, WasOutlookSafeLink, InitiatingProcessFileName,
61+
OpenedLink=iff(WasOutlookSafeLink, url_decode(tostring(ParsedUrl["Query Parameters"]["url"])), RemoteUrl);
62+
let alerts =
63+
AlertInfo | join AlertEvidence on AlertId
64+
| summarize (FirstDetectedActivity, Title)=argmin(Timestamp, Title) by AlertId, DeviceId
65+
// Filter alerts that include events from before the queried time period
66+
| where FirstDetectedActivity > minTimeRange;
67+
// Join the two together - looking for alerts that are right after an abnormal network logon
68+
alerts | join kind=inner (outlookLinks) on DeviceId | where FirstDetectedActivity - Timestamp between (0min..3min)
69+
// If there are multiple alerts close to a single click-on-link, aggregate them together to a single row
70+
// Note: bin(Timestamp, 1tick) is used because when summarizing by a datetime field, the default "bin" used is 1-hour.
71+
| summarize FirstDetectedActivity=min(FirstDetectedActivity), AlertTitles=makeset(Title) by OpenedLink, InitiatingProcessFileName, Timestamp=bin(Timestamp, 1tick), DeviceName, DeviceId, WasOutlookSafeLink

0 commit comments

Comments
 (0)