private static SharpSploit.Enumeration.Domain.DomainSearcher searcherBuilder(string[] args) { try { SharpSploit.Enumeration.Domain.Credential creds = null; string domain = "", server = "", searchBase = "", searchString = ""; System.DirectoryServices.SearchScope searchScope = System.DirectoryServices.SearchScope.Subtree; int resultPageSize = 200; TimeSpan serverTimeLimit = default(TimeSpan); bool tombStone = false; System.DirectoryServices.SecurityMasks securityMasks = 0; string[] argsLower = args.Select(s => s.ToLowerInvariant()).ToArray(); if (Array.IndexOf(argsLower, "-username") > -1) { if (Array.IndexOf(argsLower, "-password") > -1) { creds = new SharpSploit.Enumeration.Domain.Credential(args[Array.IndexOf(args, "-username") + 1], args[Array.IndexOf(args, "-password") + 1]); Console.WriteLine(args[Array.IndexOf(args, "-password") + 1]); } else { Console.WriteLine("Error, if providing credentials you must provide both a username and password"); return(null); } } if (Array.IndexOf(argsLower, "-domain") > -1) { domain = args[Array.IndexOf(args, "-domain") + 1]; } if (Array.IndexOf(argsLower, "-server") > -1) { server = args[Array.IndexOf(args, "-server") + 1]; } if (Array.IndexOf(argsLower, "-searchbase") > -1) { searchBase = args[Array.IndexOf(args, "-searchbase") + 1]; } if (Array.IndexOf(argsLower, "-searchstring") > -1) { searchString = args[Array.IndexOf(args, "-searchstring") + 1]; } var gather = new SharpSploit.Enumeration.Domain.DomainSearcher(creds, domain, server, searchBase, searchString, searchScope, resultPageSize, serverTimeLimit, tombStone, securityMasks); return(gather); } catch { Console.WriteLine("Error Generating Domain Searcher Object"); return(null); } }
public DirectorySearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, System.DirectoryServices.SearchScope scope) { this.filter = "(objectClass=*)"; this.scope = System.DirectoryServices.SearchScope.Subtree; this.serverTimeLimit = minusOneSecond; this.clientTimeout = minusOneSecond; this.serverPageTimeLimit = minusOneSecond; this.referralChasing = ReferralChasingOption.External; this.sort = new SortOption(); this.cacheResults = true; this.attributeScopeQuery = ""; this.extendedDN = System.DirectoryServices.ExtendedDN.None; this.searchRoot = searchRoot; this.filter = filter; if (propertiesToLoad != null) { this.PropertiesToLoad.AddRange(propertiesToLoad); } this.SearchScope = scope; }
public DirectorySearcher(string filter, string[] propertiesToLoad, System.DirectoryServices.SearchScope scope) : this(null, filter, propertiesToLoad, scope) { }
public DirectorySearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, System.DirectoryServices.SearchScope scope) { this.filter = "(objectClass=*)"; this.scope = System.DirectoryServices.SearchScope.Subtree; this.serverTimeLimit = minusOneSecond; this.clientTimeout = minusOneSecond; this.serverPageTimeLimit = minusOneSecond; this.referralChasing = ReferralChasingOption.External; this.sort = new SortOption(); this.cacheResults = true; this.attributeScopeQuery = ""; this.extendedDN = System.DirectoryServices.ExtendedDN.None; this.searchRoot = searchRoot; this.filter = filter; if (propertiesToLoad != null) { this.PropertiesToLoad.AddRange(propertiesToLoad); } this.SearchScope = scope; }