PowerShell to EXE

    I've written a few scripts in PowerShell to perform various tasks for clients and I usually end up with a batch file or some instructions on how to overcome the problem with "execution of scripts" or the various signing errors.  Regardless of whether it's opened with an elevated prompt or not, when you attempt to execute a PowerShell script, you get the following:

    If we were to execute this script using the following syntax:  powershell.exe -ExecutionPolicy ByPass .\PowRevSh.ps1

    ... we'd get the following:

    But we don't, we get an error instead.  Since the result is to provide a working script to perform some task, I don't actually need it to remain as a ps1 file.  Fortunately, Microsoft has a utility to convert this into an exe file.  Since I'm working with a reverse shell, I could package this up with an icon that makes it appear to be something else -- like something Adobe, we just need an ico file:

    We launch the utility and populate the source and the icon file location:

    When we select Compile, the utility performs its magic:

    When it's finished, we have an exe file with the PDF icon:

    Not only does it not require any sort of execution permission, so far, antivirus thinks it's legit:

    When we execute the file, we catch our shell. 

    © 2020 sevenlayers.com