public static void checkReport(FileReport _report, string _fileName) { if (_report != null) { if (_report.ResponseCode == ReportResponseCode.Present) { foreach (ScanEngine scan in _report.Scans) { if (scan.Detected) { killUsedProcByFile(_fileName); try { File.Delete(_fileName); //File succesfully deleted TODO: Report if (File.Exists(_fileName)) { killUsedProcByFile(_fileName); } else { } } catch { killUsedProcByFile(_fileName); } } } } } }
private static void PrintScan(FileReport fileReport) { Console.WriteLine("Scan ID: " + fileReport.ScanId); Console.WriteLine("Message: " + fileReport.VerboseMsg); if (fileReport.ResponseCode == ReportResponseCode.Present) { foreach (KeyValuePair<string, ScanEngine> scan in fileReport.Scans) { Console.WriteLine("{0,-25} Detected: {1}", scan.Key, scan.Value.Detected); } } Console.WriteLine(); }
public static void scanFile(string fnPath, ScannedFileItem _scannedFile) { try { if (File.Exists(fnPath)) { _scanW.WorkerReportsProgress = true; _scanW.WorkerSupportsCancellation = true; _scanW.RunWorkerAsync(); _scanW.DoWork += (o, e) => { var virusTotal = new VirusTotal(apiKey); virusTotal.UseTLS = true; var fInfo = new FileInfo(fnPath); _report = new FileReport(); var fReport = virusTotal.GetFileReport(fInfo); _report = fReport; bool hasFileBeenScannedBefore = fReport.ResponseCode == ReportResponseCode.Present; if (!hasFileBeenScannedBefore) { var fResult = virusTotal.ScanFile(fInfo); } }; _scanW.RunWorkerCompleted += (m, e) => { if (_report != null) { var scanWin = new ScanResultWin(); scanWin.init(_report, _scannedFile); scanWin.ShowDialog(); } }; } } catch (Exception ex) { GeneralSettings.LogException(ex); } }
public void init(FileReport _scanResult, ScannedFileItem _scannedFile) { try { if (_scannedFile != null) { lblFullPath.Content = _scannedFile.FullPath; _fullPath = _scannedFile.FullPath; lblFileName.Content = _scannedFile.FileName; lblFileDate.Content = _scannedFile.Date; lblFileSize.Content = _scannedFile.FileSize; } if (_scanResult.ResponseCode == ReportResponseCode.Present) { foreach (ScanEngine scan in _scanResult.Scans) { if (scan.Detected == true) { howMany++; _scanResultItems.Add(new ScanResultItems { AvName = scan.Name, AvResult = new Uri("/Images/inWatch.avNOT.png", UriKind.RelativeOrAbsolute), AvStatus = scan.Result }); } else { _scanResultItems.Add(new ScanResultItems { AvName = scan.Name, AvResult = new Uri("/Images/inWatch.avOK.png", UriKind.RelativeOrAbsolute), AvStatus = "OK" }); } } lstScanResults.ItemsSource = _scanResultItems.OrderBy(item => item.AvName).ToList(); if (howMany == 0) { Title = "Es wurden keine Bedrohungen gefunden!"; cmdRemove.Visibility = Visibility.Collapsed; cmdIgnore.Visibility = Visibility.Collapsed; } else { Title = "Bedrohung gefunden!"; cmdRemove.Visibility = Visibility.Visible; cmdIgnore.Visibility = Visibility.Visible; } if (_scanStoppedEventHandler != null) { _scanStoppedEventHandler(_scannedFile.FullPath, howMany); } } } catch (Exception ex) { GeneralSettings.LogException(ex); } }
// Grabs the report and allows us to access some information // We add +1 for each detection to our label // and add each detection to the llistbox // with the AV name that detected a positive trigger. private void PrintScan(FileReport fileReport) { int detectedCount = 0; if (fileReport.ResponseCode == ReportResponseCode.Present) { // foreach loop for each scan results in fileReport foreach (ScanEngine scan in fileReport.Scans) { // Checking weather or not there is a detection // If so we want to add the information to our listbox bool scangoodbad = scan.Detected; // for debugging purposes we are just checking for 'good' detections or detections = false if (scangoodbad == false) { detectedCount = Convert.ToInt32(iTalk_Label8.Text); detectedCount += 1; // for each detection we want to add +1 to our label iTalk_Label8.Text = detectedCount.ToString(); listBox1.Items.Add(string.Format("AV: {0} | Detected: {1}", scan.Name, scan.Detected)); string scanID = fileReport.ScanId; iTalk_TextBox_Small3.Text = scanID; } } } }