첫 번째에서 PING 응답을하지 않았다고 나 상태, clamd가 올바르게 응답 입증되었습니다 다음과 같이Perls 파일 : VirusScan이는 :: ClamAV를 :: Clamd하자 clamd
$ echo PING | nc -U /var/run/clamav/clamd.sock
PONG
스캐너가 설치되었다 :
#set up a Clamav scanner
use File::VirusScan;
use File::VirusScan::ResultSet;
my $scanner = File::VirusScan->new({
engines => {
'-Daemon::ClamAV::Clamd' => {
socket_name => '/var/run/clamav/clamd.sock',
},
},
});
및 전체 스크립트는 Solaris 11 상자에서 올바르게 작동합니다. 저는 Linux CentOS 5.3 (Final)에서 CPAN에서 File :: VirusScan을 설치하는 데 문제가 있습니다. 최신 버전 0.102는 컴파일되지 않으며 CPAN 테스터는 437에서 435가 실패한 것으로 확인합니다. 그래서 CPAN에서 이전 0.101 버전, 버전 나는 또한 솔라리스에서 실행하고 수동으로 분명히
perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi
sub scanner {
$|++; # buffer disabled
(my $path, my $logClean) = @_;
my $recurse = 5;
print color "yellow";
print "[i] Building file scan queue - recurse deepth $recurse \n";
print color "green";
print "SCAN QUEUE:0";
#Get list of files
if($rootPath){
use File::Find::Rule;
my $finder = File::Find::Rule->maxdepth($recurse)->file->relative->start("$$path");
while(my $file = $finder->match() ){
$|++;
#$file = substr($file,length($rootPath)); #remove path bloat
push(@scanList,"/$file");
print "\rSCAN QUEUE:" .scalar(@scanList); #update screen
}
}else{
push(@scanList,"$$path");
}
print "\rSCANING:0";
#set up a Clamav scanner
use File::VirusScan;
use File::VirusScan::ResultSet;
my $scanner = File::VirusScan->new({
engines => {
'-Daemon::ClamAV::Clamd' => {
socket_name => '/var/run/clamav/clamd.sock',
},
},
});
#scan each file
my $scanning = 0;
my $complete = -1;
foreach $scanFile (@scanList){
$scanning++;
##################################################
#scan this file
$results = $scanner->scan($rootPath.$scanFile);
##################################################
#array of hashes
my $centDone = int(($scanning/scalar(@scanList))*100);
if($centDone > $complete){
$complete = $centDone;
}
if($centDone < 100){
#\r to clear/update line
$format = "%-9s %-60s %-15s %-5s";
printf $format, ("\rSCANING:", substr($scanFile,-50), "$scanning/".scalar(@scanList), "$centDone%");
}else{
print "\rSCAN COMPLETE ";
}
# array ref
foreach $result (@$results) {
#array of pointers to hashes
#print 'data:'
#print 'state:'
if($$result{state} ne "clean"){
if($$result{data} =~ /^Clamd returned error: 2/){
$$result{data} = "File too big to scan";
}
push(@scanResults,[$scanFile,$$result{state},$$result{data}]); # results
}elsif($$logClean){
push(@scanResults,[$scanFile,$$result{state},$$result{data}]);
}
unless($$result{state} eq "clean"){
print color "red";
print "\r$scanFile,$$result{state},$$result{data}\n";
print color "green";
print "\rSCANING: $scanning/".scalar(@scanList)." : $centDone%";
if($$result{state} eq "virus"){
push(@scanVirus,scalar(@scanResults)-1); #scanResuts index of virus
}elsif($$result{state} eq "error"){
push(@scanError,scalar(@scanResults)-1); #scanResuts index of Error
}
}
}
} print "\n";
}
$ perl test.pl clamd에서 예기치 않은 응답 : 알 수 없음 COMMAND 내일 출근 할 수 있는지를 확인합니다. 출처에 대한 링크를 제공해 주셔서 감사합니다. – dannix
아, 거기에 문제가있어 최근 버전의 clamd가 SESSION 명령을 삭제 한 것 같습니다 : http://linux.die.net/man/8/clamd ("man clamd"로 확인할 수 있어야합니다). . 나는 당신을 위해 컴파일되지 않을이 모듈의 새로운 버전에서 수정되었다고 생각한다. 이 시점에서 여러분의 옵션이 작동하도록 새로운 버전을 얻거나, SESSION을 인식하는 이전 버전의 clamd를 설치하거나, Clamd.pm 소스 코드를 직접 수정하는 것 같습니다. –
아 !! 잘 찾아 냈어, 네가 틀렸다 [link] http://cpansearch.perl.org/src/DSKOLL/File-VirusScan-0.102/lib/File/VirusScan/Engine/Daemon/ClamAV/Clamd.pm은 업데이트 된 버전이다. IDSESSION이 (가) 있습니다. 나는 새 파일을 제자리에 놓았으며 잘 작동하는 것처럼 보입니다. – dannix