fi; exit $res
此时我们可以看出test.sh 文件已经被加密了,但是不影响运行。此时你删除test.sh~ 文件,别人就彻底看不到了(自己也看不到,请酌情删除)。
root@leco:~/test# ls
test.sh test.sh~
root@leco:~/test# rm test.sh~
root@leco:~/test# ls
test.sh
root@leco:~/test# sh test.sh
Mon Jul 17 15:10:36 HKT 2017
建议使用,一方面系统自带命令,达到目的即可,没人闲的破解你的脚本,就算要破解,先进入你系统再说。
我基于centos6.8 (ubuntu14.04有问题,没具体排查)
方法2: shc
shc 常用参数
-e date
Expiration date in dd/mm/yyyy format [none](指定过期日期)
-m message
message to display upon expiration ["Please contact your provider"](指定过期提示的信息)
-f script_name
File name of the script to compile(指定要编译的shell的路径及文件名)
-r > Make a redistributable binary which executes on different systems running the same operat-ing system.(可以相同操作系统的不同系统中执行)
-v Verbose compilation(编译的详细情况)
shc是一个专业的加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件,这个办法也很好的解决了脚本中含有IP、密码等不希望公开的问题
包下载链接:
http://www.datsi.fi.upm.es/~frosal/sources/
[root@leco ~]# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.6.tgz
--2017-07-17 15:23:39-- http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.6.tgz
Resolving www.datsi.fi.upm.es... 138.100.9.22
Connecting to www.datsi.fi.upm.es|138.100.9.22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35071 (34K) [application/x-gzip]
Saving to: “shc-3.8.6.tgz”
100%[=============================================================================================================================>] 35,071 21.9K/s in 1.6s