Commit Graph
30 Commits
Author SHA1 Message Date
tomas.kracmar e2a523dfda feat(report): JSON report and summary output; UPNs from the replicated accounts
The weak-password report was text only: DSInternals' formatted output
captured with Out-String, with UPNs spliced in by re-parsing that
text. Nothing downstream could consume it reliably.

- Next to the text report, Invoke-WeakPasswordTest now writes
  <domain>_WeakPasswordReport_<timestamp>.json: tool, version,
  generatedAt, domain, DC, accountsTested, and one finding per
  non-empty check (WeakPassword, LMHash, DuplicatePasswordGroups, ...)
  listing each account's logon name and UPN. Duplicate-password groups
  stay grouped. The text and UPN-only reports are unchanged.
- ConvertTo-PasswordQualityFinding builds that data generically from
  the result object's properties, so it does not depend on the exact
  set of checks a DSInternals version reports. Arrays are assembled
  with List.ToArray() rather than pipeline output, because Windows
  PowerShell 5.1's ConvertTo-Json renders pipeline-wrapped arrays as
  {"value": [...], "Count": n}.
- Test-ElysiumPasswordQuality returns a summary object: domain,
  accounts tested, finding counts per check, and the three report
  paths.
- UPNs come from the DSAccount objects already replicated for the
  test (SamAccountName -> UserPrincipalName) instead of one Get-ADUser
  query per dictionary hit; Get-UserUPN is removed. Missing UPNs still
  read "UPN not found" in the text report (null in the JSON).

Tests: the converter on a result shaped like DSInternals' (string
sets, a list of sets for duplicate groups, an empty check) - empty
checks omitted, UPNs mapped, unknown UPN null, groups preserved, no
array-wrapper artefacts in the JSON. 33/33 Pester tests pass on pwsh 7.
The JSON shape on Windows PowerShell 5.1 and the real DSInternals
result object still need the Windows run.
2026-11-04 14:22:48 +01:00
tomas.kracmar 0c3c447e5c feat: -Domain and -Credential parameters for the AD cmdlets
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.
2026-11-04 14:22:12 +01:00
tomas.kracmar 1f2b7b12fc refactor: drop the pwsh relaunch and the Elysium.Common.ps1 loader
The pwsh relaunch existed only to get ForEach-Object -Parallel for
shard transfers. Downloads now run concurrently on Windows PowerShell
5.1 through Invoke-InModuleRunspace and the publisher no longer
uploads, so Update-KHDB.ps1, Update-LithnetStore.ps1 and Uninstall.ps1
just run in whichever PowerShell starts them.

The Windows PowerShell relaunch stays for the two AD wrappers
(Test-WeakADPasswords.ps1, Extract-NTHashes.ps1): DSInternals and
ActiveDirectory need the Desktop edition. They now dot-source
src/Elysium/Private/Relaunch.ps1 directly instead of the loader.
Restart-WithPwshIfAvailable is removed.

With no script dot-sourcing it any more, the transitional
Elysium.Common.ps1 loader is deleted; every wrapper imports the
module from src/Elysium.

AGENTS.md's edition rules and the "new script" guidance now describe
the module layout (cmdlet in Public/, export in the manifest, no
`exit` in module code); README describes 5.1/7 support.

Verified on pwsh 7: with a fake powershell.exe on PATH both AD
wrappers ask it to run themselves; Update-KHDB.ps1 -MaxParallelTransfers 3
syncs 4 shards from a local HTTP server with no relaunch; Uninstall.ps1
still cancels on a wrong answer; 31/31 Pester tests and the decrypt
round trip pass.
2026-11-04 14:16:33 +01:00
tomas.kracmar 06bcd22430 refactor(storage): one HTTP storage path; server-verified uploads; parallel on 5.1
Client storage access had four implementations: raw SAS HTTP and
native SigV4 for downloads, Az.Storage cmdlets and SigV4 or AWS Tools
for the hash export upload, plus separate serial and parallel download
loops. The parallel loop needed PowerShell 7 (ForEach-Object -Parallel)
and injected helper functions into its runspaces as text through
Invoke-Expression.

Now Private/Storage.ps1 has one path:
- Get-StorageConfig: provider settings, validated up front (Azure
  account/container/SAS, S3 endpoint/bucket/keys; s3Region defaults to
  us-east-1, s3ForcePathStyle to true).
- New-StorageRequest: GET/PUT request for Azure (SAS URI) or S3
  (SigV4). A PUT carries a digest the service verifies before storing:
  Content-MD5 on Azure, the signed x-amz-content-sha256 on S3.
