sch 助shell脚本加密 02

sch 助shell脚本加密 02

一、  简介

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

二、  实验测试开始

2.1 下载并编译SHC

[[email protected] ~]# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.3.tgz
[[email protected] ~]# ll shc-3.8.3.tgz
-rw-r--r-- 1 root root 19874 Dec 31 20:40 shc-3.8.3.tgz
[[email protected] ~]# 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
[[email protected] ~]# cd shc-3.8.3
[[email protected] shc-3.8.3]# make && make install
*** ?Do you want to probe shc with a test script?
*** Please try... make test
[[email protected] shc-3.8.3]#

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

[[email protected] ~]# su - oracle
[[email protected] ~]$ 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 执行加密前的脚本

[[email protected] ~]$ ./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 对脚本进行加密操作,会在原来的基础上多出两个文件

[[email protected] shc-3.8.3]# shc -r -f /home/oracle/sqlscript.sql
[[email protected] ~]$ 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 执行加密后的文件,输出结果和加密前是一样的

[[email protected] ~]$ ./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可选参数

[[email protected] 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
[[email protected] shc-3.8.3]#
[[email protected] 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 <[email protected]>
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.

时间: 2024-08-09 07:15:52

sch 助shell脚本加密 02的相关文章

gzexe 助shell脚本加密 01

gzexe 助shell脚本加密 01 一.  简介 很多时候我们的脚本会涉及到一些私密的信息,例如:用户名,密码,或者其它重要信息的时候,我们使用一些加密的手段来屏蔽这些信息,确保系统的安全已经脚本的可流传性,通常情况下我们只需要通过系统自带的gzexe这个工具就够了. 二.         实验测试开始: 2.1 编写一个用于测试的脚本 [[email protected] ~]# vi woo.sh #! /bin/ksh echo 'PrudentWoo'' '`date +%Y-%m-

shell 脚本加密

想想好久没更新博客了,今天在群里看到讨论关于shell脚本加密的事情. 想想也是,我们在写脚本有时候会配置相关账号和密码的事情,这样只要能权限都能看到该信息,非常的不安全,有没有在正常运行的情况下对文件进行加密.大致有以下两个特点: 加密文件,防止别人看到我写的具体内容. 可以对隐藏敏感性知识点,比如脚本涉及到用户和密码,如mysql 我特意搜了一下,有两种方法,涨知识了,所以验证了一下,过程如下: 第一种方法(gzexe):基于ubuntu14.04 这种加密方式不是非常保险的方法,但是能够满

shell脚本加密形式

shell脚本在日常运维过程中显得尤为重要,通常我们在编写shel脚本中会涉及到很多参数包括密码等一些隐私信息,这个时需要将shell脚本加密,并且可执行结果.下面文章简介两种shell脚本加密方式: shc加密方式 1.shc软件安装 cd /mnt //进入或者创建目录,即选择下载位置 wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz //下载软件包 tar zxvf shc-3.8.9.tgz -C /opt //解

shell脚本加密

#shc是一个专业的加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件,这个办法很好的解决了脚本中含有IP.密码等不希望公开的问题.http://www.datsi.fi.upm.es/~frosal/sources/ shc的官网下载地址 wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgztar -xf shc-3.8.9.tgzcd shc-3.8.9mkdir -pv /usr/local

shell脚本加密笔记!

你写的shell在生产环境是否加密?反正我是没有,线上环境看就看呗,觉得没啥.其实想想,好像也有几个好处. 1.简单加密,防止别人看里面具体内容. 2.可以隐蔽脚本中的密码等信息.(比如你的备份脚本,涉及到密码等问题) 好像还有点用处,大概常用的两种方式. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 第一种方法(gzexe): 这种加密方式不是非常保险的方法,但是能够满足一般的加密用途.它是使用系统自带的gzexe程序

shell脚本加密工具

1. 加密工具 1.1 gzexe 1.1.1 说明 gzexe是用来压缩执行文件的程序.当您去执行被压缩过的执行文件时,该文件会自动解压然后继续执行,和使用一般的执行文件相同. 1.1.2 安装 Linux自带,不用单独安装. 1.1.3 用法 gzexe filename.sh 它会把原来没有加密的文件备份为 file.sh~ ,同时 file.sh 即被变成加密文件. 1.1.4 参数 -d 解开压缩文件 1.2 shc 1.2.1 说明 shc是一个专业的加密shell脚本的工具,它的作

linxu下的shell脚本加密

1.简单的加密 2.使用shc加密:下载地址:http://www.datsi.fi.upm.es/~frosal/ shc可以把shell脚本转换为一个可执行的二进制文件 参考: 1.http://www.datsi.fi.upm.es/~frosal/ 2.https://www.cnblogs.com/yuzhoushenqi/p/6950425.html 原文地址:https://www.cnblogs.com/shengulong/p/9030682.html

如何对shell脚本进行加密且不影响脚本运行

方法一:shcshc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件.shc 安装yum -y install shc使用方法:shc -r -f script-name 注意:要有-r选项, -f 后跟要加密的脚本名.运行后会生成两个文件,script-name.x 和 script-name.x.cscript-name.x是加密后的可执行的二进制文件../script-name 即可运行.script-name.x.c是生成script-name.x的

对shell脚本进行加密

用shell脚本对系统进行自动化维护,简单,便捷而且可移植性好.但shell脚本是可读写的,很有可能会泄露敏感信息,如用户名,密码,路径,IP等.同样,在shell脚本运行时会也泄露敏感信息.请问如何不影响脚本运行的前提下,对脚本进行加密? 一.shc方法 shc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件,这就很好的解决了上述问题. yum安装: yum -y install shc 编译安装: wget http://www.datsi.fi.upm