您的位置:首页 > 运维架构 > Shell

用shc给shell脚本加密

2016-09-22 10:01 441 查看
[root@bogon shc-3.8.7]# ls

CHANGES  l.sh      match    match.x.c  shc    shc-3.8.7.c  shc.html    test.bash  test.ksh

  pying  Makefile  match.x  pru.sh     shc.1  shc.c        shc.README  test.csh

[root@bogon shc-3.8.7]# ./l.sh

-bash: ./l.sh: Permission denied

#加密

[root@bogon shc-3.8.7]# ./shc -v -r -T -f l.sh          

shc shll=bash

shc [-i]=-c

shc [-x]=exec '%s' "$@"

shc [-l]=

shc opts=

shc: cc  l.sh.x.c -o l.sh.x

shc: strip l.sh.x

shc: chmod go-r l.sh.x

[root@bogon shc-3.8.7]# ls

CHANGES  l.sh.x    match      pru.sh  shc-3.8.7.c  shc.README  test.ksh

Copying  l.sh.x.c  match.x    shc     shc.c        test.bash

l.sh     Makefile  match.x.c  shc.1   shc.html     test.csh

#执行加密生成的二进制文件

[root@bogon shc-3.8.7]# ./l.sh.x        

hello world

#查看加密后的二进制文件,显示的结果如下

[root@bogon shc-3.8.7]# vi l.sh.x

^?ELF^A^A^A^@^@^@^@^@^@^@^@^@^B^@^C^@^A^@^@^@ <87>^D^H4^@^@^@t^W^@^@^@^@^@^@4^@ ^@^H^@(^@^\^@^[^

@^F^@^@^@4^@^@^@4<80>^D^H4<80>^D^H^@^A^@^@^@^A^@^@^E^@^@^@^D^@^@^@^C^@^@^@4^A^@^@4<81>^D^H4<81>^

D^H^S^@^@^@^S^@^@^@^D^@^@^@^A^@^@^@^A^@^@^@^@^@^@^@^@<80>^D^H^@<80>^D^H ^R^@^@ ^R^@^@^E^@^@^@^@^

P^@^@^A^@^@^@ ^R^@^@ ¢^D^H ¢^D^H¸^C^@^@^D^E^@^@^F^@^@^@^@^P^@^@^B^@^@^@´^R^@^@´¢^D^H´¢^D^HÈ^@^@^

@È^@^@^@^F^@^@^@^D^@^@^@^D^@^@^@H^A^@^@H<81>^D^HH<81>^D^HD^@^@^@D^@^@^@^D^@^@^@^D^@^@^@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@^@^@^@^@^@^R^@^@^@M^@^@^@^@^@^@^@^@^@^@^@^R^@^@^@Ö^@^@^@<80>¦^D^H^D^@^@

^@!^@^Y^@Õ^@^@^@<80>¦^D^H^D^@^@^@!^@^Y^@^Z^@^@^@<9c><91>^D^H^D^@^@^@^Q^@^O^@<9d>^@^@^@`¦^D^H^D^@

^@^@^Q^@^Y^@Ô^@^@^@<80>¦^D^H^D^@^@^@^Q^@^Y^@^@__gmon_start__^@libc.so.6^@_IO_stdin_used^@sprintf

^@__isoc99_sscanf^@time^@getpid^@strdup^@calloc^@strlen^@memset^@__errno_location^@memcmp^@puten

v^@memcpy^@malloc^@getenv^@stderr^@execvp^@fprintf^@atoll^@strerror^@__libc_start_main^@__enviro

[root@bogon shc-3.8.7]# file l.sh.x

l.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

[root@bogon shc-3.8.7]# ./l.sh.x   

hello world

[root@bogon shc-3.8.7]# ls

CHANGES  l.sh.x    match      pru.sh  shc-3.8.7.c  shc.README  test.ksh

Copying  l.sh.x.c  match.x    shc     shc.c        test.bash

l.sh     Makefile  match.x.c  shc.1   shc.html     test.csh

[root@bogon shc-3.8.7]# rm -rf l.sh.x*

[root@bogon shc-3.8.7]# ls

CHANGES  l.sh      match    match.x.c  shc    shc-3.8.7.c  shc.html    test.bash  test.ksh

Copying  Makefile  match.x  pru.sh     shc.1  shc.c        shc.README  test.csh

#重新加密,并为生成的二进制文件添加有效日期18/10/2006

[root@bogon shc-3.8.7]# ./shc -e 18/10/2006 -m " It’s too late to run this script " -r -v -T -f l.sh

shc shll=bash

shc [-i]=-c

shc [-x]=exec '%s' "$@"

shc [-l]=

shc opts=

shc: cc  l.sh.x.c -o l.sh.x

shc: strip l.sh.x

shc: chmod go-r l.sh.x

[root@bogon shc-3.8.7]# ls

CHANGES  l.sh.x    match      pru.sh  shc-3.8.7.c  shc.README  test.ksh

Copying  l.sh.x.c  match.x    shc     shc.c        test.bash

l.sh     Makefile  match.x.c  shc.1   shc.html     test.csh

#执行二进文件显示过期

[root@bogon shc-3.8.7]# ./l.sh.x

./l.sh.x: has expired!

 It’s too late to run this script 

#执行l.sh脚本,正确执行,不收过期时间影响

[root@bogon shc-3.8.7]# ./l.sh

-bash: ./l.sh: Permission denied

[root@bogon shc-3.8.7]# chmod 755 l.sh

[root@bogon shc-3.8.7]# ./l.sh        

hello world
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: