PHP implementation logic for detecting whether files have viruses

藏色散人
Release: 2023-04-08 13:48:01
forward
2620 people have browsed it

After the user receives the sent file, he must be able to detect whether the file is a virus. The core software is clamav, which can be executed on the Linux command line to detect viruses in files or directories

Recommended : PHP video tutorial

For downloading and installation, please refer to other technical articles.

It should be noted that you need to enable

LocalSocket /tmp/clamd.socket
Copy after login

in the configuration file

When running, a clamd program is run as a daemon. When detecting, you only need to Call the following command

/usr/local/clamav-0.102.1/bin/clamdscan File

The response information is the following content

/usr/local/clamav-0.102.1/bin/clamdscan /tmp/attachment_04613DE5A94DD00E1F48F7A5D39A802C9700000000000001_4
/tmp/attachment_04613DE5A94DD00E1F48F7A5D39A802C9700000000000001_4: Xls.Virus.Mailcab-6702020-0 FOUND
----------- SCAN SUMMARY -----------
Infected files: 1
Time: 0.176 sec (0 m 0 s)
Copy after login

Call the exec function in PHP and call the above command to achieve detection

    $cmd="/usr/local/clamav-0.102.1/bin/clamdscan {$file}";
    exec($cmd,$output);
Copy after login

PHP implementation logic for detecting whether files have viruses

The above is the detailed content of PHP implementation logic for detecting whether files have viruses. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!