Test-ElysiumPasswordQuality and Send-ElysiumHashExport only worked interactively: a Read-Host for the domain number and a credential prompt, so nothing could run unattended. - Both cmdlets take -Domain (a configured DomainNName, matched case-insensitively) and -Credential. Omitted, they prompt exactly as before; a supplied credential still goes through the same Get-ADDomain / replication-permission pre-checks. - The root wrappers take -Domain only and forward it through the Windows PowerShell relaunch; a PSCredential cannot be passed on a powershell.exe command line, so non-interactive credentials go through the cmdlets. - The two copies of the domain prompt become Select-ElysiumDomain in Private/Settings.ps1. An unknown name fails listing the configured domains; a domain without a DC fails before any credential prompt (the export previously only noticed later). Verified: unit test for by-name (case-insensitive), unknown name, missing DC, and the prompt path with Read-Host mocked (valid and invalid number); with a fake powershell.exe on PATH both wrappers relaunch with "-Domain contoso.local" intact; 32/32 Pester tests pass on this commit's tree. The AD paths need the Windows run.
40 lines
2.0 KiB
PowerShell
40 lines
2.0 KiB
PowerShell
##################################################
|
|
## ____ ___ ____ _____ _ _ _____ _____ ##
|
|
## / ___/ _ \| _ \| ____| | \ | | ____|_ _| ##
|
|
## | | | | | | |_) | _| | \| | _| | | ##
|
|
## | |__| |_| | _ <| |___ _| |\ | |___ | | ##
|
|
## \____\__\_\_| \_\_____(_)_| \_|_____| |_| ##
|
|
##################################################
|
|
## Project: Elysium ##
|
|
## File: Extract-NTHashes.ps1 ##
|
|
## Support: support@cqre.net ##
|
|
##################################################
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Script for extracting NTLM hashes from live AD for further analysis.
|
|
|
|
.DESCRIPTION
|
|
This script will connect to selected domain (defined in ElysiumSettings.txt) using account with AD replication privileges and extract NTLM hashes from all active accounts. It will then compress and encrypt the resulting file, uploads it to designated Azure Storage account, checks for validity and then deletes everything. The hashes are extracted without usernames to minimise the sensitivity of the operation. Encryption is done with AES and passphrase that was defined in environment variable during first run.
|
|
|
|
Thin wrapper around the Send-ElysiumHashExport cmdlet in src/Elysium, kept so existing
|
|
invocations and the menu keep working.
|
|
|
|
.PARAMETER Domain
|
|
Name of a configured domain (DomainNName in ElysiumSettings.txt). Omit to choose interactively.
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
param([string]$Domain)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
Set-StrictMode -Version Latest
|
|
|
|
# DSInternals/ActiveDirectory need Windows PowerShell; relaunch there when started from pwsh.
|
|
. (Join-Path -Path $PSScriptRoot -ChildPath 'src/Elysium/Private/Relaunch.ps1')
|
|
Restart-WithWindowsPowerShellIfAvailable -BoundParameters $PSBoundParameters -UnboundArguments $MyInvocation.UnboundArguments
|
|
|
|
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'src/Elysium/Elysium.psd1') -Force
|
|
Send-ElysiumHashExport @PSBoundParameters
|
|
Write-Host "Script execution completed."
|