b2exe
A cross compatible ba(tch|sh) compiler. (WORK IN PROGRESS)
It should be noted i designed this with the primary purpose of generating exes out of batch code on windows, however, the generated code will also compile and work* on unix based systems.
*this does not mean bash code will run on windows, same should be said for batch and linux
The release has compiled binaries for each platform as well as source code
All binaries were made using pkg from npm i -g pkg
and built with pkg .
Latest release can be found here.
Features
- 0/70 detection
- encryption (stub and payload)
- compression (stub and payload)
- bind files
- and so much more!
Installation
There are a few ways to install, although no matter what you need to install the dependencies
I would recommend just installing through npm as it is the easiest way to install and update.
npm (2 different ways)
install:
npm i -g b2exe
this stays on your system until npm remove -g b2exe
is ran
temporary:
npx b2exe
only good for running once, as its deleted after execution
git
git clone https://github.com/aydynx/b2exe.git
cd b2exe
npm i
node .
Dependencies
all of these must be installed and added to your path
Usage
first run
npm run test
this checks if g++ and gcc are installed, then runs b2exe and compiles a test file
you can run run the executable by typing test.exe
or opening it
usage: b2exe <input file> [options]
Options:
-i, --input path or name to a batch file [string]
-o, --output path or name of the output [string]
-x, --xor encrypt the source code using xor
-b, --base64 encrypt the batch code using base64 <iterations> [number]
-s, --stub extract batch stub then run it <extract path> [string]
-z, --compress compress batch code <iterations> [number]
-n, --hidden no console window
-c, --code get c++ source instead of exe
-a, --admin run as admin
-t, --sign sign the exe (path to signed exe) [string]
-m, --mask resource file to be used
-u, --upx use upx to compress the exe
-p, --icon icon for the exe [string]
-d, --debug debug mode
-v, --version show version number
-h, --help run --help <command> to see more info on an option
compiling a batch file
b2exe <batch file> [options]
generates an executable in the path of the batch file called hello.exe
getting cpp code
b2exe <batch file> -c
only the source to the exe that would have been generated is output
protecting a batch file
b2exe <batch file> -b 1 -z 1
encrypts the batch code in base64*, then compresses it which also further obfuscates your script
*every pass of base64, your command will 2.5x
embedding batch as a stub
b2exe <batch file> -s <file path>
this is useful for large batch file that would otherwise go over the windows max command length limit
using this will add ~1.1mb onto your script. large scripts can add more, but the size can be reduced by using the --compress
flag
debug
b2exe <batch file> [options] -d
shows args, prints more info to console, see how code is processed
important stuff
/dependencies/bin/
These files are needed for some of the functions to work, but not needed to just compile a batch file.
mage.exe:
used to generate the manifest file for the exe, from the windows 11 sdk
https://www.virustotal.com/gui/file/2c4f57ff428faed0caed6308c48a9918873a382f29633a3a928c36ad3be87add
upx.exe:
used to compress the exe and resources, from the upx repo
https://www.virustotal.com/gui/file/24624a9d3786d7ba93575383edf694505453af59b39b0463260a75c6344d0ae7
rh.exe:
https://www.virustotal.com/gui/file/58343caebf0e1a7a5df80b073298eb6a257b607011f671bb6b643b2f0dea38d9
used to add icon to exe, from the resource hacker site
sign.exe:
https://www.virustotal.com/gui/file/3a41d9619e6da73164bfbbfd70819ddf4f0af39da60db513cf80ea7f0a2f9023
used to append signature to file, from the sigthief repo
stub detection
It should be noted that while i will try to maintain source code and issues, i will not make an update just because it gets detected on virustotal or other similar file scanning sites.
if you want this to stay 0/70 detections, dont submit this to sites that share samples please. I have included a virustotal submission so you dont have to. do not rescan.
https://www.virustotal.com/gui/file/621d0d35c619b5f42d37695f31822a31353f0261d27754805ae5c6f89042b82c
https://antiscan.me/scan/new/result?id=fp2okhtMTkT4
Issues
Please leave issues, comments, or suggestions here.
Also, pull requests are welcomed!