如何使用Java上传的防病毒软件扫描文件?

我正在开发一个需要文件上传的应用程序,它还需要在服务器上使用可用的防病毒软件扫描该文件。

我听说过赛门铁克为应用程序服务器提供的APIS。

原型就像,我需要在将来在不同的地方部署应用程序。 所以,我正在考虑放置一个配置文件,从我将要获取可用的Antivirus及其路径。

我想在服务器上使用任何可用的防病毒软件,然后使用命令行,我想传回文件名和结果。

我在传递文件和检索结果时很困惑。

可能吗?

使用以下代码。

String[] commands = new String[5]; commands[0] = "cmd"; commands[1] = "/c"; commands[2] = "C:\\Program Files\\AVG\\AVG10\\avgscanx.exe"; commands[3] = "/scan=" + filename; commands[4] = "/report=" + virusoutput; Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(commands); 

Commnad线对你来说是更好的选择。 然后读取日志文件来解决问题。

我只是谷歌搜索,发现一篇有趣的文章在这里看看

要在Java中实现病毒文件扫描,需要使用第三方软件包。 出于本文的目的,我将使用随Java API一起提供的Symantec Scan Engine(SSE)程序包。 此程序包是一个用作TCP / IP服务器的应用程序,具有编程接口,可使Java应用程序包含对内容扫描技术的支持。 在本文中,我使用了Symantec Scan Engine 5.1,它可以作为Unix或Windows安装使用。

快速参考:

 public void scanFile(byte[] fileBytes, String fileName) throws IOException, Exception { if (scan) { AVClient avc = new AVClient(avServer, avPort, avMode); if (avc.scanfile(fileName, fileBytes) == -1) { throw new VirusException("WARNING: A virus was detected in your attachment: " + fileName + "
Please scan your system with the latest antivirus software with updated virus definitions and try again."); } } }

然后

 catch (Exception ex) { logger.error(ex); if (ex instanceof VirusException) { // do something here } else { // there was some other error – handle it } } 

在Java和Go中使用VirusTotal Public API V2.0实现由VIGHNESWAR RAO编写
可在https://vighnesh.me/virustotal获取
它具有丰富的function来扫描文件,URL,域,IP地址,并获得有关扫描的详细报告。
使用此API,您的文件将使用56个防病毒引擎进行扫描。 并且所有防病毒引擎都在virustotal云中运行,因此您无需维护或运行任何防病毒引擎。
此API的一个重要特性是它具有接受java.io.FileInputStream或java.io.File作为参数的方法。
所有APIfunction都通过示例清楚地解释。
使用这个API
步骤1:在http://virustotal.com (VirusTotal,Google的子公司)中创建一个帐户并获取API密钥(100%免费)
步骤2:访问https://vighnesh.me/virustotal并下载所需的jar文件
第3步:只使用API​​提供的方法。
您可以使用https://vighnesh.me/virustotal/Java/examples.html或https://vighnesh.me/virustotal/Go/examples.html中提供的示例