You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2005/02/20 20:38:16 UTC

svn commit: r154560 - in spamassassin/trunk: lib/Mail/SpamAssassin/EvalTests.pm rules/70_testing.cf

Author: felicity
Date: Sun Feb 20 11:38:15 2005
New Revision: 154560

URL: http://svn.apache.org/viewcvs?view=rev&rev=154560
Log:
more work on obfuscation eval rule.  cache REs to avoid constant rebuilding, comment more, deal with a few extra character changes, add a few more words that have been seen in spam

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
    spamassassin/trunk/rules/70_testing.cf

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm?view=diff&r1=154559&r2=154560
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm Sun Feb 20 11:38:15 2005
@@ -3324,24 +3324,53 @@
 
 ###########################################################################
 
-sub check_obfu_word {
-  my($self, $body, $word) = @_;
+{
+  my %obfu_cache = ();
 
-  my $new = $word;
-  $new =~ s/(\w)/${1}\\W+/g;
-  $new =~ s/\\W\+$//;
-  $new =~ s/a/\[a@\]/gi;
-  $new =~ s/o/\[o0\]/gi;
-  $new =~ s/i/\[i1|\]/gi;
-  $new =~ s/l/\[l1|\]/gi;
-  $new =~ s/v/(?:v|\\\/)/gi;
-
-  foreach (@{$body}) {
-    next if /\b$word\b/i;
-    return 1 if /$new/i;
-  }
+  sub check_obfu_word {
+    my($self, $body, $word) = @_;
+
+    # force lowercase since we're case insensitive anyway
+    $word = lc $word;
+
+    my $new;
+    unless ($obfu_cache{$word}) {
+      $new = $word;
+
+      # turn "foo" into "f\W*o\W*o" to match interuptus
+      # deal with character obfuscation below
+      $new =~ s/(\w)/${1}\\W*/g;
+      $new =~ s/\\W\*$//;
+
+      # 1337 speak
+      $new =~ s/a/\[a@\]/g;
+      $new =~ s/e/\[e3\]/g;
+      $new =~ s/o/\[o0\]/g;
+      $new =~ s/i/\[i1|\]/g;
+      $new =~ s/l/\[l1|\]/g;
+
+      # v -> \/
+      $new =~ s/v/(?:v|\\\/)/g;
 
-  return 0;
+      # mad skillz yo
+      $new =~ s/s$/\[sz\]/g;
+
+      # cache both the word and the new RE
+      push(@{$obfu_cache{$word}}, qr/\b$word\b/i, qr/\b$new\b/i);
+    }
+
+    # this word will be cached now, use that version
+    ($word,$new) = @{$obfu_cache{$word}};
+
+    foreach (@{$body}) {
+      if (!/$word/ && /$new/) {
+	#warn ">> $new\n$_\n\n";
+        return 1;
+      }
+    }
+
+    return 0;
+  }
 }
 
 ###########################################################################

Modified: spamassassin/trunk/rules/70_testing.cf
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/rules/70_testing.cf?view=diff&r1=154559&r2=154560
==============================================================================
--- spamassassin/trunk/rules/70_testing.cf (original)
+++ spamassassin/trunk/rules/70_testing.cf Sun Feb 20 11:38:15 2005
@@ -355,6 +355,8 @@
 body T_MALE_ENHANCE	/male enhancement/i
 body T_IMPR_STAM	/\bimprov.{1,32}stamina/i
 
+# these need to have "decently long" words.  things like "sex" FP too easily
+# in normal use, ala: "jackson's ex-wife" vs "Best S E X you"
 body T_INT_PROFIT	eval:check_obfu_word('profit')
 body T_INT_MORTGAGE	eval:check_obfu_word('mortgage')
 body T_INT_REFINANCE	eval:check_obfu_word('refinance')
@@ -363,11 +365,19 @@
 body T_INT_VIAGRA	eval:check_obfu_word('viagra')
 body T_INT_CIALIS	eval:check_obfu_word('cialis')
 body T_INT_CELEBREX	eval:check_obfu_word('celebrex')
-body T_INT_SEX		eval:check_obfu_word('sex')
 body T_INT_VICODIN	eval:check_obfu_word('vicodin')
 body T_INT_LEVITRA	eval:check_obfu_word('levitra')
 body T_INT_ERECT	eval:check_obfu_word('erection')
 body T_INT_PENIS	eval:check_obfu_word('penis')
+body T_INT_MILLION	eval:check_obfu_word('million')
+body T_INT_BILLION	eval:check_obfu_word('billion')
+body T_INT_MILF		eval:check_obfu_word('milf')
+body T_INT_PRESCRIPT	eval:check_obfu_word('prescription')
+body T_INT_PHARMACY	eval:check_obfu_word('pharmacy')
+body T_INT_PILLS	eval:check_obfu_word('pills')
+body T_INT_OFFERS	eval:check_obfu_word('offers')
+body T_INT_OBLIGATION	eval:check_obfu_word('obligation')
+body T_INT_ANXIETY	eval:check_obfu_word('anxiety')
 
 header __RATWARE_NAME_ID	eval:check_ratware_name_id()
 meta T_RATWARE_NAME_ID	__RATWARE_0_TZ_DATE && __RATWARE_NAME_ID