下午好!
我需要在VirusTotal上分析文件,然后将检测号保存在某个变量中,但我丢失了。我尝试了这段代码:https://github.com/Genbox/VirusTotal.NET但是每次运行它都会向我显示一条消息,表示我没有输入API密钥,这是不正确的。我试着把它放在任何地方。
您对此问题有经验吗?或者你有其他解决方案吗?
非常感谢! 问候, ALES
//编辑: VirusTotal.NET客户端
namespace VirusTotalNETClient
{
class Program
{
private const string ScanUrl = "http://www.google.com/";
static void Main(string[] args)
{
VirusTotal virusTotal = new VirusTotal(ConfigurationManager.AppSettings["ApiKey"]);
//Use HTTPS instead of HTTP
virusTotal.UseTLS = true;
//Create the EICAR test virus. See http://www.eicar.org/86-0-Intended-use.html
FileInfo fileInfo = new FileInfo("EICAR.txt");
File.WriteAllText(fileInfo.FullName, @"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");
//Check if the file has been scanned before.
FileReport fileReport = virusTotal.GetFileReport(fileInfo);
bool hasFileBeenScannedBefore = fileReport.ResponseCode == ReportResponseCode.Present;
Console.WriteLine("File has been scanned before: " + (hasFileBeenScannedBefore ? "Yes" : "No"));
//If the file has been scanned before, the results are embedded inside the report.
if (hasFileBeenScannedBefore)
{
PrintScan(fileReport);
}
else
{
ScanResult fileResult = virusTotal.ScanFile(fileInfo);
PrintScan(fileResult);
}
VirusTotal.NET
namespace VirusTotalNET
{
public partial class VirusTotal
{
private readonly RestClient _client = new RestClient();
private readonly string _apiKey;
private bool _useTls;
/// <summary>
/// Public constructor for VirusTotal.
/// </summary>
/// <param name="apiKey">5d8684f50946c2bdeaf5c4fd966f61f3661de808e9d7324b99788d6f4fb7ad57</param>
/// <exception cref="ArgumentException"></exception>
public VirusTotal(string apiKey)
{
if (string.IsNullOrEmpty(apiKey) || apiKey.Length < 64)
throw new ArgumentException("You have to set an API key.", "apiKey");
ApiUrl = "www.virustotal.com/vtapi/v2/";
_useTls = true;
_apiKey = apiKey;
_client.FollowRedirects = false;
FileSizeLimit = 33553369; //32 MB - 1063 = 33553369 it is the effective limit by virus total
RestrictSizeLimits = true;
RestrictNumberOfResources = true;
}