Ruby 混淆器
是否有 ruby 混淆器或“编译器”?
Is there a ruby obfuscator or "compiler"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否有 ruby 混淆器或“编译器”?
Is there a ruby obfuscator or "compiler"?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
有几个选项,例如 RubyScript2Exe 或 AllInOneRuby。然而,所有解释语言的混淆器往往都有一个严重的缺陷:它们通常不理解更复杂的元编程技术。
也就是说,他们不一定能判断出像 foo.send(:bar, ...) 这样的东西是对完全不同的库中的
bar
方法的调用,或者eval("require %w{abc def ghi}")
意味着需要三个不同的库。这些都是微不足道的例子——当你将method_missing
及其同类混入其中时,事情会变得更加复杂。当混淆器遇到此类代码时,它会尽职尽责地编译适当的指令,但它可能不知道还包含来自其他地方的某些库或其他代码。这可能会导致严重的问题,因为动态
include
d 或require
d 在运行时在静态链接的可执行文件中将不可用。不幸的是,许多 gem 和库都使用复杂的元编程技术。如果您尝试使用混淆并期望您的程序具有相同的行为,那么您可能会在这里遇到麻烦。更糟糕的是,由于存在如此多的间接级别,如果混淆版本中出现错误,您可能永远不知道到底发生了什么或如何重现它。
There are a few options, like RubyScript2Exe or AllInOneRuby. However, all obfuscators of interpreted languages tend to have a serious flaw: they usually don't understand more sophisticated metaprogramming techniques.
That is, they can't necessarily tell that something like
foo.send(:bar, ...)
is an invocation on thebar
method in a completely different library, or thateval("require %w{abc def ghi}")
means to require three different libraries. These are trivial examples -- things get much more complex when you throwmethod_missing
and its ilk into the mix.When an obfuscator encounters this sort of code, it will dutifully compile the appropriate instructions, but it may not know to also include certain libraries or other code from elsewhere. That can cause serious issues, since the dynamically
include
d orrequire
d will not be available at runtime in a statically linked executable.Unfortunately, many gems and libraries use sophisticated metaprogramming techniques. You'll likely get into trouble here if you try to use obfuscation and expect your program to have the same behavior. Worse still, because there are so many levels of indirection, if a bug occurs in the obfuscated version, you may never know what exactly happened or how to reproduce it.
根据您想要执行的操作,Gem 允许您从 Ruby 脚本创建 C 扩展,然后可以将其用作 Ruby 应用程序中的 require。它称为 ruby2cext。它将把你所有的代码混淆成 C 语言,并且你可以在单独的 Ruby 脚本中需要 .so,它的功能就像普通的 Ruby 脚本一样。
Depending on what you are trying to do, there is a Gem that will allow you to create a C extension from a Ruby script which can then be used as a require inside your Ruby app. Its called ruby2cext. It will obfuscate all of your code into C and the you can require the .so in a separate Ruby script and it will function like a normal Ruby script.
RubyScript2Exe - http://www.erikveen.dds.nl/rubyscript2exe/
RubyScript2Exe - http://www.erikveen.dds.nl/rubyscript2exe/