采用shc工具加密Shell脚本,以提高shell脚本文件的安全性。 介绍:当我们写的shell脚本,存在有敏感信息如账号密码,于是想加强脚本的安全性;还有不想让别人查看/修改您的shell核心代码等等情况。都可使用以下工具进行加密。 shc是一个脚本编译工具, 使用RC4加密算法, 它能够把shell程序转换成二进制可执行文件(支持静态链接和动态链接)。 shc官网:http://www.datsi.fi.upm.es/%7Efrosal/ 安装shc wget http://www.datsi.fi.upm.es/%7Efrosal/sources/shc-3.8.7.tgz tar vxf shc-3.8.7.tgz cd shc-3.8.7 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/ install: target `/usr/local/man/man1/' is not a directory: No such file or directory make: *** [install] Error 1 请创建 mkdir -p /usr/local/man/man1/ ,然后运行make install 常用参数: -e date (指定过期日期) -m message (指定过期提示的信息) -f script_name(指定要编译的shell的路径及文件名) -r Relax security. (可以相同操作系统的不同系统中执行) -v Verbose compilation(编译的详细情况) 使用方法: shc -v -f abc.sh -v 是现实加密过程 -f 后面跟需要加密的文件 运行后会生成两个文件: abc.sh.x 和 abc.sh.x.c abc.sh.x为二进制文件,赋予执行权限后,可直接执行。更改名字mv abc.sh.x a.sh abc.sh.x.c 是c源文件。基本没用,可以删除 另shc还提供了一种设定有效执行期限的方法,过期时间,如: # shc -e 28/01/2012 -m "过期了" -f abc.sh 选项“-e”指定过期时间,格式为“日/月/年”;选项“-m”指定过期后执行此shell程序的提示信息。 如果在过期后执行,则会有如下提示: # ./abc.sh.x ./abc.sh.x: has expired! 过期了 使用以上方法要注意,需防止用户更改系统时间,可以通过在程序中加入自动更新系统时间的命令来解决此问题。 测试都已通过,请放心使用! (责任编辑:IT) |