Reputation: 779
We can convert a PowerShell script to an executable exe file using the PS2EXE-GUI. We have an exe file now. All is well. The resulting exe file is a .Net assembly containing the Base64 encoded source script. This means that the code is not hidden. It can be easily restored back with the key -Extract:
Script.exe -Extract: 'Script.ps1'
Does this mean that I cannot create a shell where the source code will be completely hidden? Of course we are not talking about assembler. Are there any ways to hide the PowerShell source code in GUI exe file? Thanks
Upvotes: 0
Views: 979
Reputation: 23693
In the end, this would than be a reversible encryption because the script engine requires to interpret it.
And a reversible encryption (based on a symmetric key algoritm) is weak, see also: Is it possible to securely store passwords using reversible encryption?
Quote:
The primary weakness of reversible encryption is simple: if the key is compromised, the encrypted data is compromised, period.
Which means that it is essentially the same as hiding it behind a Base64 encryption.
As soon as the encryption gets popular, it will be hacked, and you will find online decrypters on the web as what happened with the VBScript .vbe
encryption.
In other words, if there is anything specific in your script you need to hide (like a password), you should look into other directions, e.g.: run the script under different credentials, prompt for a password, or simply give the user (limited) rights to the concerned application (which you effectively do by supplying the script).
Upvotes: 1