English 中文(简体)
是否可以将双管双管成双管齐下?
原标题:Is it possible to convert a bash script into an executable?

问题很简单;是否可以将书本改写成可执行的内容? 如果是,如何做到这一点?

问题回答

这是可能的,但你不想。

  • It won t be effective obfuscation.
  • It won t be smaller.
  • It won t be faster.

It won t be smaller

在有支持将文字汇编成单独可执行的地方,这项工作是通过向可执行<>提供翻译的副本。 因此,这比单是文字大得多。

It won t be faster

The execution model used by bash, unfortunately, is innately slow: Almost all functionality is provided by external commands; and simple commands arguments, or even their names, can be modified by the result of expansion operations. This level of dynamicism makes effective compilation for performance impossible. (zsh supports a precompilation process, but the benefit is limited, mostly to the process of parsing itself).

It won t be effective obfuscation

举例说: 它突然将文字原始来源作为指挥线理由。 因此,这一来源只能读到<代码>/proc的指挥线论据,或使用<代码>strace。

As they say, "security by obscurity is no security at all" -- anyone who s reasonably competent could trivially extract any passwords or other content obfuscated in this way.

www.un.org/Depts/DGACM/index_spanish.htm http://github.com/neurobin/shc”rel=“nofollow” (如Flavius Anton)。

但你们需要知道,这本书并非都是独立的。 这仍然取决于壳体,即如果该代码是专门为Bash写的,然后用sh子转换,则在该系统上没有安装Bash,就赢得了拖。

Limitations:

  1. Size: heavily increased. 23bytes of test script turned into 9.6KB of binary.
  2. Speed: It will run slower than the plain Bash script.
  3. The size of the Bash script convertible is limited by the _SC_ARG_MAX system configuration parameter.
  4. The binary is depended on Bash.
  5. It is a code obfuscation which is rendered useless against intelligent attack.


Another way is to use Bash2py:

http://www.swag.uwaterloo.ca/bash2py/"rel=“nofollow”>bash2py 换算 Bash source Code to bash。 不久前,你会发现,这在实际工作中是毫无用处的(<>bash2py<=3.2)。

How To:

  1. Download and install Bash2py
  2. Install cx_freeze (or other tool)
  3. write a sample script, test:
    #!/bin/bash
    echo works
  4. convert it to python:
    bash2pyengine ./test
  5. A test.py python script will be generated. Compile it using tools like cx_freeze:
    cxfreeze ./test.py
  6. A binary file with lots of shared object file will be created (dist directory for cx_freeze). You can find a binary (named test) there. Run it from that directory. Note that the shared object files are the dependencies for this binary. You can port this binary as long as you take all the shared object files with it.

Limitations:

  1. Size: It is a two way process and in each process size is heavily increased (super heavy), specially in cxfreeze step, as it produces a lot of shared object files and also the binary file alone becomes enormous too. For the above test script, original size is 23bytes, test.py -> 38bytes, test (binary) -> 1.3MB, and total (binary and it s dependencies) -> 6.5MB!!!
  2. Speed: I think the Bash code will run way more faster than this.
  3. All the limitations of Bash2py and freezing tool (cx_freeze or such) apply.
  4. Bash2py is yet to evolve to be usable. You will see a lot of red colored text/entry in Bash2py Manual Page. Red colored text means unsupported in their context. There are lots of loosly supported features too. For example: Array is orange colored (now) which means "not necessarily well supported", actually it s not supported at all (yet bash2py<=3.2). So even the Bash to Python conversion is not well performed where you will have to consider the limitation of the next step (freezing) too.

Finally:

以上两者都没有实际的解决办法。 简言之,Bash2pyshc差,因为它没有支持所有巴什特征(yetbash2py<=3.2)。 i.e 您可以自由书写代码,并期望与Bash2py合作。

在经过所有这些艰苦努力之后,我可以提供帮助,但同意:

It s possible, but you don t want to.

是的。 它是一个名为“shc”的小型项目(Shell Compiler)。 https://github.com/existz/shc-3.8.9“rel=” Github repo

我知道我大约在两年前就使用了它,并且做了罚款。

实际援引sh是sh——指挥。 如果该方案正在实施,则可以通过皮条获得源代码。 而且必须是一件好事。 为了解决这些问题,我开发了shellc,该软件是Gite Hub的公开来源,主要是通过类似于的管道方法,将目录输入到隐藏的源名录。 通过增加编码混淆和随机生成有效品位计算功能,增加拆分和反射工程的复杂性。





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...