메뉴 건너뛰기

리눅스 관련 모음

본문시작

조회 수 74186 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

국산 통나무 수공예 남원제기, 남원목기

자료가 도움이 되셨다면
혼수용품제수용품 필요시
남원제기 공식 홈페이지 http://남원제기.kr
남원목기 공식 홈페이지 http://otchil.kr
에서 구매 해 주세요
정성껏 모시겠습니다.
 

기존에 SpamAssassin과 ClamAV를 연동하는 방법은 많이 있어왔지만 사실상 연동이라기 보다는 Sendmail에서 둘다 따로 호출하거나 Procmail 스크립트를 사용하는 방법등이었습니다.

다음은 ClamAV를 아예 SpamAssassin으로 합쳐 바이러스 발견시 SpamAssassin의 점수계산에 포함되도록 하는 방법입니다.

무선 ClamAV를 설치하고 시작해 보도록 하겠습니다. [이곳]에서 ClamAV 소스를 다운받아 설치합니다. 패키지 모음은 [이곳]에 있습니다.

ClamAV를 설치하기 전에 우선 사용자 계정을 추가합니다.

# groupadd clamav 
# useradd -g clamav -s /bin/false -c "Clam AntiVirus" -d /var/lib/clamav clamav

다운받은 소스를 설치합니다.
# ./configure --sysconfdir=/etc/clamav 
# make 
# make install

추가로 필요한 디렉토리를 생성합니다.
# mkdir /var/lib/clamav 
# mkdir /var/log/clamav 
# mkdir /var/run/clamav 
# chown clamav.clamav /var/lib/clamav 
# chown clamav.clamav /var/log/clamav 
# chown clamav.clamav /var/run/clamav

/etc/clamav/clamd.conf 파일에 다음의 내용을 수정합니다.
LogFile /var/log/clamav/clamd.log 
LogFileMaxSize 2M 
LogTime yes 
PidFile /var/run/clamav/clamd.pid 
TemporaryDirectory /tmp 
LocalSocket /var/lib/clamav/clamd.sock 
FixStaleSocket yes 
ScanMail yes

다음으로는 /etc/clamav/freshclam.conf 파일을 수정합니다.
UpdateLogFile /var/log/clamav/freshclam.log 
PidFile /var/run/clamav/freshclam.pid 
DatabaseOwner clamav 
DNSDatabaseInfo current.cvd.clamav.net 
DatabaseMirror db.kr.clamav.net 
DatabaseMirror database.clamav.net

다음의 스크립트 파일을 /etc/rc.d/init.d 안에 추가합니다.

이제 스크립트를 실행해 봅시다.
# /etc/rc.d/init.d/freshclam start 
# /etc/rc.d/init.d/clamd start

/etc/cron.daily/freshclam이 생성되었다면 freshclam은 따로 데몬으로 돌리실 필요는 없습니다.
SpamAssassin이 설치된 설정 디렉토리 /etc/mail/spamassassin 안에 다음의 파일을 추가합니다.

clamav.cf
loadplugin ClamAV clamav.pm 
full CLAMAV eval:check_clamav() 
describe CLAMAV Clam AntiVirus detected a virus 
score CLAMAV 10 
add_header all Virus _CLAMAVRESULT_


clamav.pm
package ClamAV; 
use strict;

 

# version 2.0, 2010-01-07  #   - use SA public interface set_tag() and add_header, instead of  #     pushing a header field directly into $conf->{headers_spam}

 

# our $CLAMD_SOCK = 3310;               # for TCP-based usage  our $CLAMD_SOCK = "/var/run/clamd.basic/clamd.sock";   # change me

 

use Mail::SpamAssassin;  use Mail::SpamAssassin::Plugin;  use Mail::SpamAssassin::Logger;  use File::Scan::ClamAV;  our @ISA = qw(Mail::SpamAssassin::Plugin);

 

sub new {    my ($class, $mailsa) = @_;    $class = ref($class) || $class;    my $self = $class->SUPER::new($mailsa);    bless($self, $class);    $self->register_eval_rule("check_clamav");    return $self;  }

 

