PowerShell Code Signing
PowerShell code should be signed, from an offensive standpoint, to allow it to be executed under stricter application whitelisting policies and circumvent execution policy enforcement.
The following formats can have signatures
ps1
psm1
psd1
ps1xml
psc1
cdxml
mof
To create a self-signed certificate we can use
$Arguments = @{
Subject = 'CN=My Self-signed Code Signing'
Type = 'CodeSigningCert'
KeySpec = 'Signature'
KeyUsage = 'DigitalSignature'
FriendlyName = 'My Self-signed Code Signing'
NotAfter = ((Get-Date).AddYears(3))
CertStoreLocation = 'Cert:\CurrentUser\My'
}
$TestCodeSigningCert = New-SelfSignedCertificate @ArgumentsAnd to add a trusted root certificate
Catalog-signing permits signing of any file type regardless of “signability”. A catalog file is effectively a list of hashes that can be signed.
Last updated