exe2hexbat
A Python script to convert a Windows PE executable file to a batch file and vice versa. It supports output methods like DEBUG.exe for x86 and PowerShell for x86/x64.
Description
exe2hexbat is designed to transform Windows PE executable files into batch files or PowerShell scripts, facilitating the obfuscation and deployment of executables in Windows environments. This tool is particularly useful for penetration testers and red teamers who need to deliver payloads without triggering antivirus detection through direct EXE execution.
The primary use case involves converting an EXE into a self-contained batch or PowerShell script that can reconstruct and run the original binary. It supports reading from files or STDIN, with options for URL encoding and custom prefixes/suffixes to integrate into larger scripts or bypass basic filters.
Installed via Kali's package manager, it depends on Python 3 and provides exe2hex as the main binary. While the page shows core options, additional flags are available in the man page.
How It Works
The tool reads a Windows PE EXE file (or from STDIN), converts its binary content into a hexadecimal representation, and embeds it into a batch file using the DEBUG.exe method (x86) or a PowerShell script (x86/x64). The output script includes commands to decode the hex data and execute it in memory, avoiding disk writes. Options like URL encoding modify the hex output for web transport, while prefix/suffix flags allow line-by-line customization for evasion.
Installation
sudo apt install exe2hexbatFlags
Examples
exe2hex -hexe2hex -x payload.exeexe2hex -sexe2hex -x payload.exe -b output.batexe2hex -x payload.exe -p output.ps1exe2hex -x payload.exe -e -b encoded.batexe2hex -x payload.exe -r "echo." -f "&rem" -b custom.bat