用shc加密shell脚本

大家经常有这样的需求,比如脚本里放了一个公共的账户密码,给别人用的时候不希被发现。这个时候可以使用http://www.datsi.fi.upm.es/~frosal/sources/shc.html对脚本进行加密。可以直接在这个http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz下载。

编译后就能使用了,使用的方式比较简单

./shc -r -f script.sh

详细的用法可以help一下看看

  
# ./shc -help  
shc Version 3.8.7, Generic Script Compiler  
shc Copyright (c) 1994-2009 Francisco Rosales <[email protected]>  
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script

-e %s  Expiration date in dd/mm/yyyy format [none]  
-m %s  Message to display upon expiration ["Please contact your provider"]  
-f %s  File name of the script to compile  
-i %s  Inline option for the shell interpreter i.e: -e  
-x %s  eXec command, as a printf format i.e: exec(‘%s’,@ARGV);  
-l %s  Last shell option i.e: —  
-r     Relax security. Make a redistributable binary  
-v     Verbose compilation  
-D     Switch ON debug exec calls [OFF]  
-T     Allow binary to be traceable [no]  
-C     Display license and exit  
-A     Display abstract and exit  
-h     Display help and exit