【问题标题】:Scan uploaded files C# ASP.net扫描上传的文件 C# ASP.net
【发布时间】:2017-01-30 23:26:29
【问题描述】:

我正在尝试对上传的文件进行病毒扫描。 我无法控制已安装的病毒扫描程序,该产品由多方使用不同的扫描程序托管。

我尝试了以下库,但它总是在 eicar 文件上返回 VirusNotFound。 https://antivirusscanner.codeplex.com/

你知道其他解决方案吗?

【问题讨论】:

  • 可以使用病毒总api

标签: c# asp.net-mvc antivirus virus-scanning


【解决方案1】:

ClamAV 的检测分数很差。 VirusTotal 不在本地。

我决定为多个扫描器创建 CLI 包装器,可以在此处找到 nuget 包:https://www.nuget.org/packages?q=avscan

其文档和源代码可在https://github.com/yolofy/AvScan获得

【讨论】:

  • 此解决方案是否将文件发送到第三方服务?
【解决方案2】:

【讨论】:

    【解决方案3】:

    我将此库用于 .net(它使用 VirusTotal 公共 API):

    https://github.com/Genbox/VirusTotal.NET

    来自 github 的一个小例子:

    static void Main(string[] args)
    {
        VirusTotal virusTotal = new VirusTotal("INSERT API KEY HERE");
    
        //Use HTTPS instead of HTTP
        virusTotal.UseTLS = true;
    
        FileInfo fileInfo = new FileInfo("testfile.txt");
    
        //Create a new file
        File.WriteAllText(fileInfo.FullName, "This is a test file!");
    
         //Check if the file has been scanned before.
        Report fileReport = virusTotal.GetFileReport(fileInfo).First();
        bool hasFileBeenScannedBefore = fileReport.ResponseCode == 1;
    
        if (hasFileBeenScannedBefore)
        {
            Console.WriteLine(fileReport.ScanId);
        }
        else
        {
            ScanResult fileResults = virusTotal.ScanFile(fileInfo);
            Console.WriteLine(fileResults.VerboseMsg);
        }
    }
    

    一个完整的例子可以在这里找到:

    https://github.com/Genbox/VirusTotal.NET/blob/master/VirusTotal.NET%20Client/Program.cs

    【讨论】:

      猜你喜欢
      • 2010-10-02
      • 2013-09-13
      • 2011-05-30
      • 2020-11-21
      • 2011-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多