Brand impersonation: Microsoft with low reputation links
Detects low reputation links with Microsoft specific indicators in the body.
Sublime rule (View on GitHub)
1name: "Brand impersonation: Microsoft with low reputation links"
2description: "Detects low reputation links with Microsoft specific indicators in the body."
3type: "rule"
4severity: "medium"
5source: |
6 type.inbound
7 and 0 < length(body.links) < 50
8 // suspicious link
9 and any(body.links,
10 (
11 .href_url.domain.tld == "ru"
12 or .href_url.domain.root_domain not in $tranco_1m
13 or .href_url.domain.domain in $free_file_hosts
14 or .href_url.domain.root_domain in $free_file_hosts
15 or .href_url.domain.root_domain in $free_subdomain_hosts
16 or .href_url.domain.domain in $url_shorteners
17 or .href_url.domain.domain in $social_landing_hosts
18 // account for URL rewrites
19 or (
20 any(.href_url.query_params_decoded["domain"],
21 strings.parse_domain(.).tld == "ru"
22 or strings.parse_domain(.).root_domain not in~ $tranco_1m
23 or strings.parse_domain(.).domain in~ $free_file_hosts
24 or strings.parse_domain(.).root_domain in~ $free_file_hosts
25 or strings.parse_domain(.).root_domain in~ $free_subdomain_hosts
26 or strings.parse_domain(.).domain in~ $url_shorteners
27 or strings.parse_domain(.).domain in~ $social_landing_hosts
28 )
29 )
30 or
31
32 // mass mailer link, masks the actual URL
33 .href_url.domain.root_domain in (
34 "hubspotlinks.com",
35 "mandrillapp.com",
36 "sendgrid.net",
37 "rs6.net"
38 )
39
40 // Google AMP redirect
41 or (
42 .href_url.domain.sld == "google"
43 and strings.starts_with(.href_url.path, "/amp/")
44 )
45
46 // Recipient email address in link
47 or any(body.links,
48 any(recipients.to,
49 strings.icontains(..href_url.url, .email.email)
50 and any(recipients.to, .email.domain.valid)
51 )
52 )
53 or .href_url.domain.root_domain == "beehiiv.com"
54 )
55
56 // exclude sources of potential FPs
57 and (
58 .href_url.domain.root_domain not in (
59 "svc.ms",
60 "sharepoint.com",
61 "1drv.ms",
62 "microsoft.com",
63 "aka.ms",
64 "msftauthimages.net",
65 "office.com",
66 "microsoftproject.com"
67 )
68 or any(body.links, .href_url.domain.domain in $free_file_hosts)
69 )
70 and .href_url.domain.root_domain not in $org_domains
71 and .href_url.domain.valid
72 )
73
74 // not a reply
75 and (
76 length(headers.references) == 0
77 or not any(headers.hops, any(.fields, strings.ilike(.name, "In-Reply-To")))
78 )
79
80 // Microsoft logo
81 and (
82 any(attachments,
83 .file_type in $file_types_images
84 and any(ml.logo_detect(.).brands, strings.starts_with(.name, "Microsoft"))
85 )
86 or strings.istarts_with(strings.replace_confusables(body.current_thread.text),
87 "Microsoft "
88 )
89 or (
90 regex.imatch(strings.replace_confusables(body.current_thread.text),
91 '[\n\s]*[o0O]ff[il1]ce\b.*'
92 )
93 and not regex.icontains(strings.replace_confusables(body.current_thread.text
94 ),
95 'office (for lease|rent|sale)'
96 )
97 )
98 or any(ml.logo_detect(file.message_screenshot()).brands,
99 strings.starts_with(.name, "Microsoft")
100 )
101 or (
102 regex.icontains(body.html.raw,
103 '<table[^>]*>\s*<tbody[^>]*>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s* \s*</td>\s*){2}\s*</tr>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s* \s*</td>\s*){2}'
104 )
105 or regex.icontains(body.html.raw,
106 '<td style="background:\s*rgb\(246,\s*93,\s*53\);\s*height:\d+px;">.*?<td style="background:\s*rgb\(129,\s*187,\s*5\);\s*height:\d+px;">.*?<td style="background:\s*rgb\(4,\s*165,\s*240\);\s*height:\d+px;">.*?<td style="background:\s*rgb\(255,\s*186,\s*7\);\s*height:\d+px;">'
107 )
108 or 4 of (
109 regex.icontains(body.html.raw,
110 '<td style="width:.\d.px;.height:.\d.px;.background-color:.rgb\(245, 189, 67\);">.{0,10}</td>'
111 ),
112 regex.icontains(body.html.raw,
113 '<td style="width:.\d.px;.height:.\d.px;.background-color:.rgb\(137, 184, 57\);">.{0,10}</td>'
114 ),
115 regex.icontains(body.html.raw,
116 '<td style="width:.\d.px;.height:.\d.px;.background-color:.rgb\(217, 83, 51\);">.{0,10}</td>'
117 ),
118 regex.icontains(body.html.raw,
119 '<td style="width:.\d.px;.height:.\d.px;.background-color:.rgb\(71, 160, 218\);">.{0,10}</td>'
120 )
121 )
122 )
123 or regex.icontains(body.html.raw,
124 '<table[^>]*>\s*<tbody[^>]*>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s* \s*</td>\s*){2}\s*</tr>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s* \s*</td>\s*){2}'
125 )
126 or 3 of (
127 regex.icontains(body.html.raw, '.password-expiration'),
128 regex.icontains(body.html.raw, 'color: #2672ec;'),
129 regex.icontains(body.html.raw, 'Microsoft')
130 )
131 or 4 of (
132 regex.icontains(body.html.raw, 'rgb\(246,\s?93,\s?53\)'),
133 regex.icontains(body.html.raw, 'rgb\(129,\s?187,\s?5\)'),
134 regex.icontains(body.html.raw, 'rgb\(4,\s?165,\s?240\)'),
135 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?7\)'),
136 )
137 or 4 of (
138 regex.icontains(body.html.raw,
139 '(background-color:|background:|bgcolor=)(.)red'
140 ),
141 regex.icontains(body.html.raw, 'rgb\(19,\s?186,\s?132\)'),
142 regex.icontains(body.html.raw, 'rgb\(4,\s?166,\s?240\)'),
143 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?8\)'),
144 )
145 or 4 of (
146 regex.icontains(body.html.raw, 'rgb\(245,\s?189,\s?67\)'),
147 regex.icontains(body.html.raw, 'rgb\(137,\s?184,\s?57\)'),
148 regex.icontains(body.html.raw, 'rgb\(217,\s?83,\s?51\)'),
149 regex.icontains(body.html.raw, 'rgb\(71,\s?160,\s?218\)')
150 )
151 or 4 of (
152 regex.icontains(body.html.raw, 'rgb\(73,\s?161,\s?232\)'),
153 regex.icontains(body.html.raw, 'rgb\(224,\s?92,\s?53\)'),
154 regex.icontains(body.html.raw, 'rgb\(139,\s?183,\s?55\)'),
155 regex.icontains(body.html.raw, 'rgb\(244,\s?188,\s?65\)')
156 )
157 or 4 of (
158 regex.icontains(body.html.raw, 'rgb\(213,\s?56,\s?62\)'),
159 regex.icontains(body.html.raw, 'rgb\(0,\s?114,\s?30\)'),
160 regex.icontains(body.html.raw, 'rgb\(0,\s?110,\s?173\)'),
161 regex.icontains(body.html.raw, 'rgb\(227,\s?209,\s?43\)'),
162 )
163 or 4 of (
164 regex.icontains(body.html.raw, 'rgb\(246,\s?93,\s?53\)'),
165 regex.icontains(body.html.raw, 'rgb\(129,\s?187,\s?5\)'),
166 regex.icontains(body.html.raw, 'rgb\(4,\s?165,\s?240\)'),
167 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?7\)')
168 )
169 or 4 of (
170 regex.icontains(body.html.raw, 'rgb\(242,\s?80,\s?34\)'),
171 regex.icontains(body.html.raw, 'rgb\(127,\s?186,\s?0\)'),
172 regex.icontains(body.html.raw, 'rgb\(0,\s?164,\s?239\)'),
173 regex.icontains(body.html.raw, 'rgb\(255,\s?185,\s?0\)'),
174 )
175 or 4 of (
176 regex.icontains(body.html.raw, 'rgb\(243,\s?83,\s?37\)'),
177 regex.icontains(body.html.raw, 'rgb\(129,\s?188,\s?6\)'),
178 regex.icontains(body.html.raw, 'rgb\(5,\s?166,\s?240\)'),
179 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?8\)')
180 )
181 or 4 of (
182 regex.icontains(body.html.raw, 'rgb\(243,\s?80,\s?34\)'),
183 regex.icontains(body.html.raw, 'rgb\(128,\s?187,\s?3\)'),
184 regex.icontains(body.html.raw, 'rgb\(3,\s?165,\s?240\)'),
185 regex.icontains(body.html.raw, 'rgb\(255,\s?185,\s?3\)')
186 )
187 or 4 of (
188 regex.icontains(body.html.raw,
189 '(background-color:|background:|bgcolor=)(.)?(#)?(FF1940|eb5024|F25022|FF1941|red)'
190 ),
191 regex.icontains(body.html.raw,
192 '(background-color:|background:|bgcolor=)(.)?(#)?(36ba57|3eb55d|7db606|7FBA00|36ba58|green)'
193 ),
194 regex.icontains(body.html.raw,
195 '(background-color:|background:|bgcolor=)(.)?#(04a1d6|04B5F0|05a1e8|00A4EF|01a4ef|04a5f0)'
196 ),
197 regex.icontains(body.html.raw,
198 '(background-color:|background:|bgcolor=)(.)?#(FFCA07|f7b408|FFB900|FFCA08|ffb901|ffba07)'
199 ),
200 )
201 or 4 of (
202 regex.icontains(body.html.raw,
203 '(background-color:|background:|bgcolor=)(.)?#(f65314|f65d35|49a1e8|E74F23|F35325)'
204 ),
205 regex.icontains(body.html.raw,
206 '(background-color:|background:|bgcolor=)(.)?#(7cbf42|81bb05|e05c35|7AB206|81BC06)'
207 ),
208 regex.icontains(body.html.raw,
209 '(background-color:|background:|bgcolor=)(.)?#(00a4ef|0078d7|8bb737|04a5f0|059EE4|05A6F0)'
210 ),
211 regex.icontains(body.html.raw,
212 '(background-color:|background:|bgcolor=)(.)?#(ffb900|ffba07|f4bc41|F2B108|FFBA08)'
213 ),
214 )
215 // fuzzy approach
216 or 4 of (
217 regex.icontains(body.html.raw,
218 'rgb\((2[1-4][0-9]|250),\s?(7[0-9]|8[0-9]|9[0-3]),\s?(3[0-9]|4[0-9]|5[0-3])\)'
219 ),
220 regex.icontains(body.html.raw,
221 'rgb\((12[0-9]|13[0-9]),\s?(18[0-9]|190),\s?([0-9]|10)\)'
222 ),
223 regex.icontains(body.html.raw,
224 'rgb\(([0-9]|1[0-5]),\s?(16[0-5]|166),\s?(23[0-9]|240)\)'
225 ),
226 regex.icontains(body.html.raw,
227 'rgb\((25[0-5]),\s?(18[5-9]|19[0-9]),\s?([0-9]|10)\)'
228 )
229 )
230 )
231
232 // suspicious content
233 and (
234 // current thread is empty, but an image attachment is branded as microsoft.
235 // common in image as content
236 (
237 body.current_thread.text == ""
238 and any(attachments,
239 .file_type in $file_types_images
240 and any(ml.logo_detect(.).brands,
241 strings.starts_with(.name, "Microsoft")
242 )
243 )
244 )
245 or (
246 strings.ilike(body.plain.raw,
247 "*password*",
248 "*document*",
249 "*voicemail*",
250 "*cache*",
251 "*fax*",
252 "*storage*",
253 "*quota*",
254 "*message*"
255 )
256 and strings.ilike(body.plain.raw,
257 "*terminated*",
258 "*review*",
259 "*expire*",
260 "*click*",
261 "*view*",
262 "*exceed*",
263 "*clear*",
264 "*only works*",
265 "*failed*",
266 "*deleted*",
267 "*revalidated*",
268 "*renewal*"
269 )
270 )
271
272 or (
273 any(attachments,
274 .file_type in $file_types_images
275 and any(file.explode(.),
276 strings.ilike(.scan.ocr.raw,
277 "*password*",
278 "*document*",
279 "*voicemail*",
280 "*cache*",
281 "*fax*",
282 "*storage*",
283 "*quota*",
284 "*messages*"
285 )
286 and strings.ilike(.scan.ocr.raw,
287 "*terminated*",
288 "*review*",
289 "*expire*",
290 "*click*",
291 "*view*",
292 "*exceed*",
293 "*clear*",
294 "*only works*",
295 "*failed*",
296 "*deleted*"
297 )
298 )
299 )
300 )
301 or (
302 //
303 // This rule makes use of a beta feature and is subject to change without notice
304 // using the beta feature in custom rules is not suggested until it has been formally released
305 //
306 strings.ilike(beta.ocr(file.message_screenshot()).text,
307 "*password*",
308 "*document*",
309 "*voicemail*",
310 "*cache*",
311 "*fax*",
312 "*storage*",
313 "*quota*",
314 "*messages*"
315 )
316 and strings.ilike(beta.ocr(file.message_screenshot()).text,
317 "*terminated*",
318 "*review*",
319 "*expire*",
320 "*click*",
321 "*view*",
322 "*exceed*",
323 "*clear*",
324 "*only works*",
325 "*failed*",
326 "*deleted*",
327 "*revalidated*",
328 "*renewal*"
329 )
330 )
331 or (
332 any(ml.nlu_classifier(body.current_thread.text).intents,
333 .name == "cred_theft" and .confidence in~ ("medium", "high")
334 )
335 or any(attachments,
336 .file_type in $file_types_images
337 and any(file.explode(.),
338 any(ml.nlu_classifier(.scan.ocr.raw).intents,
339 .name == "cred_theft"
340 and .confidence in ("medium", "high")
341 )
342 )
343 )
344 )
345 )
346 and sender.email.domain.root_domain not in (
347 "bing.com",
348 "microsoft.com",
349 "microsoftonline.com",
350 "microsoftproject.com",
351 "microsoftstoreemail.com",
352 "microsoftsupport.com",
353 "microsoft365.com",
354 "office.com",
355 "office365.com",
356 "onedrive.com",
357 "sharepointonline.com",
358 "yammer.com",
359 )
360
361 // negate legitimate Office 365 bouncebacks
362 and not (
363 length(attachments) > 0
364 and all(attachments,
365 .content_type in ("message/delivery-status", "message/rfc822")
366 )
367 and (sender.email.local_part in ('postmaster', 'mailer-daemon'))
368 )
369
370 // negate Microsoft "welcome to the X group" notifications
371 and not (
372 headers.auth_summary.dmarc.pass
373 and length(attachments) == 6
374 and length(filter(attachments,
375 strings.istarts_with(.file_name, "GuestWelcomeEmail")
376 )
377 ) == 5
378 and length(filter(body.links,
379 (
380 .href_url.domain.domain not in (
381 "outlook.office365.com",
382 "aka.ms",
383 "go.microsoft.com"
384 )
385 )
386 and not .href_url.domain.domain == sender.email.domain.domain
387 )
388 ) == 0
389 and subject.subject == strings.replace_confusables(subject.subject)
390 )
391
392 // negate org domains unless they fail DMARC authentication
393 and (
394 (
395 sender.email.domain.root_domain in $org_domains
396 and (
397 not headers.auth_summary.dmarc.pass
398 // MS quarantine digest emails from an org domain are router "internally" to MS, therefore, there is no authentication information
399 or not (
400 headers.auth_summary.dmarc.pass is null
401 and all(headers.domains,
402 .root_domain in ("outlook.com", "office365.com")
403 )
404 // typical emails from freemail Outlook accounts are from prod.outlook.com
405 and strings.ends_with(headers.message_id, "protection.outlook.com>")
406 )
407 )
408 )
409 or sender.email.domain.root_domain not in $org_domains
410 )
411
412 // negate highly trusted sender domains unless they fail DMARC authentication
413 and (
414 (
415 sender.email.domain.root_domain in $high_trust_sender_root_domains
416 and not headers.auth_summary.dmarc.pass
417 )
418 or sender.email.domain.root_domain not in $high_trust_sender_root_domains
419 )
420 and (
421 not profile.by_sender().solicited
422 or (
423 profile.by_sender().any_messages_malicious_or_spam
424 and not profile.by_sender().any_messages_benign
425 )
426 )
427 and not profile.by_sender().any_messages_benign
428
429 // exclude marketing jargon from ms partners
430 and not regex.icontains(body.current_thread.text,
431 '(schedul(e|ing)|set up).{0,20}(call|meeting|demo|zoom|conversation|time|tool|discussion)|book.{0,10}(meeting|demo|call|slot|time)|connect.{0,12}(with me|phone|email)|my.{0,10}(calendar|cal)|reserve.{0,10}s[pl]ot|break the ice|want to know more?|miss your chance|if you no longer wish|if you no longer want|if you wish to opt out|low-code (development|approach|solution|journey|platform)|(?:invite|virtual).{0,30}(webinar|presentation)'
432 )
433attack_types:
434 - "Credential Phishing"
435tactics_and_techniques:
436 - "Free file host"
437 - "Image as content"
438 - "Impersonation: Brand"
439 - "Social engineering"
440detection_methods:
441 - "Computer Vision"
442 - "Content analysis"
443 - "File analysis"
444 - "Header analysis"
445 - "Natural Language Understanding"
446 - "Optical Character Recognition"
447 - "Sender analysis"
448 - "URL analysis"
449id: "b59201b6-f253-55a6-9c0a-e1500a32a751"