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