Commit Graph
21 Commits
Author SHA1 Message Date
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 50dcf8c1b7 refactor(Update-LithnetStore): move the importer into the module as Update-ElysiumLithnetStore
Second root script converted to a module cmdlet, same pattern as
Update-ElysiumKhdb:

- The script body -> src/Elysium/Public/Update-ElysiumLithnetStore.ps1,
  exported, same parameters.
- Get-ListFromSetting and Resolve-ExistingPath -> Private/Settings.ps1.
  The script's own Get-BooleanSetting copy is dropped for the shared
  one (TryParse instead of Convert.ToBoolean; both accept exactly
  true/false and fall back to the default for anything else).
- The inline default-KHDB resolution becomes Get-KhdbPath in
  Private/Khdb.ps1 (InstallationPath + WeakPasswordsDatabase via
  Get-InstallationPath), for the other scripts to reuse.
- Transcript via the shared Start/Stop-ElysiumTranscript; $PSScriptRoot
  becomes $InstallRoot.

Update-LithnetStore.ps1 is now a thin wrapper (relaunch under pwsh,
import module, call the cmdlet with the bound parameters).

Tests, with global stub functions standing in for the Lithnet cmdlets
so they can be mocked on any OS: default KHDB under
InstallationPath/WeakPasswordsDatabase plus settings and parameter
sources each go to the right import cmdlet; HIBP sync on/off;
Close-Store runs when an import fails; a missing KHDB names the path.
18/18 Pester tests pass. The wrapper also ran end-to-end against a stub
LithnetPasswordProtection module on PSModulePath: all three lists
imported, store closed, transcript written under Reports/logs.
2026-11-04 12:54:45 +01:00
tomas.kracmar 262b8ae0b8 fix(Update-LithnetStore): import lists instead of crashing on the first one
The three import loops iterated `$set.ToArray() | Sort-Object` over
HashSet[string] collections. HashSet<T> has no ToArray instance
method - that is a LINQ extension method, which PowerShell does not
bind - so member-access enumeration applied .ToArray() to each string
in the set and threw "[System.String] does not contain a method named
'ToArray'". An empty set enumerates nothing and passes silently, but
the hash list is never empty (configured sources, or the default KHDB,
otherwise the script throws earlier). So every run opened the store,
crashed on the first import, and closed it again with nothing
imported. Same behavior on Windows PowerShell 5.1 and PowerShell 7.

Pipe the sets into Sort-Object directly, which enumerates them.

Found by the Pester test written for the upcoming module conversion.
Reproduced and verified end-to-end with a stub LithnetPasswordProtection
module on PSModulePath: before, Open-Store -> ToArray error ->
Close-Store; after, the KHDB, plaintext and banned-word lists are each
imported and the store is closed.
2026-11-04 12:54:07 +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.kracmarandClaude Sonnet 5 2d90656e5c Release v2.4.6: security/correctness fixes from full codebase review
Consolidates this session's review findings, each already fixed and
committed individually: Uninstall.ps1 deleting the wrong directory,
plaintext passphrase handling, a DCSync ACL pre-check bypass via UPN
credentials, an orchestrator that crashed instead of returning to its
menu, plaintext-hash exposure window and unauthenticated AES export
in Extract-NTHashes.ps1, KHDB shard-size/backup/dedup issues in
Prepare-KHDBStorage.ps1 and Update-KHDB.ps1, and assorted resource
leaks. See CHANGELOG.md for the full list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-29 12:10:26 +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 af945f529e Release v2.4.3: fix tokenGroups retrieval and DirectoryEntry LDAP paths
Test-ReplicationPermissions:
- Replaced DirectoryEntry.RefreshCache tokenGroups retrieval with
  Get-ADUser -Properties tokenGroups. DirectoryEntry does not
  understand URI percent-encoding, so the v2.4.1 EscapeDataString
  fix caused 'invalid dn syntax' errors.
- Removed EscapeDataString from the ACL DirectoryEntry path as
  well; DirectoryEntry expects raw LDAP ADSI path syntax.

All versions bumped to unified v2.4.3.
2026-06-09 14:14:45 +02:00
tomas.kracmar 03aa72f999 Release v2.4.2: replace em-dashes with ASCII hyphens to fix encoding parse errors
UTF-8 em-dashes (U+2014) in Elysium.Common.ps1 string literals were
being misinterpreted by Windows PowerShell as containing quote
characters when the file was read without a UTF-8 BOM. This caused
cascading parse errors: unexpected tokens, missing closing braces,
and missing catch blocks.

