1.1 Create user objects from the Active Directory Users and Computers console

0 32
In the previous article, we have already discussedADthe installation andADBasics...

In the previous article, we have already discussedADthe installation andADBasics. In this article, let's start using ADobjects (such as user objects, computer objects, group objects, network shares, etc.) to fill ADenvironment, and how computers join the domain.

1. Add user objects

You can useGUI,cmd,PowerShellCreate a new user, or you can also create batch users using scripts.

1.1 Create user objects from the Active Directory Users and Computers console

Open the console from the Server Manager panel - Tools - Active Directory Users and Computers (or enter in Run)dsa.mscOpen it ()

1686720520_648950082eca9f746f068.png!small?1686720521153

1686720533_648950157aa09314b7caa.png!small?1686720534164

Click on the corresponding domain, inUsersRight-click on the container and selectNew-User

1686720546_648950224de14648ab474.png!small?1686720547338

Fill in the user's surname, given name, and login name

1686720557_6489502d495f7e2d15fef.png!small?1686720558340

Then click Next, and set the user's password

1686720568_64895038d40da43807dab.png!small?1686720569604

Click Next, and then click Finish after confirming that everything is correct.

1686720581_648950457bf7e540c51cc.png!small?1686720582252

1.2 Create user objects using CMD or Powershell

Using the command prompt, we can use net userUtility to create users.

C:\Users\Administrator>net user aduser2 Pass@123 /add /domain

UsePowerhellWe can useNew-ADUser cmdletCreate a user.

PS C:\> New-ADUser -Name "aduser3" -GivenName AD -Surname User -SamAccountName aduser3 -UserPrincipalName aduser3@pentest.com -AccountPassword (ConvertTo-SecureString Password@123 -AsPlainText -Force) -PassThru

1686720607_6489505fe3820b2a276fb.png!small?1686720608957

Now that the user account has been created, useEnable-ADAccount cmdletEnable it.

PS C:\> Enable-ADAccount aduser3

1686720619_6489506b7063f6255495d.png!small?1686720620246

UsePowershellBatch create user objects.

Create an array of users with random names. Obtain the list of random names here and create a small array of random names.

The UserNames array contains the following names: Michael, Christopher, Jessica, Matthew, Ashley, Jennifer, Joshua, Amanda, Daniel, David, James, Robert, John, Joseph, Andrew, Ryan, Brandon, Jason, Justin, Sarah, William, Jonathan, Stephanie, Brian, Nicole, Nicholas, Anthony, Heather, Eric, Elizabeth, Adam, Megan, Melissa, Kevin, Steven, Thomas, Timothy, Christina, Kyle, Rachel, Laura, Lauren, Amber, Brittany, Danielle, Richard, Kimberly, Jeffrey, Amy, Crystal, Michelle, Tiffany, Jeremy, Benjamin, Mark, Emily, Aaron, Charles, Rebecca, Jacob, Stephen, Patrick, Sean, Erin, Zachary, Jamie, Kelly, Samantha, Nathan, Sara, Dustin, Paul, Angela, Tyler, Scott, Katherine, Andrea, Gregory, Erica, Mary, Travis, Lisa, Kenneth, Bryan, Lindsey, Kristen, Jose, Alexander, Jesse, Katie, Lindsay, Shannon, Vanessa, Courtney, Christine, Alicia, 'Cody', 'Allison', 'Bradley', 'Samuel', 'Shawn', 'April', 'Derek', 'Kathryn', 'Kristin', 'Chad', 'Jenna', 'Tara', 'Maria', 'Krystal', 'Jared', 'Anna', 'Edward', 'Julie', 'Peter', 'Holly', 'Marcus', 'Kristina', 'Natalie', 'Jordan', 'Victoria', 'Jacqueline', 'Corey', 'Keith', 'Monica', 'Juan', 'Donald', 'Cassandra', 'Meghan', 'Joel', 'Shane', 'Phillip', 'Patricia', 'Brett', 'Ronald', 'Catherine', 'George', 'Antonio', 'Cynthia', 'Stacy', 'Kathleen', 'Raymond', 'Carlos', 'Brandi', 'Douglas', 'Nathaniel', 'Ian', 'Craig', 'Brandy', 'Alex', 'Valerie', 'Veronica', 'Cory', 'Whitney', 'Gary', 'Derrick', 'Philip', 'Luis', 'Diana', 'Chelsea', 'Leslie', 'Caitlin', 'Leah', 'Natasha', 'Erika', 'Casey', 'Latoya', 'Erik', 'Dana', 'Victor', 'Brent', 'Dominique', 'Frank', 'Brittney', 'Evan', 'Gabriel', 'Julia', 'Candice', 'Karen', 'Melanie', 'Adrian', 'Stacey', 'Margaret', 'Sheena', 'Wesley', 'Vincent', 'Alexandra', 'Katrina', 'Bethany', 'Nichole', 'Larry', 'Jeffery', 'Curtis', 'Carrie', 'Todd');

Then create a small function that accepts the limit of the user accounts to be created and loops through these usernames using}}New-ADUser cmdletCreate random users by passing additional parameters from global variables (such as domain, password, etc.) to it.

