Sunday, December 9, 2007

How to protect a shell script


Q: I have written a lengthy shell script (more than 1000 lines) and all the sys.admins in my company use that script and it runs as root. My concern is what if some sys.admin just add a "rm -r /" in the script which might jeopardize my whole efforts. Is there a way to convert a shell Script to an exe file ? or some other way so that others cannot see the code ? If u know pls. share.

A:
Generic shell script compiler(shc) creates a stripped binary executable version of the script specified with -f on the command line. (shc encrypts shell scripts using RC4)

Get SHC from : http://www.datsi.fi.upm.es/~frosal/
DEBIAN: apt-get install shc

$ shc -f sundays.sh

It will generate following two files
sundays.sh.x.c # Generated C source code of sundays.sh
sundays.sh.x # The binary version of sundays.sh

share "sundays.sh.x" with your friends, which is a executable and encrypted one.

Note: Paranoid Penguin - Limitations of shc, a Shell Encryption Utility

No comments:

© Jadu Saikia www.UNIXCL.com