4,495,594 th visitor since 2017.2.1 ( Today : 482 )
Computer ???
No. 382
Name. swindler
Subject. SpamAssassin 설정법
Main Cate. Linux
Sub Cate.
Date. 2009-06-26 13:55
Hit. 10496 (211.36.27.8)
File.
사용자 삽입 이미지

 


 


 




우선 스팸어쎄신을 설치해보자. cpan을 이용하면 옵션 모듈까지 손쉽게 설치할 수 있다.

# cpan
 
cpan
> install Digest::SHA1
HTML::Parser DB_File Net::DNS Mail::SPF::Query 
IP::Country Mail::Audit::Razor Net::Ident 
IO::Socket::INET6 IO::Socket::SSL Time::HiRes DBI 
LWP::UserAgent HTTP::Date Archive::Tar IO::Zlib Encode::Detect 
Net::SSLeay Mail::DKIM Mail::DomainKeys Compress::Zlib 
cpan
> install Mail::SpamAssassin


위와 같은 방법만으로도 스팸어쎄신을 손쉽게 설치할 수 있다. 옵션 모듈중에 설치 안되는 것들에 대해서는 너무 목숨걸지 말자. 다음같은 모듈은 굳이 필요없다.

Encode::Detect, IO::Socket::INET6, IO::Socket::SSL, Net::SSLeay, Razor2

이제 스팸어쎄신의 로컬 설정을 한다. 디폴트로 /etc/mail/spamassassin/local.cf 파일이다.

# This is the right place to customize your installation of SpamAssassin.
#
# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be
# tweaked.
#
# Only a small subset of options are listed below
#
###########################################################################
 
#   Save spam messages as a message/rfc822 MIME attachment instead of
#   modifying the original message (0: off, 2: use text/plain instead)
#
report_safe
0
 
#   Set the threshold at which a message is considered spam (default: 5.0)
#
required_score
5.0
 
#   Use Bayesian classifier (default: 1)
#
use_bayes
1
 
#   Bayesian classifier auto-learning (default: 1)
#
bayes_auto_learn    
1
bayes_path          
/etc/mail/spamassassin/bayes/bayes
bayes_file_mode    
0666
 
# Enable or disable network checks
skip_rbl_checks        
0
use_razor2              
0
use_dcc                
0
use_pyzor              
0
 
# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_languages            ko
 
# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_locales              ko
 
# Add your own customised scores for some tests below.  The default scores are
# read from the installed spamassassin rules files, but you can override them
# here.  To see the list of tests and their default scores, go to
# http://spamassassin.apache.org/tests.html .
score SPF_PASS
-2.0
score SPF_HELO_PASS
-2.0
score SPF_NEUTRAL
-1.0
score SPF_HELO_NEUTRAL
-1.0
 
# For Daum Communications
score WEIRD_PORT
0.0
 
# For Korean Fonts
score HTML_FONT_FACE_BAD
0.0
 
# Whitelist important senders
whitelist_from          
*@theeye.pe.kr


report_safe : 스팸으로 판단될 경우 원본글을 감출지 여부이다. 메일을 읽는 순간 당할수 있는 그 어떤 공격이 두렵다면 1로 해야 한다. 하지만 0으로 설정한다.


required_score : 몇점 이상을 스팸메일로 의심할것인지에 대한 설정이다. 이것은 서버관리자의 주관적인 부분이다. 그냥 5로 해도 무관하다고 본다.


use_bayes : 학습된 Bayesian Classifier를 사용할것인지에 대한 여부이다. 당연히 1로 한다.


bayes_auto_learn : 자동학습에 대한 설정이다. 정말로 확실한 스팸의 경우 분석하여 나누어진 토큰을 지속적으로 학습 시킨다. 물론 자동으로.


bayes_path : 학습된 토큰 파일을 저장할 위치이다. 기본적으로 사용자 별로 개별 저장되나 이런식으로 하여 중앙 관리가 가능하다. 저 값은 접두어다. 저 뒤로 _toks와 _seen이 붙는 파일 두개가 생긴다.


bayes_file_mode : 파일의 권한이다. 666정도면 되겠다.


skip_rbl_checks : RBL체크값을 점수에 활용한다. 나름 맹활약을 하게 된다.


use_razor2 : Vipul's Razor라는 곳에서 운영하는 블랙리스트 공유 시스템을 활용할지 여부이다. 난 사용안했다. 설치할것이 별도로 존재한다.


use_dcc : Distributed Checksum Clearinghouse의 약자이다. 실제 홈페이지에서는 스팸을 줄이는데 특출난 효과가 있다고 설명하고 있다. 필요하다 판단되면 사용하자


