Commit 4cd615af authored by Pavel Vainerman's avatar Pavel Vainerman

release 3.9.6-alt1

parent df4aea04
copy: *.patch
tar.gz: shc suffix=.tgz
tar: shc name=@name@-@version@
spec: shc.spec
--- Makefile.old 2005-01-27 00:16:40 +0200
+++ Makefile 2005-01-27 00:16:58 +0200
@@ -1,29 +1,29 @@
# Makefile
#
-INSTALL_PATH = /usr/local
+INSTALL_PATH =$(RPM_BUILD_ROOT)/usr
# For SCO
-CFLAGS = -b elf -O -D_SVID
+#CFLAGS = -b elf -O -D_SVID
# For IRIX
-CFLAGS = -xansi -fullwarn -O3 -g0
+#CFLAGS = -xansi -fullwarn -O3 -g0
# For Solaris
-CFLAGS = -fast -xO4 -s -v -Xa
+#CFLAGS = -fast -xO4 -s -v -Xa
# For HPUX
-CFLAGS = -Wall -O -Ae
+#CFLAGS = -Wall -O -Ae
# For OSF1
-CFLAGS = -w -verbose -fast -std1 -g0
+#CFLAGS = -w -verbose -fast -std1 -g0
# For GNU C compiler
CFLAGS = -Wall -O6 -pedantic
-SHELL = /bin/sh
+SHELL = /bin/bash
-all: shc ask_for_test
+all: shc
shc: shc.c
$(CC) $(CFLAGS) $< -o $@
@@ -63,9 +63,8 @@
install: shc
@echo '*** Installing shc and shc.1 on '$(INSTALL_PATH)
- @echo -n '*** Do you want to continue? '; read ANS; case "$$ANS" in y|Y|yes|Yes|YES) ;; *) exit 1;; esac;
install -c -s shc $(INSTALL_PATH)/bin/
- install -c -m 644 shc.1 $(INSTALL_PATH)/man/man1/
+ install -c -m 644 shc.1 $(INSTALL_PATH)/share/man/man1/
clean:
rm -f *.o *~ *.x.c
Name: shc
Version: 3.8.9
Name: shc
Version: 3.9.6
Release: alt1
Summary: Shell Script Compiler
Summary: Generic shell script compiler
License: GPLv2
Group: Development/Other
Url: http://www.datsi.fi.upm.es/~frosal/
Packager: Ilya Mashkin <oddity@altlinux.ru>
Source0: %name-%version.tgz
Group: System/Libraries
License: GPLv3
URL: https://github.com/neurobin/shc
Patch0: %name-3.7-makefile.patch
# Source0-url: https://github.com/neurobin/shc/archive/3.9.6.tar.gz
Source0: %name-%version.tar
Requires: gcc
BuildRequires: gcc
%description
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. Use with care.
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.
%prep
%setup -n %name-%version
#patch0
%setup -q
%build
mv shc-3.8.9.c shc.c
%make
# %%autoreconf
%configure
%make_build
%install
%__mkdir_p $RPM_BUILD_ROOT{%_bindir,%_man1dir}
#make_install
install -c -s %name %buildroot%_bindir
install -c -m 644 %name.1 %buildroot%_man1dir
%makeinstall_std
%files
%doc README.md
%_bindir/*
%doc CHANGES Copying shc.README shc.html
%_mandir/man?/*
%_man1dir/*
%changelog
* Thu Mar 11 2014 Ilya Mashkin <oddity@altlinux.ru> 3.8.9-alt1
* Fri Apr 06 2018 Pavel Vainerman <pv@altlinux.ru> 3.9.6-alt1
- new version (3.9.6) with rpmgs script
* Thu Mar 11 2014 Ilya Mashkin <oddity at altlinux.ru> 3.8.9-alt1
- 3.8.9 (Closes: #25694)
* Wed Oct 22 2008 Ilya Mashkin <oddity@altlinux.ru> 3.8.6-alt1
* Wed Oct 22 2008 Ilya Mashkin <oddity at altlinux.ru> 3.8.6-alt1
- 3.8.6
* Mon Jul 18 2005 Alex Yustasov <yust@altlinux.ru> 3.8.3-alt1
* Mon Jul 18 2005 Alex Yustasov <yust at altlinux.ru> 3.8.3-alt1
- 3.8.3
* Wed Jan 26 2005 Alex Yustasov <yust@altlinux.ru> 3.7-alt1
* Wed Jan 26 2005 Alex Yustasov <yust at altlinux.ru> 3.7-alt1
- initial release
Francisco Garcia <frosal@fi.upm.es>
MD. JAHIDUL HAMID <jahidulhamid@yahoo.com>
This diff is collapsed. Click to expand it.
CHANGES
3.9.6 Sat Jun 3 10:05:03 UTC 2017
* Fix issue #38
3.9.5 Wed May 31 01:35:33 UTC 2017
* Fix issue #36
3.9.4 Sat May 13 18:46:05 UTC 2017
* Fix issue #23 (debian bug #861180)
3.9.3 Sat Jul 30 18:46:34 BDT 2016
* zsh support
* Fix issue #13 (https://github.com/neurobin/shc/issues/13)
3.9.2 Fri Aug 21 16:12:33 BDT 2015
Added BusyBox support with patch taken from:
https://onedrive.live.com/prev?cid=18a41d08a9f3c543&id=18A41D08A9F3C543!231&authkey=!AJQ6Iah_5D3WJ60&v=TextFileEditor
as suggested by https://github.com/marcoburatto
3.9.1 Fri Apr 03 00:22:11 GMT 2015
Renamed option -T to -U and reversed it's logic.
So now, the executable prepared will execute without using sudo,
by default.
3.9.0 Wed Apr 01 08:35:22 AM GMT 2015
(http://github.com/neurobin)
Added output file option with [-o filename]
and fixed bug on make install (manual install failed)
Now you can access manual by entering command: man shc
in a terminal.
3.8.9 Wed Apr 25 09:24:25 CEST 2012
Thanks to Giacomo Picconi <giacomo.picconi@gpstudio.com> for:
......
This diff is collapsed. Click to expand it.
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src
EXTRA_DIST = autogen.sh README.md .gitattributes .gitignore .travis.yml test
dist_man_MANS = shc.1
This diff is collapsed. Click to expand it.
README.md
[![build status image](https://travis-ci.org/neurobin/shc.svg?branch=release)](https://travis-ci.org/neurobin/shc)
[![GitHub stars](https://img.shields.io/github/stars/neurobin/shc.svg)](https://github.com/neurobin/shc/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/neurobin/shc.svg)](https://github.com/neurobin/shc/network)
[![GitHub issues](https://img.shields.io/github/issues/neurobin/shc.svg)](https://github.com/neurobin/shc/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](https://github.com/neurobin/shc/releases/latest) 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`
1. Try: `shc -f test.bash -o test`, where <span class="light-quote">test.bash</span> is the bash source.
2. 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 - !!
<h3><a href="http://neurobin.github.io/shc/man.html">Man Page</a></h3>
<h3><a href="http://neurobin.github.io/shc">WebPage</a></h3>
This diff is collapsed. Click to expand it.
#!/bin/sh
autoreconf --force --install
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
This source diff could not be displayed because it is too large. You can view the blob instead.
AC_INIT([shc], [3.9.6], [http://github.com/neurobin/shc/issues])
AC_CONFIG_AUX_DIR(config)
#prefix="/usr"
AC_CONFIG_SRCDIR([src/shc.c])
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_MEMBERS([struct stat.st_rdev])
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memset putenv strchr strdup strrchr])
AC_OUTPUT(Makefile src/Makefile)
# Makefile
#
INSTALL_PATH = /usr/local
# For SCO
CFLAGS = -b elf -O -D_SVID
# For IRIX
CFLAGS = -xansi -fullwarn -O3 -g0
# For Solaris
CFLAGS = -fast -xO4 -s -v -Xa
# For HPUX
CFLAGS = -Wall -O -Ae
# For OSF1
CFLAGS = -w -verbose -fast -std1 -g0
# For GNU C compiler
CFLAGS = -Wall # -O6 -pedantic
#SHELL = /bin/sh
all: shc ask_for_test
shc: shc.c
$(CC) $(CFLAGS) $@.c -o $@
ask_for_test:
@echo '*** ¿Do you want to probe shc with a test script?'
@echo '*** Please try... make test'
test: make_the_test ask_for_strings
make_the_test: match.x
@echo '*** Running a compiled test script!'
@echo '*** It must show files with substring "sh" in your PATH...'
./match.x sh
match.x: shc match
@echo '*** Compiling script "match"'
CFLAGS="$(CFLAGS)" ./shc -v -f match
ask_for_strings:
@echo '*** ¿Do you want to see strings in the generated binary?'
@echo '*** Please try... make strings'
strings: make_the_strings ask_for_expiration
make_the_strings: match.x
@echo '*** Running: "strings -n 5 'match.x'"'
@echo '*** It must show no sensible information...'
strings -n 5 match.x
ask_for_expiration:
@echo '*** ¿Do you want to probe expiration date?'
@echo '*** Please try... make expiration'
expiration: til_yesterday ask_for_install
til_yesterday: shc match
@echo '*** Compiling "match" to expired date'
CFLAGS="$(CFLAGS)" ./shc -vvv -e `date "+%d/%m/%Y"` -f match
@echo '*** Running a compiled test script!'
@echo '*** It must fail showing "./match.x: has expired!"'
./match.x
ask_for_install:
@echo '*** ¿Do you want to install shc?'
@echo '*** Please try... make install'
install: shc
@echo '*** Installing shc and shc.1 on '$(INSTALL_PATH)
@echo -n '*** ¿Do you want to continue? '; read ANS; case "$$ANS" in y|Y|yes|Yes|YES) ;; *) exit 1;; esac;
install -c -s shc $(INSTALL_PATH)/bin/
install -c -m 644 shc.1 $(INSTALL_PATH)/man/man1/
clean:
rm -f *.o *~ *.x.c
cleanall: clean
rm -f shc *.x
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<meta name="date" content="2017-05-17" />
<title>shc(1) shc user manual</title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
</head>
<body>
<div id="header">
<h1 class="title">shc(1) shc user manual</h1>
<h3 class="date">May 17, 2017</h3>
</div>
<hr>
<h1 id="name">NAME</h1>
<p>shc - Generic shell script compiler</p>
<h1 id="synopsis">SYNOPSIS</h1>
<p><strong>shc</strong> [ -e <em>date</em> ] [ -m <em>addr</em> ] [ -i <em>iopt</em> ] [ -x <em>cmnd</em> ] [ -l <em>lopt</em> ] [ -o <em>outfile</em> ] [ -ABCDhUv ] -f <em>script</em></p>
<h1 id="description">DESCRIPTION</h1>
<p><strong>shc</strong> creates a stripped binary executable version of the script specified with <code>-f</code> on the command line.</p>
<p>The binary version will get a <code>.x</code> extension appended by default if <em>outfile</em> is not defined with [-o <em>outfile</em>] option and will usually be a bit larger in size than the original ascii code. Generated C source code is saved in a file with the extension <code>.x.c</code> or in a file specified with appropriate option.</p>
<p>If you supply an expiration date with the <code>-e</code> option, the compiled binary will refuse to run after the date specified. The message <strong>Please contact your provider</strong> will be displayed instead. This message can be changed with the <code>-m</code> option.</p>
<p>You can compile any kind of shell script, but you need to supply valid <code>-i</code>, <code>-x</code> and <code>-l</code> options.</p>
<p>The compiled binary will still be dependent on the shell specified in the first line of the shell code (i.e. <code>#!/bin/sh</code>), thus <strong>shc</strong> does not create completely independent binaries.</p>
<p><strong>shc</strong> 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 <code>-c</code> option. Unfortunatelly, it will not give you any speed improvement as a real C program would.</p>
<p><strong>shc</strong>'s main purpose is to protect your shell scripts from modification or inspection. You can use it if you wish to distribute your scripts but don't want them to be easily readable by other people.</p>
<h1 id="options">OPTIONS</h1>
<dl>
<dt>-e <em>date</em></dt>
<dd>Expiration date in <em>dd/mm/yyyy</em> format <code>[none]</code>
</dd>
<dt>-m <em>message</em></dt>
<dd>message to display upon expiration <code>[&quot;Please contact your provider&quot;]</code>
</dd>
<dt>-f <em>script_name</em></dt>
<dd>File path of the script to compile
</dd>
<dt>-i <em>inline_option</em></dt>
<dd>Inline option for the shell interpreter i.e: <code>-e</code>
</dd>
<dt>-x <em>command</em></dt>
<dd>eXec command, as a printf format i.e: <code>exec(\\'%s\\',@ARGV);</code>
</dd>
<dt>-l <em>last_option</em></dt>
<dd>Last shell option i.e: <code>--</code>
</dd>
<dt>-o <em>outfile</em></dt>
<dd>output to the file specified by outfile
</dd>
<dt>-r</dt>
<dd>Relax security. Make a redistributable binary which executes on different systems running the same operating system. You can release your binary with this option for others to use
</dd>
<dt>-v</dt>
<dd>Verbose compilation
</dd>
<dt>-D</dt>
<dd>Switch on debug exec calls
</dd>
<dt>-U</dt>
<dd>Make binary to be untraceable (using <em>strace</em>, <em>ptrace</em>, <em>truss</em>, etc.)
</dd>
<dt>-C</dt>
<dd>Display license and exit
</dd>
<dt>-A</dt>
<dd>Display abstract and exit
</dd>
<dt>-B</dt>
<dd>Compile for BusyBox
</dd>
<dt>-h</dt>
<dd>Display help and exit
</dd>
</dl>
<h1 id="environment-variables">ENVIRONMENT VARIABLES</h1>
<dl>
<dt>CC</dt>
<dd>C compiler command <code>[cc]</code>
</dd>
<dt>CFLAGS</dt>
<dd>C compiler flags <code>[none]</code>
</dd>
</dl>
<h1 id="examples">EXAMPLES</h1>
<p>Compile a script which can be run on other systems with the trace option enabled (without <code>-U</code> flag):</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">shc</span> -f myscript -o mybinary</code></pre></div>
<p>Compile an untraceable binary:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">shc</span> -Uf myscript -o mybinary</code></pre></div>
<h1 id="bugs">BUGS</h1>
<p>The maximum size of the script that could be executed once compiled is limited by the operating system configuration parameter <code>_SC_ARG_MAX</code> (see sysconf(2))</p>
<h1 id="authors">AUTHORS</h1>
<p>Francisco Rosales <script type="text/javascript">
<!--
h='&#102;&#x69;&#46;&#x75;&#112;&#x6d;&#46;&#x65;&#x73;';a='&#64;';n='&#102;&#114;&#x6f;&#x73;&#x61;&#108;';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
// -->
</script><noscript>&#102;&#114;&#x6f;&#x73;&#x61;&#108;&#32;&#x61;&#116;&#32;&#102;&#x69;&#32;&#100;&#x6f;&#116;&#32;&#x75;&#112;&#x6d;&#32;&#100;&#x6f;&#116;&#32;&#x65;&#x73;</noscript></p>
<p>Md Jahidul Hamid <script type="text/javascript">
<!--
h='&#x79;&#x61;&#104;&#x6f;&#x6f;&#46;&#x63;&#x6f;&#x6d;';a='&#64;';n='&#106;&#x61;&#104;&#x69;&#100;&#x75;&#108;&#104;&#x61;&#x6d;&#x69;&#100;';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
// -->
</script><noscript>&#106;&#x61;&#104;&#x69;&#100;&#x75;&#108;&#104;&#x61;&#x6d;&#x69;&#100;&#32;&#x61;&#116;&#32;&#x79;&#x61;&#104;&#x6f;&#x6f;&#32;&#100;&#x6f;&#116;&#32;&#x63;&#x6f;&#x6d;</noscript></p>
<h1 id="report-bugs-to">REPORT BUGS TO</h1>
<p><a href="https://github.com/neurobin/shc/issues" class="uri">https://github.com/neurobin/shc/issues</a></p>
</body>
</html>
% shc(1) shc user manual
%
% May 17, 2017
<hr>
# NAME
shc - Generic shell script compiler
# SYNOPSIS
**shc** [ -e *date* ] [ -m *addr* ] [ -i *iopt* ] [ -x *cmnd* ] [ -l *lopt* ] [ -o *outfile* ] [ -ABCDhUv ] -f *script*
# DESCRIPTION
**shc** creates a stripped binary executable version of the script specified with `-f` on the command line.
The binary version will get a `.x` extension appended by default if *outfile* is not defined with [-o *outfile*] option
and will usually be a bit larger in size than the original ascii code.
Generated C source code is saved in a file with the extension `.x.c` or in a file specified with appropriate option.
If you supply an expiration date with the `-e` option, the compiled binary will refuse to run after the date specified.
The message **Please contact your provider** will be displayed instead. This message can be changed with the `-m` option.
You can compile any kind of shell script, but you need to supply valid `-i`, `-x` and `-l` options.
The compiled binary will still be dependent on the shell specified in the first line of the shell code (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.
Unfortunatelly, it will not give you any speed improvement as a real C program would.
**shc**'s main purpose is to protect your shell scripts from modification or inspection.
You can use it if you wish to distribute your scripts but don't want them to be easily readable by other people.
# OPTIONS
-e *date*
: Expiration date in *dd/mm/yyyy* format `[none]`
-m *message*
: message to display upon expiration `["Please contact your provider"]`
-f *script_name*
: File path of the script to compile
-i *inline_option*
: Inline option for the shell interpreter i.e: `-e`
-x *command*
: eXec command, as a printf format i.e: `exec(\\'%s\\',@ARGV);`
-l *last_option*
: Last shell option i.e: `--`
-o *outfile*
: output to the file specified by outfile
-r
: Relax security. Make a redistributable binary which executes on different systems running the same operating system. You can release your binary with this option for others to use
-v
: Verbose compilation
-D
: Switch on debug exec calls
-U
: Make binary to be untraceable (using *strace*, *ptrace*, *truss*, etc.)
-C
: Display license and exit
-A
: Display abstract and exit
-B
: Compile for BusyBox
-h
: Display help and exit
# ENVIRONMENT VARIABLES
CC
: C compiler command `[cc]`
CFLAGS
: C compiler flags `[none]`
# EXAMPLES
Compile a script which can be run on other systems with the trace option enabled (without `-U` flag):
```bash
shc -f myscript -o mybinary
```
Compile an untraceable binary:
```bash
shc -Uf myscript -o mybinary
```
# BUGS
The maximum size of the script that could be executed once compiled is limited by the operating system configuration parameter `_SC_ARG_MAX` (see sysconf(2))
# AUTHORS
Francisco Rosales <frosal@fi.upm.es>
Md Jahidul Hamid <jahidulhamid@yahoo.com>
# REPORT BUGS TO
<https://github.com/neurobin/shc/issues>
.TH shc 1 "Jun 18, 2003" "shc Version 3.8"
.UC 4
.SH "NAME"
shc - Generic shell script compiler
.SH "SYNOPSIS"
.B shc
[ \-\fBe\fP date ]
[ \-\fBm\fP addr ]
[ \-\fBi\fP iopt ]
[ \-\fBx\fP cmnd ]
.br
[ \-\fBl\fP lopt ]
[ \-\fBACDhTv\fP ]
\-\fBf\fP script
.SH "DESCRIPTION"
.B shc
creates a stripped binary executable version of the script
specified with \fI\-f\fP on the command line.
The binary version will get a \fI.x\fP extension appended
and will usually be a bit larger in size than the original ascii code.
Generated C source code is saved in a file with the extension \fI.x.c\fP
If you supply an expiration date with the \fI\-e\fP option the
.\" Automatically generated by Pandoc 1.16.0.2
.\"
.TH "shc" "1" "May 17, 2017" "shc user manual" ""
.hy
.SH NAME
.PP
shc \- Generic shell script compiler
.SH SYNOPSIS
.PP
\f[B]shc\f[] [ \-e \f[I]date\f[] ] [ \-m \f[I]addr\f[] ] [ \-i
\f[I]iopt\f[] ] [ \-x \f[I]cmnd\f[] ] [ \-l \f[I]lopt\f[] ] [ \-o
\f[I]outfile\f[] ] [ \-ABCDhUv ] \-f \f[I]script\f[]
.SH DESCRIPTION
.PP
\f[B]shc\f[] creates a stripped binary executable version of the script
specified with \f[C]\-f\f[] on the command line.
.PP
The binary version will get a \f[C]\&.x\f[] extension appended by
default if \f[I]outfile\f[] is not defined with [\-o \f[I]outfile\f[]]
option and will usually be a bit larger in size than the original ascii
code.
Generated C source code is saved in a file with the extension
\f[C]\&.x.c\f[] or in a file specified with appropriate option.
.PP
If you supply an expiration date with the \f[C]\-e\f[] option, the
compiled binary will refuse to run after the date specified.
The message \fB"Please contact your provider"\fP will be displayed instead.
This message can be changed with the \fI\-m\fP option.
The message \f[B]Please contact your provider\f[] will be displayed
instead.
This message can be changed with the \f[C]\-m\f[] option.
.PP
You can compile any kind of shell script, but you need to supply valid
\fI\-i\fP, \fI\-x\fP and \fI\-l\fP options.
The compiled binary will still be dependent on the shell specified
in the first line of the shell code (i.e. #!/bin/sh), thus \fBshc\fP does not create
completely independent binaries.
\fBshc\fP 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 \fI-c\fP option.
Unfortunatelly, it will not give you any speed improvement as a real C program would.
\fBshc\fP's main purpose is to protect your shell scripts from modification or
inspection. You can use it if you wish to distribute your scripts but don't
want them to be easily readable by other people.
.SH "OPTIONS"
The command line options are:
.TP
.B -e date
Expiration date in dd/mm/yyyy format [none]
.TP
.B -m message
message to display upon expiration ["Please contact your provider"]
.TP
.B -f script_name
File name of the script to compile
.TP
.B -i inline_option
Inline option for the shell interpreter i.e: -e
.TP
.B -x comand
eXec command, as a printf format i.e: exec(\\\\'%s\\\\',@ARGV);
.TP
.B -l last_option
Last shell option i.e: --
.TP
.B -r
Relax security. Make a redistributable binary which executes on
different systems running the same operating system.
.TP
.B -v
\f[C]\-i\f[], \f[C]\-x\f[] and \f[C]\-l\f[] options.
.PP
The compiled binary will still be dependent on the shell specified in
the first line of the shell code (i.e.
\f[C]#!/bin/sh\f[]), thus \f[B]shc\f[] does not create completely
independent binaries.
.PP
\f[B]shc\f[] 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 \f[C]\-c\f[] option.
Unfortunatelly, it will not give you any speed improvement as a real C
program would.
.PP
\f[B]shc\f[]\[aq]s main purpose is to protect your shell scripts from
modification or inspection.
You can use it if you wish to distribute your scripts but don\[aq]t want
them to be easily readable by other people.
.SH OPTIONS
.TP
.B \-e \f[I]date\f[]
Expiration date in \f[I]dd/mm/yyyy\f[] format \f[C][none]\f[]
.RS
.RE
.TP
.B \-m \f[I]message\f[]
message to display upon expiration
\f[C]["Please\ contact\ your\ provider"]\f[]
.RS
.RE
.TP
.B \-f \f[I]script_name\f[]
File path of the script to compile
.RS
.RE
.TP
.B \-i \f[I]inline_option\f[]
Inline option for the shell interpreter i.e: \f[C]\-e\f[]
.RS
.RE
.TP
.B \-x \f[I]command\f[]
eXec command, as a printf format i.e:
\f[C]exec(\\\\\[aq]%s\\\\\[aq],\@ARGV);\f[]
.RS
.RE
.TP
.B \-l \f[I]last_option\f[]
Last shell option i.e: \f[C]\-\-\f[]
.RS
.RE
.TP
.B \-o \f[I]outfile\f[]
output to the file specified by outfile
.RS
.RE
.TP
.B \-r
Relax security.
Make a redistributable binary which executes on different systems
running the same operating system.
You can release your binary with this option for others to use
.RS
.RE
.TP
.B \-v
Verbose compilation
.RS
.RE
.TP
.B -D
.B \-D
Switch on debug exec calls
.RS
.RE
.TP
.B -T
Allow binary to be traceable (using strace, ptrace, truss, etc.)
.B \-U
Make binary to be untraceable (using \f[I]strace\f[], \f[I]ptrace\f[],
\f[I]truss\f[], etc.)
.RS
.RE
.TP
.B -C
.B \-C
Display license and exit
.RS
.RE
.TP
.B -A
.B \-A
Display abstract and exit
.RS
.RE
.TP
.B \-B
Compile for BusyBox
.RS
.RE
.TP
.B -h
.B \-h
Display help and exit
.SH "ENVIRONMENT VARIABLES"
.RS
.RE
.SH ENVIRONMENT VARIABLES
.TP
.B CC
C compiler command [cc]
C compiler command \f[C][cc]\f[]
.RS
.RE
.TP
.B CFLAGS
C compiler flags [none]
.SH "EXAMPLES"
.SM
Compile a script which can be run on other systems with the trace
option enabled:
example% \fBshc\fP -v -r -T -f myscript
.SH "BUGS"
The maximum size of the script that could be executed once compiled is limited
by the operating system configuration parameter
.B _SC_ARG_MAX
(see
.BR sysconf ( 2 )\c
)
.SH "AUTHOR"
Francisco Rosales
<frosal@fi.upm.es>
.SH "REPORT BUGS TO"
the author.
C compiler flags \f[C][none]\f[]
.RS
.RE
.SH EXAMPLES
.PP
Compile a script which can be run on other systems with the trace option
enabled (without \f[C]\-U\f[] flag):
.IP
.nf
\f[C]
shc\ \-f\ myscript\ \-o\ mybinary
\f[]
.fi
.PP
Compile an untraceable binary:
.IP
.nf
\f[C]
shc\ \-Uf\ myscript\ \-o\ mybinary
\f[]
.fi
.SH BUGS
.PP
The maximum size of the script that could be executed once compiled is
limited by the operating system configuration parameter
\f[C]_SC_ARG_MAX\f[] (see sysconf(2))
.SH AUTHORS
.PP
Francisco Rosales <frosal@fi.upm.es>
.PP
Md Jahidul Hamid <jahidulhamid@yahoo.com>
.SH REPORT BUGS TO
.PP
<https://github.com/neurobin/shc/issues>
Purpose:
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. Use with care.
Building:
Just do a "make"
Testing:
Try: "make test"
or: "shc -v -f match" then "match.x sh"
Caveat emptor: see Copyright
The results look fine to me, but I havn't used this in anger, but
the author has used shc for his work widely over SunOS, Solaris and
Linux, and done some testing on Irix and HPUX.
We tested it on a few SMALL ksh scripts - big tasks should probably
be written in C in the first place (see _SC_ARG_MAX below)!
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 - !!
Archived at: ftp://hpux.csc.liv.ac.uk/hpux/Languages/shc-2.4a
Archived by: steff@csc.liv.ac.uk
Author: Francisco Rosales Garcia
--------------------------------------------------------------------
Francisco Rosales García <frosal@fi.upm.es> TEL: +341 336 73 80
http://www.datsi.fi.upm.es/~frosal FAX: +34 1 336 73 73
Departamento de Arquitectura y Tecnología de Sistemas Informáticos
Facultad de Informática. Universidad Politécnica de Madrid. España
--------------------------------------------------------------------
shc-3.8.9.c
\ No newline at end of file
Content-type: text/html
<HTML><HEAD><TITLE>Manpage of shc</TITLE>
</HEAD><BODY>
<H1>shc</H1>
Section: User Commands (1)<BR>Updated: Jun 18, 2003<BR><A HREF="#index">Index</A>
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<P>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
shc - Generic shell script compiler
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>shc</B>
[ -<B>e</B> date ]
[ -<B>m</B> addr ]
[ -<B>i</B> iopt ]
[ -<B>x</B> cmnd ]
<BR>
[ -<B>l</B> lopt ]
[ -<B>ACDhTv</B> ]
-<B>f</B> script
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>shc</B>
creates a stripped binary executable version of the script
specified with <I>-f</I> on the command line.
<P>
The binary version will get a <I>.x</I> extension appended
and will usually be a bit larger in size than the original ascii code.
Generated C source code is saved in a file with the extension <I>.x.c</I>
<P>
If you supply an expiration date with the <I>-e</I> option the
compiled binary will refuse to run after the date specified.
The message <B>&quot;Please contact your provider&quot;</B> will be displayed instead.
This message can be changed with the <I>-m</I> option.
<P>
You can compile any kind of shell script, but you need to supply valid
<I>-i</I>, <I>-x</I> and <I>-l</I> options.
<P>
The compiled binary will still be dependent on the shell specified
in the first line of the shell code (i.e. #!/bin/sh), thus <B>shc</B> does not create
completely independent binaries.
<P>
<B>shc</B> 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 <I>-c</I> option.
Unfortunatelly, it will not give you any speed improvement as a real C program would.
<P>
<B>shc</B>'s main purpose is to protect your shell scripts from modification or
inspection. You can use it if you wish to distribute your scripts but don't
want them to be easily readable by other people.
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
The command line options are:
<DL COMPACT>
<DT><B>-e date</B>
<DD>
Expiration date in dd/mm/yyyy format [none]
<DT><B>-m message</B>
<DD>
message to display upon expiration [&quot;Please contact your provider&quot;]
<DT><B>-f script_name</B>
<DD>
File name of the script to compile
<DT><B>-i inline_option</B>
<DD>
Inline option for the shell interpreter i.e: -e
<DT><B>-x comand</B>
<DD>
eXec command, as a printf format i.e: exec(\\'%s\\',@ARGV);
<DT><B>-l last_option</B>
<DD>
Last shell option i.e: --
<DT><B>-r</B>
<DD>
Relax security. Make a redistributable binary which executes on
different systems running the same operating system.
<DT><B>-v</B>
<DD>
Verbose compilation
<DT><B>-D</B>
<DD>
Switch on debug exec calls
<DT><B>-T</B>
<DD>
Allow binary to be traceable (using strace, ptrace, truss, etc.)
<DT><B>-C</B>
<DD>
Display license and exit
<DT><B>-A</B>
<DD>
Display abstract and exit
<DT><B>-h</B>
<DD>
Display help and exit
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>ENVIRONMENT VARIABLES</H2>
<DL COMPACT>
<DT><B>CC</B>
<DD>
C compiler command [cc]
<DT><B>CFLAGS</B>
<DD>
C compiler flags [none]
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>EXAMPLES</H2>
<FONT SIZE="-1">Compile a script which can be run on other systems with the trace</FONT>
option enabled:
<P>
<BR>&nbsp;&nbsp;example%&nbsp;<B>shc</B>&nbsp;-v&nbsp;-r&nbsp;-T&nbsp;-f&nbsp;myscript
<A NAME="lbAH">&nbsp;</A>
<H2>BUGS</H2>
The maximum size of the script that could be executed once compiled is limited
by the operating system configuration parameter
<B>_SC_ARG_MAX</B>
(see
<B>sysconf</B>(<B>2</B>))
<A NAME="lbAI">&nbsp;</A>
<H2>AUTHOR</H2>
Francisco Rosales
&lt;<A HREF="mailto:frosal@fi.upm.es">frosal@fi.upm.es</A>&gt;
<A NAME="lbAJ">&nbsp;</A>
<H2>REPORT BUGS TO</H2>
the author.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">OPTIONS</A><DD>
<DT><A HREF="#lbAF">ENVIRONMENT VARIABLES</A><DD>
<DT><A HREF="#lbAG">EXAMPLES</A><DD>
<DT><A HREF="#lbAH">BUGS</A><DD>
<DT><A HREF="#lbAI">AUTHOR</A><DD>
<DT><A HREF="#lbAJ">REPORT BUGS TO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 15:46:31 GMT, July 08, 2004
</BODY>
</HTML>
bin_PROGRAMS = shc
shc_SOURCES = shc.c
#! /bin/sh -x
#!/bin/sh -x
echo "$0" "$@"
ps $$
ps wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww $$
......
#!/bin/bash -x
#!/bin/bash
echo "\$@ is $@"
echo "command line: $0 $*"
echo "hello world"
......
#! /usr/bin/ksh -x
#!/usr/bin/ksh -x
echo "\$@ is $@"
echo "command line: $0 $*"
echo "hello world"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment