Shell script encryption tool SHC


This is the 12th day of my participation in the August Text Challenge.More challenges in August


SHc (SHell compiler) is a fabulous tool created and maintained by Francisco Javier Rosales Garcia (www.datsi.fi.upm.es/~frosal/). This tool protect any shell script with encryption (ARC4).

Resource files: SHC, shc-unshc, Unshc

SHC “installation

Wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9b.tgz tar - VXF SHC "- 3.8.9 b.t gzcdSHC "- 3.8.9 make btest
make strings
sudo mkdir -p /usr/local/man/man1/
sudo make install
Copy the code

Verify that the installation is complete

which shc 
Copy the code

Common Parameter analysis

-e date (specifies the expiration date) -m message (specifies the expiration prompt) -f script_name (specifies the path and file name of the shell to be compiled) -r Relax security. (It can be executed on different operating systems of the same operating system) -v Verbose compilationCopy the code

The specific use

Generate dynamically linked binary executables

shc -r -f deploy.sh
Copy the code
-f specifies the file to be decrypted. -r specifies a secure encryption mode.Copy the code

Generate two files, deploy.sh.x, which is a dynamically linked binary executable, and deploy.sh.x.c, which corresponds to the C program. Note: There is a problem here because the deploy.sh.x runtime requires the support of the corresponding library link, which means that the target runtime environment also needs to install SHC or SHC libraries. See the solution below: Generate statically linked binaries.

run

./deploy.sh.x
Copy the code

You can directly

mv deploy.sh.x deploy
Copy the code

Simply hide the.sh.x file type information. use

file  deploy.sh.x An error may be reported
Copy the code

Set the script expiration time

shc -e 14/09/2016  -f deploy.sh
Copy the code

Generate statically linked binary executables

CFLAGS=-static shc -r -f  deploy.sh
Copy the code

Custom return information

shc   -m  "hello world "  -f  deploy.sh
Copy the code

Error handling

The reason:

You have to put the sha-bang (e.g. #! /bin/bash) at the beginning of the script, since shc need to know which shell is using. Here is an excerpt from the manual page

Explanation: Add on the first line of the script

#! /bin/bash
Copy the code