Shell 脚本加密的方法

2015-8-27 杜世伟 shell

Shc可以用来对shell脚本进行加密,可以将shell脚本转换为一个可执行的二进制文件。经过shc对shell脚本进行加密后,会同时生成两种个新的文件,一个是加密后的可执行的二进制文件(文件名以.x结束),另一个是C语言的原文件(文件名以.x.c结束)。

shc 安装 
yum -y install shc 

参数介绍:
#shc -h
shc Version 3.9.6, Generic Shell Script Compiler
shc GNU GPL Version 3 Md Jahidul Hamid <jahidulhamid@yahoo.com>
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-o outfile] [-rvDUCABh] -f script

    -e %s  Expiration date in dd/mm/yyyy format [none]
    -m %s  Message to display upon expiration ["Please contact your provider"]
    -f %s  File name of the script to compile
    -i %s  Inline option for the shell interpreter i.e: -e
    -x %s  eXec command, as a printf format i.e: exec('%s',@ARGV);
    -l %s  Last shell option i.e: --
    -o %s  output filename
    -r     Relax security. Make a redistributable binary
    -v     Verbose compilation
    -D     Switch ON debug exec calls [OFF]
    -U     Make binary untraceable [no]
    -C     Display license and exit
    -A     Display abstract and exit
    -B     Compile for busybox
    -h     Display help and exit

    Environment variables used:
    Name    Default  Usage
    CC      cc       C compiler command
    CFLAGS  <none>   C compiler flags

    Please consult the shc man page.

    -e:指定过期时间为2010年10月20日
-m:过期后打印出的信息;
-v: verbose
-r: 可在相同操作系统的不同主机上执行
-f: 指定源shell

使用方法: 

shc -r -f script-name 注意:要有-r选项, -f 后跟要加密的脚本名. 

运行后会生成两个文件,script-name.x 和 script-name.x.c 

script-name.x是加密后的可执行的二进制文件. 

./script-name 即可运行. 

script-name.x.c是生成script-name.x的原文件(c语言)

标签: linux yum install shc

Powered by emlog 沪ICP备2023034538号-1