Update get credentials method
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
##################################################
|
##################################################
|
||||||
## Project: Elysium ##
|
## Project: Elysium ##
|
||||||
## File: Test-WeakADPasswords.ps1 ##
|
## File: Test-WeakADPasswords.ps1 ##
|
||||||
## Version: 1.0 ##
|
## Version: 1.0.1 ##
|
||||||
## Support: support@cqre.net ##
|
## Support: support@cqre.net ##
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
Weak AD password finder component of Elysium tool.
|
Weak AD password finder component of Elysium tool.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This script will test the passwords of selected domain (defined in ElysiumSettings.txt) using DSInternal Test-PasswordQuality cmdlet. It writes it's output to a report file which is meant to be shared with internal security team.
|
This script will test the passwords of selected domain (defined in ElysiumSettings.txt) using DSInternal Test-PasswordQuality cmdlet. It writes its output to a report file which is meant to be shared with internal security team.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
# Current timestamp for both report generation and header
|
# Current timestamp for both report generation and header
|
||||||
@@ -48,7 +48,7 @@ Get-Content $settingsPath | ForEach-Object {
|
|||||||
if (-not [string]::IsNullOrWhiteSpace($_) -and -not $_.StartsWith("#")) {
|
if (-not [string]::IsNullOrWhiteSpace($_) -and -not $_.StartsWith("#")) {
|
||||||
$keyValue = $_ -split '=', 2
|
$keyValue = $_ -split '=', 2
|
||||||
if ($keyValue.Count -eq 2) {
|
if ($keyValue.Count -eq 2) {
|
||||||
$ElysiumSettings[$keyValue[0]] = $keyValue[1]
|
$ElysiumSettings[$keyValue[0].Trim()] = $keyValue[1].Trim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,31 +79,7 @@ if (-not (Test-Path -Path $reportPathBase)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Extract domain details from settings
|
# Extract domain details from settings
|
||||||
function Get-DomainDetailsFromSettings {
|
$domainDetails = Get-DomainDetailsFromSettings -Settings $ElysiumSettings
|
||||||
param (
|
|
||||||
[hashtable]$Settings
|
|
||||||
)
|
|
||||||
|
|
||||||
$domainDetails = @{}
|
|
||||||
$counter = 1
|
|
||||||
while ($true) {
|
|
||||||
$nameKey = "Domain${counter}Name"
|
|
||||||
$dcKey = "Domain${counter}DC"
|
|
||||||
$daKey = "Domain${counter}DA"
|
|
||||||
if ($Settings.ContainsKey($nameKey)) {
|
|
||||||
$domainDetails["$counter"] = @{
|
|
||||||
Name = $Settings[$nameKey]
|
|
||||||
DC = $Settings[$dcKey]
|
|
||||||
DA = $Settings[$daKey]
|
|
||||||
}
|
|
||||||
$counter++
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $domainDetails
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to test for weak AD passwords
|
# Function to test for weak AD passwords
|
||||||
function Test-WeakADPasswords {
|
function Test-WeakADPasswords {
|
||||||
@@ -123,16 +99,12 @@ function Test-WeakADPasswords {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prompt for DA password
|
# Prompt for DA credentials
|
||||||
$DAUsername = $selectedDomain["DA"]
|
$credential = Get-Credential -Message "Enter AD credentials with replication rights for $($selectedDomain.Name)"
|
||||||
$DApassword = Read-Host "Enter password for DA account ($DAUsername) of $($selectedDomain.Name)" -AsSecureString
|
|
||||||
|
|
||||||
# Preparing credentials for the domain
|
|
||||||
$credentials = New-Object System.Management.Automation.PSCredential ($selectedDomain["DA"], $DApassword)
|
|
||||||
|
|
||||||
# Performing the test
|
# Performing the test
|
||||||
Write-Host "Testing password quality for $($selectedDomain.Name)..."
|
Write-Host "Testing password quality for $($selectedDomain.Name)..."
|
||||||
$testResults = Get-ADReplAccount -All -Server $selectedDomain["DC"] -Credential $credentials |
|
$testResults = Get-ADReplAccount -All -Server $selectedDomain["DC"] -Credential $credential |
|
||||||
Test-PasswordQuality -WeakPasswordHashesFile $FilePath -Verbose
|
Test-PasswordQuality -WeakPasswordHashesFile $FilePath -Verbose
|
||||||
|
|
||||||
# Report generation with dynamic content
|
# Report generation with dynamic content
|
||||||
@@ -143,7 +115,6 @@ function Test-WeakADPasswords {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Main script logic
|
# Main script logic
|
||||||
$domainDetails = Get-DomainDetailsFromSettings -Settings $ElysiumSettings
|
|
||||||
Test-WeakADPasswords -DomainDetails $domainDetails -FilePath $WeakHashesSortedFilePath
|
Test-WeakADPasswords -DomainDetails $domainDetails -FilePath $WeakHashesSortedFilePath
|
||||||
|
|
||||||
Write-Host "Script execution completed."
|
Write-Host "Script execution completed."
|
||||||
|
Reference in New Issue
Block a user