Skip to content

Commit

Permalink
Merge pull request #5 from sussurro/random_add_spn
Browse files Browse the repository at this point in the history
Random add spn
  • Loading branch information
sussurro authored Jun 28, 2021
2 parents 8d261e7 + bcf71e6 commit 86a0b53
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
59 changes: 59 additions & 0 deletions AD_SPN_Randomizer/GenerateRandomSPNs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Function CreateRandomSPNs{

<#
.SYNOPSIS
Creates random SPNs based on combinations of users and computers
.DESCRIPTION
Creates random SPNs based on combinations of users and computers
.PARAMETER Count
The number of random SPNs to create
.EXAMPLE
.NOTES
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created by www.github.com/sussurro
#>
[CmdletBinding()]

param
(
[Parameter(Mandatory = $false,
Position = 1,
HelpMessage = 'supply a count for the number of spns to create')]
[int32]$SPNCount = 50
)

$services = ("https","ftp","CIFS","kafka","MSSQL","POP3")
$computers = Get-ADComputer -Filter *
$users = Get-ADUser -Filter *

$i = 0
Do {
$computer = $computers | Get-Random
$user = $users | Get-Random
$service = $services | get-Random
$cn = $computer.Name
$spn = "$service/$cn"

Try {
$user | Set-ADUser -ServicePrincipalNames @{Add=$spn} -ErrorAction Stop
}Catch { $i--}

$i++
} While($i -lt $SPNCount)
}

4 changes: 4 additions & 0 deletions Invoke-BadBlood.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ if ($badblood -eq 'badblood') {
.($basescriptPath + '\AD_Groups_Create\AddRandomToGroups.ps1')
Write-Progress -Activity "Random Stuff into A domain - Adding Stuff to Stuff and Things" -Status "Progress:" -PercentComplete ($i / $totalscripts * 100)
AddRandomToGroups -Domain $Domain -Userlist $AllUsers -GroupList $Grouplist -LocalGroupList $LocalGroupList -complist $Complist

write-host "Creating random SPNs" -ForegroundColor Green
.($basescriptpath + '\AD_SPN_Randomizer\GenerateRandomSPNs.ps1')
CreateRandomSPNs -SPNCount 50



Expand Down

0 comments on commit 86a0b53

Please sign in to comment.