Invoke-PSImage: PowerShell Script Pixel Encoder
Invoke-PSImage encodes a PowerShell script into a PNG image and then generates a single line of code to run the script. The original image is nearly perfect, and it is almost impossible to detect the embedded script in the image.
Invoke-PSImage: Powershell Script Encoder
The user has option to create a new image using only the payload data or embed the payload into an existing image by only modifying the least significant bytes of the existing image so that it looks the original picture. The input image can be of any type, but the output will be in PNG format, so it can be losslessly compressed when required while retaining the embedded script.
How Invoke-PSImage Works?
Features:
- Embed scripts into images
- Generate a single command to execute the script
- Easy to install and operate
Supported Platforms:
- Windows
Requirements:
- None
Install Invoke-PSImage
Clone the GitHub repo:
$ git clone https://github.com/peewpw/Invoke-PSImage.git
Usage
Run the Invoke-PSImage.ps1 file from the PowerShell terminal.
Arguments:
-Out [filepath] The file to save the resulting image to (image will be a PNG)
-Image [filepath] The image to embed the script in. (optional)
-WebRequest Output a command for reading the image from the web using Net.WebClient. You will need to host the image and insert the URL into the command.
-PictureBox Output a command for reading the image from the web using System.Windows.Forms.PictureBox. You will need to host the image and insert the URL into the command.
Invoke-PSImage Usage Example
To create an image with the script Invoke-Mimikatz.ps1
embeded in it and output a oneliner to execute from disk run:
$ PS>Import-Module .\Invoke-PSImage.ps1 $ PS>Invoke-PSImage -Script .\Invoke-Mimikatz.ps1 -Out .\evil-image.png -Image .\image.jpg [Oneliner to execute from a file]
To create an image and to execute from the web:
$ PS>Import-Module .\Invoke-PSImage.ps1 $ PS>Invoke-PSImage -Script .\Invoke-Mimikatz.ps1 -Out .\evil-image.png -Image .\image.jpg -WebRequest [Oneliner to execute from the web]