Posted in: Windows server

Vylepšená kontrola hesel uživatelů v Active Directory

Již před delším časem jsem publikoval sktript, který pracuje s modulem DSinternals Michaela Grafnettera a kontroloval hesla uživatelů proti databázi uniklých hesel. Dnes publikuji jeho vyleošenou verzi, která je pohodlnější na zadávání informací potřebných ke kontrole.
Prerekvizitou je nainstalovaný modul DSinternals, což lze provést příkazem:

Install-Module DSInternals -Force$rezim = Read-Host -Prompt "Plně textový režim?(A/N) (pokud ne, cestyk souborům jsou zadány výběrovým dialogem)"
if(($rezim -eq "A") -or ($rezim -eq "a") -or ($rezim -eq "y") -or ($rezim -eq "Y"))
{
$ntdsPath = Read-Host -Prompt "Zadej cestu k ntds.dit"
$systempath = Read-Host -Prompt "Zadej cestu k souboru registru SYSTEM z DC"
$slovnik = Read-Host -Prompt "Zadej cestu k souboru slovníku"
$vystup = Read-Host -Prompt "Zadej cestu k výstupnímu souboru"
}
else
{
Add-Type -AssemblyName System.Windows.Forms
$shell = New-Object -ComObject Shell.Application
[void] [System.Windows.MessageBox]::Show( "Vyber soubor ntds.dit ", "Script completed", "OK", "Information" )
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.Multiselect = $false
$response = $OpenFileDialog.ShowDialog( )
if ( $response -eq 'OK' ) { $ntdsPath = $OpenFileDialog.FileName }
[void] [System.Windows.MessageBox]::Show( "Vyber soubor SYSTEM z DC", "Script completed", "OK", "Information" )
$response = $OpenFileDialog.ShowDialog( )
if ( $response -eq 'OK' ) { $systempath = $OpenFileDialog.FileName }
[void] [System.Windows.MessageBox]::Show( "Vyber soubor slovníku hesel", "Script completed", "OK", "Information" )
$response = $OpenFileDialog.ShowDialog( )
if ( $response -eq 'OK' ) { $slovnik = $OpenFileDialog.FileName }
[void] [System.Windows.MessageBox]::Show( "Vyber umístění výstupního souboru", "Script completed", "OK", "Information" )
$selectedfolder = $shell.BrowseForFolder( 0, 'Select a folder to proceed', 16, $shell.NameSpace( 17 ).Self.Path ).Self.Path
$vystup = $selectedfolder + "\" +(Read-Host -Prompt "Zadeh název výstupního souboru") + ".txt"
}
Import-Module -Name DSInternals
$key = Get-BootKey -SystemHivePath $systempath
$hash = Read-Host -Prompt "Je slovník NTLM hash? (Y/N)"
if(($hash -eq "Y") -or ($hash -eq "y"))
{
Get-ADDBAccount -All -DBPath $ntdsPath -BootKey $key | Test-PasswordQuality -WeakPasswordHashesFile $slovnik | Out-File $vystup -Encoding utf8
}
else
{
Get-ADDBAccount -All -DBPath $ntdsPath -BootKey $key | Test-PasswordQuality -WeakPasswordsFile $slovnik | Out-File $vystup -Encoding utf8
}
Back to Top