Files
elysium/Extract-NTHashes.ps1
T
tomas.kracmar 4fe884e658 refactor(Extract-NTHashes): move the export into the module as Send-ElysiumHashExport
Fourth root script converted, same mechanical approach as
Test-ElysiumPasswordQuality (AST line ranges, then a line-by-line
comparison ignoring indentation that shows only these differences):

- Script body -> src/Elysium/Public/Send-ElysiumHashExport.ps1
  (exported, [CmdletBinding()], comment-based help).
- Protect-FileWithAES -> Private/Crypto.ps1 (the ELY2 format in one
  place). tests/test_decrypt.py now dot-sources that file instead of
  pulling the function out of the script's AST.
- S3 put/get/delete, Get-FileSha256Hex and Get-FileChecksum ->
  Private/Storage.ps1; Normalize-ReportPath -> Private/Settings.ps1.
- The script's own Domain<N> loop -> the shared
  Get-DomainDetailsFromSettings; the only difference was a
  Domain<N>DA value that nothing read.
- The hash export's Out-File gets an explicit -Encoding utf8 (the
  value the script-level $PSDefaultParameterValues default supplied),
  so that session-global default and $OutputEncoding are dropped.
- Transcript via the shared helper (same extract-hashes-*.log name),
  $scriptRoot -> $InstallRoot; the completion message moves to the
  wrapper.

Extract-NTHashes.ps1 is now a thin wrapper (relaunch under
powershell.exe, import module, call the cmdlet).

Verified on macOS: decrypt round trip passes against Crypto.ps1, 22/22
Pester tests pass, and the cmdlet runs through settings to its
passphrase check and writes its transcript. The AD extraction and
upload need a Windows run.
2026-11-04 13:01:26 +01:00

35 lines
1.8 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.
#>
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
[string]$commonHelper = Join-Path -Path $PSScriptRoot -ChildPath 'Elysium.Common.ps1'
if (-not (Test-Path -LiteralPath $commonHelper)) { throw "Common helper not found at $commonHelper" }
. $commonHelper
Restart-WithWindowsPowerShellIfAvailable -BoundParameters $PSBoundParameters -UnboundArguments $MyInvocation.UnboundArguments
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'src/Elysium/Elysium.psd1') -Force
Send-ElysiumHashExport
Write-Host "Script execution completed."