notice

当前位置: 系统之家 » 技术应用 » 阅读正文


使用shc给shell脚本加密

2011年11月3日 | 发布: admin


点击图片查看更多内容

Shell的代码平时都是源代码呈现的,如何保护Shell代码的源码呢?这里要用到shc可以加密代码并实现脚本的过期日期

1. 编译安装
# mkdir -p /usr/local/man/man1
# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz
# tar xvf shc-3.8.7.tgz
# cd shc-3.8.7
# make test
# make strings
# make install

2. 加密代码
# shc -v -f test.sh
执行后会生成test.sh.x和test.sh.x.c两个文件
test.sh.x是加密后的可执行的二进制文件
test.sh.x.c是生成test.sh.x的原文件(C语言)

# file test.sh.x
test.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8,stripped

生成的二进制文件是动态链接形式, 所以在其它平台上不能运行

生成静态链接的二进制可执行文件
$ CFLAGS=-static shc -r -f test.sh
# file test.sh.x
test.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.8, stripped

如果要使脚本使用有一个期限,可以使用以下命令
# shc -e 12/31/2011 -m "the mysql backup scrīpt is now out of date." -f test.sh

-e表示脚本将在2011年12月31日前失效, 并根据-m定义的信息返回给终端用户

请对我们的文章进行评论


版权声明:

转载时请注明文章出处,并在文章结尾表明本文链接,特此声明!

本文链接:http://www.xtgly.com/2541.htm


2 trackbacks

  1. pr agencies auckland Trackback | 2011/11/30
  2. rest homes Trackback | 2011/12/05