Powershell script integrity

452 views Asked by At

Trying to find a method of which one can verify that the running script has been modified. I was thinking I could sign the script and have it check itself, however the only protection is having all the execution policy set to only run with signed scripts, which in some locations might not be the case.

I also thought about compiling the script but didn't know really what that would actually achieve...

Trying to keep it as dependant free as possible for compatibility reasons, so lowest version of Powershell and less dependent on external libraries.

1

There are 1 answers

4
Jason Snell On

An open script is very hard to secure. There are a few options available.

1: Compile the script into an executable. This would prevent most users from knowing how to modify the script.

2: Minify/Uglify the script so that it becomes very difficult to understand or modify without breaking.

3: As you mentioned signing the script may help depending on the environment.

4: Use one of the above methods and have the script check back with a server to verify the integrity of the script.

None of those are 100% foolproof, but it does give you options depending on the environment the script is running in.

Here is an example of an app that will obfuscate a PowerShell script: PowerShell Obfuscator