shell脚本加密工具shc使用详解

 更新时间:2021年06月28日 10:02:47   作者:西京刀客  
Linux下的shell脚本用途广泛,经常包含IP、Pwd等关键信息,可读可写的特点很容易造成信息泄露,导致严重后果。基于这些原因,对脚本实施加密便变得很有必要。本文介绍shell脚本加密工具应用场景分析,一起看看吧

shell脚本加密工具shc

shc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件.

应用场景

用shell脚本对系统进行自动化维护,简单,便捷而且可移植性好.但shell脚本是可读写的,很有可能会泄露敏感信息,如用户名,密码,路径,IP等.

对于脚本中含有一些敏感信息的,通常我们都想做成二进制程序,不让用户看到源码,对于有这种需求的通常我们一般采用shc或者gzexe,我个人还是比较推荐shc。

shc 安装 和使用

yum -y install shc 或 apt install shc

我们随便写一个脚本

# cat test.sh
#!/bin/bash

echo "this is shc test"

用shc加密

shc -r -v -f test.sh

shc -r -f script-name 注意:要有-r选项, -f 后跟要加密的脚本名.

# ls -l
total 36
-rw-r--r-- 1 root root    37 12月 20 21:48 test.sh
-rwx--x--x 1 root root 11160 12月 20 21:48 test.sh.x
-rw-r--r-- 1 root root  9433 12月 20 21:48 test.sh.x.c

加密后会生成二个文件
test.sh 源文件
test.sh.x 加密后二进制文件
test.sh.x.c 脚本对应的C语言版本源码

执行一下加密后文件

# ./test.sh.x
this is shc test

shc解密

市面上面现在有对应的unshc解密程序,我们直接去github看看

https://github.com/yanncam/UnSHc/
支持x86 mips arm架构CPU
但对于我测试结果对于x86支持应该是最好的,作者自己维护的,其它的是第三方个人维护,兼容性不好。

 # ./unshc.sh /tmp/test.sh.x  -o test.txt
 _   _       _____ _   _
| | | |     /  ___| | | |
| | | |_ __ \ `--.| |_| | ___
| | | | '_ \ `--. \  _  |/ __|
| |_| | | | /\__/ / | | | (__
 \___/|_| |_\____/\_| |_/\___|

--- 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 [/tmp/test.sh.x]
[+] Output file name specified [test.txt]
[+] ARC4 address call candidate : [0x400d06]
[*] Extracting each args address and size for the 14 arc4() calls with address [0x400d06]...
	[0] Working with var address at offset [0x602179] (0x2a bytes)
	[1] Working with var address at offset [0x602121] (0x1 bytes)
	[2] Working with var address at offset [0x602319] (0xa bytes)
	[3] Working with var address at offset [0x602170] (0x3 bytes)
	[4] Working with var address at offset [0x6020e0] (0xf bytes)
	[5] Working with var address at offset [0x602141] (0x1 bytes)
	[6] Working with var address at offset [0x602127] (0x16 bytes)
	[7] Working with var address at offset [0x602144] (0x16 bytes)
	[8] Working with var address at offset [0x60215d] (0x13 bytes)
	[9] Working with var address at offset [0x6021ad] (0x1 bytes)
	[10] Working with var address at offset [0x6021ae] (0x1 bytes)
	[11] Working with var address at offset [0x6020f9] (0x26 bytes)
	[12] Working with var address at offset [0x6021b3] (0x13 bytes)
	[13] Working with var address at offset [0x6021c8] (0x13 bytes)
[*] Extracting password...
	[+] PWD address found : [0x6021ec]
	[+] PWD size found : [0x100]
[*] Executing [/tmp/MYoKED] to decrypt [/tmp/test.sh.x]
[*] Retrieving initial source code in [test.txt]
[*] All done!
root@Develop:~/UnSHc-master/latest# cat test.txt
#!/bin/bash

echo "this is shc test"

可见直接解密出来源码,对于x86的这种,支持非常的好。 其原理 就是 头部增加4096字节乱码。并且 shc加密的脚本在运行时ps -ef可以看到shell的源码。 因此,shc其实不是真的很有用!

以上就是shell脚本加密工具shc的详细内容,更多关于shell脚本加密工具的资料请关注脚本之家其它相关文章!

相关文章

  • shell脚本定时备份MySQL数据库数据并保留指定时间

    shell脚本定时备份MySQL数据库数据并保留指定时间

    这篇文章主要介绍了shell脚本定时备份MySQL数据库数据并保留指定时间,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-09-09
  • shell实现数字打印从100到200的数

    shell实现数字打印从100到200的数

    按顺序打印从100到200的数的shell脚本,需要的朋友可以参考下
    2013-02-02
  • Linux find 命令完全指南及核心用法

    Linux find 命令完全指南及核心用法

    find 是 Linux 系统最强大的文件搜索工具,支持 嵌套遍历、条件筛选、执行动作,下面给大家介绍Linux find 命令完全指南,感兴趣的朋友一起看看吧
    2025-03-03
  • 详解NC反弹shell的几种方法

    详解NC反弹shell的几种方法

    这篇文章主要介绍了详解NC反弹shell的几种方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-10-10
  • shell脚本实现本地文件与服务器文件同步

    shell脚本实现本地文件与服务器文件同步

    这篇文章主要介绍了本地文件与服务器文件同步shell脚本的方法,然后在文章给大家补充介绍了shell脚本备份本地服务器的文件到远程服务器的实例代码,需要的朋友可以参考下
    2017-11-11
  • linux 定时执行shell、python脚本的方法

    linux 定时执行shell、python脚本的方法

    这篇文章主要介绍了linux 定时执行shell、python脚本的方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧
    2024-05-05
  • Shell脚本实现进度条的两种方式

    Shell脚本实现进度条的两种方式

    本文主要介绍了Shell脚本实现进度条的两种方式,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-03-03
  • Shell脚本实现随机数多种方法介绍(date、random、uuid)

    Shell脚本实现随机数多种方法介绍(date、random、uuid)

    这篇文章主要介绍了Shell脚本实现随机数多种方法介绍,本文讲解了通过时间获得随机数、通过内部系统变量、通过系统内部唯一数据生成随机数等方法,需要的朋友可以参考下
    2014-11-11
  • awk 九九乘法表 shell实现代码

    awk 九九乘法表 shell实现代码

    这篇文章主要介绍了awk 九九乘法表 shell实现代码,需要的朋友可以参考下
    2016-03-03
  • Linux命令提示符显示格式的配置方法

    Linux命令提示符显示格式的配置方法

    今天小编就为大家分享一篇Linux命令提示符显示格式的配置方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-06-06

最新评论