如何将 linux shell 脚本编译为独立的可执行文件 *binary*(即不仅仅是 chmod 755)? [英] How to compile a linux shell script to be a standalone executable *binary* (i.e. not just e.g. chmod 755)?
问题描述
我正在寻找一个免费的开源工具集,它可以编译各种经典"脚本语言,例如Korn Shell、ksh、csh、bash 等作为可执行文件——如果脚本调用其他程序或可执行文件,则将它们包含在单个可执行文件中.
I'm looking for a free open source tool-set that will compile various "classic" scripting languages, e.g. Korn Shell, ksh, csh, bash etc. as an executable -- and if the script calls other programs or executables, for them to be included in the single executable.
原因:
混淆交付给客户的代码,以免泄露我们的知识产权 - 交付给客户自己的机器/系统,我无法控制我的权限可以设置访问权限,因此程序文件必须是二进制文件,因此无法通过文本编辑器或
hexdump
查看器轻松查看其工作原理.
To obfuscate the code for delivery to a customer so as not to reveal our Intellectual Property - for delivery onto a customer's own machine/systems for which I have no control over what permissions I can set regarding access, so the program file has to be binary whereby the workings cannot be easily seen by viewing in a text editor or
hexdump
viewer.
为客户制作一个单一的、简单部署的程序,没有/或任何外部依赖项最少.
To make a single, simply deployed program for the customer without/or a minimal amount of any external dependencies.
我更喜欢不需要包管理器的简单的东西,因为:
I would prefer something simple without the need for package manager since:
我不能依赖客户的知识来执行(取消)包装说明和
I can't rely on the customer's knowledge to carry out (un) packaging instructions and
我不能依赖管理他们机器的有关安装包的政策(实际上是来自第三方的).
I can't rely on the policies governing their machines regarding installing packages (and indeed from third parties).
最简单的首选方法是能够将单个可执行文件编译为正确的机器代码,该可执行文件将开箱即用,没有任何依赖关系.
The simplest preferred approach is to be able to compile to proper machine code a single executable that will run out of the box without any dependencies.
推荐答案
完全满足我需求的解决方案是 SHC - 免费工具,或 CCsh 商业工具.两者都将 shell 脚本编译为 C,然后可以使用 C 编译器进行编译.
The solution that fully meets my needs would be SHC - a free tool, or CCsh a commercial tool. Both compile shell scripts to C, which then can be compiled using a C compiler.
关于 SHC 的链接:
Links about SHC:
- https://github.com/neurobin/shc
- http://www.datsi.fi.upm.es/~frosal/
- http://www.downloadplex.com/Linux/System-Utilities/Shell-Tools/Download-shc_70414.html
关于 CCsh 的链接:
Links about CCsh:
这篇关于如何将 linux shell 脚本编译为独立的可执行文件 *binary*(即不仅仅是 chmod 755)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!