You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

misc.lua 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. --[[
  2. Copyright (c) 2022, Vsevolod Stakhov <vsevolod@rspamd.com>
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ]]--
  13. local reconf = config['regexp']
  14. reconf['HTML_META_REFRESH_URL'] = {
  15. -- Requires options { check_attachements = true; }
  16. re = '/<meta\\s+http-equiv="refresh"\\s+content="\\d+\\s*;\\s*url=/{sa_raw_body}i',
  17. description = "Has HTML Meta refresh URL",
  18. score = 5.0,
  19. one_shot = true,
  20. group = 'HTML'
  21. }
  22. reconf['HAS_DATA_URI'] = {
  23. -- Requires options { check_attachements = true; }
  24. re = '/data:[^\\/]+\\/[^; ]+;base64,/{sa_raw_body}i',
  25. description = "Has Data URI encoding",
  26. group = 'HTML',
  27. one_shot = true,
  28. }
  29. reconf['DATA_URI_OBFU'] = {
  30. -- Requires options { check_attachements = true; }
  31. re = '/data:text\\/(?:plain|html);base64,/{sa_raw_body}i',
  32. description = "Uses Data URI encoding to obfuscate plain or HTML in base64",
  33. group = 'HTML',
  34. one_shot = true,
  35. score = 2.0
  36. }
  37. reconf['INTRODUCTION'] = {
  38. re = '/\\b(?:my name is\\b|(?:i am|this is)\\s+(?:mr|mrs|ms|miss|master|sir|prof(?:essor)?|d(?:octo)?r|rev(?:erend)?)(?:\\.|\\b))/{sa_body}i',
  39. description = "Sender introduces themselves",
  40. score = 2.0,
  41. one_shot = true,
  42. group = 'scams'
  43. }
  44. -- Message contains a link to a .onion URI (Tor hidden service)
  45. local onion_uri_v2 = '/[a-z0-9]{16}\\.onion?/{url}i'
  46. local onion_uri_v3 = '/[a-z0-9]{56}\\.onion?/{url}i'
  47. reconf['HAS_ONION_URI'] = {
  48. re = string.format('(%s | %s)', onion_uri_v2, onion_uri_v3),
  49. description = 'Contains .onion hidden service URI',
  50. score = 0.0,
  51. group = 'experimental'
  52. }
  53. local my_victim = [[/(?:victim|prey)/{words}]]
  54. local your_webcam = [[/webcam/{words}]]
  55. local your_onan = [[/(?:mast[ur]{2}bati(?:on|ng)|onanism|solitary)/{words}]]
  56. local password_in_words = [[/^pass(?:(?:word)|(?:phrase))$/i{words}]]
  57. local btc_wallet_address = [[has_symbol(BITCOIN_ADDR)]]
  58. local wallet_word = [[/^wallet$/{words}]]
  59. local broken_unicode = [[has_flag(bad_unicode)]]
  60. local list_unsub = [[header_exists(List-Unsubscribe)]]
  61. local x_php_origin = [[header_exists(X-PHP-Originating-Script)]]
  62. reconf['LEAKED_PASSWORD_SCAM_RE'] = {
  63. re = string.format('%s & (%s | %s | %s | %s | %s | %s | %s | %s | %s)',
  64. btc_wallet_address, password_in_words, wallet_word,
  65. my_victim, your_webcam, your_onan,
  66. broken_unicode, 'lua:check_data_images',
  67. list_unsub, x_php_origin),
  68. description = 'Contains BTC wallet address and malicious regexps',
  69. functions = {
  70. check_data_images = function(task)
  71. local tp = task:get_text_parts() or {}
  72. for _,p in ipairs(tp) do
  73. if p:is_html() then
  74. local hc = p:get_html()
  75. if hc and hc:has_property('data_urls') then
  76. return true
  77. end
  78. end
  79. end
  80. return false
  81. end
  82. },
  83. score = 0.0,
  84. group = 'scams'
  85. }
  86. rspamd_config:register_dependency('LEAKED_PASSWORD_SCAM', 'BITCOIN_ADDR')