sub check_clamav {    my($self, $pms, $fulltext) = @_;    dbg("ClamAV: invoking File::Scan::ClamAV, port/socket: %s", $CLAMD_SOCK);    my $clamav = new File::Scan::ClamAV(port => $CLAMD_SOCK);    my($code, $virus) = $clamav->streamscan(${$fulltext});    my $isspam = 0;    my $header = "";    if (!$code) {      my $errstr = $clamav->errstr();      $header = "Error ($errstr)";    } elsif ($code eq 'OK') {      $header = "No";    } elsif ($code eq 'FOUND') {      $header = "Yes ($virus)";      $isspam = 1;      # include the virus name in SpamAssassin's report      $pms->test_log($virus);    } else {      $header = "Error (Unknown return code from ClamAV: $code)";    }    dbg("ClamAV: result - $header");    $pms->set_tag('CLAMAVRESULT', $header);    # add a metadatum so that rules can match against the result too    $pms->{msg}->put_metadata('X-Spam-Virus',$header);    return $isspam;  }

 

1;


이후에 File::Scan::ClamAV 를 설치하여야 합니다.

# cpan File::Scan::ClamAV


이제 SpamAssassin에서 메일을 처리할때 ClamAV를 호출하여 바이러스 검사까지 하게 되며 바이러스가 존재할시 스코어 10점을 부여하고 X-Spam-Virus: Yes 헤더를 붙이게 됩니다.

세세한 점수를 확인하고 싶다면 [이곳]에서 확인해 보시면 됩니다.

SpamAssassin을 데몬형태로 사용하고 계신다면 재시작 해주시면 됩니다. 그외의 경우에는 바로 적용됩니다.

참고 : http://wiki.apache.org/spamassassin/ClamAVPlugin

 

 

+++++++++++++++++++++++++++++++++

로그확인은 /var/log/maillog 에서
로그쌓이는걸 원하지않는경우 /etc/init.d/spamd 에서 SPAMDOPTIONS 부분에 -s null 을추가해주자
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

   

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
190 Mail Server 구축(postfix, dovecot, amavisd-new, spamassassin, clamav) file 햇빛소년 2011.05.02 96532
189 에러해결 pcre최신버전 소스설치 후 modsecurity-apache 컴파일시 에러 햇빛소년 2013.01.19 76372
» Spam Assassin + ClamAV 바이러스 필터 연동하기 file 햇빛소년 2011.03.29 74186
187 Amavisd 에서 spam filtering 수준 조절 햇빛소년 2011.04.09 72539
186 iptables 삭제명령 햇빛소년 2012.05.15 71450
185 Iptables 간략 사용하기 햇빛소년 2011.05.12 65473
184 Install amavisd-new, SpamAssassin 햇빛소년 2011.04.09 62639
183 리눅스 관리자가 알아두어야 할 50가지 햇빛소년 2011.05.12 60492
182 에러해결 phpmyadmin 4.0 로그인시 에러.. 햇빛소년 2013.06.18 59730
181 Apache 2.4.1 소스설치시 에러에 대한 해결 햇빛소년 2012.02.26 57551
180 rndc: connection to remote host closed 네임서버오류 햇빛소년 2011.04.10 55308
179 su 명령의 문제점 햇빛소년 2011.10.04 54625
178 httpd 스크립트 - /etc/rc.d 햇빛소년 2011.05.01 51811
177 ModSecurity-Apache 설치, Lua, readline 햇빛소년 2013.01.07 51527
176 [1원짜리 팁] hosts.deny 햇빛소년 2011.05.11 51435
175 [Mysql] password설정 및 변경, root 비번 잃어버렸을 경우 변경법 햇빛소년 2011.03.20 51422
174 DCC로 안티스팸 기능 확장하기 햇빛소년 2011.03.18 51328
173 MySQL에러[Warning] IP address '211.154.154.171' could not be resolved: no reverse address mapping. 햇빛소년 2011.05.09 51310
172 SURBL을 이용해 스팸 정확도 극대화하기 file 햇빛소년 2011.04.14 50988
171 MYSQL / 필드내 특정 문자열 치환하는 mysql 명령문 햇빛소년 2011.03.26 50687
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 Next
/ 10