Table of Contents
This function will convert a PowerShell script to a Batch file
Using this function will convert your powershell payload over to Base64 and then change the extension on it to be a .BAT file Make the conversion with this function using the following syntax:
P2B -Path "C:\Users\User\Desktop\example.ps1"
or
"C:\Users\User\Desktop\example.ps1" | P2B
function P2B {
param
(
[Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[string]
$Path
)
process
{
$encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes((Get-Content -Path $Path -Raw -Encoding UTF8)))
$newPath = [Io.Path]::ChangeExtension($Path, ".bat")
"@echo off`npowershell -w h -NoP -NonI -Exec Bypass -enc $encoded" | Set-Content -Path $newPath -Encoding Ascii
}
}
Listed below are payloads that have used one of these functions:
No payloads have made use of this function yet, please feel free to contact me to get your payload featured here if you do use it