public void Start(string virusTotalApiKey) { _virusTotal = new VirusTotalNET.VirusTotal(virusTotalApiKey); _shouldStopWorking = false; _virusTotalThread = new Thread(ThreadMethod); _virusTotalThread.Start(); }
public static async Task ScanURL(string url, RichTextBox richtextbox, DataGridView datagridview) { try { VirusTotalNET.VirusTotal virusTotal = new VirusTotalNET.VirusTotal(APIKey); //Use HTTPS instead of HTTP virusTotal.UseTLS = true; UrlReport urlReport = await virusTotal.GetUrlReport(url); bool hasUrlBeenScannedBefore = urlReport.ResponseCode == ReportResponseCode.Present; //If the url has been scanned before, the results are embedded inside the report. if (hasUrlBeenScannedBefore) { PrintScan(urlReport, url, hasUrlBeenScannedBefore, richtextbox, datagridview); } else { UrlScanResult urlResult = await virusTotal.ScanUrl(url); PrintScan(urlResult, url, hasUrlBeenScannedBefore, richtextbox, datagridview); } } catch (Exception e) { MessageBox.Show(e.Message, "Something went wrong!"); } }
public static async Task ScanFile(string path, RichTextBox richtextbox, DataGridView datagridview) { try { VirusTotalNET.VirusTotal virusTotal = new VirusTotalNET.VirusTotal(APIKey); //Use HTTPS instead of HTTP virusTotal.UseTLS = true; ////Create the EICAR test virus. See http://www.eicar.org/86-0-Intended-use.html //////test //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*"); FileInfo fileInfo = new FileInfo(path); //Check if the file has been scanned before. FileReport fileReport = await virusTotal.GetFileReport(fileInfo); bool hasFileBeenScannedBefore = fileReport.ResponseCode == ReportResponseCode.Present; //If the file has been scanned before, the results are embedded inside the report. if (hasFileBeenScannedBefore) { PrintScan(fileReport, path, hasFileBeenScannedBefore, richtextbox, datagridview); } else { ScanResult fileResult = await virusTotal.ScanFile(fileInfo); PrintScan(fileResult, path, hasFileBeenScannedBefore, richtextbox, datagridview); } } catch (Exception e) { MessageBox.Show(e.Message, "Something went wrong!"); } }
/// <summary> /// Public constructor for VirusTotalComplete /// </summary> /// <param name="apiKey">The API key you got from Virus Total</param> public VirusTotalComplete(string apiKey) { _virusTotal = new VirusTotal(apiKey); }