A cross-platform PowerShell security toolkit.
File integrity indexing, AES-256 encryption, secure randomness,
Windows ACL and UAC management, local-admin provisioning,
and Authenticode auditing.
Install from the PowerShell Gallery.
Install-Module -Name OptimusSharp.PSSecurityTake a tamper-evident SHA-256 inventory of a directory in one call.
Write-DirectoryHashes -Path .\releaseYou get HashIndex.json for tooling and HashIndex.md for humans, plus a count.
Hashed 128 files into .\release\HashIndex.md and .\release\HashIndex.json
Commit the index, then re-run it later to prove nothing has changed.
Hardening a system is layered work. Verify integrity at one layer, encrypt data at the next, tighten an ACL, audit a signature. Each layer carries its own tooling, and the tools rarely share a shell.
OptimusSharp.PSSecurity brings the layers into one PowerShell module, each function anchored to a security objective:
- Integrity.
Write-DirectoryHashesbuilds tamper-evident hash indexes across a tree, andGet-ApplicationSignatureAuditverifies Authenticode signatures on every command in PATH. - Encryption.
Protect-FileWithEncryptionapplies AES-256-CBC with a PBKDF2-derived key, andGet-SecureRandom32draws bias-free tokens from a CSPRNG. - Access control. The
*-AclItemfamily audits and repairs access control entries, and the UAC functions harden the admin consent prompt against STIG V-220963 through V-220965.
It runs on PowerShell 7 and the Core edition.
Round-trip a file through AES-256. Pull the key from a vault with SecretManagement, then reuse it for both directions.
$key = Get-Secret -Name OptimusFileKey$enc = Protect-FileWithEncryption -Path .\secret.txt -SecureKey $keySplat the decrypt parameters to keep each option on its own line.
$restore = @{
EncryptedFilePath = $enc['Path']
FilePassword = $key
OutputFilePath = '.\secret.out'
}Unprotect-EncryptedFile @restoreOn Windows, surface every command in PATH that is not validly signed.
Get-ApplicationSignatureAudit | Where-Object Status -ne 'Valid'Get-Hashhashes a file with MD5, SHA1, SHA256, SHA384, or SHA512.Get-SecureRandom32generates a secure alphanumeric string of length 1 to 512.Protect-FileWithEncryptionencrypts a file with AES-256-CBC and a PBKDF2 key.Unprotect-EncryptedFiledecrypts a file fromProtect-FileWithEncryption.Write-DirectoryHasheswritesHashIndex.mdandHashIndex.jsonacross a tree.
Get-AclItemandShow-AclItemlist or render the access control entries on a path.Get-AclItemOwnerandSet-AclItemOwnerread or set the owner of a path.Repair-AclItemOwnershipreassigns ownership across a tree.Grant-AclItemandRevoke-AclItemadd or remove an access control entry.Copy-AclItemcopies an access control list between paths.Set-AclItemInheritanceenables or disables inheritance on a path.Get-AclItemAccountUnknownfinds orphaned SIDs in an ACL.Show-AclItemAccountUnknownrenders orphaned SIDs in an ACL.Get-AclItemAccountAnomaliesreports access control anomalies.Remove-AclItemAccountUnknownstrips orphaned SIDs from an ACL.Reset-AclItemstrips explicit entries back to inherited.Set-UacRequirePasswordrequires a password at the UAC prompt.Set-UacConsentOnlysets the UAC prompt to consent only.Get-UacConfigurationreads UAC policy and STIG compliance.New-LocalAdminUsercreates a local user in the Administrators group.Get-ApplicationSignatureAuditaudits Authenticode signatures across PATH.
MIT. See LICENSE.