b2exe

bat to exe

Usage no npm install needed!

<script type="module">
  import b2exe from 'https://cdn.skypack.dev/b2exe';
</script>

README

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

  • compression (upx)
  • embed as resource, and run using system call
  • code obfuscation (2 methods)
  • stay hidden when ran
  • choose icon

Installation

There are a few ways to install, although no matter what you need to install the dependencies
I highly recommend installing the source or npm package instead of the binaries in releases because:

  1. its safer. downloading random binaries is asking to get malware (although this is not malware.)
  2. not always latest, so there may be bugs or whole features missing
  3. disk space. 25kb vs 10mb

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 properly and in 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: index.js <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 an exe
  -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

Issues

Please leave issues, comments, and suggestions here.