9
9
[String]
10
10
. NOTES
11
11
Written by David Rowe, Blog secframe.com
12
- Twitter : @davidprowe
12
+ Twitter : @davicdprowe
13
13
I take no responsibility for any issues caused by this script. I am not responsible if this gets run in a production domain.
14
14
Thanks HuskyHacks for user/group/computer count modifications. I moved them to parameters so that this tool can be called in a more rapid fashion.
15
15
. FUNCTIONALITY
29
29
[Parameter (Mandatory = $false ,
30
30
Position = 2 ,
31
31
HelpMessage = ' Supply a count for user creation default 500' )]
32
- [int32 ]$GroupCount = 500 ,
32
+ [int32 ]$GroupCount = 10 ,
33
33
[Parameter (Mandatory = $false ,
34
34
Position = 3 ,
35
35
HelpMessage = ' Supply the script directory for where this script is stored' )]
@@ -123,20 +123,84 @@ if ($badblood -eq 'badblood') {
123
123
124
124
.($basescriptPath + ' \AD_Users_Create\CreateUsers.ps1' )
125
125
$createuserscriptpath = $basescriptPath + ' \AD_Users_Create\'
126
- # write-host $createuserscriptpath
127
- # Add custom function to runspace pool https://devblogs.microsoft.com/scripting/powertip-add-custom-function-to-runspace-pool/
128
- # . .\AD_Users_Create\CreateUsers.ps1
126
+ do {
127
+ createuser - Domain $Domain - OUList $ousAll - ScriptDir $createuserscriptpath
128
+ Write-Progress - Activity " Random Stuff into A domain - Creating $UserCount Users" - Status " Progress:" - PercentComplete ($x / $UserCount * 100 )
129
+ $x ++
130
+ }while ($x -lt $UserCount )
131
+
132
+ # Group Creation
133
+ $AllUsers = Get-aduser - Filter *
134
+ write-host " Creating Groups on Domain" - ForegroundColor Green
135
+
129
136
$x = 1
130
- $Definition = Get-Content Function:\CreateUser - ErrorAction Stop
131
- # $Definition = Get-Content ($basescriptPath + '\AD_Users_Create\CreateUsers.ps1') -ErrorAction Stop
137
+ Write-Progress - Activity " Random Stuff into A domain - Creating $GroupCount Groups" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
138
+ $i ++
139
+ .($basescriptPath + ' \AD_Groups_Create\CreateGroup.ps1' )
140
+ $createGroupScriptPath = $basescriptPath + ' \AD_Groups_Create\'
141
+
142
+ do {
143
+ Creategroup - Domain $Domain - OUList $ousAll - UserList $AllUsers - ScriptDir $createGroupScriptPath
144
+ Write-Progress - Activity " Random Stuff into A domain - Creating $GroupCount Groups" - Status " Progress:" - PercentComplete ($x / $GroupCount * 100 )
145
+ $x ++
146
+ }while ($x -lt $GroupCount )
147
+ $Grouplist = Get-ADGroup - Filter { GroupCategory -eq " Security" -and GroupScope -eq " Global" } - Properties isCriticalSystemObject
148
+ $LocalGroupList = Get-ADGroup - Filter { GroupScope -eq " domainlocal" } - Properties isCriticalSystemObject
149
+
150
+ # Computer Creation Time
151
+ write-host " Creating Computers on Domain" - ForegroundColor Green
152
+
153
+ $X = 1
154
+ Write-Progress - Activity " Random Stuff into A domain - Creating Computers" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
155
+ .($basescriptPath + ' \AD_Computers_Create\CreateComputers.ps1' )
156
+ $I ++
157
+ do {
158
+ Write-Progress - Activity " Random Stuff into A domain - Creating $ComputerCount computers" - Status " Progress:" - PercentComplete ($x / $ComputerCount * 100 )
159
+ createcomputer
160
+ $x ++
161
+ }while ($x -lt $ComputerCount )
162
+ $Complist = get-adcomputer - filter *
163
+
164
+
165
+ # Permission Creation of ACLs
166
+ $I ++
167
+ write-host " Creating Permissions on Domain" - ForegroundColor Green
168
+ Write-Progress - Activity " Random Stuff into A domain - Creating Random Permissions" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
169
+ .($basescriptPath + ' \AD_Permissions_Randomizer\GenerateRandomPermissions.ps1' )
170
+
171
+
172
+ # Nesting of objects
173
+ $I ++
174
+ write-host " Nesting objects into groups on Domain" - ForegroundColor Green
175
+ .($basescriptPath + ' \AD_Groups_Create\AddRandomToGroups.ps1' )
176
+ Write-Progress - Activity " Random Stuff into A domain - Adding Stuff to Stuff and Things" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
177
+ AddRandomToGroups - Domain $Domain - Userlist $AllUsers - GroupList $Grouplist - LocalGroupList $LocalGroupList - complist $Complist
178
+
179
+ # ATTACK Vector Automation
180
+
181
+ # SPN Generation
182
+ $I ++
183
+ write-host " Adding random SPNs to a few User and Computer Objects" - ForegroundColor Green
184
+ Write-Progress - Activity " SPN Stuff Now" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
185
+ .($basescriptpath + ' \AD_Attack_Vectors\AD_SPN_Randomizer\CreateRandomSPNs.ps1' )
186
+ CreateRandomSPNs - SPNCount 50
187
+
188
+
189
+
190
+ }
191
+ # $Definition = Get-Content Function:\CreateUser -ErrorAction Stop
192
+ <#
193
+ Attempt at multi threading. Issues with AD Limits and connections per user per second.
194
+ #Add custom function to runspace pool https://devblogs.microsoft.com/scripting/powertip-add-custom-function-to-runspace-pool/
195
+ $Definition = Get-Content ($basescriptPath + '\AD_Users_Create\CreateUsers.ps1') -ErrorAction Stop
132
196
#Create a sessionstate function entry
133
197
$SessionStateFunction = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList ‘CreateUser’, $Definition
134
198
#Create a SessionStateFunction
135
199
$InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
136
200
$initialSessionState.ImportPSModule("ActiveDirectory")
137
201
$InitialSessionState.Commands.Add($SessionStateFunction)
138
202
139
- $RunspacePool = [RunspaceFactory ]::CreateRunspacePool(1 , 10 , $InitialSessionState , $Host )
203
+ $RunspacePool = [RunspaceFactory]::CreateRunspacePool(1,5 ,$InitialSessionState,$Host)
140
204
$RunspacePool.Open()
141
205
$runspaces = $results = @()
142
206
do {
@@ -191,7 +255,7 @@ if ($badblood -eq 'badblood') {
191
255
$initialSessionState.ImportPSModule("ActiveDirectory")
192
256
$InitialSessionState.Commands.Add($SessionStateFunction)
193
257
194
- $RunspacePool = [RunspaceFactory ]::CreateRunspacePool(1 , 10 , $InitialSessionState , $Host )
258
+ $RunspacePool = [RunspaceFactory]::CreateRunspacePool(1,5 ,$InitialSessionState,$Host)
195
259
$RunspacePool.Open()
196
260
$runspaces = $results = @()
197
261
do {
@@ -237,7 +301,7 @@ if ($badblood -eq 'badblood') {
237
301
$initialSessionState.ImportPSModule("ActiveDirectory")
238
302
$InitialSessionState.Commands.Add($SessionStateFunction)
239
303
240
- $RunspacePool = [RunspaceFactory ]::CreateRunspacePool(1 , 10 , $InitialSessionState , $Host )
304
+ $RunspacePool = [RunspaceFactory]::CreateRunspacePool(1,5 ,$InitialSessionState,$Host)
241
305
$RunspacePool.Open()
242
306
$runspaces = $results = @()
243
307
@@ -259,33 +323,4 @@ if ($badblood -eq 'badblood') {
259
323
}
260
324
$RunspacePool.Close()
261
325
$RunspacePool.Dispose()
262
-
263
- $Complist = get-adcomputer - filter *
264
-
265
-
266
- # Permission Creation of ACLs
267
- $I ++
268
- write-host " Creating Permissions on Domain" - ForegroundColor Green
269
- Write-Progress - Activity " Random Stuff into A domain - Creating Random Permissions" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
270
- .($basescriptPath + ' \AD_Permissions_Randomizer\GenerateRandomPermissions.ps1' )
271
-
272
-
273
- # Nesting of objects
274
- $I ++
275
- write-host " Nesting objects into groups on Domain" - ForegroundColor Green
276
- .($basescriptPath + ' \AD_Groups_Create\AddRandomToGroups.ps1' )
277
- Write-Progress - Activity " Random Stuff into A domain - Adding Stuff to Stuff and Things" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
278
- AddRandomToGroups - Domain $Domain - Userlist $AllUsers - GroupList $Grouplist - LocalGroupList $LocalGroupList - complist $Complist
279
-
280
- # ATTACK Vector Automation
281
-
282
- # SPN Generation
283
- $I ++
284
- write-host " Adding random SPNs to a few User and Computer Objects" - ForegroundColor Green
285
- Write-Progress - Activity " SPN Stuff Now" - Status " Progress:" - PercentComplete ($i / $totalscripts * 100 )
286
- .($basescriptpath + ' \AD_Attack_Vectors\AD_SPN_Randomizer\CreateRandomSPNs.ps1' )
287
- CreateRandomSPNs - SPNCount 50
288
-
289
-
290
-
291
- }
326
+ #>
0 commit comments