我正在尝试对上传的文件进行病毒扫描。
我无法控制安装的病毒扫描器,因为该产品由多个方面提供宿主服务,使用不同的扫描器。
我尝试了下面的库,但对于eicar文件它总是返回VirusNotFound。 https://antivirusscanner.codeplex.com/ 您知道其他解决方案吗?
我尝试了下面的库,但对于eicar文件它总是返回VirusNotFound。 https://antivirusscanner.codeplex.com/ 您知道其他解决方案吗?
我使用了这个库来进行 .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);
}
}
Clam AV相当不错。 https://www.clamav.net/downloads
C# API在这里: https://github.com/michaelhans/Clamson/
我刚刚尝试了各种方法,但有些并没有起作用。 然后我决定使用ESET NOD32命令行工具。
对我来说它很好用:
public bool Scan(string filename)
{
var result = false;
try
{
Process process = new Process();
var processStartInfo = new ProcessStartInfo(@"C:/Program Files/ESET/ESET Security/ecls.exe")
{
Arguments = $" \"{filename}\"",
CreateNoWindow = true,
ErrorDialog = false,
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false
};
process.StartInfo = processStartInfo;
process.Start();
process.WaitForExit();
if (process.ExitCode == 0) //if it doesn't exist virus ,it returns 0 ,if not ,it returns 1
{
result = true;
}
}
catch (Exception)
{ //nothing;
}
return result;
}