You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Adi Nugroho <ad...@internux.co.id> on 2009/03/05 14:31:17 UTC
how to make a custom ruleset
Dear all,
I found that a lot of spam is using recipient email address as the sender.
(from adi@internux.co.id to adi@internux.co.id, or from info@apache.org to
info@apache.org).
Since if we mail to our self, usually we have very low score, I hope it is
save to give a BIG score (probably 2 or 3).
Is there a hint how to make this custom rule set?
Re: how to make a custom ruleset
Posted by Benny Pedersen <me...@junc.org>.
On Thu, March 5, 2009 14:31, Adi Nugroho wrote:
> I found that a lot of spam is using recipient email address as the
> sender. (from adi@internux.co.id to adi@internux.co.id, or from
> info@apache.org to info@apache.org).
all this happends on domains that have no spf and or testing spf in
mta, when spf is used properly this will soon go away
> Since if we mail to our self, usually we have very low score, I hope
> it is save to give a BIG score (probably 2 or 3).
you know where you send from (ip-wise, smtp auth) there should be no
problem to make a wall on this
> Is there a hint how to make this custom rule set?
enable spf / dkim, testing spf / dkim, problem solved
http://www.openspf.org/
http://www.dkim.org/
--
http://localhost/ 100% uptime and 100% mirrored :)
Re: how to make a custom ruleset
Posted by LuKreme <kr...@kreme.com>.
On Mar 5, 2009, at 7:28, Martin Gregorie <ma...@gregorie.org> wrote:
> On Thu, 2009-03-05 at 21:31 +0800, Adi Nugroho wrote:
>> I found that a lot of spam is using recipient email address as the
>> sender.
>> (from adi@internux.co.id to adi@internux.co.id, or from info@apache.org
>> to
>> info@apache.org).
>>
> The only disadvantage is that you'll label test messages as spam.
If you allow address delimiters this is trivial to get around, just
have the email their test to user+test@example.com
>>
>>
Re: how to make a custom ruleset
Posted by Theo Van Dinter <fe...@kluge.net>.
Just fyi, this particular topic keeps getting raised here. It'd be
great if people would search the list archives. :)
One of the last times around:
http://www.nabble.com/forum/ViewPost.jtp?post=21296293&framed=y
In short, if you want to do this, write a plugin. REs are great until
you get complicated, like doing multiple headers and comparing
captured text.
SA used to have a rule that looked for from=to, but it didn't do well
and got removed. Some pointers in the above thread.
On Fri, Mar 6, 2009 at 2:44 PM, Mark Martinec <Ma...@ijs.si> wrote:
> Adi,
>
>> First, it read the sender, and put it into a variable
>> Then, it check, if the recipient is the same as that variable
>> if true, then give score 3.0
>
> The trick is to let a regexp see an entire mail header section.
> Unfortunately it means we can't reuse already parsed addresses
> in From and To header fields, but need to reparse it all in a regexp.
>
> The rules below comes close, but is not exact (the TOFROM rule
> only checks the first To). Mind the line wraps, there are three
> long lines, each starting by 'header':
>
>
> header SAME_FROMTO1 ALL =~ m{^From: (?: . | \n[\ \t] )* <\s*(.+)\s*> (?s:.*) ^To: (?: (?: "[^"]*" | \([^)]*\) |
> [\ \t]+ | \n[\ \t]+ )*? \1 [,(\ \t\n] | (?: . | \n[\ \t])* <\s*\1\s*>)}mix
> header SAME_FROMTO2 ALL =~ m{^From: (?: "[^"]*" | \([^)]*\) | [\ \t]+ | \n[\ \t]+ )* ([^<>,;\s]+\@[0-9a-z._-]+\.
> [a-z]{2,})\b (?s:.*) ^To: (?: (?: "[^"]*" | \([^)]*\) | [\ \t]+ | \n[\ \t]+ )*? \1 [,(\ \t\n] | (?: . | \n[\
> \t])* <\s*\1\s*>)}mix
> header SAME_TOFROM ALL =~ m{^To: (?: . | \n[\ \t] )* (?:\b|<) ([^<>,;\s]+\@[0-9a-z._-]+\.[a-z]{2,}) \b (?!\.)
> (?s:.*) ^From: (?: (?: "[^"]*" | \([^)]*\) | [\ \t]+ | \n[\ \t]+ )*? \1 [,(\ \t\n] | (?: . | \n[\ \t])*
> <\s*\1\s*>)}mix
> meta SAME_FROMTO SAME_FROMTO1 || SAME_FROMTO2 || SAME_TOFROM
> score SAME_FROMTO1 0.1
> score SAME_FROMTO2 0.1
> score SAME_TOFROM 0.1
> score SAME_FROMTO 1.5
>
>
> Mark
>
Re: how to make a custom ruleset
Posted by Mark Martinec <Ma...@ijs.si>.
Adi,
> First, it read the sender, and put it into a variable
> Then, it check, if the recipient is the same as that variable
> if true, then give score 3.0
The trick is to let a regexp see an entire mail header section.
Unfortunately it means we can't reuse already parsed addresses
in From and To header fields, but need to reparse it all in a regexp.
The rules below comes close, but is not exact (the TOFROM rule
only checks the first To). Mind the line wraps, there are three
long lines, each starting by 'header':
header SAME_FROMTO1 ALL =~ m{^From: (?: . | \n[\ \t] )* <\s*(.+)\s*> (?s:.*) ^To: (?: (?: "[^"]*" | \([^)]*\) |
[\ \t]+ | \n[\ \t]+ )*? \1 [,(\ \t\n] | (?: . | \n[\ \t])* <\s*\1\s*>)}mix
header SAME_FROMTO2 ALL =~ m{^From: (?: "[^"]*" | \([^)]*\) | [\ \t]+ | \n[\ \t]+ )* ([^<>,;\s]+\@[0-9a-z._-]+\.
[a-z]{2,})\b (?s:.*) ^To: (?: (?: "[^"]*" | \([^)]*\) | [\ \t]+ | \n[\ \t]+ )*? \1 [,(\ \t\n] | (?: . | \n[\
\t])* <\s*\1\s*>)}mix
header SAME_TOFROM ALL =~ m{^To: (?: . | \n[\ \t] )* (?:\b|<) ([^<>,;\s]+\@[0-9a-z._-]+\.[a-z]{2,}) \b (?!\.)
(?s:.*) ^From: (?: (?: "[^"]*" | \([^)]*\) | [\ \t]+ | \n[\ \t]+ )*? \1 [,(\ \t\n] | (?: . | \n[\ \t])*
<\s*\1\s*>)}mix
meta SAME_FROMTO SAME_FROMTO1 || SAME_FROMTO2 || SAME_TOFROM
score SAME_FROMTO1 0.1
score SAME_FROMTO2 0.1
score SAME_TOFROM 0.1
score SAME_FROMTO 1.5
Mark
Re: how to make a custom ruleset
Posted by Kai Schaetzl <ma...@conactive.com>.
Adi Nugroho wrote on Fri, 6 Mar 2009 10:40:26 +0800:
> Is there a howto about this ruleset?
http://wiki.apache.org/spamassassin/WritingRules
Kai
--
Kai Schätzl, Berlin, Germany
Get your web at Conactive Internet Services: http://www.conactive.com
Re: how to make a custom ruleset
Posted by Adi Nugroho <ad...@internux.co.id>.
On Thursday 05 March 2009 23:44:39 Benny Pedersen wrote:
> ups
>
> header SELF_FROM From =~ /\@my.address/i
> header SELF_TO To =~ /\@my.address/i
> meta SELF (SELF_FROM && SELF_TO)
> describe SELF Trap mail with forged sender the same as recipient
> score SELF 3.0
I have tried above syntax but failed.
No mail identified as SELF.
Is there a howto about this ruleset?
Re: how to make a custom ruleset
Posted by John Hardin <jh...@impsec.org>.
On Fri, 6 Mar 2009, Adi Nugroho wrote:
> It is working well, but not global (just check for my.address, and not
> for everyone).
Actually, it _is_ global, as it can only match on the domain name. Any
mail from any user in your domain to any other user in your domain will
hit this rule.
> Please help me again to teach me, how to make it a little bit different:
>
> First, it read the sender, and put it into a variable
> Then, it check, if the recipient is the same as that variable
Unfortunately this cannot be done in SpamAssassin, and adding the ability
to do that (have one rule depend on the actual text matched by another
rule rather than just whether or not that rule matched _something_) is
difficult and will likely not be done anytime soon.
This particular test - whether from == to - is something that is best done
by something outside SA.
(1) configure your MTA to reject it at SMTP time
(2) configure your MTA to reject mail claiming to be from your domain when
it's coming in from outside your network
(3) do something like write a procmail rule to check for that match and
add a customer header if it is found, then have SA add points if that
header is present (which, of course, depends on your using procmail to
glue SA into your mail system)
--
John Hardin KA7OHZ http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
Failure to plan ahead on someone else's part does not constitute
an emergency on my part. -- David W. Barts in a.s.r
-----------------------------------------------------------------------
2 days until Daylight Saving Time begins in U.S. - Spring Forward
Re: how to make a custom ruleset
Posted by Adi Nugroho <ad...@internux.co.id>.
On Thursday 05 March 2009 23:44:39 Benny Pedersen wrote:
> header SELF_FROM From =~ /\@my.address/i
> header SELF_TO To =~ /\@my.address/i
> meta SELF (SELF_FROM && SELF_TO)
> describe SELF Trap mail with forged sender the same as recipient
> score SELF 3.0
Finally I understand above rule.
First it check if the sender is my.address
then it check if the recipient is my.address
and finally, if both are true, then it give the score 3.0
Thank you.
It is working well, but not global (just check for my.address, and not for
everyone).
Please help me again to teach me, how to make it a little bit different:
First, it read the sender, and put it into a variable
Then, it check, if the recipient is the same as that variable
if true, then give score 3.0
Thank you again :)
Re: how to make a custom ruleset
Posted by Benny Pedersen <me...@junc.org>.
On Thu, March 5, 2009 17:31, John Hardin wrote:
>> header SELF_FROM From =~ /\@my.address/i
>> header SELF_TO To =~ /\@my.address/i
>
> Are you sure you want to give 1 point to each of those cases in
> addition to whatever points the meta adds?
it was not me that maked the rules, just edit them :)
> If not, then they should be named __SELF_FROM and __SELF_TO
sure
when do you stop CC me ?
--
http://localhost/ 100% uptime and 100% mirrored :)
Re: how to make a custom ruleset
Posted by John Hardin <jh...@impsec.org>.
On Thu, 5 Mar 2009, Benny Pedersen wrote:
> header SELF_FROM From =~ /\@my.address/i
> header SELF_TO To =~ /\@my.address/i
Are you sure you want to give 1 point to each of those cases in addition
to whatever points the meta adds?
If not, then they should be named __SELF_FROM and __SELF_TO
--
John Hardin KA7OHZ http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
Failure to plan ahead on someone else's part does not constitute
an emergency on my part. -- David W. Barts in a.s.r
-----------------------------------------------------------------------
3 days until Daylight Saving Time begins in U.S. - Spring Forward
Re: how to make a custom ruleset
Posted by Benny Pedersen <me...@junc.org>.
On Thu, March 5, 2009 16:27, Adi Nugroho wrote:
> describe SELF Trap mail with forged sender the same as recipient
> header SELF From =~ /\@my.address/i
> header SELF_TO To =~ /\@my.address/i
> meta SELF 5.0
ups
header SELF_FROM From =~ /\@my.address/i
header SELF_TO To =~ /\@my.address/i
meta SELF (SELF_FROM && SELF_TO)
describe SELF Trap mail with forged sender the same as recipient
score SELF 3.0
> But all mail identified as SELF :D
then it works
> Did I misunderstood something?
nope, make sure NO_RELAYS or ALL_TRUSTED have highter scores then SELF
eg:
score NO_RELAYS -3.1
or
score ALL_TRUSTED -3.1
--
http://localhost/ 100% uptime and 100% mirrored :)
Re: how to make a custom ruleset
Posted by Adi Nugroho <ad...@internux.co.id>.
On Thursday 05 March 2009 22:28:23 Martin Gregorie wrote:
> describe SELF Trap mail with forged sender the same as recipient
> header SELF From =~ /\@my.address/i
> header SELF To =~ /\@my.address/i
> meta SELF 5.0
Dear Martin,
Thank you for the rule...
I made a file self.cf in /etc/mail/spamassassin:
describe SELF Trap mail with forged sender the same as recipient
header SELF From =~ /\@my.address/i
header SELF To =~ /\@my.address/i
meta SELF 5.0
score SELF 3.0
But all mail identified as SELF :D
Did I misunderstood something?
Re: how to make a custom ruleset
Posted by Martin Gregorie <ma...@gregorie.org>.
On Thu, 2009-03-05 at 21:31 +0800, Adi Nugroho wrote:
> I found that a lot of spam is using recipient email address as the sender.
> (from adi@internux.co.id to adi@internux.co.id, or from info@apache.org to
> info@apache.org).
>
The only disadvantage is that you'll label test messages as spam.
> Since if we mail to our self, usually we have very low score, I hope it is
> save to give a BIG score (probably 2 or 3).
>
> Is there a hint how to make this custom rule set?
>
Use a meta rule:
describe SELF Trap mail with forged sender the same as recipient
header SELF From =~ /\@my.address/i
header SELF To =~ /\@my.address/i
meta SELF 5.0
This will work for a domain where internal mail is *not* scanned by SA.
Martin
Re: how to make a custom ruleset
Posted by Daniel J McDonald <da...@austinenergy.com>.
On Thu, 2009-03-05 at 21:31 +0800, Adi Nugroho wrote:
> Dear all,
>
> I found that a lot of spam is using recipient email address as the sender.
> (from adi@internux.co.id to adi@internux.co.id, or from info@apache.org to
> info@apache.org).
>
> Since if we mail to our self, usually we have very low score, I hope it is
> save to give a BIG score (probably 2 or 3).
>
> Is there a hint how to make this custom rule set?
Here's one way. I'm sure there will be many holes in this approach.
1. Define and publish SPF policies for your network.
2. Create a rule like this:
header __OUR_DOMAIN_FROM From:addr example.com
header __OUR_DOMAIN_ENVELOPE EnvelopeFrom:addr example.com
meta OUR_DOMAIN (__OUR_DOMAIN_FROM || __OUR_DOMAIN_ENVELOPE) && SPF_FAIL
describe OUR_DOMAIN claims to be from our domain but fails SPF
score OUR_DOMAIN 2.5
--
Daniel J McDonald, CCIE #2495, CISSP #78281, CNX
Austin Energy
http://www.austinenergy.com