用shc給shell腳本加密

[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^@^@^@PåtdÔ^Q^@
^@Ô<91>^D^HÔ<91>^D^H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@^@^@^@^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
發佈了11 篇原創文章 · 獲贊 28 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章