shc:将shell脚本封装为二进制程序

脚本的好处是便捷、高效,拿起来就可以写,写完就能跑,都不用编译

但坏处也显而易见,一些敏感的、不想让外人知道的东西都是明文写在里面的,所以,在这推荐一款神奇的脚本封装程序——shc

作者是位长得有几分像皮克的帅气西班牙人

下载地址

下载后解压,一顿简单操作即可使用:

tar xzvf shc.tar.tgz 
cd shr/
make && make install 

贴出官方给出的参数和解释:

OPTIONS

     The command line options are:

     -e date
          Expiration date in dd/mm/yyyy format [none]

     -m message
          message to display  upon  expiration  ["Please  contact
          your provider"]

     -f script_name
          File name of the script to compile

     -i inline_option
          Inline option for the shell interpreter i.e: -e

     -x comand
          eXec    command,    as    a    printf    format    i.e:
          exec(\\'%s\\',@ARGV);

     -l last_option
          Last shell option i.e: --

     -r   Relax security. Make  a  redistributable  binary  which
          executes  on different systems running the same operat-
          ing system.

     -v   Verbose compilation

     -D   Switch on debug exec calls

     -T   Allow binary to be  traceable  (using  strace,  ptrace,
          truss, etc.)

     -C   Display license and exit

     -A   Display abstract and exit

     -h   Display help and exit

就不翻译了…

日常用法:

shc -r -f /shellfile.sh

运行成功后会在当前目录下生成两个文件:

  • shellfile.sh.x
  • shellfile.sh.c

shellfile.sh.x是脚本所对应的可执行程序

shellfile.sh.cshellfile.sh.x对应的c语言实现的源码

shc根据脚本文件的第一行#!/bin/bash或其他shell将脚本翻译成相应的c源码并生成可执行程序。

但shc似乎无法识别expect

封装后的脚本安全性会有所提高,但这也仅能防个君子,通过gdb或其他调试工具仍然能获得最初的源码

发布了24 篇原创文章 · 获赞 3 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/saeba5566/article/details/104851493