Exemple #1
0
        private void GenerateUserData(FakeHealthCheckDataGeneratorDomainModel model, HealthcheckData healthcheckData)
        {
            healthcheckData.UserAccountData    = new HealthcheckAccountData();
            healthcheckData.AdminLastLoginDate = DateBetween2Dates(healthcheckData.DomainCreation, DateTime.Now);;
            healthcheckData.AdminAccountName   = GraphObjectReference.Administrator;
            int size = GetCountFromSize(model);

            for (int i = 0; i < size; i++)
            {
                ADItem x = new ADItem();
                x.DistinguishedName = "CN=123";
                // disabled
                x.UserAccountControl += BoolOnChance(15) * 0x00000002;
                //preauth
                x.UserAccountControl += BoolOnChance(1) * 0x400000;
                // locked
                x.UserAccountControl += BoolOnChance(4) * 0x00000010;
                // pwd never expires
                x.UserAccountControl += BoolOnChance(10) * 0x00010000;
                // pwd not required
                x.UserAccountControl += BoolOnChance(2) * 0x00000020;
                // trusted to authenticate
                x.UserAccountControl += BoolOnChance(2) * 0x80000;
                x.PrimaryGroupID      = 515 + BoolOnChance(1);
                HealthcheckAnalyzer.ProcessAccountData(healthcheckData.UserAccountData, x, false);
            }
            healthcheckData.LoginScript = new List <HealthcheckLoginScriptData>();
        }
Exemple #2
0
        private void GenerateComputerData(FakeHealthCheckDataGeneratorDomainModel model, HealthcheckData healthcheckData)
        {
            healthcheckData.OperatingSystem        = new List <HealthcheckOSData>();
            healthcheckData.OperatingSystemVersion = new List <HealthcheckOSVersionData>();
            healthcheckData.ComputerAccountData    = new HealthcheckAccountData();
            int size = GetCountFromSize(model);

            for (int i = 0; i < size; i++)
            {
                ADItem x = new ADItem();
                x.DistinguishedName = "CN=123";
                // disabled
                x.UserAccountControl += BoolOnChance(15) * 0x00000002;
                //preauth
                x.UserAccountControl += BoolOnChance(1) * 0x400000;
                // locked
                x.UserAccountControl += BoolOnChance(4) * 0x00000010;
                // pwd never expires
                x.UserAccountControl += BoolOnChance(10) * 0x00010000;
                // pwd not required
                x.UserAccountControl += BoolOnChance(2) * 0x00000020;
                // trusted to authenticate
                x.UserAccountControl += BoolOnChance(2) * 0x80000;
                x.PrimaryGroupID      = 515 + BoolOnChance(1);
                HealthcheckAnalyzer.ProcessAccountData(healthcheckData.ComputerAccountData, x, true);
            }
            healthcheckData.LoginScript = new List <HealthcheckLoginScriptData>();

            healthcheckData.DomainControllers = new List <HealthcheckDomainController>();
            size = (int)Math.Exp(Math.Log10(size) / 2);
            if (size < 1)
            {
                size = 1;
            }
            for (int i = 0; i < size; i++)
            {
                HealthcheckDomainController dc = new HealthcheckDomainController();
                dc.DCName       = "DC" + i;
                dc.CreationDate = DateBetween2Dates(healthcheckData.DomainCreation, DateTime.Now);
                // last logon timestam can have a delta of 14 days
                dc.LastComputerLogonDate = DateTime.Now.AddDays(-1 * rnd.Next(180));
                dc.DistinguishedName     = "DC=DC";
                dc.OperatingSystem       = "Windows 2019";
                healthcheckData.DomainControllers.Add(dc);
            }
        }
Exemple #3
0
        public override void Export(string filename)
        {
            ADDomainInfo domainInfo = null;

            using (ADWebService adws = new ADWebService(Server, Port, Credential))
            {
                domainInfo = adws.DomainInfo;

                int export = 0;
                using (StreamWriter sw = File.CreateText(filename))
                {
                    var header = new List <string>();
                    var hcprop = AddData.GetProperties();
                    header.Add("DistinguishedName");
                    header.Add("sAMAccountName");
                    header.Add("scriptPath");
                    header.Add("primaryGroupID");
                    header.Add("lastLogonTimestamp");
                    header.Add("pwdLastSet");
                    header.Add("whenCreated");
                    header.Add("objectClass");
                    header.Add("userAccountControl");
                    header.AddRange(hcprop);

                    sw.WriteLine(string.Join("\t", header.ToArray()));


                    WorkOnReturnedObjectByADWS callback =
                        (ADItem x) =>
                    {
                        var d = new AddData();
                        HealthcheckAnalyzer.ProcessAccountData(d, x, false);
                        if ((++export % 500) == 0)
                        {
                            DisplayAdvancement("Exported: " + export);
                        }


                        var data = new List <string>();
                        data.Add(x.DistinguishedName);
                        data.Add(x.SAMAccountName);
                        data.Add(x.ScriptPath);
                        data.Add(x.PrimaryGroupID.ToString());
                        data.Add(x.LastLogonTimestamp.ToString("u"));
                        data.Add(x.PwdLastSet.ToString("u"));
                        data.Add(x.WhenCreated.ToString("u"));
                        data.Add(x.Class);
                        data.Add(x.UserAccountControl.ToString());
                        foreach (var p in hcprop)
                        {
                            data.Add(d.PropertiesSet.Contains(p).ToString());
                        }
                        sw.WriteLine(string.Join("\t", data.ToArray()));
                    };

                    DisplayAdvancement("Starting");
                    adws.Enumerate(domainInfo.DefaultNamingContext, HealthcheckAnalyzer.userFilter, HealthcheckAnalyzer.userProperties, callback, "SubTree");
                    DisplayAdvancement("Done");
                }
            }
        }