Scan uploaded files C# ASP.net

孤街醉人 提交于 2019-12-06 08:30:34
Yolofy

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

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

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