public void TestLongPaths() { var LongDirectories = new List <string> { Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\testfiles\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ienflaflieflanfeifnalnfae\dfiwnfwnfwnfownefinewnf.txt", }; var Regex = new SauronEye.RegexSearch(new List <string> { "pass" }); var Keywords = new List <string> { "pass" }; var ContentSearcher = new SauronEye.ContentsSearcher(LongDirectories, Keywords, Regex, 1024); ContentSearcher.Search(); var currentConsoleOut = Console.Out; var outputPath = @"ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ienflaflieflanfeifnalnfae\dfiwnfwnfwnfownefinewnf.txt"; var outputMatch = @"this is pass"; using (var consoleOutput = new ConsoleOutput()) { ContentSearcher.Search(); Assert.IsTrue(consoleOutput.GetOuput().Contains(outputPath)); Assert.IsTrue(consoleOutput.GetOuput().Contains(outputMatch)); } Assert.AreEqual(currentConsoleOut, Console.Out); }
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); } } foreach (string i in Results) { 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); contentsSearcher.Search(); } } }
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(); } } }
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(); } } }