Re: [Mimedefang] Rejecting Cyrillic

2009-04-16 Thread Kevin A. McGrail

Richard,

I've been looking at this and the code seems to work but I wonder if you 
can't achieve the same result with just a regexp:


if ($Subject =~ /=\?(koi8-r|Windows-1251)\?/i) {
}

I've included a test stub below to show this information based on these code 
pages:


http://en.wikipedia.org/wiki/CP1251
http://en.wikipedia.org/wiki/KOI8-R

Additionally, I'm wondering if you have looked at the SpamAssassin Plug 
TextCat and enabled it in v310.pre.


# TextCat - language guesser
#
loadplugin Mail::SpamAssassin::Plugin::TextCat


Then add something like this to your local config

ok_locales  en
ok_languagesen

man Mail::SpamAssassin::Plugin::TextCat  for more information.


Anyway, here's the quick modifications I ran to look at this with two test 
subjects I found.  NOTE: If you understand these languages, please don't 
blame me for the content.  I have no idea what they say.


use Encode;
use MIME::Words;


$Subject[0] = "Subject: 
=?gb2312?B?v+y93dans9ajrM341b7T0LXAIKGqIM73w8XX07y8yvXWp7PW0+u3/g==?=

   =?gb2312?B?zvHN+NW+zqrE+szhuam0tNDCt/7O8Q==?=";

$Subject[1] = "Subject: 
=?koi8-r?B?8sHT0NLPxMHWwSDP0snHyc7BzNjO2cgg0sXQzMnLIN7B08/XLiDw0g==?=

   =?koi8-r?B?ySDL1dLTxSAxIMTPzMzB0iA9IDI1INLVwszFyiwg3sHT2SDT1M/R1A==?=
   =?koi8-r?B?IM3FztjbxSAxMCDU2dPR3i4g88HK1CDLz9DJyjo=?=";

$Subject[2] = "Subject: 
=?Windows-1251?B?IP3r5ezl7fL7IPPx7+X47e7pIO/w5efl7fLg9ujo?=";


foreach $Subject (@Subject) {

if ($Subject =~ /=\?(koi8-r|Windows-1251)\?/i) {
 print "DEBUG: Cyrillic Test 1\n";
}

if ($Subject =~ m/=\?.+\?.+\?.+\?=/) {
   my $decoded_subject = "";
   foreach my $pair (MIME::Words::decode_mimewords($Subject))
   {
   if (defined($pair->[1]) && $pair->[1] ne "")
   {
   $decoded_subject .= decode($pair->[1], $pair->[0]);
   }
   else
   {
   $decoded_subject .= decode("us-ascii", $pair->[0]);
   }
   }

   if ($decoded_subject =~ m/\p{Cyrillic}/)
   {
   # DO SOMETHING HERE: REJECT, ETC.
   print "DEBUG: Cyrillic Test 2\n";
   }
}
}

___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang


Re: [Mimedefang] Rejecting Cyrillic

2009-04-16 Thread Richard Laager
On Wed, 2009-03-25 at 12:46 -0700, Kenneth Porter wrote:
> I've noticed a lot of spam lately in codepage Windows-1251 (Cyrillic). I'd 
> like to reject it with a "Cyrillic not understood; please resubmit as 
> Unicode". Is there a canonical MIMEDefang idiom for doing that?

I wanted to do largely the same thing and finally found the time to
write it. I was concerned only with Cyrillic subjects as the indicator
of spam. I put the code below in filter_end(), except for the "use"
statements, which I put at the top with the others. In my filter, I
added points to the SpamAssassin score, but you could call
action_bounce() if you wanted.

I don't know if it's strictly necessary to call decode with "us-ascii".
I did it because I was concerned about Perl's internal handling of bytes
vs. characters.

Any feedback on this code would be greatly appreciated.

Richard



use Encode;
use MIME::Words;

if ($Subject =~ m/=\?.+\?.+\?.+\?=/)
{
my $decoded_subject = "";
foreach my $pair (MIME::Words::decode_mimewords($Subject))
{
if (defined($pair->[1]) && $pair->[1] ne "")
{
$decoded_subject .= decode($pair->[1], $pair->[0]);
}
else
{
$decoded_subject .= decode("us-ascii", $pair->[0]);
}
}

if ($decoded_subject =~ m/\p{Cyrillic}/)
{
# DO SOMETHING HERE: REJECT, ETC.
}
}


signature.asc
Description: This is a digitally signed message part
___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang


Re: [Mimedefang] Stripping attachments only from bounce emails

2009-04-16 Thread Joseph Brennan


"Conan ."  wrote:


Hi,
Is it possible to tell mimedefang to stip banned attachments but only
from bounce messages?





if ($Sender eq '<>') {
# statements to strip attachments
}


That will get bounces from standards-compliant systems anyway.  There
are a few odd systems around that send DSNs with non-null senders.


Joseph Brennan
Lead Email Systems Engineer
Columbia University Information Technology



___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang


[Mimedefang] Stripping attachments only from bounce emails

2009-04-16 Thread Conan .
Hi,
Is it possible to tell mimedefang to stip baned attachments but only
from bounce messages? I want to prevent situations where emails sent
out from users of one of my domains get bounced back to me for
containing banned attachment, but the bounce never gets back to the
user on my network because my mimedefang rejects the bounce message as
it contains the original banned file. Currently I have an exception
for my SMTP servers to allow them to send any type of attachment. I
only scan incoming emails.

Thanks,
Tom
___
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang