Jump to content

Shc (shell script compiler)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jahid.Hamid (talk | contribs) at 06:50, 25 August 2015 (Mechanism: layout fix). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

SHC is a shell script compiler written in C programming language. The Shell Script Compiler (SHC) converts linux shell scripts directly into executable binaries. Compiling shell scripts into binaries provides protection against accidental changes, source modification and renders a way of hiding source code written in linux shell scripting language.[1]

Mechanism

SHC takes a shell script which is specified on the command line by option and produces a C source code of the script. The generated source code is then compiled and linked to produce a binary executable. Thus it's a two step process where, at first step, it creates a file of the shell script file . Then it is compiled with and thus build the binary from a C source code with the default C compiler available in any system.[1]

The compiled binary will still be dependent on the shell specified in the first line of the shell code (i.e Shebang: #!/bin/sh or such), 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 shells' -c option.

Versions

Available Versions[2][3]
Version Release Date Changes
shc-3.9.2 21-Aug-2015 Added Busybox support ( -B flag to compile for Busybox[4]).
shc-3.9.1 03-Apr-2015 Set -T option as default, and renaming it to -U to its counter logic
shc-3.9.0 01-Apr-2015 Adding output file option with [-o filename] and bug fixes
shc-3.8.9 04-Dec-2013 Fixing a long-standing bug making the source not hidden
shc-3.8.7 10-Feb-2010 Bug on 64bit systems with expiration dates
shc-3.8.5 10-Feb-2010
shc-3.8.3 10-Jul-2006 Fixed untraceable() problems on FreeBSD
shc-3.8.2 06-Jul-2006 Read permission of the script.x exposes it to disassembling.

Group and others read permission is now removed by default.

shc-3.7 28-Jun-2005 Removed all strings in the compiled script. Improved program output and error messages.

The -m option allows to define the *complete* expiration message. Updated manpage shc.1

shc-3.6 16-Jun-2005 Two new options:

-D switch on Debug exec calls. -T switch off unTraceable.

shc-3.4 19-Jun-2003 Remove "bad alignment" problem on AIX and other systems.

Where exists, use /proc/<pid>/as in untraceable.

shc-3.3 21-Apr-2003 Prevent to ptrace the process
shc-3.2 05-Aug-2002 Find ancient pclose that must be fclose
shc-3.1 05-Aug-2002 Fixed a misbehavior on scripts with a in-frist-line option equal to "end of options"

(i.e. #!/bin/sh -- ) GCC "warning: return type of `main' is not `int'" removed

shc-2.4 05-Aug-2002

Alternatives

  1. obfs
  2. shellcrypt
  1. https://raw.githubusercontent.com/neurobin/shc/release/README.md
  2. http://www.l0d.org/Decrypt_an_shc_crypted_file-4.html
  3. http://neurobin.github.io/shc

References

  1. ^ a b http://www.linux-magazine.com/Online/Features/SHC-Shell-Compiler
  2. ^ http://www.datsi.fi.upm.es/~frosal/sources/
  3. ^ https://raw.githubusercontent.com/neurobin/shc/release/CHANGES
  4. ^ "Man page of shc". neurobin.github.io. Retrieved 2015-08-25.