shell脚本是可读写的, 很有可能会泄露敏感信息, 如用户名/密码/路径/IP等. 同样在shell脚本运行时会也泄露敏感信息.
shc是一个加密shell脚本的工具, 它的作用是把shell脚本转换为一个可执行的二进制文件. 这就很好的解决了上述问题.
下载: http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.6.tgz
安装:
# mkdir -p /orahome/wangnc/shc && cd /orahome/wangnc/shc
# rz (上传安装包shc-3.8.6.tgz)
# mkdir /usr/local/man/man1/ (install时会把man文件放入该目录,如果该目录不存在需提前建好)
# tar vxf shc-3.8.6.tgz && cd shc-3.8.6
# make test
# make strings
# 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/
用法:
#---------------------------------------#
# which shc
/usr/local/bin/shc
#---------------------------------------#
# shc
shc parse(-f): No source file specified
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script
#---------------------------------------#
[root@VMTest shc-3.8.9b]# shc --help
shc: invalid option -- '-'
shc parse: Unknown option
shc Version 3.8.9b, Generic Script Compiler
shc Copyright (c) 1994-2015 Francisco Rosales <frosal@fi.upm.es>
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -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: --
-r Relax security. Make a redistributable binary
-v Verbose compilation
-D Switch ON debug exec calls [OFF]
-T Allow binary to be traceable [no]
-C Display license and exit
-A Display abstract and exit
-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(1) man page.