码迷,mamicode.com
首页 > 系统相关 > 详细

sch 助shell脚本加密 02

时间:2015-01-01 00:18:54      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:

sch shell脚本加密 02

一、  简介

SHC(shell script compiler),即shell脚本编译器。通过SHC编译过的脚本对普通用户而言是不可读的,因此如果你想让你的代码实现加密功能,让其有效的屏蔽一些敏感信息,这个时候可以考虑使用SHC;它通常情况下是不太容易被破解的,但是还是有些人可以通过反编译SHC的方法来实现破解加密过的脚本。

二、  实验测试开始
2.1 下载并编译SHC

[root@woo ~]# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.3.tgz
[root@woo ~]# ll shc-3.8.3.tgz
-rw-r--r-- 1 root root 19874 Dec 31 20:40 shc-3.8.3.tgz
[root@woo ~]# tar -zxvf shc-3.8.3.tgz
shc-3.8.3/CHANGES
shc-3.8.3/Copying
shc-3.8.3/Makefile
shc-3.8.3/match
shc-3.8.3/pru.sh
shc-3.8.3/shc.1
shc-3.8.3/shc.c
shc-3.8.3/shc.html
shc-3.8.3/shc.README
shc-3.8.3/test.bash
shc-3.8.3/test.csh
[root@woo ~]# cd shc-3.8.3
[root@woo shc-3.8.3]# make && make install
*** ?Do you want to probe shc with a test script?
*** Please try... make test
[root@woo shc-3.8.3]#

2.2 编译完成之后,我们切换到oracle用户下编辑一个脚本

[root@woo ~]# su - oracle
[oracle@woo ~]$ vi sqlscript.sql
#!/bin/sh
sqlplus -S system/oracle << EOF
set pagesize 0 linesize 80 feedback off
select 'The database ' || instance_name ||
        ' has been running since '||
to_char(startup_time, 'HH24:MI MM/DD/YYYY')
from v\$instance;
select 'There are ' || count(status) ||
        ' data files with a status of ' || status
from dba_data_files
group by status
order by status;
exit;
EOF
2.3 执行加密前的脚本

[oracle@woo ~]$ ./sqlscript.sql
The database woo has been running since 18:17 12/23/2014
There are 4 data files with a status of AVAILABLE
2.4 对脚本进行加密操作,会在原来的基础上多出两个文件

[root@woo shc-3.8.3]# shc -r -f /home/oracle/sqlscript.sql
[oracle@woo ~]$ ll sqlscript*
-rwxr-xr-x 1 oracle oinstall 365 Dec 31 18:55 sqlscript.sql --运行文件
-rwx--x--x 1 root root 12048 Dec 31 22:00 sqlscript.sql.x –加密后的二进制文件
-rw-r--r-- 1 root root 11416 Dec 31 22:00 sqlscript.sql.x.c --x源文件(c语言)
2.5 执行加密后的文件,输出结果和加密前是一样的

[oracle@woo ~]$ ./sqlscript.sql.x
The database woo has been running since 18:17 12/23/2014
There are 4 data files with a status of AVAILABLE
2.6 SHC可选参数
[root@woo shc-3.8.3]# ./shc -v
shc parse(-f): No source file specified
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script
[root@woo shc-3.8.3]#
[root@woo shc-3.8.3]# ./shc --help
./shc: invalid option -- '-'
shc parse: Unknown option
shc Version 3.8.3, Generic Script Compiler
shc Copyright (c) 1994-2005 Francisco Rosales <frosal@fi.upm.es>
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script
#设置过期时间
-e %s  Expiration date in dd/mm/yyyy format [none]
       #过期信息提示
-m %s  Message to display upon expiration ["Please contact your provider"]
       #加密脚本名称
    -f %s  File name of the script to compile
    -i %s  Inline option for the shell interpreter i.e: -e
    -x %s  eXec command, as a printf format i.e: exec('%s',@ARGV);
-l %s  Last shell option i.e: --
        #宽松的安全性,可以想通操作系统的不同机器中运行
    -r     Relax security. Make a redistributable binary
    -v     Verbose compilation
    -D     Switch ON debug exec calls [OFF]
-T     Allow binary to be traceable [no]
         #显示许可证并退出
    -C     Display license and exit
-A     Display abstract and exit
          #显示帮助和退出
    -h     Display help and exit
    Environment variables used:
    Name    Default  Usage
    CC      cc       C compiler command
    CFLAGS  <none>   C compiler flags
    Please consult the shc(1) man page.





sch 助shell脚本加密 02

标签:

原文地址:http://blog.csdn.net/wuweilong/article/details/42303751

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!