コード例 #1
0
ファイル: Program.cs プロジェクト: scmccart/nClam
        static void Main(string[] args)
        {
            if(args == null || args.Length != 1)
            {
                Console.WriteLine("Invalid arguments.  Usage: nClam.ConsoleTest [FileName]");
                return;
            }

            var fileName = args[0];
            var client = new ClamClient("localhost", 3310);
            Console.WriteLine("GetVersion(): {0}", client.GetVersion());
            Console.WriteLine("GetPing(): {0}", client.Ping());
            Console.WriteLine("ScanFileOnServer(): {0}", client.ScanFileOnServer(fileName));
            Console.WriteLine("ScanFileOnServerMultithreaded(): {0}", client.ScanFileOnServerMultithreaded(fileName));

            if (!IsFolder(fileName))
            {
                try
                {
                    Console.WriteLine("SendAndScanFile(string): {0}", client.SendAndScanFile(fileName));
                    Console.WriteLine("SendAndScanFile(byte[]): {0}", client.SendAndScanFile(File.ReadAllBytes(fileName)));
                }
                catch (MaxStreamSizeExceededException msee)
                {
                    Console.WriteLine(msee.Message);
                }
            }
            else
            {
                Console.WriteLine("SendAndScanFile(): Not run because argument is a folder, not a file.");
            }
            Console.WriteLine("Finished, Press <enter> to quit.");
            Console.ReadLine();
        }
コード例 #2
0
        //scan the folder or file
        private int ScanFile(string loc, bool silent)
        {
            if (av_service_error)
            {
                MetroFramework.MetroMessageBox.Show(this, "Antivirus services are not running, kindly restart the software or see the help manual to troubleshoot", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(0);
            }

            int ret = 0;

            if (File.Exists(loc))
            {
                var clam       = new ClamClient("localhost", 3310);
                var scanResult = clam.ScanFileOnServer(loc);
                switch (scanResult.Result)
                {
                case ClamScanResults.Clean:
                    if (!silent)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "The file is clean, it's not infected!", "Fine", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    ret = 0;
                    break;

                case ClamScanResults.VirusDetected:
                {
                    if (!silent)
                    {
                        DialogResult dr = MetroFramework.MetroMessageBox.Show(this, "The file is infected\nVirus: " + scanResult.InfectedFiles.First().VirusName + "\nDo you want to delete?", "Virus Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == DialogResult.Yes)
                        {
                            try
                            {
                                File.Delete(loc);
                            }
                            catch { }
                        }
                    }
                    ret = 1;
                }
                break;
                }
                return(ret);
            }
            else
            {
                if (!silent)
                {
                    MetroFramework.MetroMessageBox.Show(this, "Invalid file to scan", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                ret = 3;
                return(ret);
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            if (args == null || args.Length != 1)
            {
                Console.WriteLine("Invalid arguments.  Usage: nClam.ConsoleTest [FileName]");
                return;
            }

            var fileInfo = new FileInfo(args[0]);

            var client = new ClamClient("localhost", 3310);

            Console.WriteLine("GetVersion(): {0}", client.GetVersion());
            Console.WriteLine("GetPing(): {0}", client.Ping());

            if (!fileInfo.Exists)
            {
                Console.WriteLine("{0} could not be found.  Exiting.", fileInfo.FullName);
                return;
            }

            Console.WriteLine("ScanFileOnServer(): {0}", client.ScanFileOnServer(fileInfo.FullName));
            Console.WriteLine("ScanFileOnServerMultithreaded(): {0}", client.ScanFileOnServerMultithreaded(fileInfo.FullName));

            if (!IsFolder(fileInfo.FullName))
            {
                Console.WriteLine("SendAndScanFile(string): {0}", client.SendAndScanFile(fileInfo.FullName));
                Console.WriteLine("SendAndScanFile(byte[]): {0}", client.SendAndScanFile(File.ReadAllBytes(fileInfo.FullName)));
            }
            else
            {
                Console.WriteLine("SendAndScanFile(): Not run because argument is a folder, not a file.");
            }
            Console.WriteLine("Finished, Press <enter> to quit.");
            Console.ReadLine();
        }
コード例 #4
0
        /// <summary>
        /// Scans a file for viruses
        /// </summary>
        /// <param name="pathToFile">The full path to the file</param>
        public ScanResult ScanFile(string pathToFile)
        {
            var clam = new ClamClient("localhost", 3310);

            return(MapScanResult(clam.ScanFileOnServer(pathToFile)));
        }
コード例 #5
0
        public bool Execute()
        {
            string path = Path.Combine(GitRepositoryPath, CatalogRecordId.ToString());

            //path = Path.Combine(path, ".git");

            logger.Debug("Starting AddFiles operation for " + path);

            var managedFiles = new List <ManagedFile>();

            // virus check
            bool virusError = false;

            using (var db = ApplicationDbContext.Create())
            {
                ApplicationUser user = new ApplicationUser {
                    Id = UserId.ToString()
                };
                db.Users.Attach(user);
                CatalogRecord record = new CatalogRecord {
                    Id = CatalogRecordId
                };
                db.CatalogRecords.Attach(record);
                foreach (var incomingFile in IncomingFileNames)
                {
                    var log = new Data.Event()
                    {
                        EventType            = EventTypes.EditManagedFile,
                        Timestamp            = DateTime.UtcNow,
                        User                 = user,
                        RelatedCatalogRecord = record,
                        Title                = "Virus Scan",
                        Details              = string.Empty
                    };

                    ManagedFile mf = db.Files.Where(x => x.Id == incomingFile.Key).First();
                    managedFiles.Add(mf);
                    log.RelatedManagedFiles.Add(mf);

                    string fileNameOnly = Path.GetFileName(incomingFile.Value);

                    // Virus check
                    try
                    {
                        mf.VirusCheckMethod = "ClamAV";
                        mf.VirusCheckDate   = DateTime.UtcNow;

                        logger.Debug("Running virus check on " + incomingFile.Value);

                        ClamClient scanner = new ClamClient("localhost", 3310);
                        var        result  = scanner.ScanFileOnServer(incomingFile.Value);

                        switch (result.Result)
                        {
                        case ClamScanResults.Clean:
                            mf.Status            = Data.FileStatus.Accepted;
                            mf.AcceptedDate      = DateTime.UtcNow;
                            mf.VirusCheckOutcome = "OK";

                            log.Details = "Clean virus scan on " + fileNameOnly;
                            logger.Debug(log.Details);

                            break;

                        case ClamScanResults.VirusDetected:
                            //TODO delete/quarentine? remove from incoming files.
                            mf.Status            = Data.FileStatus.Rejected;
                            mf.VirusCheckOutcome = log.Details;

                            //result.InfectedFiles.First().VirusName
                            virusError  = true;
                            log.Details = "Virus " + result.InfectedFiles.First().VirusName + "found on " + fileNameOnly;
                            logger.Warn(log.Details);

                            break;

                        case ClamScanResults.Error:
                            mf.Status            = Data.FileStatus.Accepted;
                            mf.AcceptedDate      = DateTime.UtcNow;
                            mf.VirusCheckOutcome = log.Details;

                            virusError  = true;
                            log.Details = "Virus scan error on " + fileNameOnly + " " + result.RawResult;
                            logger.Error(log.Details);

                            break;
                        }
                    }
                    catch (System.Net.Sockets.SocketException se)
                    {
                        virusError           = true;
                        log.Details          = "Could not connect to virus scanner for " + fileNameOnly + " " + se.Message;
                        mf.VirusCheckOutcome = log.Details;

                        logger.Error("Socket exception during virus check", se);
                    }
                    catch (Exception e)
                    {
                        virusError           = true;
                        log.Details          = "Error during virus scan " + fileNameOnly + " " + e.Message;
                        mf.VirusCheckOutcome = log.Details;

                        logger.Error("Problem during virus check", e);
                    }

                    db.Events.Add(log);
                }

                try
                {
                    db.SaveChanges();
                }
                catch (Exception)
                {
                }
            }

            if (virusError)
            {
                return(false);
            }

            // Add the files to the git repository.
            using (Repository repo = new Repository(path))
            {
                #region rename
                foreach (var rename in RenamedFileNames)
                {
                    Guid   fileId           = rename.Key;
                    string originalFileName = rename.Value.Item1;
                    string newFileName      = rename.Value.Item2;

                    string source      = Path.Combine(repo.Info.WorkingDirectory, originalFileName);
                    string destination = Path.Combine(repo.Info.WorkingDirectory, newFileName);
                    //File.Move(source, destination);
                    LibGit2Sharp.Commands.Move(repo, source, destination);
                }

                string authorEmail = UserEmail;
                if (string.IsNullOrWhiteSpace(authorEmail))
                {
                    authorEmail = "*****@*****.**";
                }

                Signature author    = new Signature(Username, authorEmail, DateTime.UtcNow);
                Signature committer = new Signature(UserId.ToString(), UserId.ToString() + "@curator", DateTime.UtcNow);

                try
                {
                    Commit commit = repo.Commit("Renaming Files", author, committer);
                }
                catch
                {
                    // Nothing to rename
                }
                #endregion

                foreach (var incomingFile in IncomingFileNames)
                {
                    string filename    = Path.GetFileName(incomingFile.Value);
                    string destination = Path.Combine(repo.Info.WorkingDirectory, filename);
                    File.Copy(incomingFile.Value, destination, true);

                    // For files that are larger than a gigabyte, do not stage them.
                    // gitlib throws an AccessViolationException.
                    var fileInfo = new FileInfo(incomingFile.Value);
                    if (fileInfo.Length > 1024 * 1024 * 1024)
                    {
                        continue;
                    }

                    try
                    {
                        LibGit2Sharp.Commands.Stage(repo, filename);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error while staging. " + ex.Message);
                    }
                }


                if (string.IsNullOrWhiteSpace(CommitMessage))
                {
                    CommitMessage = "Adding Files";
                }

                try
                {
                    if (repo.Index.Count > 0)
                    {
                        Commit commit = repo.Commit(CommitMessage, author, committer);
                    }
                }
                catch
                {
                    // TODO
                }
            }

            // Find the agency ID to use, based on the CatalogRecord.
            string agencyId = null;
            using (var db = ApplicationDbContext.Create())
            {
                var record = db.CatalogRecords.Where(x => x.Id == this.CatalogRecordId).Include(x => x.Organization).FirstOrDefault();
                if (record != null && record.Organization != null && !string.IsNullOrWhiteSpace(record.Organization.AgencyID))
                {
                    agencyId = record.Organization.AgencyID;
                }
                else
                {
                    //TODO error
                }

                var user = db.Users.Find(UserId.ToString());

                // Run any addin actions on each file.
                foreach (var file in managedFiles)
                {
                    foreach (var addin in FileActions)
                    {
                        try
                        {
                            if (!addin.CanRun(file))
                            {
                                continue;
                            }

                            addin.Run(file.CatalogRecord, file, user, db, path, agencyId);
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Error running file action: " + addin.Name, ex);

                            var note = new Data.Note()
                            {
                                CatalogRecord = file.CatalogRecord,
                                File          = file,
                                Timestamp     = DateTime.UtcNow,
                                User          = user,
                                Text          = "Error runnning file action: " + addin.Name + ". " + ex.Message
                            };
                            db.Notes.Add(note);
                            db.SaveChanges();
                        }
                    }
                }
            }

            return(true);
        }
コード例 #6
0
        protected void btnPreviewMain_Click(object sender, EventArgs e)
        {
            //Storage of database essentials
            ViewState["filesizeMain"]  = FileUploadMain.PostedFile.ContentLength.ToString();
            ViewState["medianameMain"] = FileUploadMain.PostedFile.FileName;
            //filesizeMain = FileUploadMain.PostedFile.ContentLength.ToString();
            //medianameMain = FileUploadMain.PostedFile.FileName;

            extensionMain = Path.GetExtension(FileUploadMain.FileName);
            extensionSec  = Path.GetExtension(FileUploadMain.FileName);
            ViewState["extensionMain"] = extensionMain;
            ViewState["extensionSec"]  = extensionSec;
            if (FileUploadMain.HasFile)
            {
                try
                {
                    if (FileUploadMain.PostedFile.ContentType == "image/png" || FileUploadMain.PostedFile.ContentType == "text/plain")
                    {
                        if (FileUploadMain.PostedFile.ContentLength < 1000000)
                        {
                            photoFolderMain           = Path.Combine(fromRootToPhotosMain, randomPicIDMain);
                            ViewState["StoredIdMain"] = randomPicIDMain;

                            photoFolderSec           = Path.Combine(fromRootToPhotosSec, randomPicIDSec);
                            ViewState["StoredIdSec"] = randomPicIDSec;
                            //Main Create Dir
                            if (!Directory.Exists(photoFolderMain))
                            {
                                Directory.CreateDirectory(photoFolderMain);
                            }
                            //Sec Create Dir
                            if (!Directory.Exists(photoFolderSec))
                            {
                                Directory.CreateDirectory(photoFolderSec);
                            }
                            ViewState["PhotoFolderMain"]    = photoFolderMain;
                            ViewState["PhotoFolderSec"]     = photoFolderSec;
                            uniqueFileNameMain              = Path.ChangeExtension(FileUploadMain.FileName, DateTime.Now.Ticks.ToString());
                            ViewState["uniqueFileNameMain"] = uniqueFileNameMain;

                            //Editing of main image
                            //Stream strm = FileUploadMain.PostedFile.InputStream;
                            //string targetPath;
                            //using (var img = System.Drawing.Image.FromStream(strm))
                            //{
                            //    int newWidth = 240;
                            //    int newHeight = 240;
                            //    var thumbImg = new Bitmap(newWidth, newHeight);
                            //    var thumbGraph = Graphics.FromImage(thumbImg);
                            //    thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                            //    thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            //    thumbGraph.SmoothingMode = SmoothingMode.HighQuality;
                            //    var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                            //    thumbGraph.DrawImage(img, imgRectangle);

                            //    targetPath = photoFolderMain + randomPicIDMain + "\\" + uniqueFileNameMain;
                            //    using (Bitmap bmp = new Bitmap(thumbImg))
                            //    {
                            //        bmp.Save(targetPath ,bmp.RawFormat);
                            //    }
                            //}

                            //Embedding secretText into ImageMain
                            Stream strm = FileUploadMain.PostedFile.InputStream;
                            Bitmap WatermarkedImageMain = (Bitmap)Image.FromStream(strm);
                            secretTextMain         = Cryptography.GetRandomString();
                            secretTextKeyMain      = Cryptography.GetRandomString();
                            encrytedSecretTextMain = EncryptStringAesIntoImage(secretTextMain, secretTextKeyMain);
                            WatermarkedImageMain   = Cryptography.embedText(encrytedSecretTextMain, WatermarkedImageMain);
                            WatermarkedImageMain.Save(Path.Combine(photoFolderMain, uniqueFileNameMain + extensionMain));

                            ViewState["secretTextKeyMain"]      = secretTextKeyMain;
                            ViewState["encrytedSecretTextMain"] = encrytedSecretTextMain;

                            var clam       = new ClamClient("localhost", 3310);
                            var scanResult = clam.ScanFileOnServer(Path.Combine(photoFolderMain, uniqueFileNameMain + extensionMain));

                            switch (scanResult.Result)
                            {
                            case ClamScanResults.Clean:
                                StatusLabelMain.CssClass = "label label-success";
                                StatusLabelMain.Text     = "Upload status: File uploaded!";
                                DisplayMainUploadedPhotos(imageToByteArray(WatermarkedImageMain));
                                DisplaySecondaryUploadedPhotos();

                                break;

                            case ClamScanResults.VirusDetected:
                                StatusLabelMain.Text = "Upload status: Virus Found!!!!!";
                                File.Delete(Path.Combine(photoFolderMain, uniqueFileNameMain + extensionMain));
                                StatusLabelMain.CssClass = "label label-danger";
                                break;

                            case ClamScanResults.Error:
                                StatusLabelMain.Text = scanResult.RawResult;
                                File.Delete(Path.Combine(photoFolderMain, uniqueFileNameMain + extensionMain));
                                StatusLabelMain.CssClass = "label label-danger";
                                break;
                            }
                        }
                        else
                        {
                            StatusLabelMain.Text     = "Upload status: The file has to be less than 1 MB!";
                            StatusLabelMain.CssClass = "label label-danger";
                        }
                    }
                    else
                    {
                        StatusLabelMain.Text     = "Upload status: Only PNG Or BMP files are accepted!";
                        StatusLabelMain.CssClass = "label label-danger";
                    }
                }
                catch (Exception ex)
                {
                    StatusLabelMain.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
            else
            {
                StatusLabelMain.Text     = "Upload status: You have not chosen a picture to preview!!";
                StatusLabelMain.CssClass = "label label-danger";
            }
        }
コード例 #7
0
        //Real time scanner
        private void RealTime(object sender, FileSystemEventArgs e)
        {
            if (av_service_error)
            {
                return;
            }
            if (exclusion.isExclusion(e.FullPath))
            {
                return;
            }

            FileAttributes attr;
            int            inf = 0;

            try
            {
                if (realToggle.Checked)
                {
                    Invoke(new Action(() =>
                    {
                        metroLabel13.Text = e.FullPath;
                    }));

                    attr = File.GetAttributes(e.FullPath);
                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        //give some to create the whole dir at once...
                        Thread.Sleep(3000);
                        //Now start scanning the folder

                        string[] fls = getFiles(e.FullPath, wildcard, SearchOption.AllDirectories);
                        if (fls != null)
                        {
                            //MessageBox.Show(fls.Length.ToString());
                            foreach (string s in fls)
                            {
                                if (File.Exists(s))
                                {
                                    var clam       = new ClamClient("localhost", 3310);
                                    var scanResult = clam.ScanFileOnServer(s);
                                    switch (scanResult.Result)
                                    {
                                    case ClamScanResults.VirusDetected:
                                    {
                                        inf++;
                                        AddToResult(s, scanResult.InfectedFiles.First().VirusName);
                                        Invoke(new Action(() =>
                                            {
                                                objectListView1.Visible = true;
                                                objectListView1.Show();
                                                this.Visible = true;
                                                this.Show();
                                                metroTabControl1.SelectedIndex = 2;
                                            }));
                                    }
                                    break;
                                    }
                                }
                            }
                            //Every found virus is listed, now play sound
                            if (inf > 0)
                            {
                                SoundPlayer snd = new SoundPlayer(Properties.Resources.virfound);
                                snd.Play();
                            }
                        }
                    }
                    else
                    {
                        //it's a file let's scan it...
                        var clam       = new ClamClient("localhost", 3310);
                        var scanResult = clam.ScanFileOnServer(e.FullPath);
                        switch (scanResult.Result)
                        {
                        case ClamScanResults.VirusDetected:
                        {
                            AddToResult(e.FullPath, scanResult.InfectedFiles.First().VirusName);
                            SoundPlayer snd = new SoundPlayer(Properties.Resources.virfound);
                            snd.Play();
                            Invoke(new Action(() =>
                                {
                                    objectListView1.Visible = true;
                                    objectListView1.Show();
                                    this.Visible = true;
                                    this.Show();
                                    metroTabControl1.SelectedIndex = 2;
                                }));
                        }
                        break;
                        }
                    }
                }
            }
            catch { }
        }
コード例 #8
0
        //scan a folder
        private void ScanFolder()
        {
            if (av_service_error)
            {
                MetroFramework.MetroMessageBox.Show(this, "Antivirus services are not running, kindly restart the software or see the help manual to troubleshoot", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                try
                {
                    Invoke(new Action(() =>
                    {
                        metroProgressSpinner1.Visible = false;
                        metroProgressBar1.Value       = 0;
                        metroLabel8.Text          = "No scan is going on...";
                        infec.Text                = "Infected Files: 0";
                        metroTile2.Enabled        = false;
                        metroTile3.Enabled        = false;
                        metroTile1.Enabled        = true;
                        curr_File.Text            = "...";
                        metroRadioButton2.Enabled = true;
                        metroRadioButton3.Enabled = true;
                        metroRadioButton4.Enabled = true;
                    }));

                    scanning = false;
                    search.Abort();
                }
                catch { }
            }

            scanning = true;
            bool error    = false;
            int  infected = 0;

            //if it's a quick scan, first check all the running processes
            if (metroRadioButton2.Checked)
            {
                metroLabel8.Text = "Scanning running processes";
                notifyIcon1.ShowBalloonTip(5, "Quick scan", "Scanning all running processes", ToolTipIcon.Info);
                foreach (string proc in GetAllRunningProcesses())
                {
                    if (File.Exists(proc))
                    {
                        try
                        {
                            var clam       = new ClamClient("localhost", 3310);
                            var scanResult = clam.ScanFileOnServer(proc);
                            Invoke(new Action(() =>
                            {
                                curr_File.Text = proc;
                            }));

                            switch (scanResult.Result)
                            {
                            case ClamScanResults.VirusDetected:
                                infected++;
                                Invoke(new Action(() =>
                                {
                                    infec.Text = "Infected Files: " + infected.ToString();
                                }));
                                AddToResult(proc, scanResult.InfectedFiles.First().VirusName);
                                break;
                            }
                        }
                        catch { error = true; }
                    }
                }
                Invoke(new Action(() =>
                {
                    curr_File.Text = "...";
                }));
            }//end of process scanning

            // normal scan process follows...

            Invoke(new Action(() =>
            {
                metroTile1.Enabled            = false;
                metroTile2.Enabled            = true;
                metroTile3.Enabled            = true;
                metroLabel8.Text              = "Please wait, while we prepare a list of files to be scanned. It may take some time...";
                metroProgressSpinner1.Visible = true;
                metroProgressSpinner1.Show();

                metroRadioButton2.Enabled = false;
                metroRadioButton3.Enabled = false;
                metroRadioButton4.Enabled = false;
            }));

            if (smart_Toggle.Checked)
            {
                files = getFiles(loc_to_search, smart_ext, SearchOption.AllDirectories);
            }
            else
            {
                files = getFiles(loc_to_search, wildcard, SearchOption.AllDirectories);
            }
            int total = files.Length;

            Invoke(new Action(() =>
            {
                metroProgressSpinner1.Visible = false;
                metroLabel8.Text          = "Scanning: " + loc_to_search + " (" + total.ToString() + " file)";
                metroProgressBar1.Maximum = total;
                metroProgressBar1.Minimum = 0;
                metroProgressBar1.Value   = 0;
                notifyIcon1.ShowBalloonTip(5, "Netsky Scanning...", "Virus scan has been started", ToolTipIcon.Info);
            }));

            foreach (string file in files)
            {
                if (File.Exists(file))
                {
                    try
                    {
                        var clam       = new ClamClient("localhost", 3310);
                        var scanResult = clam.ScanFileOnServer(file);
                        Invoke(new Action(() =>
                        {
                            curr_File.Text = file;
                        }));

                        switch (scanResult.Result)
                        {
                        case ClamScanResults.VirusDetected:
                            infected++;
                            Invoke(new Action(() =>
                            {
                                infec.Text = "Infected Files: " + infected.ToString();
                            }));
                            AddToResult(file, scanResult.InfectedFiles.First().VirusName);
                            break;
                        }
                    }
                    catch { error = true; }
                }
                Invoke(new Action(() =>
                {
                    metroProgressBar1.Value = (metroProgressBar1.Value + 1);
                }));
            }
            if (infected > 0)
            {
                // virus found
                SoundPlayer snd = new SoundPlayer(Properties.Resources.virfound);
                snd.Play();
                Invoke(new Action(() =>
                {
                    objectListView1.Visible = true;
                    objectListView1.Show();
                    //listView1.Visible = true;
                    //listView1.Show();
                    metroTabControl1.SelectedIndex = 2;
                }));
            }

            if (error)
            {
                /*
                 * Invoke(new Action(() =>
                 * {
                 *  metroTabControl1.SelectedIndex = 0;
                 *  pictureBox1.Image = Properties.Resources.unsecured;
                 *  pictureBox3.Image = Properties.Resources.cross;
                 * }));
                 *
                 * MetroFramework.MetroMessageBox.Show(this, "There is a problem with scanner engine, kindly restart the antivirus", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 */
            }

            files = null; // allow garbage collector to collect it
            Invoke(new Action(() =>
            {
                metroProgressSpinner1.Visible = false;
                metroProgressBar1.Value       = 0;
                metroLabel8.Text          = "No scan is going on...";
                infec.Text                = "Infected Files: 0";
                metroTile2.Enabled        = false;
                metroTile3.Enabled        = false;
                metroTile1.Enabled        = true;
                curr_File.Text            = "...";
                metroRadioButton2.Enabled = true;
                metroRadioButton3.Enabled = true;
                metroRadioButton4.Enabled = true;
            }));

            scanning = false;


            try
            {
                search.Abort();
            }
            catch { }
        }