bin2src

bin2src is a simple command line that converts a binary file to an array of bytes, assigned to a variable in a source file of another language; therefore you can embed it into your program.

Currently supported output languages:

Overview

bin2src reads a binary file (e.g. jpg, wav, mp3, etc.) and generates a source file with the binary data embeded into it as a byte array and assigned to a variable.

It is useful if you don't want to distribute a binary file together with your application and let users have direct access to it.

With bin2src you can embed the data inside the final executable and use it through the variable stored in memory.

Keep in mind that it is always possible for an "advanced" user to extract the data, either from the executable or from a memory dump.

Usage

bin2src < -l LANG | --out-lang LANG > [ OPTIONS ] < FILE >

LANG and FILE are required.

Options:

        -l, --out-language LANG         specify the language, where LANG={c|cshell|pascal|python|rust}

        -d, --out-dir PATH              specify where to output source(s) file(s);
                                        if not specified, generate in current directory

        -f, --out-file OUTFILE          specify the output file(s) name (* without extension *);
                                        if not specified, output file(s) will have the same name
                                        of input file (without extra dots).

        -h, --hex                       output bytes in hexadecimal (for C shellcode this flag has
                                        diferent behaviors. See the Github site for more information)

Currently supported languages:

  - C
  - C for shellcode
  - Pascal
  - Python
  - Rust    

Some Examples

Suppose you have an image myimage.jpg that you want to embed into your executable:

Example 1:

bin2src --out-language pascal --out-dir "X:\My Projects\project01" --out-file image01 myimage.jpg

Windows paths with spaces need quotation marks

This command will create the file ...\image01.pas with the data defined using decimal format: [210, 0, ...].

Example 2:

bin2src -l c -d "X:\My Projects\project02" -f image01 -h myimage.jpg

This command will create the files, but with binary data in hexadecimal format: [0x10, 0xfa, ...]:


Example 3:

bin2src --out-language python myimage.jpg

This command will create the file myimage.py at the current directory.

Check other examples at examples directory for some practical uses of bin2src.

Atention

License

Developed by Alexandre Gomiero de Oliveira under the MIT License.

Any code generated by bin2src are under MIT License.

Please, contact me if you need another license type.