問題描述
我想看看如何通過 PHP 檢查上傳的文件是否帶有病毒.存在哪些選項(xiàng),每種選項(xiàng)的優(yōu)缺點(diǎn)等.
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.
推薦答案
ClamAV 是服務(wù)器上常用的免費(fèi)殺毒軟件應(yīng)用程序.
ClamAV is a free anti virus commonly used on server applications.
php-clamav 是一個(gè)將 ClamAV 綁定到 PHP 的擴(kuò)展.您可以查看他們的文檔.
php-clamav is an extension for binding ClamAV to PHP. You can check their documentation.
我找到了一個(gè) 關(guān)于如何使用 clamav 作為 Zend 框架驗(yàn)證器的教程,其中已經(jīng)包含有關(guān)如何驗(yàn)證上傳文件的說明.本教程還應(yīng)該幫助您在其他框架或架構(gòu)上使用它.
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.
您還可以使用 clamscan
通過命令行界面調(diào)用 clamav.這需要安裝 clamav 但不需要安裝 PHP 擴(kuò)展.在 PHP 端,您可以 shell_exec('clamscan myuploadedfile.zip');
然后解析輸出.以 OK
結(jié)尾的行是安全文件,以 FOUND
結(jié)尾的行是惡意文件.
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.
這篇關(guān)于我有哪些選項(xiàng)可以檢查 PHP 上傳中的病毒?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!