Ruby 混淆器

发布于 2024-08-19 03:20:03 字数 28 浏览 2 评论 0原文

是否有 ruby​​ 混淆器或“编译器”?

Is there a ruby obfuscator or "compiler"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

╭ゆ眷念 2024-08-26 03:20:03

有几个选项,例如 RubyScript2ExeAllInOneRuby。然而,所有解释语言的混淆器往往都有一个严重的缺陷:它们通常不理解更复杂的元编程技术。

也就是说,他们不一定能判断出像 foo.send(:bar, ...) 这样的东西是对完全不同的库中的 bar 方法的调用,或者 eval("require %w{abc def ghi}") 意味着需要三个不同的库。这些都是微不足道的例子——当你将 method_missing 及其同类混入其中时,事情会变得更加复杂。

当混淆器遇到此类代码时,它会尽职尽责地编译适当的指令,但它可能不知道还包含来自其他地方的某些库或其他代码。这可能会导致严重的问题,因为动态 included 或 required 在运行时在静态链接的可执行文件中将不可用。

不幸的是,许多 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 the bar method in a completely different library, or that eval("require %w{abc def ghi}") means to require three different libraries. These are trivial examples -- things get much more complex when you throw method_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 included or required 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.

忆沫 2024-08-26 03:20:03

根据您想要执行的操作,Gem 允许您从 Ruby 脚本创建 C 扩展,然后可以将其用作 Ruby 应用程序中的 require。它称为 ruby​​2cext。它将把你所有的代码混淆成 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文