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

荒凉一梦 提交于 2019-12-28 13:09:28

问题


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.


回答1:


ClamAV is a free anti virus commonly used on server applications.

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

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

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 OK are safe files, lines ending with FOUND are malicious files.




回答2:


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.

https://www.virustotal.com/

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



来源:https://stackoverflow.com/questions/10660260/what-are-my-options-to-check-for-viruses-on-a-php-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!