- Invoke-StorageDownload: streams to disk; retries network errors and
  408/429/5xx (5 attempts, 2-30 s backoff), fails at once on other
  statuses (previously a 403/404 was retried for ~30 s).
- Invoke-StorageUpload: one PUT, service error body surfaced.
- Invoke-InModuleRunspace: runs a module function per parameter set in
  a runspace pool whose sessions import the module normally - works on
  Windows PowerShell 5.1 and 7, no code injection, failures collected
  and rethrown after all workers finish.

Update-ElysiumKhdb (434 -> 186 lines) fetches the manifest with
Invoke-StorageDownload and runs Receive-KhdbShard (download, size and
SHA-256 check, move into place) per shard through the pool, so
-MaxParallelTransfers now works on 5.1 too.

Send-ElysiumHashExport (230 -> 132 lines) validates storage settings
before replicating anything and uploads with Invoke-StorageUpload. The
download-back comparison, the delete-on-mismatch branch and the
Az.Storage container probe are gone: a mismatched body is rejected by
the service and never stored, and the credentials no longer need read
or list access to the upload location.

Removed: Get-FunctionDefinitionText, New-HttpClient,
Invoke-DownloadWithRetry, Invoke-S3HttpDownloadWithRetry,
Ensure-AWSS3Module, New-S3Client, Invoke-S3PutFile/GetToFile/DeleteFile,
Get-FileSha256Hex, Get-FileChecksum; the s3UseAwsTools setting. TLS
1.2 is set once at module import.

Known limit, marked in code: MD5 is unavailable on FIPS-enforced
Windows, so Azure uploads would fail there (S3 is unaffected);
Test-ElysiumPasswordQuality already refuses FIPS hosts.

Tests now run the real HttpClient/SigV4/runspace code against
tests/FakeStorage.ps1, an S3-style store on HttpListener that, like S3,
only accepts a PUT whose body matches x-amz-content-sha256. Covered:
incremental sync with 1/2/4 runspaces, a tampered shard failing the
run while keeping the previous KHDB, the publish -> update round trip
with 8 runspaces, Azure PUT headers (Content-MD5, block blob), up-front
settings validation, an S3 upload with no read-back, a rejected upload
surfacing the service error, 404 failing without retry, and a 503
retried once. 30/30 pass on pwsh 7; mutations (404 treated as
transient, worker failures dropped) each fail exactly the matching
test. Windows PowerShell 5.1 runs are still to do.
2026-11-04 13:20:31 +01:00
tomas.kracmar cb6431c82a refactor(tools)!: make the KHDB publisher build-only and standalone
The publisher runs on the provider's macOS machine and is a separate
workflow from the client. It carried its own Azure SAS and SigV4 S3
upload code, parallel uploads via ForEach-Object -Parallel with
helper functions injected through Invoke-Expression, an -UploadOnly
mode, and storage defaults read from the client's ElysiumSettings.txt
- all through the client's Elysium.Common.ps1 loader.

It now only builds the package (shards, manifest.json, khdb-clean.txt,
invalid-hashes.txt) and depends on nothing outside itself: no loader,
no relaunch, no settings file, no credentials. Uploading is left to
the storage provider's CLI, documented in the README for aws s3 /
rclone (S3-compatible) and azcopy (Azure): shards first, manifest
last, so a client never reads a manifest that points at shards that
are not there yet. -ShardRemotePrefix stays, since it is written into
the manifest and tells clients where to fetch shards from.

Removed: Upload-AzureBlob, Invoke-S3HttpUpload, the settings and
parallel-helper setup, the -UploadOnly branch and the upload section;
parameters StorageProvider, StorageAccountName, ContainerName,
SasToken, S3*, ManifestRemotePath, SkipUpload, UploadOnly,
MaxParallelTransfers, SettingsPath. 1,191 -> 770 lines. The shard
splitter and manifest writer are untouched.

BREAKING for the provider workflow only: existing invocations with
-SkipUpload or storage parameters now fail with "parameter cannot be
found"; clients are unaffected.

