前奏
| Linux下的shell脚本用途广泛,经常包含IP、Pwd等关键信息,可读可写的特点很容易造成信息泄露,导致严重后果。基于这些原因,对脚本实施加密便变得很有必要 |
| shc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件. |
| |
| |
| 应用场景 |
| 用shell脚本对系统进行自动化维护,简单,便捷而且可移植性好.但shell脚本是可读写的,很有可能会泄露敏感信息,如用户名,密码,路径,IP等. |
| 对于脚本中含有一些敏感信息的,通常我们都想做成二进制程序,不让用户看到源码,对于有这种需求的通常我们一般采用shc或者gzexe,推荐shc |
shc安装和使用
| # 安装 |
| yum -y install epel-release |
| yum -y install shc |
| 或者 |
| apt install -y shc |
| |
| |
| # 使用 |
| ~]# vim test.sh |
| #!/bin/bash - |
| echo "this is shc test" |
| |
| |
| ~]# bash test.sh |
| this is shc test |
| |
| |
| # 注:要有-r选项, -f后跟要加密的脚本名 |
| ~]# shc -rvf test.sh |
| ~]# ll |
| -rw-r--r--. 1 root root 38 3月 10 08:16 test.sh ===> 源文件 |
| -rwxrwxr-x. 1 root root 11136 3月 10 08:16 test.sh.x ===> 加密后二进制文件 |
| -rw-r--r--. 1 root root 17660 3月 10 08:16 test.sh.x.c ===> 脚本对应的C语言版本源码 |
| |
| # 运行一下加密后文件 |
| ~]# ./test.sh.x |
| this is shc test |
| |
| ~]# mv test.sh{,-bak} |
| ~]# mv test.sh.x test.sh |
| ~]# ./test.sh |
| this is shc test |
shc解密(测试的有问题,不过作者在README.md中也有写明原因)
I will not decrypt any file for people.
Issues on GitHub are only to discuss about bug and/or improvement of the tool "UnSHc".
| # https://github.com/yanncam/UnSHc/ |
| # 支持x86、mips、arm架构CPU |
| |
| x86版本 |
| git@github.com:yanncam/UnSHc.git |
| unshc-arm版本 |
| https://github.com/cliffalbert/UnSHc-arm |
| |
| |
| |
| ~]# git clone --depth=1 git@github.com:yanncam/UnSHc.git |
| ~]# cd UnSHc/latest/ |
| latest]# ./unshc.sh ~/test.sh -o test.sh |
| _ _ _____ _ _ |
| | | | | / ___| | | | |
| | | | |_ __ \ `--.| |_| | ___ |
| | | | | '_ \ `--. \ _ |/ __| |
| | |_| | | | /\__/ / | | | (__ |
| \___/|_| |_\____/\_| |_/\___| |
| |
| --- 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/] |
| ------------------------------ |
| |
| [*] Input file name to decrypt [/root/test.sh] |
| [+] Output file name specified [test.sh] |
| [-] Unable to define arc4() call address... =====> 报错 |
| |
gzexe加密与解密shell脚本
gzexe支持bash a.sh 和 ./a.sh,但shc只支持./a.sh这种方式运行
| ~]# vim test.sh |
| #!/bin/bash |
| echo "this is shc test" |
| |
| |
| ~]# gzexe test.sh |
| test.sh: 0.0% |
| |
| |
| ~]# ll test.sh* |
| -rw-r--r--. 1 root root 865 3月 10 09:25 test.sh ===> 压缩后的二进制文件 |
| -rw-r--r--. 1 root root 38 3月 10 09:24 test.sh~ ===> 原文件 |
| |
| |
| ~]# bash test.sh |
| this is shc test |
| |
.
.
.
.
游走在各发行版间老司机QQ群:905201396
不要嫌啰嗦的新手QQ群:756805267
Debian适应QQ群:912567610
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器