经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » Linux/Shell » 查看文章
shell脚本加密工具shc使用详解
来源:jb51  时间:2021/6/28 10:56:55  对本文有异议

shell脚本加密工具shc

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

应用场景

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

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

shc 安装 和使用

yum -y install shc 或 apt install shc

我们随便写一个脚本

  1. # cat test.sh
  2. #!/bin/bash
  3.  
  4. echo "this is shc test"

用shc加密

  1. shc -r -v -f test.sh

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

  1. # ls -l
  2. total 36
  3. -rw-r--r-- 1 root root 37 12 20 21:48 test.sh
  4. -rwx--x--x 1 root root 11160 12 20 21:48 test.sh.x
  5. -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语言版本源码

执行一下加密后文件

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

shc解密

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

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

  1. # ./unshc.sh /tmp/test.sh.x -o test.txt
  2. _ _ _____ _ _
  3. | | | | / ___| | | |
  4. | | | |_ __ \ `--.| |_| | ___
  5. | | | | '_ \ `--. \ _ |/ __|
  6. | |_| | | | /\__/ / | | | (__
  7. \___/|_| |_\____/\_| |_/\___|
  8.  
  9. --- UnSHc - The shc decrypter.
  10. --- Version: 0.8
  11. ------------------------------
  12. UnSHc is used to decrypt script encrypted with SHc
  13. Original idea from Luiz Octavio Duarte (LOD)
  14. Updated and modernized by Yann CAM
  15. - SHc : [http://www.datsi.fi.upm.es/~frosal/]
  16. - UnSHc : [https://www.asafety.fr/unshc-the-shc-decrypter/]
  17. ------------------------------
  18.  
  19. [*] Input file name to decrypt [/tmp/test.sh.x]
  20. [+] Output file name specified [test.txt]
  21. [+] ARC4 address call candidate : [0x400d06]
  22. [*] Extracting each args address and size for the 14 arc4() calls with address [0x400d06]...
  23. [0] Working with var address at offset [0x602179] (0x2a bytes)
  24. [1] Working with var address at offset [0x602121] (0x1 bytes)
  25. [2] Working with var address at offset [0x602319] (0xa bytes)
  26. [3] Working with var address at offset [0x602170] (0x3 bytes)
  27. [4] Working with var address at offset [0x6020e0] (0xf bytes)
  28. [5] Working with var address at offset [0x602141] (0x1 bytes)
  29. [6] Working with var address at offset [0x602127] (0x16 bytes)
  30. [7] Working with var address at offset [0x602144] (0x16 bytes)
  31. [8] Working with var address at offset [0x60215d] (0x13 bytes)
  32. [9] Working with var address at offset [0x6021ad] (0x1 bytes)
  33. [10] Working with var address at offset [0x6021ae] (0x1 bytes)
  34. [11] Working with var address at offset [0x6020f9] (0x26 bytes)
  35. [12] Working with var address at offset [0x6021b3] (0x13 bytes)
  36. [13] Working with var address at offset [0x6021c8] (0x13 bytes)
  37. [*] Extracting password...
  38. [+] PWD address found : [0x6021ec]
  39. [+] PWD size found : [0x100]
  40. [*] Executing [/tmp/MYoKED] to decrypt [/tmp/test.sh.x]
  41. [*] Retrieving initial source code in [test.txt]
  42. [*] All done!
  43. root@Develop:~/UnSHc-master/latest# cat test.txt
  44. #!/bin/bash
  45.  
  46. echo "this is shc test"

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

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

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号