dafthack / DomainPasswordSpray

DomainPasswordSpray is a tool written in PowerShell to perform a password spray attack against users of a domain. By default it will automatically generate the userlist from the domain. BE VERY CAREFUL NOT TO LOCKOUT ACCOUNTS!
MIT License
1.78k stars 377 forks source link

Function Get-ObservationWindow get troubles on -verbose #43

Open sPROFFEs opened 8 months ago

sPROFFEs commented 8 months ago

Errors when using -Verbose on lines 565/572

Powershell advices - Error: Cannot index into a null array. Error in method invocation because [System.String] does not contain a method named 'ConvertLargeIntegerToInt64'.

PosibleFix: Change the function Get-ObservationWindow on lines 565/572 to

function Get-ObservationWindow($DomainEntry)
{
    # Check if $DomainEntry is null
    if ($null -eq $DomainEntry) {
        Write-Host "Error: DomainEntry is null."
        return $null
    }

    # Check if 'Properties' exists and is not null
    if ($null -eq $DomainEntry.Properties) {
        Write-Host "Error: Properties is null."
        return $null
    }

    # Check if 'lockoutObservationWindow' exists in the object's properties
    if ($DomainEntry.Properties.ContainsKey('lockoutObservationWindow')) {
        # Get the value of the 'lockoutObservationWindow' attribute
        $lockObservationWindow_attr = $DomainEntry.Properties['lockoutObservationWindow']

        # Check if the attribute has an assigned value
        if ($null -ne $lockObservationWindow_attr -and $lockObservationWindow_attr.Count -gt 0) {
            # Convert the value from LargeInteger to TimeSpan
            $observation_window = [System.TimeSpan]::FromTicks($lockObservationWindow_attr.Value)

            # Return the observation window in minutes
            return $observation_window.TotalMinutes
        } else {
            Write-Host "lockoutObservationWindow attribute has no value."
            return $null
        }
    } else {
        Write-Host "lockoutObservationWindow attribute not found."
        return $null
    }
}

I am not sure if it modifies much the behavior of the original function but it seems to work. Feel free to modify it and comment

Also on line 265 be sure you´ve changed the parameter $Message to ${Message}