chenzhch / shellc

Tool for converting scripts into C code
GNU General Public License v3.0
27 stars 6 forks source link
bash binary bsh compiler converter csh dash fish javascript lua obfuscator perl php python rc rsh shell tclsh zsh

shellc

Tool for converting scripts into C code

Install

cc shellc.c -O2 -o shellc

Compile shell scripts and generate executable programs

shellc sh example.sh
cc example.sh.c -O2 -o example

The generated C code is example.sh.c, which is the original file name followed by .c. For programs used in production environments, it is recommended to add the parameter -s or use the strip command after compilation to remove the symbol table in the executable program, increasing the difficulty of disassembly and reverse engineering.

I have tried the tools shc, which can compile shell scripts into executable programs. The main problems are:

The shc command actually calls the sh -c command. The source code can be seen through the ps -ef command. The length of the shell script cannot exceed ARG_MAX. Obtaining script source code through methods such as forging interpreters or memory dumps (currently, all tools for converting scripts to C code on GITHUB have this vulnerability).

Shellc not only solves the problems that exist in shc, shellc also adds code obfuscation, randomly generating effective character position calculation functions, random character encryption, and debugging to increase the complexity of disassembly and reverse engineering.If further difficulty is required, professional tools such as obfuscator-llvm can be used to further obfuscate the generated C code.

Version 1.0 or above not only support shell, but also other scripting languages, which can completely replace shc. Version 1.6 adds the function of obtaining script source code through anti-counterfeiting interpreter or memory dump. The anti-counterfeiting interpreter needs to enable the -a or -i option. At present, the program has practical applications in AIX, UNIX, Linux environments. It is recommended to conduct comprehensive testing on the compiled program to prevent production failures.

User manual

Untraceable

Version 0.3 or above has added untraceable and tested the following tools for untraceable

OS TOOL SUPPORTED
AIX 7.1 dbx sdb YES
SCO UNIX 5.0.6 dbx sdb adb YES
Red Hat Linux7.8 gdb YES
CentOS Linux6.4 gdb YES
debian 12.4.0 gdb YES
Fedora 39 gdb lldb YES
FreeBSD 14.0 gdb YES
openSUSE Leap 15.5 gdb YES
OracleLinux R9 gdb YES
ubuntu 22.04.3 gdb lldb YES
openEuler gdb YES
Debian gdb YES
NetBSD 10.0 gdb NO
DragonFly 6.4 gdb NO
macOS 13 lldb NO

History