ORF反垃圾邮件系统

邮件服务器-邮件系统-邮件技术论坛(BBS)

 找回密码
 会员注册
查看: 10373|回复: 2
打印 上一主题 下一主题

[推荐] Dspam打造自己的反垃圾邮件网关(open source)

[复制链接]
跳转到指定楼层
顶楼
发表于 2010-8-17 22:36:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Dspam是一款很不错的开源反垃圾邮件软件,并且还能配合clamav反病毒,通过学习后,能达到99%的正确率,误判很小,并且能针对每个用户的习性学习垃圾邮件及反垃圾邮件,在国外很流行,国内很少有人用。
下面是我的安装步骤,希望能对所需之人有所帮助。
groupadd -g 1005 dspam
useradd -g dspam -u 1005 dspam
1\编译安装,支持mysql
./configure \
--prefix=/usr/ \
--enable-daemon \
--enable-clamav \
--enable-debug \
--enable-syslog \
--enable-preferences-extension \
--enable-long-usernames \
--enable-domain-scale \
--enable-virtual-users \
--with-dspam-home-owner=dspam \
--with-dspam-home-group=dspam \
--with-dspam-mode=2510 \
--with-dspam-owner=dspam \
--with-dspam-group=dspam \
--with-storage-driver=mysql_drv \
--with-mysql-includes=/usr/include/mysql \
--with-mysql-libraries=/usr/lib/mysql \
--with-logdir=/var/log/dspam \
--with-delivery-agent=/usr/sbin/sendmail
make
make install

2\建立mysql用户及数据库
cd src/tools.mysql_drv
mysql -u root -p -e "create database dspam"
mysql -u root -p -e "grant all on dspam.* to dspam@localhost identified by '123456'"
vi mysql_objects-4.1.sql
增加一行内容到最上面:
use dspam;
vi virtual_users.sql
增加一行内容到最上面:
use dspam;
mysql -u dspam -p
mysql -u dspam -p
cp purge-4.1.sql /usr/local/dspam/var/dspam/purge.sql
crontab -e
15 23 * * * /usr/bin/mysql -u dspam -p'123456' dspam
30 23 * * * dspam /usr/local/dspam/bin/dspam_logrotate -a 30 -d /usr/local/dspam/var/dspam/data

3\配置 dspam
vi /usr/etc/dspam.conf
TrustedDeliveryAgent    /usr/sbin/sendmail
Trust dspam
Trust postfix
Preference "spamAction=quarantine"
Preference "signatureLocation=headers"  # 'message' or 'headers'
Preference "showFactors=on"
#Preference "spamAction=tag"  //此参数注释掉,否则不能更改message handling.
Preference "spamSubject=SPAM"

MySQLServer             /var/lib/mysql/mysql.sock
MySQLUser               dspam
MySQLPass               123456
MySQLDb                 dspam
MySQLCompress           true

4\配置postfix
[Postfix] (LMTP) -> [DSPAM]                     [Postfix] -> { Delivery }
                       |___ (SMTP Reinjection) ____|
vi /usr/etc/dspam.conf

ServerMode      auto
ServerParameters        "--deliver=innocent"
ServerIdent             "localhost.localdomain"
ServerPID               /var/run/dspam.pid
ServerDomainSocketPath  "/tmp/dspam.sock"

Start dspam : /usr/bin/dspam --daemon &

Configure Postfix to use a content filter
修改master.cf
smtp      inet  n       -       n       -       -        smtpd
  To:
smtp      inet  n       -       n       -       -        smtpd
     -o content_filter=dspam:
#            -o content_filter=lmtp:unix:/tmp/dspam.sock

5\测试dspam工作是否正常
随便发一封测试邮件,查看信头,有如下,说明正常:
X-DSPAM-Result: Innocent
X-DSPAM-Processed: Mon Nov 12 16:49:17 2007
X-DSPAM-Confidence: 1.0000
X-DSPAM-Probability: 0.0023
X-DSPAM-Signature: 1,4738138d233081377414986
X-DSPAM-Factors: 27,

