Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to convert my shell scripts into binary executable so that nobody else could edit or read it. Is there a way to convert it into a binary executable?

share|improve this question
21  
Don't do it! – l0b0 Feb 14 '13 at 11:23
    
github.com/neurobin/shc – Jahid Apr 1 '15 at 10:56
up vote 2 down vote accepted

There's an alternative to compiling your scripts. Since the goal here is to make it so that no one can read it or alter it, you may want to give the following link a try:

http://www.kinglazy.com/shell-script-encryption-kinglazy-shieldx.htm

On the above page, all you have to do is submit your script (you can submit a sample script first for your peace of mind). A zip file will be generated for you.

Installation:

  1. wget link-to-the-zip-file

  2. unzip the-newly-downloaded-zip-file

  3. cd /tmp/KingLazySHIELD

  4. ./install.sh /var/tmp/KINGLAZY/SHIELDX /bin -force

What the above install command will do for you is:

  1. It'll install the encrypted script in the directory /var/tmp/KINGLAZY/SHIELDX.

  2. It'll place a link to this encrypted script in /bin - that way, you need not type the absolute path to your script each time you want to run it.

  3. Ensures NO ONE can modify the script - Any attempts to modify the encrypted script will render it inoperable...until the attempts are removed.

  4. Ensures absolutely NO ONE can make copies of it. No one can copy your script to a secluded location and try to screw around with it to see how it works.

share|improve this answer
    
i have not tested this but i selected this as an answer since it looks better otpion than SHC since it seems from the comments of @sthephan there are easy way to bypass shc – munish Jan 15 at 0:38

shc is what you're looking for. get it here: shc
Extract, cd into dir, make and then ./shc -f SCRIPT. Done.

Everything you need to do this, you find here:
SHC Howto

share|improve this answer
6  
+1 wow, that is interesting. Just beware that if the process is exactly as it is described, this is a weak method of concealing a password -- it could still be extracted by someone who knows how executables are structured. However, it would be very effective for obscuring a script from casual observers. I'd be interested to learn if scripts pre-compiled this way are faster to execute. – goldilocks Feb 14 '13 at 6:48
16  
Note that it doesn't work with bash (or sh based on bash), as one can do: env SHELLOPTS=verbose ./script.x to see the content of the script. There's probably easy ways to bypass with other shells as well. – Stéphane Chazelas Feb 14 '13 at 11:14
3  
From the shc man page, "Unfortunatelly, it will not give you any speed improvement as a real C program would." datsi.fi.upm.es/~frosal/sources/shc.html – Adam Feb 14 '13 at 19:35
    
shc has been updated to 3.9.0: github.com/neurobin/shc – Jahid Apr 1 '15 at 10:53
    
Although SHC might not give you a speed improvement you hope for, it offers the possibility of hacking SHC itself to obtain a better translation of your script. Writing a clean shell script and then improving SHC could be more productive than writing a C program from scratch, or convoluting a shell script to make it faster. – Kaz Jun 30 '15 at 19:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.