Esempio n. 1
0
 public FSSearcher(string d, List <string> f, List <string> k, bool s, UInt64 maxfs, bool systemdirs, RegexSearch regex, DateTime beforedate, DateTime afterdate, bool CheckForMacro, string ossstring)
 {
     this.SearchDirectory = d;
     this.Filetypes       = f;
     this.Keywords        = k;
     this.Results         = new List <string>();
     this.searchContents  = s;
     this.maxFileSizeInKB = maxfs;
     this.SystemDirs      = systemdirs;
     this.RegexSearcher   = regex;
     if (string.IsNullOrEmpty(ossstring))
     {
         this.ossflag = false;
     }
     else
     {
         this.ossflag   = true;
         this.ossstring = ossstring;
         string[] arr = ossstring.Split(':');
         this.bucketName      = arr[0];
         this.accessKeyId     = arr[1];
         this.accessKeySecret = arr[2];
         this.endpoint        = arr[3];
     }
     if (beforedate != null)
     {
         this.BeforeDate = beforedate;
     }
     if (afterdate != null)
     {
         this.AfterDate = afterdate;
     }
     this.CheckForMacro = CheckForMacro;
     this.OLXExplorer   = null;
 }
Esempio n. 2
0
        public void Search()
        {
            if (Directory.Exists(SearchDirectory))
            {
                FilesFilteredOnExtension = EnumerateFiles(SearchDirectory, "*.*", SearchOption.AllDirectories);
                foreach (string filepath in FilesFilteredOnExtension)
                {
                    if (ContainsKeyword(Path.GetFileName(filepath)))
                    {
                        Results.Add(filepath);
                    }
                }
                if (CheckForMacro)
                {
                    OLXExplorer = new OLEExplorer();
                }
                foreach (string i in Results)
                {
                    bool containsVBA = false;
                    if (CheckForMacro && EndsWithOffice2003Extension(i))
                    {
                        containsVBA = OLXExplorer.CheckForVBAMacros(i);
                        if (!containsVBA)
                        {
                            continue;
                        }
                    }
                    if (BeforeDate != DateTime.MinValue || AfterDate != DateTime.MinValue)
                    {
                        if (MatchesLastWrite(i))
                        {
                            Console.WriteLine("[+] {0}", i);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        Console.WriteLine("[+] {0}", i);
                    }
                }

                // Now search contents
                if (searchContents)
                {
                    Console.WriteLine("[*] Done searching file system, now searching contents");
                    var contentsSearcher = new ContentsSearcher(FilesFilteredOnExtension, Keywords, RegexSearcher, this.maxFileSizeInKB);
                    contentsSearcher.Search();
                }
            }
        }
Esempio n. 3
0
 public FSSearcher(string d, List <string> f, List <string> k, bool s, UInt64 maxfs, bool systemdirs, RegexSearch regex, DateTime beforedate, DateTime afterdate, bool CheckForMacro)
 {
     this.SearchDirectory = d;
     this.Filetypes       = f;
     this.Keywords        = k;
     this.Results         = new List <string>();
     this.searchContents  = s;
     this.maxFileSizeInKB = maxfs;
     this.SystemDirs      = systemdirs;
     this.RegexSearcher   = regex;
     if (beforedate != null)
     {
         this.BeforeDate = beforedate;
     }
     if (afterdate != null)
     {
         this.AfterDate = afterdate;
     }
     this.CheckForMacro = CheckForMacro;
     this.OLXExplorer   = null;
 }
Esempio n. 4
0
        public void Search()
        {
            if (Directory.Exists(SearchDirectory))
            {
                FilesFilteredOnExtension = EnumerateFiles(SearchDirectory, "*.*", SearchOption.AllDirectories);
                foreach (string filepath in FilesFilteredOnExtension)
                {
                    if (ContainsKeyword(Path.GetFileName(filepath)))
                    {
                        Results.Add(filepath);
                    }
                }
                if (CheckForMacro)
                {
                    OLXExplorer = new OLEExplorer();
                }
                foreach (string i in Results)
                {
                    bool containsVBA = false;
                    if (CheckForMacro && EndsWithOffice2003Extension(i))
                    {
                        containsVBA = OLXExplorer.CheckForVBAMacros(i);
                        if (!containsVBA)
                        {
                            continue;
                        }
                    }
                    if (BeforeDate != DateTime.MinValue || AfterDate != DateTime.MinValue)
                    {
                        if (MatchesLastWrite(i))
                        {
                            Console.WriteLine("[+] Find {0}", i);
                            if (ossflag)
                            {
                                Uploadfiles.Add(i);
                                Console.WriteLine("[+] Add {0} to Zip", i);
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        Console.WriteLine("[+] Find {0}", i);
                        if (ossflag)
                        {
                            Uploadfiles.Add(i);
                            Console.WriteLine("[+] Add {0} to Zip", i);
                        }
                    }
                }
                if (ossflag)
                {
                    Console.WriteLine("\n[*] Now Create Zipfile and Upload Zipfile to aliyunOSS");
                    Zipfile(Uploadfiles, this.bucketName, this.accessKeyId, this.accessKeySecret, this.endpoint);
                }

                // Now search contents
                if (searchContents)
                {
                    Console.WriteLine("[*] Done searching file system, now searching contents");
                    var contentsSearcher = new ContentsSearcher(FilesFilteredOnExtension, Keywords, RegexSearcher, this.maxFileSizeInKB, this.ossstring);
                    contentsSearcher.Search();
                }
            }
        }