Ejemplo n.º 1
0
        public object ScanM(string filename)
        {
            FileInfo fi = new FileInfo(filename);

            try
            {
                if (fi.Length < MaximumSize)
                {
                    using (KCompress.KCompressExtractor extr = new KCompressExtractor(filename))
                    {
                        extr.ExtractArchive(AVEngine.TempDir + Path.GetFileNameWithoutExtension(filename) + @"\");
                    }
                    object svir = null;
                    foreach (string file in FileHelper.GetFilesRecursive(AVEngine.TempDir + Path.GetFileNameWithoutExtension(filename) + @"\"))
                    {
                        if (file.EndsWith(".text"))
                        {
                            svir = VDB.GetPEMD5(Security.GetMD5HashFromFile(file));
                            if (svir != null)
                            {
                                return(svir);
                            }
                        }
                        else if (file.EndsWith(".data"))
                        {
                            svir = VDB.GetPEMD5(Security.GetMD5HashFromFile(file));
                            if (svir != null)
                            {
                                return(svir);
                            }
                        }
                        else if (file.EndsWith(".idata"))
                        {
                            svir = VDB.GetPEMD5(Security.GetMD5HashFromFile(file));
                            if (svir != null)
                            {
                                return(svir);
                            }
                        }
                        File.Delete(file);
                    }
                    return(VDB.GetMD5(Security.GetMD5HashFromFile(filename)));
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
            finally
            {
            }
            return(null);
        }
Ejemplo n.º 2
0
        public object ScanM(string filename, System.Windows.Forms.Label lb)
        {
            try
            {
                FileInfo sv = new FileInfo(filename);
                if (sv.Length < MaximumSize)
                {
                    using (KCompressExtractor extr = new KCompressExtractor(filename))
                    {
                        extr.ExtractArchive(AVEngine.TempDir + Path.GetFileNameWithoutExtension(filename) + @"\");
                    }
                    foreach (string file in FileHelper.GetFilesRecursive(AVEngine.TempDir + Path.GetFileNameWithoutExtension(filename) + @"\"))
                    {
                        try
                        {
                            GUI.UpdateLabel(lb, filename + ":" + file.Replace(AVEngine.TempDir + Path.GetFileNameWithoutExtension(filename), ""));

                            object slst = FileFormat.GetFileFormat(file).ScanM(file);

                            if (slst != null)
                            {
                                return(slst + "&" + file.Replace(AVEngine.TempDir + Path.GetFileNameWithoutExtension(filename) + @"\", ""));
                            }


                            File.Delete(file);
                        }
                        catch
                        {
                        }
                    }
                    return(null);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return("KavprotSensor/Unpackable.Archive");
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        public static void ZoneScan(string path, Label CurFile, ProgressBarX progress, ItemPanel lst)
        {
            Stopwatch st      = Stopwatch.StartNew();
            int       total   = 0;
            int       scanned = 0;
            object    vir     = null;

            try
            {
                if (AVEngine.ScanSensitivity == ScanSense.High)
                {
                    List <string> list = FileHelper.GetFilesRecursive(path);
                    total = list.Count;
                    foreach (string file in list)
                    {
                        scanned++;
                        GUI.UpdateProgress(progress, scanned, total);
                        GUI.UpdateLabel(CurFile, file);
                        vir = FileFormat.GetFileFormat(file).ScanHS(file, CurFile);
                        if (vir != null)
                        {
                            if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner)
                            {
                                string[] s = vir.ToString().Split('&');
                                GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst);
                            }
                            else
                            {
                                GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst);
                            }
                        }
                    }
                }
                else if (AVEngine.ScanSensitivity == ScanSense.Medium)
                {
                    List <string> list = FileHelper.GetFilesRecursive(path);
                    total = list.Count;
                    foreach (string file in list)
                    {
                        scanned++;
                        GUI.UpdateProgress(progress, scanned, total);
                        GUI.UpdateLabel(CurFile, file);
                        vir = FileFormat.GetFileFormat(file).ScanM(file, CurFile);
                        if (vir != null)
                        {
                            if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner)
                            {
                                string[] s = vir.ToString().Split('&');
                                GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst);
                            }
                            else
                            {
                                GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst);
                            }
                        }
                    }
                }
                else
                {
                    List <string> list = FileHelper.GetFilesRecursive(path);
                    total = list.Count;
                    foreach (string file in list)
                    {
                        scanned++;
                        GUI.UpdateProgress(progress, scanned, total);
                        GUI.UpdateLabel(CurFile, file);
                        vir = FileFormat.GetFileFormat(file).Scan(file, CurFile);
                        if (vir != null)
                        {
                            if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner)
                            {
                                string[] s = vir.ToString().Split('&');
                                GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst);
                            }
                            else
                            {
                                GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                st.Stop();
                // alert needed
                GUI.UpdateLabel(CurFile, "Scan Performed in " + st.Elapsed.ToString());
                Alert.ScanCompleted();
            }
        }