如何制作ClamAV扫描结果的详细报告(包括受感染文件的位置)?

我正在使用ClamAv进行扫描,得到了以下摘要:
----------- SCAN SUMMARY -----------
Known viruses: 4724261
Engine version: 0.99
Scanned directories: 128878
Scanned files: 791920
Infected files: 29
Total errors: 25699
Data scanned: 187109.62 MB
Data read: 1683517.68 MB (ratio 0.11:1)
Time: 19860.535 sec (331 m 0 s)

我的问题是:如何找到被感染的文件? 我尝试打开stdout,但不知道有什么应用程序可以做到这一点。 我试图找到日志文件...但没有找到。

欢迎来到Ask Ubuntu!你用哪个命令进行扫描的?虽然已经有一段时间了,但我记得当时我使用的是clamscan -avr(如果没记错的话),它对文件的情况非常清楚明了。 - Andrea Lazzarotto
如果某个答案对您有帮助,请考虑将其标记为被接受的答案,这样其他人在将来更容易找到它。这也是向回答您问题的人表示感谢的一种礼貌方式。 - Andrea Lazzarotto
3个回答

我使用sudo clamscan / --recursive | tee clamscan.log命令,这样我既可以实时查看结果,又可以事后检查整个输出。

显然,您需要告诉ClamAv将感染文件的报告放在哪里。查看维基百科,该软件似乎并不出色,如果安全是您的首要关注点,则可能有更好的软件包可供使用。但是,ClamAV是开源和免费的,因此如果预算是优先考虑的话,它可能是最好的选择。

至于查看感染文件报告,我在社区帮助Wiki中找到了以下信息:

Infected files reporting

In case you are recursively scanning the whole /home folder (or even the whole system) from a terminal emulator on your GUI, possibly there will be lots of files. In that case, as the output you will get is not infinite, it probably will help to generate a report containing the paths to all infected files. In that case you can do the following:

sudo clamscan -r /folder/to/scan/ | grep FOUND >> /path/to/save/report/file.txt

Be patient if you run that command and it doesn't seem to be working because even if you don't see the complete output it is really scanning the files. When you see the prompt again, that will mean the scan is finished and that you can open the file it has created to check any infected file detected in your system.

As Clamav doesn't disinfect the files, sometimes will be better to just know what are the infected files before putting it on quarantine or removing it. For example, you could be using Wine and by deleting an infected file you could break a program without having saved some data.


你应该考虑引用你获取信息的链接。 :) - Andrea Lazzarotto
1没错,@Andrea Lazzarotto,我已经在Ubuntu帮助帖子中添加了链接。 :) - WinEunuuchs2Unix
在Community Help Wiki引用的命令中,不仅会列出受感染的文件,还会列出所有路径中包含字符串"FOUND"的文件,无论它们是否受感染。 - Tilman
@Tilman 你认为我应该删除这个回答吗?如果这是最好的做法,我不介意。 - WinEunuuchs2Unix
是的,对我来说,使用其他答案中提出的“-i”选项似乎是更好的方法。如果您可以编辑社区帮助维基的话,或许您可以改进那里的文章。 - Tilman
@Tilman 我无法对维基页面进行编辑。请注意命令| grep FOUND,它限制了报告只显示找到的病毒。表面上看,维基页面是正确的。 - WinEunuuchs2Unix
这并不是这样的。| grep FOUND会匹配包含字符串"FOUND"的任何位置的行。所以,如果你有一个名为"404NOTFOUND.html"的文件,即使它没有被感染,它也会出现在报告中。我发表评论的原因是一个用户遇到了这个问题,并且想知道是否应该删除那个被ClamAV报告为感染的文件(实际上它并没有被感染)。 - Tilman
如果grep FOUND log不起作用,你可以使用grep FOUND$ log。它只会打印出最后一个单词FOUND。 - MaXi32

如果你在终端中输入man clamscan,你将看到所有可用的选项。其中之一是-i,它只打印感染的文件。例如,输入clamscan -ir /folder将显示该文件夹及其所有子文件夹中的所有感染文件。

2虽然ClamAV在使用“-i”标志时不会记录已扫描文件的列表,但它确实会记录读取文件时出现的错误。如果您正在扫描整个驱动器或者以非管理员权限扫描家目录之外的文件夹,可能会产生大量的错误日志。 - Jehanzeb.Malik