Scan uploaded files C# ASP.net

非 Y 不嫁゛ 提交于 2019-12-22 18:56:13

问题


I'm trying to do a virus scan on uploaded files. I have no control over the installed virus scanner, the product hosted by multiple parties with different scanners.

I tried the following library but it always returns VirusNotFound on the eicar file. https://antivirusscanner.codeplex.com/

Do you know any other solutions?


回答1:


ClamAV has pretty bad detection scores. VirusTotal is not on premises.

I decided to create CLI wrappers for multiple scanners, nuget packages can be found here: https://www.nuget.org/packages?q=avscan

And its documentation and source code available at https://github.com/yolofy/AvScan




回答2:


I used this library for .net (It uses the VirusTotal public api):

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

A little example from 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);
    }
}

A full example can be found here :

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




回答3:


Clam AV is pretty good. https://www.clamav.net/downloads

C# Api here: https://github.com/michaelhans/Clamson/



来源:https://stackoverflow.com/questions/39638114/scan-uploaded-files-c-sharp-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!