shell脚本加密
来源:互联网 发布:mac number 下拉菜单 编辑:程序博客网 时间:2024/05/21 00:49
如何保护自己编写的shell程序
要保护自己编写的shell脚本程序,方法有很多,最简单的方法有两种:1、加密 2、设定过期时间,下面以shc工具为例说明:
一、下载安装shc工具
shc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件.
# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz
安装:
# tar zxvf shc-3.8.7.gz
# cd shc-3.8.7
# mkdir /usr/local/man/man1/ (install时会把man文件放入该目录,如果该目录不存在需提前建好) 这一步需要root权限
# make test
# make
# make test
# make strings
# make install 这一步需要root权限
二、加密方法:
shc -r -f script-name 注意:要有-r选项, -f 后跟要加密的脚本名.
运行后会生成两个文件,script-name.x 和 script-name.x.c
script-name.x是加密后的可执行的二进制文件.
./script-name 即可运行.
script-name.x.c是生成script-name.x的原文件(c语言)
# shc -v -f test.sh
-v是verbose模式, 输出更详细编译日志;
-f 指定脚本的名称.
# ll test*
-rwxr-xr-x 1 oracle oinstall 1178 Aug 18 10:00 test.sh
-rwx--x--x 1 oracle oinstall 8984 Aug 18 18:01 test.sh.x
-rw-r--r-- 1 oracle oinstall 14820 Aug 18 18:01 test.sh.x.c
# file test.sh.x
test.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
可以看到生成了动态链接可执行二进制文件test.sh.x和C源文件testup.sh.x.c, 注意生成的二进制文件因为是动态链接形式, 所以在其它平台上不能运行.
生成静态链接的二进制可执行文件
可以通过下面的方法生成一个静态链接的二进制可执行文件:
$ CFLAGS=-static shc -r -f test.sh
$ file testup.sh.x
三. 通过sch加密后的脚本文件很安全吗?
一般来说是安全的, 不过可以使用gdb和其它的调试工具获得最初的源代码. 如果需要更加安全的方法, 可以考虑使用wzshSDK. 另外shc还可以设置脚本的运行期限和自定义返回信息:
$ shc -e 03/31/2007 -m "the mysql backup scrīpt is now out of date." -f test.sh
-e表示脚本将在2007年3月31日前失效, 并根据-m定义的信息返回给终端用户.
题外:
如果你仅仅是看不见内容就行了的话,不妨用
gzexe a.sh
原来的 a.sh 就被存为 a.sh~,新的 a.sh 是乱码,但是可以用 sh 的方式运行
要保护自己编写的shell脚本程序,方法有很多,最简单的方法有两种:1、加密 2、设定过期时间,下面以shc工具为例说明:
一、下载安装shc工具
shc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件.
# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz
安装:
# tar zxvf shc-3.8.7.gz
# cd shc-3.8.7
# mkdir /usr/local/man/man1/ (install时会把man文件放入该目录,如果该目录不存在需提前建好) 这一步需要root权限
# make test
# make
# make test
# make strings
# make install 这一步需要root权限
二、加密方法:
shc -r -f script-name 注意:要有-r选项, -f 后跟要加密的脚本名.
运行后会生成两个文件,script-name.x 和 script-name.x.c
script-name.x是加密后的可执行的二进制文件.
./script-name 即可运行.
script-name.x.c是生成script-name.x的原文件(c语言)
# shc -v -f test.sh
-v是verbose模式, 输出更详细编译日志;
-f 指定脚本的名称.
# ll test*
-rwxr-xr-x 1 oracle oinstall 1178 Aug 18 10:00 test.sh
-rwx--x--x 1 oracle oinstall 8984 Aug 18 18:01 test.sh.x
-rw-r--r-- 1 oracle oinstall 14820 Aug 18 18:01 test.sh.x.c
# file test.sh.x
test.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
可以看到生成了动态链接可执行二进制文件test.sh.x和C源文件testup.sh.x.c, 注意生成的二进制文件因为是动态链接形式, 所以在其它平台上不能运行.
生成静态链接的二进制可执行文件
可以通过下面的方法生成一个静态链接的二进制可执行文件:
$ CFLAGS=-static shc -r -f test.sh
$ file testup.sh.x
三. 通过sch加密后的脚本文件很安全吗?
一般来说是安全的, 不过可以使用gdb和其它的调试工具获得最初的源代码. 如果需要更加安全的方法, 可以考虑使用wzshSDK. 另外shc还可以设置脚本的运行期限和自定义返回信息:
$ shc -e 03/31/2007 -m "the mysql backup scrīpt is now out of date." -f test.sh
-e表示脚本将在2007年3月31日前失效, 并根据-m定义的信息返回给终端用户.
题外:
如果你仅仅是看不见内容就行了的话,不妨用
gzexe a.sh
原来的 a.sh 就被存为 a.sh~,新的 a.sh 是乱码,但是可以用 sh 的方式运行
- shell 脚本加密
- shell 脚本加密
- shell脚本加密
- shell脚本加密
- shell脚本加密
- Linux shell脚本加密
- Shell脚本加密
- shell脚本加密
- shell脚本加密
- Shell 脚本加密工具shc
- 使用shc加密shell脚本
- 用shc加密shell脚本
- 用shc加密shell脚本
- 用shc加密shell脚本
- 使用shc加密shell脚本
- shell脚本简单密码加密
- shc对shell脚本加密
- 使用shc加密shell脚本
- Android 4.3 新特性
- QFtp 协议下载
- 关于Java中的匿名内部类
- Centos 6.3 编译安装Nginx+php+Mysql
- ARC 类型转换:显示转换 id 和 void *
- shell脚本加密
- LaTex中表格固定列宽并且居中的方法
- C#调用REST API
- 这位程序员桌面很干净
- uboot/board/mini2440/conifg.mk 之TEXT_BASE
- 敏捷的价值
- java获取当天的开始时间,当前周的开始时间
- 【Android内存机制分析】了解Android堆和栈
- 添加sudo用户