File: junkfilter.four

package info (click to toggle)
junkfilter 20030115-4
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 300 kB
  • ctags: 16
  • sloc: makefile: 147; sh: 115
file content (224 lines) | stat: -rw-r--r-- 8,489 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# junkfilter
# a junk email filter system for procmail 
# Copyright 1997-2002 Gregory Sutter <gsutter@zer0.org>
#
# $Id: junkfilter.four,v 2.22 2003/01/16 01:40:56 gsutter Exp $
#
# Please read the file "README" and the page
# http://junkfilter.zer0.org/ before using junkfilter.

# Four is the testing section.  All recipes in beta.  Careful!

JFSEC=4

# Block all of China Telecom
# Thanks, Joe Altman <ja@panix.com>
:0
* ^Received:.*\[(202\.(9[6-9]|10[0-9]|11[0-1])|(\[61\.(12[8-9]|13[0-9]|14[0-9]|15[0-9])))\.
{ JFMATCH="$JFSEC: Received from China Telecom" INCLUDERC=$JFDIR/junkfilter.match }

# Block Korea
:0
* ^Received:.*\[210\.12[4567]\.
{ JFMATCH="$JFSEC: Received from KRNIC" INCLUDERC=$JFDIR/junkfilter.match }

# Multiple addresses in From: without single address in Sender:
:0
* $ ^From:.*${JFADDR}${JFWS}?,${JFWS}?${JFADDR}+
* $ ! ^Sender:${JFWS}${JFADDR}${JFWS}${JFNL}
{ JFMATCH="$JFSEC: Invalid From: header" INCLUDERC=$JFDIR/junkfilter.match }

# If only one Received: header AND from a common dialup, junk.  (RFMS again)
# Thanks Rik Kabel <rik@netcom.com>
:0
* 2^0
* -1^1 ^\/Received:.*
* $ MATCH ?? from [ 	]+(($JFIPNUM\.)+|[-0-9a-z]+|$JFDIALUPS)[ 	]+\(\/[-0-9a-z\.]+[ 	]
* MATCH ?? \\/[^ 	]+
{ JFMATCH="$JFSEC: RapidFire Mail Server: $MATCH" INCLUDERC=$JFDIR/junkfilter.match }

# Hosts claiming to be other hosts... note trailing space
:0
* $ ^X-Authentication-Warning:.*Host ($JFDOMDAM\.)*\/($JFDOMNAM)\.($JFTLD)\>
{
	JFHOSTREAL=$MATCH
	:0
	* $ ^X-Authentication-Warning:.*Host ($JFDOMDAM\.)*($JFDOMNAM)\.($JFTLD)\>[ 	]+\[$JFIPNUM\.$JFIPNUM\.$JFIPNUM\.$JFIPNUM\][ 	]+claimed to be[ 	]+(($JFDOMDAM\.)*\/($JFDOMNAM)\.($JFTLD)|\[$JFIPNUM\.$JFIPNUM\.$JFIPNUM\.$JFIPNUM\])\>
	{
		JFHOSTCLAIM=$MATCH
		:0
		* ! JFHOSTREAL ?? JFHOSTCLAIM
		{ JFMATCH="$JFSEC: X-Authentication-Warning: a host in $JFHOSTCLAIM claimed to be in $JFHOSTREAL" INCLUDERC=$JFDIR/junkfilter.match }
	}
} 

# Empty To: header
:0
* $ ^To:$JFWS\(?${JFWS}?\)?${JFWS}[^a-z0-9]+
{ JFMATCH="$JFSEC: Empty To header" INCLUDERC=$JFDIR/junkfilter.match }

# Apparently from self, but Received: header from outside local domain.
:0
* -10000^0
* -10000^0 $ ^Message-Id:.*${JFMAILDOM}
* 10000^0 $ ^From:.*${JFMAILADDRESS}
* -1^1 $ ^Received:${JFWS}from (${JFDOMNAM}\.)*${JFMAILDOM}
*  1^1 ^Received:
{ JFMATCH="$JFSEC: Forged header from self" INCLUDERC=$JFDIR/junkfilter.match }

## Apparently from self, but Received: header from outside local domain.
#:0
#* $ ^Received:${JFWS}from \/.* by (${JFDOMNAM}\.)*${JFMAILDOM}
#* $ ()\/$MATCH by
#* $ $MATCH ?? ${JFMAILDOM}
#{ JFMATCH="$JFSEC: Forged header from Self" INCLUDERC=$JFDIR/junkfilter.match }

# One of these damn spam mailers leaves a distinctive signature
:0
* $ ^From:${JFWS}[0-9][0-9][0-9][0-9]+\.${JFADDR}
* $ ^To:${JFWS}[0-9][0-9][0-9][0-9]+\.
* $ ^Subject:.*-[0-9][0-9][0-9][0-9]+$
{ JFMATCH="$JFSEC: Sent by a not-tricky-enough junk email program" INCLUDERC=$JFDIR/junkfilter.match }

# Bcc: header visible?  
:0
* ()\/^Bcc:.*
{ JFMATCH="$JFSEC: Bcc header: $MATCH" INCLUDERC=$JFDIR/junkfilter.match }

# Capital Bogosity In E-Mail Is A Near-Sure Sign Of Spam
# Thanks, Era Erikkson and Phil Hord <phil.hord@antec.com>
#:0D
#* -65^0
#* -1^1 B ?? [-a-z'][,:;]?[        ]+[a-z][-a-z']
#* 1^1 B ?? [-a-z'][,:;]?[        ]+[A-Z][-a-z']
#* 8^1 B ?? ()\<[A-Z][-a-z']+[,:;]?[ 	]+[A-Z][-a-z']+[,:;]?[ 	]+[A-Z][-a-z']+[,:;]?
#{ JFMATCH="$JFSEC: Capital Bogosity" INCLUDERC=$JFDIR/junkfilter.match }

#* $ ^Message-Id:${JFWS}<.*@\/.*>
#* $ $MATCH ?? .*>
# Message-Id: from domain that's not in any Received: header
:0
* $ ^Message-Id:${JFWS}<.*@.*$JFDOMNAM\.$JFTLD>
* $ $MATCH ?? ^Received:.*>
{ JFMATCH="$JFSEC: Message-Id from domain not in Received headers" INCLUDERC=$JFDIR/junkfilter.match }

# If it's all in base64, it's junk.
# exception: Content-Type is S/MIME 
:0
* ^Content-Transfer-Encoding:[ 	]*base64
* ! ^Content-Type:[ 	]*application/(x-)?pkcs7-mime
{ JFMATCH="$JFSEC: Entire email base64 encoded" INCLUDERC=$JFDIR/junkfilter.match }

JFBADCHARSET=(big5|euc-kr|gb2312|gbk|koi8-r|ks_c_5601-1987|windows-(874|125[14]))

# If it's MIME...
:0
* ^MIME-Version:
* ^Content-Type:.*$?(.*$)?(.*$)?[ 	]+boundary *= *\"?\/[^\";]+
{
	JFMIMEBND1=$MATCH
#	LOG="multipart-mixed mail: boundary: --> $JFMIMEBND1 <--
#"

	# even if it's hidden a second MIME level deep...
	:0 B
	* $ ^(--)?${JFMIMEBND1}\<Content-Type:.*($[ 	]+)?boundary *= *\"?\/[^\";]+
	{
		JFMIMEBND2=$MATCH
	}

	# and got an html part encoded in base64, it's junk.
	:0 B
	* $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:[ 	]*text/html;\<(.*\<)?(.*\<)?Content-Transfer-Encoding:[ 	]*base64
	{ JFMATCH="$JFSEC: Base64-encoded HTML" INCLUDERC=$JFDIR/junkfilter.match }

	# and got a text/plain part encoded in base64, it's junk.
	:0 B
	* $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:[ 	]*text/plain;\<(.*\<)?(.*\<)?Content-Transfer-Encoding:[ 	]*base64
	{ JFMATCH="$JFSEC: Base64-encoded text/plain section" INCLUDERC=$JFDIR/junkfilter.match }

#	# and got any part in base64, it's junk.
#	:0 B
#	* $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:.*\<(.*\<)?(.*\<)?Content-Transfer-Encoding:[ 	]*base64
#	{ JFMATCH="$JFSEC: Base64-encoded MIME attachment" INCLUDERC=$JFDIR/junkfilter.match }

	# and got a part in a charset I don't understand, it's junk.
	:0 B
	* $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:(.*$)?[ 	]+charset=\"?\/${JFBADCHARSET}
	{ JFMATCH="$JFSEC: MIME attachment in charset $MATCH" INCLUDERC=$JFDIR/junkfilter.match }

	# and got an empty MIME part, it's junk.
	:0 B
	* $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-.*$(.*$)?Content-.*$+${MATCH}
	{ JFMATCH="$JFSEC: empty MIME attachment" INCLUDERC=$JFDIR/junkfilter.match }

	# and _doesn't_ have an inline, 7-bit part, it's junk.
	:0 B
	* $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:.*\<(.*\<)?(.*\<)?Content-(Disposition|Transfer-Encoding):
	* ! $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:[ 	]+text/[-_a-z0-9]+
	* ! $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:.*\<(.*\<)?(.*\<)?Content-Transfer-Encoding:[ 	]*(quoted-printable|7bit)
	* ! $ ^(--)?(${JFMIMEBND1}|${JFMIMEBND2})\<Content-Type:.*\<(.*\<)?(.*\<)?Content-Disposition:[ 	]*inline
	{ JFMATCH="$JFSEC: MIME with no quoted-printable part" INCLUDERC=$JFDIR/junkfilter.match }

}

# Kill charsets that I don't understand from From: and Subject:
:0 
* $ ^(From|Subject):[ 	]*=\?\/$JFBADCHARSET
{ JFMATCH="$JFSEC: Subject in charset $MATCH" INCLUDERC=$JFDIR/junkfilter.match }

# Kill charsets that I don't understand using Content-Type:
# commented out 2002-03-04 due to many many false matches
#:0 HB
#* $ ^Content-Type:.*charset=\"?\/$JFBADCHARSET
#{ JFMATCH="$JFSEC: Message in charset $MATCH" INCLUDERC=$JFDIR/junkfilter.match }

#* ^Subject:[ 	]*\/[^-_+=!@#$%^&*() 	0-9a-z\[\]\|\\,<.>/?;:'"`~]+
# \0127-\0254
# Kill non-English (latin-1, iso-8859-1) characters in subjects
#:0 
#* $ ^Subject:[ 	]*\/[^($JFPCHAR|$JFWS)]+
#{ JFMATCH="$JFSEC: Subject contains data ($MATCH) in non-western charset" INCLUDERC=$JFDIR/junkfilter.match }

#* ^Subject:[ 	]*\/[^-_+=!@#$%^&*() 	0-9a-z\[\]\|\\,<.>/?;:'"`~]+
#* $ ^Subject:[ 	]*\/[\127-\254]+
# Kill non-English (latin-1, iso-8859-1) characters in subjects
:0 
* $ ^Subject:[ 	]*\/[^[:print:]]+
{ JFMATCH="$JFSEC: Subject has data ($MATCH) in non-western charset" INCLUDERC=$JFDIR/junkfilter.match }

# mails in HTML-only are >99% spam
# from arjan de vet
:0
* $ ^Content-Type:${JFWS}text/html
{ JFMATCH="$JFSEC: HTML-only mail" INCLUDERC=$JFDIR/junkfilter.match }

# Subject: line contains five or more consecutive instances of
# a single character followed by whitespace.
:0
* $ ^Subject:[ 	]*(${JFPCHAR}${JFWS})(${JFPCHAR}${JFWS})(${JFPCHAR}${JFWS})(${JFPCHAR}${JFWS})(${JFPCHAR}${JFWS})+
{ JFMATCH="$JFSEC: Subject is spaced out" INCLUDERC=$JFDIR/junkfilter.match }

## Use external program 'rblcheck' to see if the source should be blackholed
#:0
#* $ 1^1 ^Received:.*\[\/${JFIP}
#* $ ! ? rblcheck -q $MATCH
#{ JFMATCH="$JFSEC: IP address $MATCH is in RBL" INCLUDERC=$JFDIR/junkfilter.match }

# Received: liar claims to be from AOL
:0
* 1^1 ^Received: from aol.com \(
* -1^0 ^Received: from aol.com \((.*\.)aol.com
{ JFMATCH="$JFSEC: Falsely claims to be from aol.com" INCLUDERC=$JFDIR/junkfilter.match }

# Body contains lots of upper ASCII characters
# was 1^1.2 but added up too quickly.
:0 B
* -1^1 .
* 1^1.1 [^	 -~]
{ JFMATCH="$JFSEC: Contains too many high ASCII characters (score: $=)" INCLUDERC=$JFDIR/junkfilter.match }


JFSEC

# EOF junkfilter.four