linux shc shell脚本_用shc加密shell脚本

Shc可以用来对shell脚本进行加密,可以将shell脚本转换为一个可执行的二进制文件。经过shc对shell脚本进行加密后,会同时生成两种个新的文件,一个是加密后的可执行的二进制文件(文件名以.x结束),另一个是C语言的原文件(文件名以.x.c结束)。

下面就说明一下shc的安装,参数,以及使用示例:

下载安装:

(官网下载地址: http://www.datsi.fi.upm.es/~frosal/sources/)

# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz

# cd shc-3.8.7

# make

# make install

(仅用make就可以完成安装,运行shc时要指出绝对路径;用make install,将shc安装到/usr/local/bin下,可以直接运行)

常用参数:

-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 Relax security.

Make a redistributable binary which executes on different systems running the same operat-ing system.(可以相同操作系统的不同系统中执行)

-v Verbose compilation(编译的详细情况)

使用示例:

[root@centos54 tmp]# /usr/local/src/shc-3.8.7/shc -e 20/10/2010 -m "contact xxx@163.com" -v -r -f ./ex.sh

-e:指定过期时间为2010年10月20日

-m:过期后打印出的信息;

-v: verbose

-r: 可在相同操作系统的不同主机上执行

-f: 指定源shell

使用:

# 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语言)

但由于生成的文件需要动态谅解不能用作其他机器,需要下面的方法来生成静态的链接库文件。

生成静态链接的二进制可执行文件

可以通过下面的方法生成一个静态链接的二进制可执行文件:

# CFLAGS=-static shc -r -f test.sh

# file test.sh.x

自己在机器上测试

使用命令

wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz 下载并解压缩包后

[root@redhat shc-3.8.7]# cat shc.README

Purpose:

A generic shell script compiler. Shc takes a script, which is

specified on the command line and produces C source code. The

generated source code is then compiled and linked to produce a

stripped binary executable. Use with care.

Building:

Just do a "make"

Testing:

Try: "make test"

or: "shc -v -f match" then "match.x sh"

Caveat emptor: see Copyright

The results look fine to me, but I havn't used this in anger, but

the author has used shc for his work widely over SunOS, Solaris and

Linux, and done some testing on Irix and HPUX.

We tested it on a few SMALL ksh scripts - big tasks should probably

be written in C in the first place (see _SC_ARG_MAX below)!

Bugs:

The one (and I hope the only) limitation using shc is the

_SC_ARG_MAX system configuration parameter.

It limits the maximum length of the arguments to the exec function,

limiting the maximum length of the runnable script of shc.

!! - CHECK YOUR RESULTS CAREFULLY BEFORE USING - !!

Archived at: ftp://hpux.csc.liv.ac.uk/hpux/Languages/shc-2.4a

Archived by: steff@csc.liv.ac.uk

Author: Francisco Rosales Garcia

--------------------------------------------------------------------

Francisco Rosales Garc韆 TEL: +341 336 73 80

http://www.datsi.fi.upm.es/~frosal FAX: +34 1 336 73 73

Departamento de Arquitectura y Tecnolog韆 de Sistemas Inform醫icos

Facultad de Inform醫ica. Universidad Polit閏nica de Madrid. Espa馻

--------------------------------------------------------------------

[root@redhat shc-3.8.7]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值