首页 > 系统服务 > 详细

shell脚本加密形式

时间:2018-06-22 10:55:31      阅读:285      评论:0      收藏:0      [点我收藏+]
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 //解压软件包

解压完成压缩包后先不着急安装,首先安装环境依赖包:

yum install gcc gcc-c++ make -y
cd /opt/shc-3.8.9
make install //执行安装

注:若安装时报如下错误,则需创建工作目录。
技术分享图片

mkdir -p /usr/local/man/man1 //创建软件默认工作目录
make install //再次安装即可

2、加密shell脚本

cd /opt
ls -l

-rw-r--r--. 1  root   root    38 6月  22 09:54 123.sh

shc -r -f 123.sh //对脚本进行shc加密
ls -l

-rwx--x--x. 1 root root 11184 6月 22 09:56 123.sh.x  //加密后的可执行的二进制文件
-rw-r--r--. 1 root root 9456 6月 22 09:56 123.sh.x.c  //生成123.sh.x的原文件(c语言)

./123.sh.x //执行加密后的shell脚本

this is test shell    //依旧可正常输出

gzexe加密方式

gzexe加密shell脚本方式为系统自带,其功能比起shc而言相对较弱,只能满足一般需求。

cd /opt
ls -l

-rw-r--r--. 1  root   root    38 6月  22 09:54 123.sh

gzexe 123.sh //加密文件
ls -l

-rw-r--r--. 1 root     root       864 6月  22 10:05 123.sh   //加密后文件
-rw-r--r--. 1 root     root        38 6月  22 09:54 123.sh~   //原文件备份文件

注:系统自带的gzexe程序,它不但加密,同时压缩文件,且加密后,原文件被备份成了123.sh~文件。

./123/sh

this is test shell    //依旧可正常输出

shell脚本加密形式

原文:http://blog.51cto.com/13659253/2131596

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!