Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements on DomainPasswordSpray #40

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
24 changes: 14 additions & 10 deletions DomainPasswordSpray.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function Invoke-DomainPasswordSpray{
Write-Host -ForegroundColor Yellow "[*] WARNING - Be very careful not to lock out accounts with the password list option!"
}

$observation_window = Get-ObservationWindow $CurrentDomain
$observation_window = Get-ObservationWindowForLockouts $CurrentDomain

Write-Host -ForegroundColor Yellow "[*] The domain password policy observation window is set to $observation_window minutes."
Write-Host "[*] Setting a $observation_window minute wait in between sprays."
Expand Down Expand Up @@ -258,7 +258,7 @@ function Countdown-Timer
)
if ($quiet)
{
Write-Host "$Message: Waiting for $($Seconds/60) minutes. $($Seconds - $Count)"
Write-Host "${Message: Waiting for $($Seconds/60) minutes. $($Seconds - $Count)}"
Start-Sleep -Seconds $Seconds
} else {
foreach ($Count in (1..$Seconds))
Expand Down Expand Up @@ -396,7 +396,7 @@ function Get-DomainUserList
}
}

$observation_window = Get-ObservationWindow $CurrentDomain
$observation_window = Get-ObservationWindowForLockouts $CurrentDomain

# Generate a userlist from the domain
# Selecting the lowest account lockout threshold in the domain to avoid
Expand Down Expand Up @@ -559,14 +559,18 @@ function Invoke-SpraySinglePassword
Start-Sleep -Seconds $RandNo.Next((1-$Jitter)*$Delay, (1+$Jitter)*$Delay)
}
}

}

function Get-ObservationWindow($DomainEntry)

Function Get-ObservationWindowForLockouts
{
# Get account lockout observation window to avoid running more than 1
# password spray per observation window.
$lockObservationWindow_attr = $DomainEntry.Properties['lockoutObservationWindow']
$observation_window = $DomainEntry.ConvertLargeIntegerToInt64($lockObservationWindow_attr.Value) / -600000000
return $observation_window
# Get the account lockout observation window to prevent more than one password spray during the observation period.
$domainPolicy = Get-ADDefaultDomainPasswordPolicy -Identity $Domain
if ($domainPolicy.LockoutObservationWindow -eq $null) {
return $null
}

$observationWindowInMinutes = $domainPolicy.LockoutObservationWindow.Minutes

return $observationWindowInMinutes
}