for ($i=1; $i -le $UsersLimit; $i=$i+1 ) {
        $firstname = (Get-Random -InputObject $UserNames);
        $lastname = (Get-Random -InputObject $UserNames);
        $fullname = "{0} {1}" -f ($firstname , $lastname);
        $SamAccountName = ( "{0}.{1}" -f ($firstname, $lastname)).ToLower();
        $principalname = "{0}.{1}" -f ($firstname, $lastname);
        if($SamAccountName.Length -le 20){
            try { 
                Write-Host "Creating user object: $SamAccountName" -ForegroundColor 'Gray'; 
                New-ADUser -Name "$firstname $lastname" -GivenName $firstname -Surname $lastname -SamAccountName $SamAccountName -UserPrincipalName $principalname@$Global:Domain -AccountPassword (ConvertTo-SecureString $Global:default_password -AsPlainText -Force) -PassThru | Enable-ADAccount
            } 
                Write-Host "Error creating user object: $SamAccountName" -ForegroundColor 'Red'
            }
        }
    }

由于Active Directory中用户名的最大长度限制为20因此,我们需要检查用户名的长度if($SamAccountName.Length -le 20)然后尝试创建用户,以避免创建用户时出错。

然后就可以批量创建用户了,你也可以通过向New-ADUser cmdlet传递额外的参数来设置标题、部门等属性,使用户账户看起来更真实。

PS C:\Scripts> Invoke-LoadADObjects -DomainName rootdse.org -LimitUsers 15

[+] 在rootdse.org中创建批量域用户
创建用户对象:katie.courtney
创建用户对象:danielle.latoya
创建用户对象:craig.laura
创建用户对象:aaron.anna
创建用户对象:rebecca.julia
创建用户对象:catherine.candice
创建用户对象:jesse.todd
创建用户对象:william.jessica
创建用户对象:nicholas.april
创建用户对象:christopher.meghan
创建用户对象:whitney.ronald
创建用户对象:derek.jennifer
Creating user object: charles.carlos
Creating user object: catherine.joel
Creating user object: sarah.cassandra
[+] Bulk user object creation completed.

2. Add computer objects

To ADWe can use New-ADComputer cmdlet:

New-ADComputer -Name testPC01 -SamAccountName testPC01 -DNSHostName testPC01.pentest.com

1686720634_6489507a873d3144e1e2c.png!small?1686720635258

To create multiple computer accounts in bulk, similar to creating user objects in bulk, first create a number

$CompNames = @('APPSRV01', 'APPSRV02', 'APPSRV03', 'APPSRV04', 'APPSRV05', 'SQLSRV01', 'SQLSRV02', 'SQLSRV03', 'SQLSRV04', 'SQLSRV05', 'VNCSRV01', 'VNCSRV02', 'VNCSRV03', 'VNCSRV04', 'VNCSRV05', 'WEBSRV01', 'WEBSRV02', 'WEBSRV03', 'WEBSRV04', 'WEBSRV05', 'BCKUPSRV01', 'BCKUPSRV02', 'BCKUPSRV03', 'BCKUPSRV04', 'BCKUPSRV05');

then runNew-ADComputer cmdlet:

foreach($computer in $CompNames){
    $SamAccountName = "$computer"
    try { 
        Write-Host "Creating computer object: $($computer + "." + $Global:domainname)" -ForegroundColor 'Gray'; 
        New-ADComputer -Name $computer -SamAccountName $computer -Instance $Global:templateComp -DNSHostName $($computer + "." + $Global:domainname);
    } 
        Write-Host "Error creating computer object" -ForegroundColor 'Red'
        }
}

3. Add group object

We can use New-ADGroup cmdletCreate group object

New-ADGroup -name "DB Administrators" -GroupScope Global

1686720649_6489508988e08d1256dd3.png!small?1686720650642

To create groups in bulk, we can follow the same process.

The related scripts can be downloaded here:https://github.com/ScarredMonk/PopulateActiveDirectory

Use scripts to fill in data:

4. Description

This article is compiled from the original text by the author, please indicate the original source when转载.

Original Source:Active Directory Lab Setup (Part 2)- Add data to AD domain

你可能想看:

Class and object - object characteristics - separate storage of member variables and member functions

4.3. List API: Display all objects (object) that a user can access

It is possible to perform credible verification on the system boot program, system program, important configuration parameters, and application programs of computing devices based on a credible root,

2.1 Find the location and the root cause of the problem in the code for the large object

5. Collect exercise results The main person in charge reviews the exercise results, sorts out the separated exercise issues, and allows the red and blue sides to improve as soon as possible. The main

4.5 Main person in charge reviews the simulation results, sorts out the separated simulation issues, and allows the red and blue teams to improve as soon as possible. The main issues are as follows

Announcement regarding the addition of 7 units as technical support units for the Ministry of Industry and Information Technology's mobile Internet APP product security vulnerability database

2. The related concepts and demands extended from the identified subject

As announced today, Glupteba is a multi-component botnet targeting Windows computers. Google has taken action to disrupt the operation of Glupteba, and we believe this action will have a significant i

(3) Is the national secret OTP simply replacing the SHA series hash algorithms with the SM3 algorithm, and becoming the national secret version of HOTP and TOTP according to the adopted dynamic factor

最后修改时间:
admin
上一篇 2025年03月25日 10:17
下一篇 2025年03月25日 10:40

评论已关闭