(六)
配置DSPAM Web Control
mkdir /var/www/cgi-bin/dspam
cp -r /usr/src/dspam-3.8.0/webui/cgi-bin/* /var/www/cgi-bin/dspam/
cp /usr/src/dspam-3.8.0/webui/htdocs/base.css /var/www/cgi-bin/dspam/
cp /usr/src/dspam-3.8.0/webui/htdocs/dspam-logo-small.gif /var/www/cgi-bin/dspam/
chown -R dspam.dspam /var/www/cgi-bin/dspam/
修改webui/cgi-bin下的admins.
echo “vmail” >admins
htpasswd -c /var/www/cgi-bin/dspam vmail
配置apache:
DocumentRoot /var/www/cgi-bin/dspam
SuexecUserGroup dspam dspam
Options ExecCGI
Options -Indexes
Addhandler cgi-script .cgi
DirectoryIndex dspam.cgi
AllowOverride All
   Order deny,allow
   Deny from all
   AuthType Basic
   AuthName "DSPAM Control Center"
   AuthUserFile /var/www/cgi-bin/dspam/password
   Require valid-user
   Satisfy Any

crontab -e
15 23 * * * /usr/bin/mysql -u dspam -p'123456' dspam
30 * * * * dspam /usr/bin/dspam_logrotate -a 30 -d /usr/var/dspam/data

1Postfix filtering
vi /usr/etc/dspam.conf
TrustedDeliveryAgent "/usr/sbin/sendmail"

vi /etc/postfix/master.cf
smtp      inet  n       -       n       -       -       smtpd
  -o content_filter=dspam:
dspam   unix    -       n       n       -       10      pipe
  flags=Rhqu user=dspam argv=/usr/bin/dspam --deliver=innocent --user $user -i -f $sender -- $recipient
spam   unix    -       n       n       -       10      pipe
  flags=Ru user=dspam argv=/usr/bin/dspam --class=spam --source=error --user dspam
notspam   unix    -       n       n       -       10      pipe
  flags=Ru user=dspam argv=/usr/bin/dspam --class=innocent --source=error --user dspam

vi /etc/postfix/dspam_filter_access
/./   FILTER dspam:dspam

vi /etc/postfix/transport,add
spam@jimzhang.com    spam
notspam@jimzhang.com     notspam

vi /etc/postfix/main.cf
transport_maps = hash:/etc/postfix/transport
smtpd_client_restrictions = check_client_access hash:/etc/postfix/dspam_filter_access
local_recipient_maps = proxy:unix:passwd.byname $transport_maps $alias_maps
dspam_destination_recipient_limit = 1

最后检查一下/var/www/cgi-bin/dspam,configure.pl文件
若不能生成图像,安装以下:
Can't locate GD/Graph/bars.pm
Install GD::Graph::bars
wget http://cpan.mirror.ac.za/authors ... raph-1.44_01.tar.gz
Can't locate GD/Graph/lines3d.pm
Install GD::Graph::lines3d
wget http://search.cpan.org/CPAN/auth ... Graph3d-0.63.tar.gz
yum install gd-devel

Can't locate GD.pm
Install GD
http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.39.tar.gz
tar zxfv GD-2.39.tar.gz
cd GD-2.39
perl Makefile.PL
make & make install

Can't locate GD/Graph.pm
http://search.cpan.org/CPAN/authors/id/B/BW/BWARFIELD/GDGraph-1.44_01.tar.gz
cd GDGraph-1.44_01
perl Makefile.PL
make & make install

Can't locate GD/Text/Align.pm
GD::Text::Align
http://search.cpan.org/CPAN/authors/id/M/MV/MVERB/GDTextUtil-0.86.tar.gz
cd GDTextUtil-0.86
perl Makefile.PL
make & make install

若中文主题有乱码,将httpd.confAddDefaultCharset GB2312.
装好clamav,并启动
Vi dspam.conf
Clamavport 3310
Clamavhost 127.0.0.1
Clamavresponse     reject

若训练垃圾邮件的时候,出现以下错误:
dspam[2380]: Signature retrieval for '2,457582a423802003310769' failed
dspam[2380]: Unable to find a valid signature. Aborting.
dspam[2380]: process_message returned error -5. dropping message.

将以下三项打开
ParseToHeaders on
ChangeModeOnParse on
ChangeUserOnParse on
MySQLUIDInSignature on //此项一定要打开

http://www.ccert.edu.cn/spam/sa/2005-Jun.tar.gz
下载学习样本。
dspam_train spam ham/ spam/ (dspam_train username spam_dir ham_dir)
您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

小黑屋|手机版|Archiver|邮件技术资讯网

GMT+8, 2024-11-17 23:39

Powered by Discuz! X3.2

© 2001-2016 Comsenz Inc.

本论坛为非盈利中立机构,所有言论属发表者个人意见,不代表本论坛立场。内容所涉及版权和法律相关事宜请参考各自所有者的条款。
如认定侵犯了您权利,请联系我们。本论坛原创内容请联系后再行转载并务必保留我站信息。此声明修改不另行通知,保留最终解释权。
*本论坛会员专属QQ群:邮件技术资讯网会员QQ群
*本论坛会员备用QQ群:邮件技术资讯网备用群

快速回复 返回顶部 返回列表