All em-dashes in .ps1 files have been replaced with ASCII hyphens.
All versions bumped to unified v2.4.2.
2026-06-09 13:51:13 +02:00
tomas.kracmar 10cbf0285d Release v2.4.1: URI-escape DNs in DirectoryEntry LDAP URLs
Test-ReplicationPermissions and Test-DCClockSkew now escape
Distinguished Names via [System.Uri]::EscapeDataString before
constructing DirectoryEntry LDAP URLs. This prevents URL
mis-parsing when DNs contain /, #, or other reserved characters.

All versions bumped to unified v2.4.1.
2026-06-09 13:42:34 +02:00
tomas.kracmar fc91f0d6b0 Release v2.4.0: DC clock skew check, SDProp/Protected Users warnings, and DSInternals install fix
Added pre-flight diagnostics:
- Test-DCClockSkew: validates local/DC clock skew before DCSync to
  catch Kerberos auth failures early.
- Test-ReplicationPermissions now warns on adminCount=1 (SDProp
  protected) and Protected Users group membership (RID 525), both
  of which can silently block or revert replication rights.

Fixed DSInternals update flow:
- Replaced Update-Module with Install-Module -Force -AllowClobber
  to work around a PowerShellGet null PublishedDate bug.

All versions bumped to unified v2.4.0.
2026-06-09 13:32:21 +02:00
tomas.kracmar 6b2ae6c8b5 Release v2.3.0: add DSInternals version check and auto-update
Test-WeakADPasswords.ps1 now validates the installed DSInternals
version at startup:
- v6.2 (unsigned) warns that native DLLs are blocked and replication
  will fail; directs operator to Update-Module DSInternals.
- Below v7.0 prompts to auto-update via Update-Module -Force and
  exits cleanly so the new version is loaded on re-run.
- v7.0+ passes silently.

All versions bumped to unified v2.3.0.
2026-06-09 13:16:47 +02:00
tomas.kracmar 37d1a8d971 Release v2.2.5: resolve DSInternals module path in block error
The Zone.Identifier block detection now dynamically resolves the
actual DSInternals module installation path via Get-Module instead
of hardcoding a ProgramFiles path, so the Unblock-File command in
the error message is always correct.

All versions bumped to unified v2.2.5.
2026-06-09 13:10:36 +02:00
tomas.kracmar 0175864e72 Release v2.2.4: permission check InheritOnly fix and DSInternals block detection
Test-ReplicationPermissions:
- Skip InheritOnly ACEs since they do not apply to the domain root
  object itself, only to child objects.

Test-WeakADPasswords:
- Detect Windows Zone.Identifier blocks on DSInternals DLLs and
  emit a clear error with the exact Unblock-File remediation
  command instead of a vague warning.

All versions bumped to unified v2.2.4.
2026-06-09 13:07:46 +02:00
tomas.kracmar 9496063b97 Release v2.2.3: improve replication permission detection
Test-ReplicationPermissions now recognizes:
- GenericAll as satisfying replication rights
- Blanket ExtendedRight (empty ObjectType) ACEs

Also adds diagnostic hints distinguishing between
'missing ACE entirely' and 'ACE exists but not for you'.

All versions bumped to unified v2.2.3.
2026-06-09 11:53:44 +02:00
tomas.kracmar 27a682a968 Release v2.2.2: fix replication permission check for nested groups
Test-ReplicationPermissions now uses the tokenGroups constructed
attribute to resolve all effective SIDs in the caller's Kerberos
token, including nested group memberships. This replaces the
previous MemberOf walk which missed indirect entitlement and
could produce false-positive missing-permission errors.

All versions bumped to unified v2.2.2.
2026-06-09 11:41:14 +02:00
tomas.kracmar 09c30f97e9 Release v2.2.1: DRY refactoring and housekeeping
Consolidated duplicated helpers into Elysium.Common.ps1:
- Settings parsing (Read-KeyValueSettingsFile, Read-ElysiumSettings, Get-SettingsValue)
- Azure Blob URI builder (Build-BlobUri)
- S3 SigV4 signing helpers and AWS module bootstrap
- AD credential validation and replication permission pre-check
- Parallel execution helper (Get-FunctionDefinitionText)

Test-WeakADPasswords.ps1 and Extract-NTHashes.ps1 now import
Elysium.Common.ps1 for the first time. Update-KHDB.ps1 and
Prepare-KHDBStorage.ps1 removed their local duplicates.

Deleted legacy Settings.ps1 (superseded by ElysiumSettings.txt).
Removed stray placeholder comment in Elysium.ps1.

All versions bumped to unified v2.2.1.
2026-06-09 10:52:19 +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 be96cbf9a5 Bumped versions 2025-11-07 20:56:02 +01:00
tomas.kracmar bda19432e2 Update to prefer PS7 if available 2025-11-07 20:21:03 +01:00