This article is a mirror article of machine translation, please click here to jump to the original article.

View: 2614|Reply: 0

[Console Program] .NET/C# calls the ClamAV open source virus scanning service

[Copy link]
Posted on 9/20/2024 10:08:24 AM | | | |
Requirements: The site has a file upload function, allowing users to upload any file, and it is necessary to simply scan the files uploaded by the user for viruses. Websites developed using .NET require ClamAV to be called to scan files for viruses.

About ClamAV

ClamAV is an open-source antivirus engine that detects Trojans, viruses, malware, and other malicious threats. ClamAV is provided by Cisco Systems, Inc.

Source code address:The hyperlink login is visible.
Program download:The hyperlink login is visible.
Document address:The hyperlink login is visible.

Windows deploys ClamAV

Hardware requirements: RAM 3G+, 1 CPU at 2.0 Ghz+, disk space 5 GiB+
Download the "clamav-1.4.1.win.x64.zip" zip package at the address:The hyperlink login is visible., unzip it after the download is complete.

Find the conf_examples folder, copy clamd.conf.sample, freshclam.conf.sample to the root directory, and then remove the .sample extension.

Edit freshclam.conf to the following configuration:

Edit clamd.conf to the following configuration:

First, run the freshclam.exe program using a command line window to update the virus library, as shown in the figure below:

D:\安装包\clamav-1.4.1.win.x64>freshclam.exe
Creating missing database directory: D:\ClamAV\database
ClamAV update process started at Fri Sep 20 09:32:00 2024
daily database available for download (remote version: 27403)
Time:   55.6s, ETA:    0.0s [========================>]   61.18MiB/61.18MiB
Testing database: 'D:\ClamAV\database\tmp.d64fd1cf48\clamav-ad91cd251b522559b99112e9a7995de9.tmp-daily.cvd' ...
Database test passed.
daily.cvd updated (version: 27403, sigs: 2066962, f-level: 90, builder: raynman)
main database available for download (remote version: 62)
Time:  2m 28s, ETA:    0.0s [========================>]  162.58MiB/162.58MiB
Testing database: 'D:\ClamAV\database\tmp.d64fd1cf48\clamav-805c2cf0ba744d985fd353443d712278.tmp-main.cvd' ...
Database test passed.
main.cvd updated (version: 62, sigs: 6647427, f-level: 90, builder: sigmgr)
bytecode database available for download (remote version: 335)
Time:    0.9s, ETA:    0.0s [========================>]  282.94KiB/282.94KiB
Testing database: 'D:\ClamAV\database\tmp.d64fd1cf48\clamav-536bbccba0eea1b222515688f1c6e113.tmp-bytecode.cvd' ...
Database test passed.
bytecode.cvd updated (version: 335, sigs: 86, f-level: 90, builder: raynman)


After the update is complete, run the clamd.exe program using a command-line window, as shown in the following image:



.NET calls ClamAV to scan for viruses

Create a new .NET 8 console app,No need to reference any third-party dependencies, the source code is as follows:

Download some Trojan virus samples for testing at the following address:The hyperlink login is visible.

The scan results are as follows:



(End)





Previous:.NET/C# to call the HUAWEI CLOUD OCR business license identification interface
Next:Windows resolves an issue where SSH to Linux automatically disconnects after a while
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com