shell 脚本加密工具


shell 脚本加密工具 - shc

shell 脚本写起来很方便,身为脚本的问题就是保密性不行,写了什么内容编辑器一打开看看就知道了, 脚本里面完全不能放用户名,密码什么的, shc 可以解决你的这一部分问题。

安装shc

* ubuntu

<code>sudo add-apt-repository ppa:neurobin/ppa
sudo apt-get update
sudo apt-get install shc/<code>

* mac(需要使用原生的/usr/bin/strip, brew 安装的/usr/local/bin/strip会让程序启动不了)

<code>brew install shc/<code>

加密脚本

<code>shc -v -f test.sh/<code>

-v是verbose模式, 输出更详细编译日志;

-f 指定脚本的名称.

<code> ll test*/<code>

-rwxr-xr-x 1 oracle oinstall 1178 Aug 18 10:00 test.sh

-rwx--x--x 1 oracle oinstall 8984 Aug 18 18:01 test.sh.x

-rw-r--r-- 1 oracle oinstall 14820 Aug 18 18:01 test.sh.x.c

<code> file test.sh.x/<code>

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

可以看到生成了动态链接可执行二进制文件test.sh.x和C源文件testup.sh.x.c, 注意生成的二进制文件因为是动态链接形式, 所以在其它平台上不能运行.


生成静态链接的二进制可执行文件

可以通过下面的方法生成一个静态链接的二进制可执行文件:

<code>CFLAGs=-static shc -r -f test.sh
file testup.sh.x/<code>

通过sch加密后的脚本的有效时间

一般来说是安全的, 不过可以使用gdb和其它的调试工具获得最初的源代码. 如果需要更加安全的方法, 可以考虑使用wzshSDK. 另外shc还可以设置脚本的运行期限和自定义返回信息:

<code>shc -e 03/31/2007 -m "the mysql backup scrīpt is now out of date." -f test.sh/<code>

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


工具地址 :

https://github.com/neurobin/shc


分享到:


相關文章: