home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 April / Chip_2003-04_cd1.bin / tema / internet / spam / download / sweas / sweasx86.exe / %MAINDIR% / spamfltr / system.sfr < prev    next >
Encoding:
Text File  |  2003-02-24  |  19.3 KB  |  635 lines

  1. // -------------------------------------------------------------------
  2. // MailGate SpamWeasel Filter Rules - Version 1.002 - May 2001
  3. //
  4. // This file contains the spam filter system rules.
  5. // DO NOT EDIT THIS FILE as updates will overwrite any changes you make.
  6. // Updates to these rules are available for download on our website.
  7. // Vist http://www.mailgate.com to check out the latest version.
  8. // -------------------------------------------------------------------
  9.  
  10. // -------------------------------------------------------------------
  11. // Section 1 - Rules to positively identify Non Spam mails and
  12. // definite Spam using user defined lists.
  13. // -------------------------------------------------------------------
  14.  
  15. // -------------------------------------------------------------------
  16. #rule "Pass if From listed in 'Friendly From Addresses'"
  17. //
  18. // This rule checks the mail From: address and marks the mail as
  19. // Not Spam if the sender is listed in the 'Friendly From Addresses'
  20. // pattern list. You should add your own friendly addresses to this
  21. // list in the patterns tab so your friends emails are always passed.
  22. //
  23.  
  24. from$ = ParseAddress(HeaderFieldValue("From"))
  25. if MatchesListItem("Friendly From Addresses",from$) then
  26.    IsOK()
  27. endif
  28.  
  29. #endrule
  30.  
  31. // -------------------------------------------------------------------
  32. #rule "Spam if From listed in 'Unfriendly From Addresses'"
  33. //
  34. // This rule checks the mail From: address and marks the mail as
  35. // Spam if the sender is listed in the 'Unfriendly From Addresses'
  36. // pattern list.
  37. // If you are troubled by regular mails from known sources, like
  38. // unwanted lists, which you can not unsubscribe from you can add
  39. // these addresses to this list to block these mails.
  40. //
  41.  
  42. from$ = ParseAddress(HeaderFieldValue("From"))
  43. if MatchesListItem("Unfriendly From Addresses",from$) then
  44.    IsSpam()
  45. endif
  46.  
  47. #endrule
  48.  
  49. // -------------------------------------------------------------------
  50. #rule "Spam if To or Cc address is not found in 'My Addresses'"
  51. //
  52. // This rule checks the addresses in the To: and/or CC: fields
  53. // against the 'My Addresses' patterns list. Mail marked as Spam
  54. // if a match is NOT found otherwise the mail is passed on for
  55. // further checks.
  56. // TIP - You should enable either this rule or the similar rule
  57. //  "Pass if To or Cc address is found in 'My Addresses'".
  58. // This rule can be useful to seperate out mails sent to general
  59. // addresses and not to your to personal addresses.
  60. //
  61.  
  62. addr$ = GetFirstAddress("To")
  63.  
  64. :loop
  65.     if length(addr$) = 0 then loopend:
  66.     if MatchesListItem("My Addresses",addr$) then goto notspam:
  67.     addr$ = GetNextAddress()
  68.     goto loop:
  69. :loopend
  70.  
  71. addr$ = GetFirstAddress("Cc")
  72. :loop2
  73.     if length(addr$) = 0 then loopend2:
  74.     if MatchesListItem("My Addresses",addr$) then goto notspam:
  75.     addr$ = GetNextAddress()
  76.     goto loop2:
  77. :loopend2
  78.  
  79. IsSpam()
  80.  
  81. :notspam
  82.  
  83. #endrule
  84.  
  85. // -------------------------------------------------------------------
  86. #rule "Pass if To or Cc address is found in 'My Addresses'"
  87. //
  88. // This rule checks the addresses in the To: and/or CC: fields
  89. // against the 'My Addresses' patterns list. Mail passes as NOT Spam
  90. // if a match IS found otherwise the mail is passed on for further
  91. // checks.
  92. // Note - If you use this rule and a match is not found the mail
  93. // may still pass if none of the other rules identify it as spam.
  94. // TIP - You should enable either this rule or the similar rule
  95. //  "Spam if To and Cc addresses are not found in 'My Addresses'"
  96. // This rule can be useful to seperate mail addressed to a personal
  97. // address from mail using a more general address
  98. // like 'info@mydomain.com'.
  99. //
  100.  
  101. addr$ = GetFirstAddress("To")
  102.  
  103. :loop
  104.     if length(addr$) = 0 then loopend:
  105.     if MatchesListItem("My Addresses",addr$) then goto notspam:
  106.     addr$ = GetNextAddress()
  107.     goto loop:
  108. :loopend
  109.  
  110. addr$ = GetFirstAddress("Cc")
  111. :loop2
  112.     if length(addr$) = 0 then loopend2:
  113.     if MatchesListItem("My Addresses",addr$) then goto notspam:
  114.     addr$ = GetNextAddress()
  115.     goto loop2:
  116. :loopend2
  117.  
  118. goto end:
  119.  
  120. :notspam
  121. IsOK()
  122.  
  123. :end
  124.  
  125. #endrule
  126.  
  127. // -------------------------------------------------------------------
  128. #rule "Pass if Subject listed in 'Friendly Subjects'"
  129. //
  130. // This rule checks the mail Subject: field and marks the mail as
  131. // Not Spam if the subject is listed in the 'Friendly Subject'
  132. // pattern list.
  133. //
  134.  
  135. field$ = HeaderFieldValue("Subject")
  136. if MatchesListItem("Friendly Subjects",field$) then
  137.    IsOk()
  138. endif
  139.  
  140. #endrule
  141.  
  142. // -------------------------------------------------------------------
  143. // Section 2 - Rules to check mail header integrity.
  144. // -------------------------------------------------------------------
  145.  
  146. // -------------------------------------------------------------------
  147. #rule "Check for valid Message-Id:"
  148. //
  149. // This rule checks that the Message-Id: field follows the RFC standards
  150. // guidelines. Spam mail with a fake mail header may have a false
  151. // Message-Id.
  152. // Mail is marked as Spam if the check fails.
  153. //
  154.  
  155. field$ = HeaderFieldValue("Message-Id")
  156. if not WildcardMatch(field$,"<*@*>*") then
  157.    IsSpam()
  158. endif
  159.  
  160. #endrule
  161.  
  162. // -------------------------------------------------------------------
  163. #rule "Check for blank or missing From: field"
  164. //
  165. // This rule checks that the From field both exists and is not blank.
  166. // Mail is marked as Spam if the check fails.
  167. //
  168.  
  169. if not HeaderFieldExists("From") then
  170.    IsSpam()
  171. endif
  172. if HeaderFieldValue("From") = "" then
  173.    IsSpam()
  174. endif
  175.  
  176. #endrule
  177.  
  178. // -------------------------------------------------------------------
  179. #rule "Check for blank or missing To: field"
  180. //
  181. // This rule checks that the To: field both exists and is not blank.
  182. // Mail is marked as Spam if the check fails.
  183. //
  184.  
  185. if not HeaderFieldExists("To") then
  186.    IsSpam()
  187. endif
  188. if HeaderFieldValue("To") = "" then
  189.    IsSpam()
  190. endif
  191.  
  192. #endrule
  193.  
  194. // -------------------------------------------------------------------
  195. #rule "Check Date: field is present and valid"
  196. //
  197. // This rule checks the Date: field both exists and is valid.
  198. // Mail is marked as Spam if the check fails.
  199. //
  200.  
  201. if not IsValidDate(HeaderFieldValue("Date")) then
  202.    IsSpam()
  203. endif
  204.  
  205. #endrule
  206.  
  207. // -------------------------------------------------------------------
  208. #rule "Check for all zero IP address"
  209. //
  210. // This rule checks for an all zero IP address appearing in the mail
  211. // header Received ... for... section.
  212. // This section of the mail header records the path a mail has taken
  213. // through the Internet and will normally record the IP addresses of
  214. // the servers used. All zero IP addresses indicates the header data
  215. // is fake.
  216. // Mail is marked as Spam if a match is found.
  217. //
  218.  
  219. if WildcardMatchHeader("*^Received:*0.0.0.0*") then goto spam:
  220. if WildcardMatchHeader("*^Received:*000.000.000.000*") then goto spam:
  221. goto notspam:
  222.  
  223. :spam
  224. IsSpam()
  225.  
  226. :notspam
  227.  
  228. #endrule
  229.  
  230. // -------------------------------------------------------------------
  231. // Section 3 - Rules to check if typical Spam mail header fields
  232. //             exist or contain known Spam markers.
  233. // -------------------------------------------------------------------
  234.  
  235. // -------------------------------------------------------------------
  236. #rule "Check X-Mailer: field for bulk emailer programs"
  237. //
  238. // This rule checks the X-mailer: field for a match against known
  239. // bulk email programs in the 'Bulk Emailer Programs' list.
  240. // X-Mailer: generally contains a reference to the email software
  241. // used to create the mail so this rule can identify mail sent
  242. // by Bulk or Spam mail creation programs.
  243. // Mail is marked as Spam if a match is found.
  244. //
  245.  
  246. Field$ = HeaderFieldValue("X-mailer")
  247. if MatchesListItem("Bulk Emailer Programs",field$) then
  248.    IsSpam()
  249. endif
  250.  
  251. #endrule
  252.  
  253. // -------------------------------------------------------------------
  254. #rule "Check header for matches listed in 'Definite Spam Markers'"
  255. //
  256. // This rule checks the header generally for the existence of
  257. // matches with the contents of the list 'Definite Spam Markers'.
  258. // Mail is marked as Spam if a match is found.
  259. // This list contain pattern matches for known spam mail and this
  260. // rule should normally be given a high priority setting.
  261. //
  262.  
  263. if HeaderMatchesListItem("Definite Spam Markers") then
  264.    IsSpam()
  265. endif
  266.  
  267. #endrule
  268.  
  269. // -------------------------------------------------------------------
  270. #rule "Check header for matches listed in 'Likely Spam Markers'"
  271. //
  272. // This rule checks the header generally for the existence of
  273. // matches with the contents of the list 'Likely Spam Markers'.
  274. // Mail is marked as Spam if a match is found.
  275. // This list contain pattern matches for probable spam mail and
  276. // this rule should normally be given a lower priority setting.
  277. //
  278.  
  279. if HeaderMatchesListItem("Likely Spam Markers") then
  280.    IsSpam()
  281. endif
  282.  
  283. #endrule
  284.  
  285. // -------------------------------------------------------------------
  286. #rule "Check if X-BulkEmail: header field exists"
  287. //
  288. // This rule checks to see if the header field BulkEmail: exists.
  289. // Mail is marked as Spam if it is found.
  290. // Note - There is more than one way for doing this type of check.
  291. // See "Check if X-Advertisement: header field exists" for an
  292. // alternative scripting method.
  293. //
  294.  
  295. if HeaderFieldExists("X-BulkEmail") then
  296.    IsSpam()
  297. endif
  298.  
  299. #endrule
  300.  
  301. // -------------------------------------------------------------------
  302. #rule "Check if X-Authentication-Warning: header field exists"
  303. //
  304. // This rule checks to see if the header field
  305. // X-Authentication-Warning: exists. Mail is marked as Spam if it
  306. // is found.
  307. // Note - There is more than one way for doing this type of check.
  308. // See "Check if X-Advertisement: header field exists" for an
  309. // alternative scripting method.
  310. //
  311.  
  312. if HeaderFieldExists("X-Authentication-Warning") then
  313.    IsSpam()
  314. endif
  315.  
  316. #endrule
  317.  
  318. // -------------------------------------------------------------------
  319. #rule "Check if X-Advertisement: header field exists"
  320. //
  321. // This rule checks to see if the header field X-Advetisement: exists.
  322. // Mail is marked as Spam if it is found.
  323. // Note - There is more than one way for doing this type of check.
  324. // See "Check if X-Authentication-Warning: header field exists" for an
  325. // alternative scripting method. Note the use of ^ to define the
  326. // start of a new line in the data in this rule.
  327. //
  328.  
  329. if WildcardMatchHeader("*^X-Adverti[zs]e*") then
  330.    IsSpam()
  331. endif
  332.  
  333. #endrule
  334.  
  335. // -------------------------------------------------------------------
  336. #rule "Check Mail Header for 'Likely Spam Words'"
  337. //
  338. // This rule checks the mail header for any of the words in the
  339. // 'Likely Spam Words' word list.
  340. // Mail is marked as Spam if a match is found.
  341. //
  342.  
  343. if FindWordInHeader("Likely Spam Words") then
  344.    IsSpam()
  345. endif
  346.  
  347. #endrule
  348.  
  349. // -------------------------------------------------------------------
  350. // Section 4 - Rules for more general checks on the mail
  351. //             addresses used.
  352. // -------------------------------------------------------------------
  353.  
  354. // -------------------------------------------------------------------
  355. #rule "Check To/Cc addresses against 'Spam Domain Patterns'"
  356. //
  357. // This rule checks the To/Cc fields for a match against the
  358. // 'Spam domain patterns' list. These domains are typically found in
  359. // the addresses used in false mail headers.
  360. // Mail is marked as Spam if a match is found.
  361. //
  362.  
  363. if MatchesListItem("Spam domain patterns",HeaderFieldValue("To")) then goto spam:
  364. if MatchesListItem("Spam domain patterns",HeaderFieldValue("Cc")) then goto spam:
  365. goto notspam:
  366.  
  367. :spam
  368. IsSpam()
  369.  
  370. :notspam
  371.  
  372. #endrule
  373.  
  374. // -------------------------------------------------------------------
  375. #rule "Check From: against valid 'Root domains'"
  376. //
  377. // This rule checks the address in the From: field against the
  378. // valid 'Root domains' patterns list. This will identify if a false
  379. // From address has been used.
  380. // Mail is marked as Spam if a valid domain match is not found.
  381. //
  382.  
  383. field$ = ParseAddress(HeaderFieldValue("From"))
  384. if not MatchesListItem("Root domains",field$) then
  385.    IsSpam()
  386. endif
  387.  
  388. #endrule
  389.  
  390. // -------------------------------------------------------------------
  391. #rule "Check From: against 'Known Spammer From addresses'"
  392. //
  393. // This rule checks the From: address against the list of
  394. // 'Known Spammer From addresses'.
  395. // Mail is marked as Spam if a match is found.
  396. //
  397.  
  398. field$ = ParseAddress(HeaderFieldValue("From"))
  399. if MatchesListItem("Known Spammer From addresses",field$) then
  400.    IsSpam()
  401. endif
  402.  
  403. #endrule
  404.  
  405. // -------------------------------------------------------------------
  406. #rule "Check all addresses for 'friend@public'"
  407. //
  408. // This rule checks for 'friend@public' appearing in any of the addressing
  409. // fields. Existence of this indicates a false mail header.
  410. // Mail is marked as spam if it is found.
  411. //
  412.  
  413. if WildcardMatch(HeaderFieldValue("To"),"*friend@public.*") then goto spam:
  414. if WildcardMatch(HeaderFieldValue("From"),"*friend@public.*") then goto spam:
  415. if WildcardMatch(HeaderFieldValue("Reply-To"),"*friend@public.*") then goto spam:
  416. if WildcardMatch(HeaderFieldValue("X-Reply-To"),"*friend@public.*") then goto spam:
  417.  
  418. goto notspam:
  419.  
  420. :spam
  421. IsSpam()
  422.  
  423. :notspam
  424.  
  425. #endrule
  426.  
  427. // -------------------------------------------------------------------
  428. #rule "Check From: for an account ending in a number"
  429. //
  430. // This rule checks the From: field for an email address user part that
  431. // ends with a number. Spam quite often originates from mail accounts
  432. // with the large portals which use this style of account name.
  433. // Mail is marked as Spam if a match is found.
  434. //
  435.  
  436. field$ = ParseAddress(HeaderFieldValue("From"))
  437. if WildcardMatch(field$,"*[0-9]@*") then
  438.    IsSpam()
  439. endif
  440.  
  441. #endrule
  442.  
  443. // -------------------------------------------------------------------
  444. // Section 5 - Subject analysis rules to check for typical
  445. // Spam characteristics. These rules are the least accurate method of
  446. // identifying Spam and should be used with care.
  447. // -------------------------------------------------------------------
  448.  
  449. // -------------------------------------------------------------------
  450. #rule "Check if Subject: is all uppercase"
  451. //
  452. // This rules checks the Subject: field for all uppercase characters.
  453. // This is typical of Spam mail. Mail is marked as Spam if all uppercase
  454. // characters are found.
  455. //
  456.  
  457. field$ = HeaderFieldValue("Subject")
  458. if (field$ = Upper(field$)) and (Length(field$) > 0) then
  459.    IsSpam()
  460. endif
  461.  
  462. #endrule
  463.  
  464. // -------------------------------------------------------------------
  465. #rule "Check that the Subject: is not a question"
  466. //
  467. // This rule checks the Subject for a '?' character.
  468. // Marks the mail as spam if it is found.
  469. //
  470.  
  471. if WildcardMatch(HeaderFieldValue("Subject"),"*\?") then
  472.    IsSpam()
  473. endif
  474.  
  475. #endrule
  476.  
  477. // -------------------------------------------------------------------
  478. #rule "Check the Subject: against 'Money Patterns'"
  479. //
  480. // This rule checks the Subject against the 'Money patterns' list.
  481. // Money patterns are typical of commercial advert mails.
  482. // Mail is marked as Spam if a match is found.
  483. // NOTE - Some mail clients convert international 'Money' characters
  484. // into encoded phrases to resolve issues with differing character
  485. // sets. This can lead to matches not being made when expected.
  486. //
  487.  
  488. field$ = HeaderFieldValue("Subject")
  489. if MatchesListItem("Money patterns",field$) then
  490.    IsSpam()
  491. endif
  492.  
  493. #endrule
  494.  
  495. // -------------------------------------------------------------------
  496. #rule "Check the Subject: against 'Usual Spam Subject Phrases'"
  497. //
  498. // This rule checks the Subject for a match against the
  499. // 'Usual Spam Subject Phrases' list. Mail is marked as Spam if
  500. // a match is found.
  501. //
  502.  
  503. field$ = HeaderFieldValue("Subject")
  504. if MatchesListItem("Usual spam subject phrases",field$) then
  505.    IsSpam()
  506. endif
  507.  
  508. #endrule
  509.  
  510. // -------------------------------------------------------------------
  511. #rule "Check the Subject: against 'Usual Spam Subject Words'"
  512. //
  513. // This rule checks the Subject for a match against the
  514. // 'Usual Spam Subject Words' list. Mail is marked as Spam if
  515. // a match is found.
  516. //
  517.  
  518. field$ = HeaderFieldValue("Subject")
  519. if FindWordInString("Usual Spam Subject Words",field$) then
  520.    IsSpam()
  521. endif
  522.  
  523. #endrule
  524.  
  525. // -------------------------------------------------------------------
  526. #rule "Check the Subject: against 'Adult Words'"
  527. //
  528. // This rule checks the Subject for a match against the 'Adult words'
  529. // list. Mail is marked as Spam if a match is found.
  530. //
  531.  
  532. field$ = HeaderFieldValue("Subject")
  533. if FindWordInString("Adult Words",field$) then
  534.    IsSpam()
  535. endif
  536.  
  537. #endrule
  538.  
  539. // -------------------------------------------------------------------
  540. // Section 6 - Mail Body analysis rules to check for typical
  541. // Spam characteristics. These rules are the least accurate method of
  542. // identifying Spam and should be used with care.
  543. // -------------------------------------------------------------------
  544.  
  545. // -------------------------------------------------------------------
  546. #rule "Check Mail Body for 'Usual Spam Message Phrases'"
  547. //
  548. // This rule checks the mail body for any of the phrases in the
  549. // 'Usual spam message phrases' list. Mail is marked as Spam if
  550. // a match is found.
  551. //
  552.  
  553. if BodyMatchesListItem("Usual spam message phrases") then
  554.    IsSpam()
  555. endif
  556.  
  557. #endrule
  558.  
  559. // -------------------------------------------------------------------
  560. #rule "Check Mail Body for 'Adult Words'"
  561. //
  562. // This rule checks the mail body for any of the words in the
  563. // 'Adult Words' word list. Mail is marked as Spam if
  564. // a match is found.
  565. //
  566.  
  567. if FindWordInBody("Adult Words") then
  568.    IsSpam()
  569. endif
  570.  
  571. #endrule
  572.  
  573. // -------------------------------------------------------------------
  574. #rule "Check Mail Body GUARANTEE in capitals"
  575. //
  576. // This rule check the mail body for the word GUARANTEE (in uppercase).
  577. // Mail is marked as Spam if a match is found.
  578. //
  579.  
  580. if WildcardMatchBody("*[G][U][A][R][A][N][T][E][E]*") then
  581.    IsSpam()
  582. endif
  583.  
  584. #endrule
  585.  
  586. // -------------------------------------------------------------------
  587. #rule "Check Mail Body for BILLION/MILLION in capitals"
  588. //
  589. // This rule check the mail body for the words BILLION or MILLION
  590. // (in uppercase).  Mail is marked as Spam if a match is found.
  591. //
  592.  
  593. if WildcardMatchBody("*[BM][I][L][L][I][O][N]*") then
  594.    IsSpam()
  595. endif
  596.  
  597. #endrule
  598.  
  599. // -------------------------------------------------------------------
  600. #rule "Check Mail Body for FREE in capitals"
  601. //
  602. // This rule check the mail body for the word FREE (in uppercase).
  603. // Mail is marked as Spam if a match is found.
  604. //
  605.  
  606. if WildcardMatchBody("*[F][R][E][E]*") then
  607.    IsSpam()
  608. endif
  609.  
  610. #endrule
  611.  
  612. // -------------------------------------------------------------------
  613. // Section 7 - Using Mail Body analysis rules to check for undesirable
  614. // attachments. Note this should be used in conjunction with other
  615. // Anti-Virus measures.
  616. // -------------------------------------------------------------------
  617.  
  618. // -------------------------------------------------------------------
  619. #rule "Check Mail Body for 'Undesirable Attachment Marks'"
  620. //
  621. // This rule checks the mail body for a match with patterns in the
  622. // 'Undesirable Attachment Marks' list. This method should not be
  623. // treated as your primary defence against viruses, but can assist
  624. // in an overall strategy. 
  625. // Mail is marked as Spam if a match is found.
  626. //
  627.  
  628. if BodyMatchesListItem("Undesirable Attachment Marks") then
  629.    IsSpam()
  630. endif
  631.  
  632. #endrule
  633.  
  634.  
  635.