您现在的位置是:首页 > 技术人生 > 服务器相关服务器相关

shell脚本加密

高晓波2024-01-11【服务器相关】人已围观

简介有些shell脚本包含一些敏感信息,不希望被别人看到,或者更改脚本内容,可以将shell脚本进行加密处理,本文介绍使用shc将shell脚本二进制化,达到加密的效果

有些shell脚本包含一些敏感信息,不希望被别人看到,或者更改脚本内容,可以将shell脚本进行加密处理,本文介绍使用shc将shell脚本二进制化,达到加密的效果。shc是一个专业加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件。Shc的主要目的是保护shell脚本不被修改或检查。
 

1、下载shc


当前最新版本为4.0.3
wget https://github.com/neurobin/shc/archive/refs/tags/4.0.3.tar.gz


2、编译安装

./configure
make
sudo make install


3、命令介绍

查看命令
shc -h
 
shc Version 4.0.3, Generic Shell Script Compiler
shc GNU GPL Version 3 Md Jahidul Hamid <jahidulhamid@yahoo.com>
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-o outfile] [-rvDSUHCABh] -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: --
    -o %s  output filename
    -r     Relax security. Make a redistributable binary
    -v     Verbose compilation
    -S     Switch ON setuid for root callable programs [OFF]
    -D     Switch ON debug exec calls [OFF]
    -U     Make binary untraceable [no]
    -H     Hardening : extra security protection [no]
           Require bourne shell (sh) and parameters are not supported
    -C     Display license and exit
    -A     Display abstract and exit
    -B     Compile for busybox
    -h     Display help and exit

    Environment variables used:
    Name    Default  Usage
    CC      cc       C compiler command
    CFLAGS  <none>   C compiler flags
    LDFLAGS <none>   Linker flags

    Please consult the shc man page.


4、shc使用

我们使用shc命令加密bbbb.sh脚本
 
shc -r -f bbbb.sh 
生成如下文件:bbbb.sh.x和bbbb.sh.x.c,其中bbbb.sh.x便是具备和我们脚本相同功能的二进制可执行文件,bbbb.sh.x.c可以删除。


 

Tags:脚本加密

很赞哦! ()

文章评论