예제 #1
0
    protected bool OnScan(IList <ScanResult> results, string relativeFolderPath, string stateFileName, string[] loginSubfolderPatterns, string loginFileName)
    {
        string mainFolder = AppArgs.GetArgString("-scan-main-folder", string.Empty);

        if (string.IsNullOrEmpty(mainFolder))
        {
            mainFolder = applicationDataPath.FullName;
        }
        else
        {
            mainFolder = Path.Combine(mainFolder, applicationDataPath.Name);
        }

        string rootFolder = Path.Combine(mainFolder, relativeFolderPath);

        return(ScanHelper.Scan(rootFolder, stateFileName, loginSubfolderPatterns, loginFileName, results));
    }
예제 #2
0
        private static void ScanProcess()
        {
            Process[] processlist = Process.GetProcesses();

            foreach (Process theprocess in processlist)
            {
                try
                {
                    string processlocation = GetMainModuleFilepath(theprocess.Id);
                    byte[] fileBytes       = File.ReadAllBytes(processlocation);
                    string read            = Encoding.UTF8.GetString(fileBytes);

                    if (ScanHelper.Scan(read, ScanHelper.ScanTypes.Mutil, signatures))
                    {
                        Console.WriteLine($"Malware is {theprocess.ProcessName}");
                        //  theprocess.Kill();
                    }
                }
                catch
                {
                }
            }
        }
예제 #3
0
        private static void ScanFile()
        {
            Console.WriteLine("Enter path folder:\n");

            string        path      = @"C:\Users\luong\Desktop\demoScan";
            DirectoryInfo directory = new DirectoryInfo(path);

            FileInfo[]    pathsFile = directory.GetFiles("*.*", SearchOption.AllDirectories);
            List <string> lstPath   = new List <string>();

            lstPath = pathsFile.Select(x => x.FullName).ToList();

            foreach (string item in lstPath)
            {
                if (item.Contains(".txt") || item.Contains(".pdf") || item.Contains(".doc"))
                {
                    continue;
                }
                else
                {
                    try
                    {
                        using (StreamReader stream = new StreamReader(item))
                        {
                            string read = stream.ReadToEnd();
                            if (ScanHelper.Scan(read, ScanHelper.ScanTypes.Mutil, signatures))
                            {
                                Console.WriteLine($"Malware is: {item}");
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }