ClamAV supports in Unix, Linus, MaxOS and Window. ClamAV is under Cisco Systems and can be reliable.
In this article, I am going to demonstrate how to install ClamAV in Window and write a sample java application to send a file for scanning.
- Download and install ClamAV.
- Download "clamav-0.99-x64.msi" at http://www.clamav.net/documents/installing-clamav.
- Double click on "clamav-0.99-x64.msi" to start the installation by selecting default options.
- ClamAV is installed in folder C:\Program Files\ClamAV-x64 if you follow default options.
- Configure ClamAV.
- Copy clamd.conf.sample and freshclam.conf.sample from C:\Program Files\ClamAV-x64\conf_examples\ to C:\Program Files\ClamAV-x64\.
- Rename clamd.conf.sample to clamd.conf.
- Rename freshclam.conf.sample to freshclam.conf.
- In clamd.conf,
- comment "Example" in line number 8.
- uncomment "TCPSocket" in line number 101.
- uncomment "TCPAddr" in line number 109.
- In freshclam.conf,
- comment "Example" in line number 8.
- Run freshclam using command prompt to download antivirus database.
- Start ClamAV by run clamd using command prompt.
- Test ClamAV
- Go to folder C:\Program Files\ClamAV-x64.
- Run clamscan and scan all files in the directory.
- Write a sample JAVA Program
- Download clamavj-0.1.jar and org.apache.commons.logging.jar at http://soniyj.altervista.org/blog/free-solution-for-check-infected-files-with-java-and-clamav/?doing_wp_cron=1456213243.7796299457550048828125
- Create Test.java and copy below code:
import com.philvarner.clamavj.ClamScan; import com.philvarner.clamavj.ScanResult; import java.io.*; import java.io.FileInputStream; public class Test { public static void main(String args[]) { System.out.println("Start"); ClamScan clamScan = new ClamScan("127.0.0.1", 3310, 20); try { ScanResult result = clamScan.scan(new FileInputStream("D:\\14k.png")); System.out.println(result.getStatus()); } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println("End"); } }
- Compile Test.java using the command:
javac -cp clamavj-0.1.jar;org.apache.commons.logging.jar Test.java
- Run Test.java using the command:
java -cp .;clamavj-0.1.jar;org.apache.commons.logging.jar Test
- The code actually sending "D:\14k.png" to scan and return pass. Passed means the file is clean.
References:
http://www.clamav.net/
http://soniyj.altervista.org/blog/free-solution-for-check-infected-files-with-java-and-clamav/?doing_wp_cron=1456213243.7796299457550048828125\
Another JAVA Example for ICAP Anti-Virus Protocol. Its not related to ClamAV, just in case needed:
https://github.com/Baekalfen/ICAP-avscan
http://soniyj.altervista.org/blog/free-solution-for-check-infected-files-with-java-and-clamav/?doing_wp_cron=1456213243.7796299457550048828125\
Another JAVA Example for ICAP Anti-Virus Protocol. Its not related to ClamAV, just in case needed:
https://github.com/Baekalfen/ICAP-avscan