Verified: an AST check finds no calls to anything not defined in the
script or built into PowerShell; the publish -> update round-trip
test passes without -SkipUpload; 23/23 Pester tests pass.
2026-11-04 13:12:57 +01:00
tomas.kracmar ffccedb439 refactor: move provider-side tools to tools/
Prepare-KHDBStorage.ps1 (publishes the KHDB) and decrypt.py
(decrypts client hash exports on the provider's cracking machine)
are only ever run by the tool provider, but sat next to the client
scripts that every customer clones. Moved both to tools/ so the
client surface (root wrappers + src/Elysium) is separate from
provider tooling; packaging the module later ships only src/Elysium.

Prepare-KHDBStorage.ps1 now resolves Elysium.Common.ps1 and the
default ElysiumSettings.txt from the repo root (one level up) instead
of its own folder. tests/test_decrypt.py imports decrypt from tools/.
README and AGENTS paths updated; AGENTS' structure listing also gets
the module lines back after the settings sample, where they belong.

Verified: decrypt round trip passes from the new location, and
tools/Prepare-KHDBStorage.ps1 -SkipUpload runs from the repo root and
produces a package (manifest, 256 shards, khdb-clean.txt).
2026-11-04 13:04:10 +01:00
tomas.kracmar 05a09d82aa refactor: make the module manifest the only version source
The project version was stamped into the banner of every file and
kept in sync by Bump-Version.ps1, which rewrote them with regexes.
It had already drifted: ElysiumSettings.txt.sample still said 2.4.4.

Now that src/Elysium/Elysium.psd1 carries ModuleVersion and both the
module and the Elysium.Common.ps1 loader read $ElysiumVersion from it,
the banner "Version:" lines and Bump-Version.ps1 have no job left.
Removed both. Releasing is: change ModuleVersion, add the CHANGELOG
entry, commit, tag - documented in the README's versioning section.

AGENTS.md: project structure now lists the module layout, and agents
are told not to add version numbers back into banners.
2026-11-04 11:45:51 +01:00
tomas.kracmar bf14a254b4 fix(Update-LithnetStore): resolve KHDB via settings, add transcript, use shared parser
The default hash source ignored InstallationPath/WeakPasswordsDatabase and
always looked for khdb.txt next to the script; it now resolves the same path
as Update-KHDB.ps1 and Test-WeakADPasswords.ps1. The script also writes a
transcript to Reports/logs/ and uses Read-KeyValueSettingsFile from
Elysium.Common.ps1 instead of its own copy.

CHANGELOG [Unreleased] also records the earlier fixes on this branch.
2026-11-04 10:31:07 +01:00
tomas.kracmar 89c5e21002 fix(decrypt): read ELY2 and use PBKDF2-SHA256 to match the PowerShell side
decrypt.py could not decrypt any current export:
- It did not know the ELY2 format introduced in v2.4.6, so ELY2 files
  fell through to the legacy branch and failed.
- Its ELY1 branch called pycryptodome's PBKDF2 with the default PRF
  (HMAC-SHA1), while Extract-NTHashes.ps1 has used HMAC-SHA256 since
  ELY1 was introduced, so ELY1 files never decrypted either.

Now reads ELY2 (HMAC-SHA256 verified before decrypting, keys taken
from one 64-byte PBKDF2 output exactly like the two sequential
Rfc2898DeriveBytes.GetBytes(32) calls), ELY1, and the legacy format.
Key derivation uses stdlib hashlib.pbkdf2_hmac with the passphrase
encoded as UTF-8, matching .NET's string overload (pycryptodome
defaulted to latin-1). Padding is checked with Crypto.Util.Padding
instead of a length-byte range check.

Also: the passphrase prompt no longer echoes (getpass), an input path
not ending in .enc is refused instead of being overwritten by the
output, and failures exit non-zero.

tests/test_decrypt.py encrypts with the real Protect-FileWithAES
(extracted from Extract-NTHashes.ps1's AST, so the script body never
runs) via pwsh and decrypts with decrypt.py: ASCII and non-ASCII
passphrases round-trip; a wrong passphrase and a flipped ciphertext
bit are rejected by the HMAC check. With the old SHA1 derivation
patched back in, the test fails.
2026-11-04 09:24:37 +01:00
tomas.kracmar aba74fc4c2 fix(Uninstall): require confirmation; fix swapped menu numbers in docs
README.md documented Lithnet as menu option 5 and Uninstall as option
4, the reverse of the actual menu (and of Elysium.ps1's own help
block). Uninstall.ps1 recursively force-deletes the install directory
- reports, KHDB and settings included - with no prompt, so an
operator following the README to update the Lithnet store wiped the
tool instead.

Fixed the numbering in both docs, and Uninstall.ps1 now requires
typing YES (case-sensitive) before deleting anything. -Force skips
the prompt for unattended removal; Restart-WithPwshIfAvailable
already forwards bound switches to the relaunched process.

Verified on scratch copies: answering "yes" cancels and leaves the
directory intact, "YES" deletes it.
2026-11-04 09:22:44 +01:00
tomas.kracmarandClaude Sonnet 5 5b761d8d56 fix(Extract-NTHashes): add HMAC-SHA256 to the AES export (breaking format bump to ELY2)
Protect-FileWithAES used AES-256-CBC with no integrity check. A wrong
passphrase or corrupted/tampered ciphertext just decrypts to garbage
(or an unhelpful padding exception) instead of being detected.

