You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Ruben Cardenal <ru...@ruben.cn> on 2006/02/26 11:45:45 UTC
I catch all this spam, but just for curiosity...
Hi,
There's lately a bunch of new spam who has "Fw: 12345" in the subject (for
example). All this spam dies nicely with Bayes and other regular rules. I'd
like to know, anyway, how could I write a rule that would catch it. This
spam has a common element for every one of its mails. For example, for those
mails whose subject has "Fw: 123456"
In the headers of the mail:
To: john@domain.com
Subject: /^Fw:\s\d{3,6}$/
In the body of the mail:
/^Subject:\sjohn$/
How could a rule score catch those 3 things at a time? I know how to do it
for the headers part (someone in this lists told me how), but I don't know
how to relate that line of the body with the "To" part of the headers. I
mean, the "john" word in that line of the body matches the "john" word in
the "To". I hope I've explained myself enough :) Thanks for any suggestions
about this.
Ruben
RE: I catch all this spam, but just for curiosity...
Posted by Ruben Cardenal <ru...@ruben.cn>.
Thanks Matt, I was curious, your explanation is enough :)
Ruben.
> -----Mensaje original-----
> De: Matt Kettler [mailto:mkettler_sa@comcast.net]
> Enviado el: domingo, 26 de febrero de 2006 17:01
> Para: Ruben Cardenal
> CC: Spamassassin
> Asunto: Re: I catch all this spam, but just for curiosity...
>
> Ruben Cardenal wrote:
> >
> > How could a rule score catch those 3 things at a time? I know how to
> do it
> > for the headers part (someone in this lists told me how), but I don't
> know
> > how to relate that line of the body with the "To" part of the headers. I
> > mean, the "john" word in that line of the body matches the "john" word
> in
> > the "To". I hope I've explained myself enough :) Thanks for any
> suggestions
> > about this.
>
> Correlating headers to body text can be done, but it's not practical...
>
> 1) you can use a "full" rule with the /s option and backtracking (i.e.
> \1). This is *horribly* slow, and memory hungry. For a non-matching
> message SA is going to have to check every byte of the complete message,
> including all attachments. Backreferences are expensive, that's why we
> normally use (:? instead of ( for most things. Full rules are expensive.
> Put the two together and you have a very expensive rule.
>
> 2) you can write a perl plugin for spamassassin that does this.
> Unfortunately, this is a fair amount of work.
>
> Given 1 and 2, this generally isn't very practical. It's certainly not
> practical enough to be worth the effort when there are better ways.
>
> Realistically, I'd be more apt to try to match the presence of a short
> "Subject" header in the body text and meta that with the numeric real
> subject header.
Re: I catch all this spam, but just for curiosity...
Posted by Matt Kettler <mk...@comcast.net>.
Ruben Cardenal wrote:
>
> How could a rule score catch those 3 things at a time? I know how to do it
> for the headers part (someone in this lists told me how), but I don't know
> how to relate that line of the body with the "To" part of the headers. I
> mean, the "john" word in that line of the body matches the "john" word in
> the "To". I hope I've explained myself enough :) Thanks for any suggestions
> about this.
Correlating headers to body text can be done, but it's not practical...
1) you can use a "full" rule with the /s option and backtracking (i.e.
\1). This is *horribly* slow, and memory hungry. For a non-matching
message SA is going to have to check every byte of the complete message,
including all attachments. Backreferences are expensive, that's why we
normally use (:? instead of ( for most things. Full rules are expensive.
Put the two together and you have a very expensive rule.
2) you can write a perl plugin for spamassassin that does this.
Unfortunately, this is a fair amount of work.
Given 1 and 2, this generally isn't very practical. It's certainly not
practical enough to be worth the effort when there are better ways.
Realistically, I'd be more apt to try to match the presence of a short
"Subject" header in the body text and meta that with the numeric real
subject header.
RE: I catch all this spam, but just for curiosity...
Posted by Ruben Cardenal <ru...@ruben.cn>.
Marco,
Thanks, but I already know how to write meta rules :) That's not what I'm
asking. My example lines are not textual lines, but the form that spam
takes. It's not that simple.
Ruben.
> -----Mensaje original-----
> De: Marco Maske [mailto:maskemarco@netcologne.de]
> Enviado el: domingo, 26 de febrero de 2006 12:28
> Para: users@spamassassin.apache.org
> Asunto: Re: I catch all this spam, but just for curiosity...
>
> Ruben Cardenal wrote:
>
> > To: john@domain.com
> > Subject: /^Fw:\s\d{3,6}$/
> >
> > In the body of the mail:
> >
> > /^Subject:\sjohn$/
> >
> > How could a rule score catch those 3 things at a time? I know how to
> > do it for the headers part (someone in this lists told me how), but I
> > don't know how to relate that line of the body with the "To" part of
> > the headers. I mean, the "john" word in that line of the body matches
> > the "john" word in the "To". I hope I've explained myself enough :)
>
> If I understand you right, then you want a meta Rule:
> First the rules for meta must start with "__":
>
> header __MY_FIRST_RULE To =~ /john@domain\.com/
> header __MY_SECOND_RULE Subject =~ /^Fw:\s\d{3,6}$/
> body __MY_THIRD_RULE /^Subject:\sjohn$/
>
> # Then the meta is easy. The rules can be: AND "&&", OR "||"
> # NAND, NOR (negotation) is set so: !__MY_FIRST_RULE
>
> meta EXAMPLE_RULE ( __MY_FIRST_RULE && __MY_SECOND_RULE &&
> __MY_THIRD_RULE)
>
> describe EXAMPLE_RULE How to write a meta rule
> score EXAMPLE_RULE 5
>
> --
> Ciao Marco, registered GNU/Linux-User 313353
Re: I catch all this spam, but just for curiosity...
Posted by Marco Maske <ma...@netcologne.de>.
Ruben Cardenal wrote:
> To: john@domain.com
> Subject: /^Fw:\s\d{3,6}$/
>
> In the body of the mail:
>
> /^Subject:\sjohn$/
>
> How could a rule score catch those 3 things at a time? I know how to
> do it for the headers part (someone in this lists told me how), but I
> don't know how to relate that line of the body with the "To" part of
> the headers. I mean, the "john" word in that line of the body matches
> the "john" word in the "To". I hope I've explained myself enough :)
If I understand you right, then you want a meta Rule:
First the rules for meta must start with "__":
header __MY_FIRST_RULE To =~ /john@domain\.com/
header __MY_SECOND_RULE Subject =~ /^Fw:\s\d{3,6}$/
body __MY_THIRD_RULE /^Subject:\sjohn$/
# Then the meta is easy. The rules can be: AND "&&", OR "||"
# NAND, NOR (negotation) is set so: !__MY_FIRST_RULE
meta EXAMPLE_RULE ( __MY_FIRST_RULE && __MY_SECOND_RULE &&
__MY_THIRD_RULE)
describe EXAMPLE_RULE How to write a meta rule
score EXAMPLE_RULE 5
--
Ciao Marco, registered GNU/Linux-User 313353