Clone or download
Latest commit 379c501 Jun 3, 2017
Permalink
Failed to load latest commit information.
config merge release Oct 11, 2016
src code formatting Jun 3, 2017
test merge release Oct 11, 2016
.gitattributes remove groff from language bar in github Oct 11, 2016
.gitignore merge release Oct 11, 2016
.travis.yml fix travis Oct 11, 2016
AUTHORS merge release Oct 11, 2016
COPYING merge release Oct 11, 2016
ChangeLog release after fix #38 Jun 3, 2017
INSTALL merge release Oct 11, 2016
Makefile.am remove binaries May 31, 2017
Makefile.in remove binaries May 31, 2017
NEWS merge release Oct 11, 2016
README merge release Oct 11, 2016
README.md Updates README May 31, 2017
aclocal.m4 merge release Oct 11, 2016
autogen.sh merge release Oct 11, 2016
configure update package info Jun 3, 2017
configure.ac fix exec (null) problem Jun 3, 2017
shc.1 update man May 17, 2017

README.md

build status image GitHub stars GitHub forks GitHub issues

Shell Script Compiler

A generic shell script compiler. Shc takes a script, which is specified on the command line and produces C source code. The generated source code is then compiled and linked to produce a stripped binary executable.

The compiled binary will still be dependent on the shell specified in the first line of the shell code (i.e shebang) (i.e. #!/bin/sh), thus shc does not create completely independent binaries.

shc itself is not a compiler such as cc, it rather encodes and encrypts a shell script and generates C source code with the added expiration capability. It then uses the system compiler to compile a stripped binary which behaves exactly like the original script. Upon execution, the compiled binary will decrypt and execute the code with the shell -c option.

Install

  1. ./configure
  2. make
  3. sudo make install

Note If make fails due to automake version, run ./autogen.sh before running the above commands.

Ubuntu-specific

sudo add-apt-repository ppa:neurobin/ppa
sudo apt-get update
sudo apt-get install shc

If the above installation method seems like too much work, then just download a compiled binary package from release page and copy the shc binary to /usr/bin and shc.1 file to /usr/share/man/man1.

Usage

shc [options]
shc -f script.sh -o binary
shc -U -f script.sh -o binary # Untraceable binary (prevent strace, ptrace etc..)

Testing

  1. cd to test directory: cd test
  2. Try: shc -f test.bash -o test, where test.bash is the bash source.
  3. output binary file will be test. If no output file is specified by the -o option, then it will create an executable with .x extension by default.

Known bugs

The one (and I hope the only) limitation using shc is the _SC_ARG_MAX system configuration parameter. It limits the maximum length of the arguments to the exec function, limiting the maximum length of the runnable script of shc.

!! - CHECK YOUR RESULTS CAREFULLY BEFORE USING - !!

Man Page

WebPage