Derives a second 32-byte key from the same PBKDF2 stream (the AES key
and HMAC key are sequential, non-overlapping ranges of one
Rfc2898DeriveBytes instance) and computes HMAC-SHA256 over
magic+salt+iv+ciphertext (encrypt-then-MAC), appended as a trailer.
Bumped the format magic from 'ELY1' to 'ELY2' so old and new files
are distinguishable.

This is a breaking change for whatever external tooling decrypts
these exports (this repo only ever encrypts - decryption happens on
a separate air-gapped machine per the README's FAQ) - documented the
new layout and the break in the README.

Verified with an isolated round-trip test (function extracted,
dot-sourced, paired with a hand-written decrypt+HMAC-verify): correct
passphrase round-trips cleanly, a wrong passphrase is rejected via
HMAC mismatch, and a single flipped ciphertext byte is also rejected
via HMAC mismatch, in all cases before any AES decryption is
attempted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-29 12:10:04 +02:00
tomas.kracmarandClaude Sonnet 5 65e451413e Release v2.4.5: detect explicit Deny ACEs in replication permission check
Test-ReplicationPermissions previously only scanned Allow ACEs, so an
explicit Deny on the DCSync extended rights (common in hardening
baselines that Deny a broad group and Allow only named service
accounts) was invisible to the pre-flight check: it reported
"verified" while Get-ADReplAccount still failed with "Replication
access was denied". The check now flags exactly which right is
blocked and by which identity's Deny ACE.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-29 11:49:14 +02:00
tomas.kracmar 1d98b908c6 Release v2.4.4: check schema NC replication rights for DSInternals 7.0
DSInternals 7.0 fetches the AD schema via DRS (GetNCChanges) before
replicating accounts, so the schema NC has its own ACL requirement.

- Test-ReplicationPermissions now validates rights on both the
  domain NC and the configuration NC (schema NC inherits from it).
- Updated README with dsacls delegation examples and dual-NC
  least-privilege requirements.
- Improved 'Replication access was denied' error message to name
  both NCs and explain the DSInternals 7.0 change.
- Diagnostic dump now includes SchemaDN.

All versions bumped to unified v2.4.4.
2026-06-15 08:38:04 +02:00
tomas.kracmar ad1db86232 Release v2.2.0: unified versioning and replication permission pre-check
- Unified project versioning (v2.2.0) across all scripts, settings template,
  and documentation. All components now share a single version number.
- Added Test-ReplicationPermissions to Test-WeakADPasswords.ps1 to validate
  the three required AD replication extended rights before DCSync, providing
  clear fail-fast errors when permissions are missing.
- Updated CHANGELOG.md with unified versioning strategy and release history.
- Updated README.md with versioning section and improved troubleshooting docs.
2026-06-09 09:43:43 +02:00
tomas.kracmar 60a7671ceb Fix KHDB password match format handling 2026-03-16 16:38:19 +01:00
Tom Frost 7f1df7b102 Improve weak password test credential diagnostics and docs 2026-02-17 12:40:04 +01:00
tomas.kracmar 7874c0e65b Clarified privileges needed 2025-12-08 16:24:26 +01:00
tomas.kracmar a55ef3713f Bug fixes 2025-11-07 20:33:21 +01:00
tomas.kracmar bda19432e2 Update to prefer PS7 if available 2025-11-07 20:21:03 +01:00
tomas.kracmar 7c2bb65a86 Parallel transfers 2025-11-07 18:14:43 +01:00
tomas.kracmar 4b1b841383 KHDB rework 2025-11-07 15:58:35 +01:00
tomas.kracmar 964e91d20f Fixing handling errors in datasets 2025-10-21 15:34:44 +02:00
tomas.kracmar 05e9358357 Versions bump 2025-10-21 13:42:46 +02:00
tomas.kracmar f7b83e14a5 Updates 2025-10-13 12:39:46 +02:00
tomas.kracmar 2269660984 Update README.md 2024-05-09 13:54:32 +02:00
tomas.kracmar bc8947bd50 Updated README for detailed report explanation. 2024-05-09 13:51:13 +02:00
tomas.kracmar 2a34a5ca52 Typo fix 2024-04-12 20:42:07 +02:00
tomas.kracmar 538dde8a5b Version 1.0 2024-03-22 08:35:52 +01:00
tomas.kracmar 81ad45b4fe First commit 2024-03-15 09:25:58 +01:00
tomas.kracmar 8d74a9159b Initial commit 2023-11-24 12:27:44 +00:00