Fixing table sorting and S3 upload
This commit is contained in:
@@ -122,7 +122,14 @@ function New-S3Client {
|
|||||||
function Get-Bytes([string]$s) { return [System.Text.Encoding]::UTF8.GetBytes($s) }
|
function Get-Bytes([string]$s) { return [System.Text.Encoding]::UTF8.GetBytes($s) }
|
||||||
function Get-HashHex([byte[]]$bytes) {
|
function Get-HashHex([byte[]]$bytes) {
|
||||||
$sha = [System.Security.Cryptography.SHA256]::Create()
|
$sha = [System.Security.Cryptography.SHA256]::Create()
|
||||||
try { return ([BitConverter]::ToString($sha.ComputeHash($bytes))).Replace('-', '').ToLowerInvariant() } finally { $sha.Dispose() }
|
try {
|
||||||
|
if ($null -eq $bytes) { $bytes = [byte[]]@() }
|
||||||
|
$ms = [System.IO.MemoryStream]::new($bytes)
|
||||||
|
try {
|
||||||
|
$hashBytes = $sha.ComputeHash($ms)
|
||||||
|
return ([BitConverter]::ToString($hashBytes)).Replace('-', '').ToLowerInvariant()
|
||||||
|
} finally { $ms.Dispose() }
|
||||||
|
} finally { $sha.Dispose() }
|
||||||
}
|
}
|
||||||
function Get-FileSha256Hex([string]$path) {
|
function Get-FileSha256Hex([string]$path) {
|
||||||
$sha = [System.Security.Cryptography.SHA256]::Create()
|
$sha = [System.Security.Cryptography.SHA256]::Create()
|
||||||
@@ -131,7 +138,11 @@ function Get-FileSha256Hex([string]$path) {
|
|||||||
}
|
}
|
||||||
function HmacSha256([byte[]]$key, [string]$data) {
|
function HmacSha256([byte[]]$key, [string]$data) {
|
||||||
$h = [System.Security.Cryptography.HMACSHA256]::new($key)
|
$h = [System.Security.Cryptography.HMACSHA256]::new($key)
|
||||||
try { return $h.ComputeHash((Get-Bytes $data)) } finally { $h.Dispose() }
|
try {
|
||||||
|
$dataBytes = Get-Bytes $data
|
||||||
|
$ms = [System.IO.MemoryStream]::new($dataBytes)
|
||||||
|
try { return $h.ComputeHash($ms) } finally { $ms.Dispose() }
|
||||||
|
} finally { $h.Dispose() }
|
||||||
}
|
}
|
||||||
function GetSignatureKey([string]$secret, [string]$dateStamp, [string]$regionName, [string]$serviceName) {
|
function GetSignatureKey([string]$secret, [string]$dateStamp, [string]$regionName, [string]$serviceName) {
|
||||||
$kDate = HmacSha256 (Get-Bytes ('AWS4' + $secret)) $dateStamp
|
$kDate = HmacSha256 (Get-Bytes ('AWS4' + $secret)) $dateStamp
|
||||||
@@ -159,7 +170,7 @@ function BuildAuthHeaders($method, [System.Uri]$uri, [string]$region, [string]$a
|
|||||||
$amzdate = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssZ')
|
$amzdate = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssZ')
|
||||||
$datestamp = (Get-Date).ToUniversalTime().ToString('yyyyMMdd')
|
$datestamp = (Get-Date).ToUniversalTime().ToString('yyyyMMdd')
|
||||||
$hostHeader = $uri.Host
|
$hostHeader = $uri.Host
|
||||||
if (-not $uri.IsDefaultPort) { $hostHeader = "$hostHeader:$($uri.Port)" }
|
if (-not $uri.IsDefaultPort) { $hostHeader = "{0}:{1}" -f $hostHeader, $uri.Port }
|
||||||
|
|
||||||
$canonicalUri = BuildCanonicalPath $uri
|
$canonicalUri = BuildCanonicalPath $uri
|
||||||
$canonicalQueryString = ''
|
$canonicalQueryString = ''
|
||||||
@@ -308,8 +319,8 @@ function Get-FileChecksum {
|
|||||||
$reportBase = Normalize-ReportPath -p $ElysiumSettings['ReportPathBase']
|
$reportBase = Normalize-ReportPath -p $ElysiumSettings['ReportPathBase']
|
||||||
if (-not (Test-Path $reportBase)) { New-Item -Path $reportBase -ItemType Directory -Force | Out-Null }
|
if (-not (Test-Path $reportBase)) { New-Item -Path $reportBase -ItemType Directory -Force | Out-Null }
|
||||||
|
|
||||||
# Build domain details from settings
|
# Build domain details from settings (ordered to keep numeric index order)
|
||||||
$DomainDetails = @{}
|
$DomainDetails = [ordered]@{}
|
||||||
for ($i = 1; $ElysiumSettings.ContainsKey("Domain${i}Name"); $i++) {
|
for ($i = 1; $ElysiumSettings.ContainsKey("Domain${i}Name"); $i++) {
|
||||||
$DomainDetails["$i"] = @{
|
$DomainDetails["$i"] = @{
|
||||||
Name = $ElysiumSettings["Domain${i}Name"]
|
Name = $ElysiumSettings["Domain${i}Name"]
|
||||||
@@ -320,7 +331,7 @@ for ($i = 1; $ElysiumSettings.ContainsKey("Domain${i}Name"); $i++) {
|
|||||||
|
|
||||||
# User selects a domain
|
# User selects a domain
|
||||||
Write-Host "Select a domain to extract NTLM hashes:"
|
Write-Host "Select a domain to extract NTLM hashes:"
|
||||||
$DomainDetails.GetEnumerator() | ForEach-Object { Write-Host "$($_.Key): $($_.Value.Name)" }
|
$DomainDetails.GetEnumerator() | Sort-Object { [int]$_.Key } | ForEach-Object { Write-Host "$($_.Key): $($_.Value.Name)" }
|
||||||
$selection = Read-Host "Enter the number of the domain"
|
$selection = Read-Host "Enter the number of the domain"
|
||||||
$selectedDomain = $DomainDetails[$selection]
|
$selectedDomain = $DomainDetails[$selection]
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ function Get-DomainDetailsFromSettings {
|
|||||||
[hashtable]$Settings
|
[hashtable]$Settings
|
||||||
)
|
)
|
||||||
|
|
||||||
$domainDetails = @{}
|
$domainDetails = [ordered]@{}
|
||||||
$counter = 1
|
$counter = 1
|
||||||
while ($true) {
|
while ($true) {
|
||||||
$nameKey = "Domain${counter}Name"
|
$nameKey = "Domain${counter}Name"
|
||||||
@@ -330,7 +330,7 @@ function Test-WeakADPasswords {
|
|||||||
|
|
||||||
# User selects a domain
|
# User selects a domain
|
||||||
Write-Host "Select a domain to test:"
|
Write-Host "Select a domain to test:"
|
||||||
$DomainDetails.GetEnumerator() | ForEach-Object { Write-Host "$($_.Key): $($_.Value.Name)" }
|
$DomainDetails.GetEnumerator() | Sort-Object { [int]$_.Key } | ForEach-Object { Write-Host "$($_.Key): $($_.Value.Name)" }
|
||||||
$selection = Read-Host "Enter the number of the domain"
|
$selection = Read-Host "Enter the number of the domain"
|
||||||
|
|
||||||
if (-not ($DomainDetails.ContainsKey($selection))) {
|
if (-not ($DomainDetails.ContainsKey($selection))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user