Saturday, November 3, 2012

How to install SHC on your Linux system

SHC stands for Generic shell script compiler. Created by Francisco Javier Rosales GarcĂ­a, 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 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 .

In a simple word, SHC compile your Bash script into binary so no one can see your code. 

And here's step by step how to install SHC (I use Ubuntu 12.04 LTS) :

1. Download the latest version of SHC at here 

2. Put the package at your home (~) directory

3. Extract the tarball :

adee@thinkpad:~$ tar -xzvf shc-3.8.9.tgz 
shc-3.8.9/CHANGES
shc-3.8.9/Copying
shc-3.8.9/match
shc-3.8.9/pru.sh
shc-3.8.9/shc-3.8.9.c
shc-3.8.9/shc.1
shc-3.8.9/shc.README
shc-3.8.9/shc.html
shc-3.8.9/test.bash
shc-3.8.9/test.csh
shc-3.8.9/test.ksh
shc-3.8.9/makefile


4. Step inside into the shc folder and do the 'make' command :

adee@thinkpad:~$ cd shc-3.8.9/
adee@thinkpad:~/shc-3.8.9$ make
make: *** No rule to make target `shc.c', needed by `shc'.  Stop.


5. As you see above, there's an error about missing file named 'shc.c' Actually the 'shc.c' is already there, we just have to rename  / duplicate it into the right name :

adee@thinkpad:~/shc-3.8.9$ cp shc-3.8.9.c shc.c
adee@thinkpad:~/shc-3.8.9$ make
cc -Wall  shc.c -o shc
*** �Do you want to probe shc with a test script?
*** Please try... make test


6. Ok, then we shall continue to 'make install' command (need sudo):

adee@thinkpad:~/shc-3.8.9$ sudo make install
*** Installing shc and shc.1 on /usr/local
*** �Do you want to continue? y
install -c -s shc /usr/local/bin/
install -c -m 644 shc.1 /usr/local/man/man1/
install: target `/usr/local/man/man1/' is not a directory: No such file or directory
make: *** [install] Error 


7. Something sucks occurs again. It's looks like there's no such directory named '/usr/local/man/man1/'. So what should we do? Simple, just create that folder and repeat again the make install command. It should works now!

adee@thinkpad:~/shc-3.8.9$ sudo mkdir /usr/local/man/man1
adee@thinkpad:~/shc-3.8.9$ sudo make install
*** Installing shc and shc.1 on /usr/local
*** �Do you want to continue? y
install -c -s shc /usr/local/bin/
install -c -m 644 shc.1 /usr/local/man/man1/


8. Next, we have to move the shc binary file into /bin and give it the excecutable bit :

adee@thinkpad:~/shc-3.8.9$ sudo cp shc /bin/shc
adee@thinkpad:~/shc-3.8.9$ sudo chmod +x /bin/shc


9. OK Done! SHC is installed into your system. To test it, try type 'shc' at the terminal, and it should looks like this :

adee@thinkpad:~/shc-3.8.9$ shc 
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script


OK on the next few days, i will write an article about the usage of SHC. So stay tuned :-)

17 comments:

  1. Hi,
    This post help me,

    Thank you.

    ReplyDelete
  2. Great Post! Thats exactly the same errors I had!
    Thanks

    ReplyDelete
  3. [root@localhost shc-3.8.9]# make
    cc -Wall shc.c -o shc
    make: cc: Command not found
    make: *** [shc] Error 127

    ReplyDelete
    Replies
    1. you should install gcc before install shc :

      yum -y install make automake autoconf gcc gcc++
      apt-get -y install build-essential
      aptitude -y install build-essential

      Delete
  4. [root@localhost shc-3.8.9]# make
    cc -Wall shc.c -o shc
    make: cc: Command not found
    make: *** [shc] Error 127

    lol

    install gcc after install shc

    yum -y install make automake autoconf gcc gcc++

    apt-get -y install build-essential

    aptitude -y install build-essential

    or mac install xcode command line tools https://developer.apple.com/xcode/

    ReplyDelete
  5. on many of machines shc encrypted script running
    After i encrypted it my script did not working.
    [root@my shc-3.8.7]# ./op.sh.x

    [8]+ Stopped ./op.sh.x

    kindly help

    ReplyDelete
    Replies
    1. install glibc package
      and be careful about shc version. it should be right version with right os release.

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. i am having the issue like this kindly help me

    [root@localhost shc-3.8.9]# ./abc.x

    [2]+ Stopped ./abc.x

    ReplyDelete
    Replies
    1. install glibc package
      and be careful about shc version. it should be right version with right os release.

      Delete

Leave your comments with attitude please. This blog does DOFOLLOW :-)