欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

Script Encryption

程序员文章站 2022-11-22 08:49:35
一.shc加密 加密软件shcshc是linux的一款加密脚本的插件东西比较安全我们可以利用wget将文件放在root目录下也可以通过sftp放在root目录也可以直接利用cd命令选择目录 wget https://files-cdn.cnblogs.com/files/meilong/shc-3. ......
wget https://files-cdn.cnblogs.com/files/meilong/shc-3.8.9b.tar
tar vxf shc-3.8.9b.tgz
cd shc-3.8.9b
make test
make strings
make install

复制代码
发现报错的情况比较严重
如果报错内容如下

*** installing shc and shc.1 on /usr/local
*** ?do you want to continue? y
install -c -s shc /usr/local/bin/
install -c -m 644 shc.1 /usr/local/man/man1/
install: target `/usr/local/man/man1/' is not a directory: no such file or directory
make: *** [install] error 1

复制代码
请创建 mkdir -p /usr/local/man/man1/ ,然后运行make install
也可以直接无视,一般没什么影响,只是少了对应的帮助文档。

常用参数:
-e date (指定过期日期)
-m message (指定过期提示的信息)
-f script_name(指定要编译的shell的路径及文件名)
-r relax security. (可以相同操作系统的不同系统中执行)
-v verbose compilation(编译的详细情况)

加密方法
假如说我们这个脚本名字叫sokebox.com.sh那我们就执行bashshc -v -f sokebox.com
-v 是现实加密过程
-f 后面跟需要加密的文件
abc.sh.x为二进制文件,赋予执行权限后,可直接执行。更改名字mv sokebox.com.sh.x sokebox.com.sh
abc.sh.x.c 是c源文件。基本没用,可以删除
过期加密法
另shc还提供了一种设定有效执行期限的方法,过期时间,如:

shc -e 14/09/2016 -m -f sokebox.com.sh

选项“-e”指定过期时间,格式为“日/月/年”;选项“-m”指定过期后执行此shell程序的提示信息。
如果在过期后执行,则会有如下提示:

./abc.sh.x

./abc.sh.x: has expired!(文件已经过期)
使用以上方法要注意,需防止用户更改系统时间,可以通过在程序中加入自动更新系统时间的命令来解决此问题。
测试都已通过,请放心使用!

二.unshc解密

解密方法 https://github.com/yanncam/unshc

注:需要gcc环境

wget https://files-cdn.cnblogs.com/files/meilong/unshc.sh
[*] usage : ./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.sh script.sh.x ./unshc.sh script.sh.x -o script_decrypted.sh ./unshc.sh script.sh.x -a 400f9b ./unshc.sh script.sh.x -d /tmp/dumpfile -s /tmp/strfile ./unshc.sh script.sh.x -a 400f9b -d /tmp/dumpfile -s /tmp/strfile -o script_decrypted.sh