Esempio n. 1
0
        public override string[] Execute(ParsedArgs args)
        {
            LDAP          computerQuery = new LDAP();
            List <string> domainSystems = computerQuery.CaptureComputers();
            Amass         shareMe       = new Amass();
            List <string> allShares     = shareMe.GetShares(domainSystems);

            return(allShares.ToArray());
        }
Esempio n. 2
0
        public override string[] Execute(ParsedArgs args)
        {
            try
            {
                LDAP          computerQuery = new LDAP();
                List <string> domainSystems = computerQuery.CaptureComputers();
                Amass         shareMe       = new Amass();
                string[]      allShares     = shareMe.GetShares(domainSystems, args.Threads);

                return(allShares);
            }
            catch (Exception e)
            {
                return(new string[] { "[X] Failure to enumerate info - " + e });
            }
        }
Esempio n. 3
0
        public override string[] Execute(ParsedArgs args)
        {
            List <string> readableShares = new List <string>();

            try
            {
                LDAP          computerQuery = new LDAP();
                List <string> domainSystems = computerQuery.CaptureComputers();
                Amass         shareMe       = new Amass();
                string[]      allShares     = shareMe.GetShares(domainSystems, args.Threads);

                foreach (string shareDir in allShares)
                {
                    try
                    {
                        string[] subdirectoryEntries = Directory.GetDirectories(shareDir);
                        readableShares.Add(shareDir);
                    }
                    catch (UnauthorizedAccessException)
                    {
                        // do nothing
                    }
                    catch (IOException)
                    {
                        // do nothing either
                    }
                }

                return(readableShares.ToArray());
            }
            catch (Exception e)
            {
                foreach (string path in readableShares)
                {
                    Console.WriteLine(path);
                }

                Console.WriteLine("[X] ERROR State Occurred - Paths above are current status prior to error!");
                return(new string[] { "[X] Failure to enumerate info - " + e });
            }
        }
Esempio n. 4
0
        public override string[] Execute(ParsedArgs args)
        {
            LDAP          computerQuery    = new LDAP();
            List <string> interestingFiles = new List <string>();
            List <Regex>  regexList        = new List <Regex>();

            string[] allShares = new string[1];

            if (string.IsNullOrEmpty(args.SharePath))
            {
                List <string> domainSystems = computerQuery.CaptureComputers();
                Amass         shareMe       = new Amass();
                allShares = shareMe.GetShares(domainSystems, args.Threads);
            }
            else
            {
                allShares[0] = args.SharePath;
            }


            // We need to convert the given wildcard string to regex and account for multiple strings
            foreach (var term in args.SearchTerms)
            {
                if (term.Contains("*"))
                {
                    string regexText = WildcardToRegex(term);
                    Regex  regex     = new Regex(regexText, RegexOptions.IgnoreCase);
                    regexList.Add(regex);
                }
                else
                {
                    Regex regex = new Regex(term, RegexOptions.IgnoreCase);
                    regexList.Add(regex);
                }
            }

            // Pipe multiple search strings together into one regex string
            var regexString = regexList.Count() > 1 ? string.Join("|", regexList) : regexList[0].ToString();

            if (allShares != null)
            {
                foreach (var share in allShares)
                {
                    try
                    {
                        Parallel.ForEach(GetFiles(share), file =>
                        {
                            if (Regex.IsMatch(file, regexString, RegexOptions.IgnoreCase))
                            {
                                interestingFiles.Add(file);
                            }
                        });
                    }
                    catch (UnauthorizedAccessException)
                    {
                        //Do nothing
                    }
                }
            }

            return(interestingFiles.ToArray());
        }
        public override string[] Execute(ParsedArgs args)
        {
            List <string> successfulShareWrites = new List <string>();

            try
            {
                LDAP          computerQuery = new LDAP();
                List <string> domainSystems = computerQuery.CaptureComputers();
                Amass         shareMe       = new Amass();
                string[]      allShares     = shareMe.GetShares(domainSystems, args.Threads);

                foreach (string sharePath in allShares)
                {
                    // Get current date to have something to write
                    string time = DateTime.Now.ToString();

                    // try to write directly to the root of the share
                    try
                    {
                        using (StreamWriter outputFile = new StreamWriter(Path.Combine(sharePath, "testwritefile.txt")))
                        {
                            outputFile.WriteLine(time);
                            successfulShareWrites.Add(sharePath);
                        }

                        File.Delete(Path.Combine(sharePath, "testwritefile.txt"));
                        if (File.Exists(Path.Combine(sharePath, "testwritefile.txt")))
                        {
                            Console.WriteLine("[-] ALERT: Successfully wrote file but could not delete it at this location: " + Path.Combine(sharePath, "testwritefile.txt"));
                        }
                    }
                    catch (UnauthorizedAccessException)
                    {
                        // do nothing
                    }
                    catch (IOException)
                    {
                        // do nothing
                    }

                    try
                    {
                        // enumerate folders in the share
                        string[] dirNames = Directory.GetDirectories(sharePath, "*", SearchOption.TopDirectoryOnly);

                        // try to write to the 1st level of folders
                        foreach (string subdirPath in dirNames)
                        {
                            try
                            {
                                using (StreamWriter outputFile =
                                           new StreamWriter(Path.Combine(subdirPath, "testwritefile.txt")))
                                {
                                    outputFile.WriteLine(time);
                                    successfulShareWrites.Add(subdirPath);
                                }
                                File.Delete(Path.Combine(subdirPath, "testwritefile.txt"));
                                if (File.Exists(Path.Combine(subdirPath, "testwritefile.txt")))
                                {
                                    Console.WriteLine("[-] ALERT: Successfully wrote file but could not delete it at this location: " + Path.Combine(subdirPath, "testwritefile.txt"));
                                }
                            }
                            catch (UnauthorizedAccessException)
                            {
                                // do nothing
                            }
                            catch (IOException)
                            {
                                // do nothing
                            }
                        }
                    }
                    catch (IOException)
                    {
                        // ignore
                    }
                    catch (UnauthorizedAccessException)
                    {
                        // ignore
                    }
                }

                return(successfulShareWrites.ToArray());
            }
            catch (Exception e)
            {
                foreach (string path in successfulShareWrites)
                {
                    Console.WriteLine(path);
                }

                Console.WriteLine("[X] ERROR State Occurred - Paths above are current status prior to error!");
                return(new string[] { "[X] Failure to enumerate info - " + e });
            }
        }