コード例 #1
0
        public static List <User> GetUserTargets(PlaybookTask playbook_task, Logger logger)
        {
            PrincipalContext context;
            string           dc;
            List <User>      targetusers = new List <User>();


            switch (playbook_task.user_target_type)
            {
            case 1:
                logger.TimestampInfo("Targeting playbook defined users");
                foreach (string user in playbook_task.user_targets)
                {
                    User nuser = new User(user);
                    targetusers.Add(nuser);
                }
                break;

            case 2:
                context = new PrincipalContext(ContextType.Domain);
                dc      = context.ConnectedServer;
                logger.TimestampInfo("Targeting random domain users");
                targetusers = Ldap.GetADUsers(playbook_task.user_target_total, logger, dc, true);
                logger.TimestampInfo(String.Format("Obtained {0} user records", targetusers.Count));

                break;

            case 3:
                logger.TimestampInfo("Targeting randomly generated users");
                targetusers = Targets.GetRandomUsernames(playbook_task.user_target_total, new Random());
                break;

            case 4:
                logger.TimestampInfo("Targeting administrative accounts (adminCount=1) ");
                targetusers = Ldap.GetADAdmins(playbook_task.user_target_total, logger);
                logger.TimestampInfo(String.Format("Obtained {0} user records", targetusers.Count));
                break;

            case 5:
                logger.TimestampInfo("Targeting domain admins");
                targetusers = Ldap.GetDomainAdmins(logger);
                logger.TimestampInfo(String.Format("Obtained {0} user records", targetusers.Count));
                break;

            case 6:
                context = new PrincipalContext(ContextType.Domain);
                dc      = context.ConnectedServer;
                logger.TimestampInfo("Targeting disabled users");
                targetusers = Ldap.GetADUsers(playbook_task.user_target_total, logger, dc, false);
                logger.TimestampInfo(String.Format("Obtained {0} user records", targetusers.Count));
                break;

            default:
                return(targetusers);
            }

            return(targetusers);
        }
コード例 #2
0
        public static List <User> GetUserTargets(int usertype, int nuser)
        {
            List <User> targetusers = new List <User>();

            /*
             * string logonserver, dnsdomain, dc;
             * logonserver = Environment.GetEnvironmentVariable("logonserver").Replace("\\", "");
             * dnsdomain = Environment.GetEnvironmentVariable("USERDNSDOMAIN");
             * dc = logonserver + "." + dnsdomain;
             */

            PrincipalContext context = new PrincipalContext(ContextType.Domain);
            string           dc      = context.ConnectedServer;


            switch (usertype)
            {
            case 1:

                Console.WriteLine("[*] Targeting domain neighbor users");
                targetusers = Ldap.GetADUsers(nuser, dc, true);
                break;

            case 2:
                Console.WriteLine("[*] Targeting domain foreign users");
                targetusers = Ldap.GetADUsers(nuser, "", true);
                break;

            case 3:
                Console.WriteLine("[*] Targeting disabled users");
                targetusers = Ldap.GetADUsers(nuser, dc, false);
                break;

            case 4:
                Console.WriteLine("[*] Targeting administrative accounts (adminCount=1) ");
                targetusers = Ldap.GetADAdmins(nuser);
                break;

            case 5:
                Console.WriteLine("[*] Targeting domain admins");
                targetusers = Ldap.GetDomainAdmins();
                break;

            case 6:
                targetusers = Targets.GetRandomUsernames(nuser);
                break;

            default:
                return(targetusers);
            }

            return(targetusers);
        }
コード例 #3
0
ファイル: Targets.cs プロジェクト: mcomtzg/PurpleSharp
        public static List <User> GetUserTargets(int usertype, int nuser, Lib.Logger logger)
        {
            List <User>      targetusers = new List <User>();
            PrincipalContext context     = new PrincipalContext(ContextType.Domain);
            string           dc          = context.ConnectedServer;

            switch (usertype)
            {
            case 1:

                logger.TimestampInfo("Targeting domain neighbor users");
                targetusers = Ldap.GetADUsers(nuser, logger, dc, true);
                break;

            case 2:
                logger.TimestampInfo("Targeting domain foreign users");
                targetusers = Ldap.GetADUsers(nuser, logger, "", true);
                break;

            case 3:
                logger.TimestampInfo("Targeting disabled users");
                targetusers = Ldap.GetADUsers(nuser, logger, dc, false);
                break;

            case 4:
                logger.TimestampInfo("Targeting administrative accounts (adminCount=1) ");
                targetusers = Ldap.GetADAdmins(nuser);
                break;

            case 5:
                logger.TimestampInfo("Targeting domain admins");
                targetusers = Ldap.GetDomainAdmins();
                break;

            case 6:
                targetusers = Targets.GetRandomUsernames(nuser);
                break;

            default:
                return(targetusers);
            }

            return(targetusers);
        }