使用shc提高Shell脚本的安全性
来源:互联网 发布:淘宝上怎么卖二手货 编辑:程序博客网 时间:2024/05/02 00:20
shc主页:
http://www.datsi.fi.upm.es/%7Efrosal/
现在的版本是3.8.6(shc-3.8.6.tgz), 以此为例介绍shc的安装及应用:
准备:
首先你需要检查系统是否安装了gcc编译器, 以Fedora Core 6为例介绍gcc的检查和安装:
# rpm -qa|grep compat-gcc
compat-gcc-34-3.4.6-4
如果没有安装, 按下面步骤安装gcc
# wget ftp://mirrors.kernel.org/fedora/core/6/i386/os/Fedora/RPMS/compat-gcc-34-3.4.6-4.i386.rpm
然后
# ln -s /usr/bin/gcc34 /usr/bin/cc
安装:
# wget http://www.datsi.fi.upm.es/%7Efrosal/sources/shc-3.8.6.tgz
# tar zvxf shc-3.8.6.tgz
# cd shc-3.8.6
# make test
# make strings
# make install
应用:
下面以mysql数据库备份(备份文件通过ftp上传到一台远程的服务器)脚本为例:
############################### mysql_backup.sh ##############################
#!/bin/sh
newtime=`date +%m-%d-%y_%I%M%p`
mysqldump -u ****** -p ****** dbname | gzip > /Users/****/Documents/dbName_$newtime.sql.gz
echo “backup of dbname”
curl –upload-file dbname$newtime.sql.gz –url “ftp://*****:*****@host/”
echo “ftp of dbname done”
############################### mysql_backup.sh ##############################
1). 加密脚本.
# shc -v -r -f mysql_backup.sh
-v: 是verbose模式,输出更详细编译日志. -f: 指定脚本的名称.
上面命令在屏幕上的输出:
shc shll=sh
shc [-i]=-c
shc [-x]=exec ‘%s’ “$@”
shc [-l]=
shc opts=
shc: cc mysql_backup.sh.x.c -o mysql_backup.sh.x
shc: strip mysql_backup.sh.x
shc: chmod go-r mysql_backup.sh.x
我们可以看到生成了动态链接可执行二进制文件mysql_back.sh.x和C源文件mysql_backup.sh.x.c, 注意生成的二进制文件因为是动态链接形式, 所以在其它平台上不能运行:
mysql_backup.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
2). 生成静态链接的二进制可执行文件.
不过, 我们可以通过下面的方法生成一个静态链接的二进制可执行文件:
# CFLAGS=-static shc -r -f mysql_backup.sh
# file mysql_backup.sh.x
mysql_backup.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
statically linked, for GNU/Linux 2.6.9, stripped
提示: 通过sch加密后的脚本文件很安全吗?
一般来说是安全的, 不过可以使用gdb和其它的调试工具获得最初的源代码. 如果你需要更加安全的方法, 可以考虑使用wzshSDK.
另外, sch还可以设置脚本的运行期限和自定义返回信息:
shc -e 03/31/2007 -m “the mysql backup script is now out of date.” -f mysql_back.sh
-e表示脚本将在2007年3月31日前失效, 并根据-m定义的信息返回给终端用户.
3). 二进制文件的剖析
有兴趣的朋友可以参阅下面的文章:
Paranoid Penguin - Limitations of shc, a Shell Encryption Utility
- 使用shc提高Shell脚本的安全性
- 使用shc加密shell脚本
- 使用shc加密shell脚本
- 使用shc加密shell脚本
- shell脚本加密(使用shc)
- 使用shc工具加密shell脚本详解
- 使用shc工具加密shell脚本详解
- 提高Shell脚本安全性工具
- Shell 脚本加密工具shc
- 用shc加密shell脚本
- 用shc加密shell脚本
- 用shc加密shell脚本
- shc对shell脚本加密
- [shell]采用shc工具加密Shell脚本
- shell加密工具shc的安装和使用
- 使用shc简单加密后的脚本文件恢复
- 用shc加密或者编译shell脚本
- shc对shell脚本文件加密
- 告别ide 之UEdit32的Java环境配置
- 关于oracle远程1521不通的问题
- oracle数据库连接信息的初始用户名和口令
- Sql Server参数化查询之where in和like实现详解
- 计算广告学习笔记 4.4竞价广告系统-流量预测
- 使用shc提高Shell脚本的安全性
- Ubuntu获得超级用户权限
- 开Blog了,谨此做纪念。
- lcd驱动解析(一)
- StringBuilder与StringBuffer的区别(转)
- Ubuntu12.04 下面 Virtualbox 下使用USB
- windows XP下安装Python2.7及其安装包的方法
- 道路救援企业IT系统初探
- 日常纠错