use_pyzor : Razor2와 비슷한 역할을 하는것 같다. 자세한건 사용해 보지 않아서 모르겠다. 홈페이지는 여기


ok_languages : 중요하게 사용되는 언어를 설정해 주면 된다. 한국의 경우 ko를 적어주면 된다. 영어권과 메일을 주고 받을일이 많다면 en도 추가해 주자.


ok_locales : 위와 같은 역할을 한다.


score : 별도로 특정 룰에 대한 점수를 강제로 지정할 수 있다.


whitelist_from : 믿을 수 있는 메일주소를 지정해주자. 매우 중요한 거래처의 메일이나 같은 서버의 메일은 굳이 점수를 매길필요가 없다.


다음의 SPF설정은 SPF의 신뢰도를 믿고 점수를 -해주겠다는 뜻을 가지게 된다.

score SPF_PASS -2.0
score SPF_HELO_PASS
-2.0
score SPF_NEUTRAL
-1.0
score SPF_HELO_NEUTRAL
-1.0


다음의 한메일의 경우 메일을 보내는데 기본 포트가 아닌 특이한 포트를 사용하는것 같다. 다음메일이 무조건 스팸메일화 되는것을 막을려면 설정해 주자.
score WEIRD_PORT 0.0


다음의 설정은 한글 폰트 설정때문에 스팸메일의 의심을 받게 되는것을 막기 위한 설정이다. 보통은 font-face가 영문으로 설정되기 마련이지만 국내의 메일 시스템은 "font-face:돋음"과 같이 한글로 표기하는 경우가 많다. 무시하도록 하자.
score HTML_FONT_FACE_BAD 0.0


위와 같이 설정을 하였으면 procmailrc스크립트에 스팸어쎄신을 등록하자. 보통은 spamd로 데몬으로 띄우기 마련이지만 이렇게 하는 편이 더 간단하다. procmailrc스크립트의 제일 상단에 추가해 주자.

# Pipe the mail through spamassassin (replace 'spamassassin' with 'spamc'
# if you use the spamc/spamd combination)
#
# The condition line ensures that only messages smaller than 250 kB
# (250 * 1024 = 256000 bytes) are processed by SpamAssassin. Most spam
# isn't bigger than a few k and working with big messages can bring
# SpamAssassin to its knees.
#
# The lock file ensures that only 1 spamassassin invocation happens
# at 1 time, to keep the load down.
 
:0fw: spamassassin.lock
* < 256000
| spamassassin
 
# Mails with a score of 15 or higher are almost certainly spam (with 0.05%
# false positives according to rules/STATISTICS.txt). Let's put them in a
# different mbox. (This one is optional.)
:0:
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
/var/spool/mail/spam


여기서 주목할 점은 X-Spam-Level 체크 구문인데 *한개가 1점을 뜻한다. 위의 경우 15개이므로 15점 이상이면 spam으로 포워딩 해버리겠다는 뜻을 가지게 된다. 주관적인 판단아래 조정하길 바란다.

여기서 *의 수는 이정도 점수면 스팸이 확실하다라는 확신이 서는 기준을 점수로 하면 되겠다.

그리고 스팸메일을 spam 파일에 1달정도 모으자. 그리고 학습을 시켜보도록 하자.

# sa-learn --spam --mbox /var/spool/mail/spam
# sa-learn --ham --mbox /var/spool/mail/ham


위와 같은 방법으로 스팸메일을 모은 파일을 --spam옵션을 주고 분석하여 학습 시키면 된다. 반대로 스팸메일이 아닐경우에는 --ham으로 등록하면 된다. 정확히 스팸메일만 분류되어있다면 ham은 학습을 시키지 않아도 정확성이 높다.

위에서 설정한 대로라면 학습한 데이터는 /etc/mail/spamassassin/bayes/ 안에 존재하게 된다.



[바로가기 링크] : http://coolx.net/cboard/computer/382


swindler skip_rbl_checks 1을 주게 되면 RBL을 이용하지 않아 속도는 빨라진다. 2009-11-02
swindler skip_rbl_checks 1 =>메일발송 ip가 rlb에서 블락된 ip인지여부체크 모든메일에대해 체크하므로 상당한 부하가 예상 1=>사용안함 2009-11-02
swindler 학습을 시키기 위한 mbox를 모으기 위해서는 IMAP으로 연결해서 아웃룩에서 폴더하나를 만들어두어 모으면 됨. 그러면 홈디렉토리의 mail 폴더안에 해당 mbox 파일이 생성됨 2015-10-08
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog