shc

相关github地址: https://github.com/yanncam/UnSHc

下载安装shc

yum install gcc -y
wget -q http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz
#curl -fsSl http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz > shc-3.8.9.tgz   #没有wget命令,也不想装,用curl下载也可以。
tar zxvf shc-3.8.9.tgz
cd shc-3.8.9
make
mv shc /bin/

使用shc加密

-v 是现实加密过程

-f 后面跟需要加密的文件

运行后会生成两个文件:abc.sh.x 和 abc.sh.x.c

abc.sh.x为二进制文件,赋予执行权限后,可直接执行。更改名字mv abc.sh.x a.sh

abc.sh.x.c 是c源文件。基本没用,可以删除

shc -v -r -f abc.sh

这里注意-r参数很重要,如果需要脚本只在当前服务器上能执行,可以不加,如果需要在别的系统下也能执行,就需要加-r

解密

下载软件

[root@test1 ~]# git clone https://github.com/yanncam/UnSHc.git
[root@test1 ~]# ./UnSHc/latest/unshc.sh -h
 _   _       _____ _   _
| | | |     /  ___| | | |
| | | |_ __ \ `--.| |_| | ___
| | | | '_ \ `--. \  _  |/ __|
| |_| | | | /\__/ / | | | (__
 \___/|_| |_\____/\_| |_/\___|

--- UnSHc - The shc decrypter.
--- Version: 0.8
------------------------------
UnSHc is used to decrypt script encrypted with SHc
Original idea from Luiz Octavio Duarte (LOD)
Updated and modernized by Yann CAM
- SHc   : [http://www.datsi.fi.upm.es/~frosal/]
- UnSHc : [https://www.asafety.fr/unshc-the-shc-decrypter/]
------------------------------

[*] Usage : ./UnSHc/latest/unshc.sh [OPTIONS] <file.sh.x>
     -h | --help                          : print this help message
     -a OFFSET | --arc4 OFFSET            : specify the arc4() offset arbitrarily (without 0x prefix)
     -d DUMPFILE | --dumpfile DUMPFILE    : provide an object dump file (objdump -D script.sh.x > DUMPFILE)
     -s STRFILE | --stringfile STRFILE    : provide a string dump file (objdump -s script.sh.x > STRFILE)
     -o OUTFILE | --outputfile OUTFILE    : indicate the output file name

[*] e.g :
    ./UnSHc/latest/unshc.sh script.sh.x
    ./UnSHc/latest/unshc.sh script.sh.x -o script_decrypted.sh
    ./UnSHc/latest/unshc.sh script.sh.x -a 400f9b
    ./UnSHc/latest/unshc.sh script.sh.x -d /tmp/dumpfile -s /tmp/strfile
    ./UnSHc/latest/unshc.sh script.sh.x -a 400f9b -d /tmp/dumpfile -s /tmp/strfile -o script_decrypted.sh

要解密脚本 aa,就执行./UnSHc aa 就可以了。