In this lab, I will try to sign a simple "rogue" powershell script test-forged.ps1 that only has one line of code, with Microsoft's certificate and bypass any whitelisting protections/policies the script may be subject to if it is not signed.
The script that I will try to sign:
Just before I start, let's make sure that the script is not signed by using a Get-AuthenticodeSignature cmdlet and sigcheck by SysInternals:
In order to sign the script with Microsoft's certificate, we need to first find a native Microsoft Signed PowerShell script. I used powershell for this:
Get-ChildItem -Path C:\*.ps*-Recurse -ErrorAction SilentlyContinue | Select-String -Pattern "# SIG # Begin signature block"
I chose one script at random and simply checked if it was signed - luckily it was:
Let's copy the Microsoft signature block to my script: