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*&nbsp;\s*</td>\s*){2}\s*</tr>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s*&nbsp;\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*&nbsp;\s*</td>\s*){2}\s*</tr>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s*&nbsp;\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, 'M\x{00AD}ic\x{00AD}ro\x{00AD}so\x{00AD}ft')
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   or (
272     any(attachments,
273         .file_type in $file_types_images
274         and any(file.explode(.),
275                 strings.ilike(.scan.ocr.raw,
276                               "*password*",
277                               "*document*",
278                               "*voicemail*",
279                               "*cache*",
280                               "*fax*",
281                               "*storage*",
282                               "*quota*",
283                               "*messages*"
284                 )
285                 and strings.ilike(.scan.ocr.raw,
286                                   "*terminated*",
287                                   "*review*",
288                                   "*expire*",
289                                   "*click*",
290                                   "*view*",
291                                   "*exceed*",
292                                   "*clear*",
293                                   "*only works*",
294                                   "*failed*",
295                                   "*deleted*"
296                 )
297         )
298     )
299   )
300   or (
301     //
302     // This rule makes use of a beta feature and is subject to change without notice
303     // using the beta feature in custom rules is not suggested until it has been formally released
304     //
305     strings.ilike(beta.ocr(file.message_screenshot()).text,
306                   "*password*",
307                   "*document*",
308                   "*voicemail*",
309                   "*cache*",
310                   "*fax*",
311                   "*storage*",
312                   "*quota*",
313                   "*messages*"
314     )
315     and strings.ilike(beta.ocr(file.message_screenshot()).text,
316                       "*terminated*",
317                       "*review*",
318                       "*expire*",
319                       "*click*",
320                       "*view*",
321                       "*exceed*",
322                       "*clear*",
323                       "*only works*",
324                       "*failed*",
325                       "*deleted*",
326                       "*revalidated*",
327                       "*renewal*"
328     )
329   )
330   or (
331     any(ml.nlu_classifier(body.current_thread.text).intents,
332         .name == "cred_theft" and .confidence in~ ("medium", "high")
333     )
334     or any(attachments,
335            .file_type in $file_types_images
336            and any(file.explode(.),
337                    any(ml.nlu_classifier(.scan.ocr.raw).intents,
338                        .name == "cred_theft"
339                        and .confidence in ("medium", "high")
340                    )
341            )
342     )
343   )
344 )
345 and sender.email.domain.root_domain not in (
346   "bing.com",
347   "microsoft.com",
348   "microsoftonline.com",
349   "microsoftproject.com",
350   "microsoftstoreemail.com",
351   "microsoftsupport.com",
352   "microsoft365.com",
353   "office.com",
354   "office365.com",
355   "onedrive.com",
356   "sharepointonline.com",
357   "yammer.com",
358 )
359 
360 // negate legitimate Office 365 bouncebacks
361 and not (
362   length(attachments) > 0
363   and all(attachments,
364           .content_type in ("message/delivery-status", "message/rfc822")
365   )
366   and (sender.email.local_part in ('postmaster', 'mailer-daemon'))
367 )
368 
369 // negate Microsoft "welcome to the X group" notifications
370 and not (
371   headers.auth_summary.dmarc.pass
372   and length(attachments) == 6
373   and length(filter(attachments,
374                     strings.istarts_with(.file_name, "GuestWelcomeEmail")
375              )
376   ) == 5
377   and length(filter(body.links,
378                     (
379                       .href_url.domain.domain not in (
380                         "outlook.office365.com",
381                         "aka.ms",
382                         "go.microsoft.com"
383                       )
384                     )
385                     and not .href_url.domain.domain == sender.email.domain.domain
386              )
387   ) == 0
388   and subject.subject == strings.replace_confusables(subject.subject)
389 )
390 
391 // negate org domains unless they fail DMARC authentication
392 and (
393   (
394     sender.email.domain.root_domain in $org_domains
395     and (
396       not headers.auth_summary.dmarc.pass
397       // MS quarantine digest emails from an org domain are router "internally" to MS, therefore, there is no authentication information
398       or not (
399         headers.auth_summary.dmarc.pass is null
400         and all(headers.domains,
401                 .root_domain in ("outlook.com", "office365.com")
402         )
403         // typical emails from freemail Outlook accounts are from prod.outlook.com
404         and strings.ends_with(headers.message_id, "protection.outlook.com>")
405       )
406     )
407   )
408   or sender.email.domain.root_domain not in $org_domains
409 )
410 
411 // negate highly trusted sender domains unless they fail DMARC authentication
412 and (
413   (
414     sender.email.domain.root_domain in $high_trust_sender_root_domains
415     and not headers.auth_summary.dmarc.pass
416   )
417   or sender.email.domain.root_domain not in $high_trust_sender_root_domains
418 )
419 and (
420   not profile.by_sender().solicited
421   or (
422     profile.by_sender().any_messages_malicious_or_spam
423     and not profile.by_sender().any_messages_benign
424   )
425 )
426 and not profile.by_sender().any_messages_benign
427 
428 // exclude marketing jargon from ms partners
429 and not regex.icontains(body.current_thread.text,
430                         '(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)'
431 ) 
432attack_types:
433  - "Credential Phishing"
434tactics_and_techniques:
435  - "Free file host"
436  - "Image as content"
437  - "Impersonation: Brand"
438  - "Social engineering"
439detection_methods:
440  - "Computer Vision"
441  - "Content analysis"
442  - "File analysis"
443  - "Header analysis"
444  - "Natural Language Understanding"
445  - "Optical Character Recognition"
446  - "Sender analysis"
447  - "URL analysis"
448id: "b59201b6-f253-55a6-9c0a-e1500a32a751"
to-top