我有哪些选项可以检查 PHP 上传中的病毒?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10660260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:44:47  来源:igfitidea点击:

What are my options to check for viruses on a PHP upload?

phpfile-uploadantivirusvirus

提问by Carl

I am looking to see how I can go about checking if an uploaded file has a virus or not via PHP. What options exist, pros and cons of each, etc.

我想看看如何通过 PHP 检查上传的文件是否有病毒。存在哪些选项,每种选项的优缺点等。

回答by alganet

ClamAVis a free anti virus commonly used on server applications.

ClamAV是一种免费的反病毒软件,通常用于服务器应用程序。

php-clamavis an extension for binding ClamAV to PHP. You can check their documentation.

php-clamav是一个将 ClamAV 绑定到 PHP 的扩展。您可以查看他们的文档

I've found a tutorial on how to use clamav as a Zend Framework Validatorwhich already includes instructions on how to verify upload files. The tutorial should also help you on using it on another frameworks or architectures.

我找到了一个关于如何使用 clamav 作为 Zend Framework Validator教程,其中已经包含有关如何验证上传文件的说明。本教程还应该帮助您在其他框架或架构上使用它。

You can also call clamav by its command line interface with clamscan. This requires clamav to be installed but not the PHP extension. In the PHP side, you can shell_exec('clamscan myuploadedfile.zip');then parse the output. Lines ending with OKare safe files, lines ending with FOUNDare malicious files.

您还可以通过命令行界面调用 clamav clamscan。这需要安装 clamav 但不需要安装 PHP 扩展。在 PHP 端,您可以shell_exec('clamscan myuploadedfile.zip');解析输出。以 结尾的行OK是安全文件,以 结尾的行FOUND是恶意文件。

回答by Jeroen

You can use VirusTotal.com, they have an API which you can use to upload files and they will scan them using multiple virus scanners.

您可以使用 VirusTotal.com,他们有一个 API,您可以使用它来上传文件,他们将使用多个病毒扫描程序对其进行扫描。

https://www.virustotal.com/

https://www.virustotal.com/

(unfortunately, their website is currently under maintenance, but I expect it to be back up soon enough)

(不幸的是,他们的网站目前正在维护中,但我希望它能尽快恢复)