shell脚本加密办法

1第一种加密假的:

普通压缩隐藏密码:

gzexe wx.sh

解密;

gzexe -d wx.sh

2 shell加密工具shc的安装和使用

1) 工具说明

shell脚本是可读写的, 很有可能会泄露敏感信息, 如用户名/密码/路径/IP等. 同样在shell脚本运行时会也泄露敏感信息. shc是一个加密shell脚本的工具, 它的作用是把shell脚本转换为一个可执行的二进制文件. 这就很好的解决了上述问题.

2) 下载安装

下载: 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

3) 加密脚本

# shc -v -f test.sh -v是verbose模式, 输出更详细编译日志;  -f 指定脚本的名称.

$ ll test* -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

$ file test.sh.x 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, 

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

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

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

$ CFLAGs=-static shc -r -f test.sh 
$ file testup.sh.x

5) 通过sch加密后的脚本文件很安全吗?

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

$ shc -e 03/31/2007 -m "the MySQL backup scrīpt is now out of date." -f test.sh

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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值