是否可以将 PPC 汇编转换为 C 语言?

发布于 2024-10-06 07:29:50 字数 80 浏览 0 评论 0原文

我有一些 PPC 代码,我想将其转换回原来的 C 代码,有办法做到这一点吗?可能是一个人(比如知道 PPC 来重建 C 代码的人?)还是一个程序?

i have some PPC code that i want to convert back into its original C code, is there a way to do this? Possibly a person (such as somebody who knows PPC to reconstruct the C code?) or a program?

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

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

发布评论

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

评论(4

从此见与不见 2024-10-13 07:29:50

是和不是。

原则上可以将任何语言的程序翻译成任何其他语言。结果不会很美好。

如果现有代码确实是没有太多巧妙优化的编译结果,那么很可能一个相当死记硬背的过程可以将其返回到 C。对于少量代码来说,这通常很容易手工完成,但很乏味且大型代码库容易出错。

有一些逆向工程工具声称可以进行反编译。在一般情况下,这不是一个简单的问题。

自动化解决问题的一种方法是为已经支持 C 语言后端的编译器创建 PPC 汇编(甚至二进制)前端。结果是一个交叉编译器可以读取 PPC 代码并生成高度混淆的 C 代码。例如,我知道 GCC 有一个 C 后端。

无论您采用哪种方法,对于现有二进制文件来说,拥有一个良好的测试套件(以及运行它的能力)可能至关重要,这样您就有办法证明翻译是等效的。

编辑:请注意,您将永远无法取回原始注释,并且只能访问使其成为符号表或类似调试信息的原始变量和函数名称。

Yes and no.

It is possible in principle to translate a program in any language to any other language. The results will not be pretty.

If the existing code really is the result of a compilation without too much clever optimization, then it is likely that a fairly rote process can turn it back to C. This is often straightforward to do by hand for small amounts of code, but tedious and error prone for large code bases.

There are some reverse engineering tools out there in the wild that make claims about decompilation. It isn't an easy problem in the general case.

One approach to automating the problem is to create a PPC assembly (or even binary) front-end for a compiler that already supports a C language back-end. The result is a cross-compiler that reads PPC code and produces highly obfuscated C code. I know there is a C back-end for GCC, for instance.

Regardless of the approach you take, it will likely be critical that you have a good test suite (and the ability to run it) for the existing binary so that you have a means of proving that the translation is equivalent.

Edit: Note that you will never get the original comments back, and will only have access to original variable and function names that made it into a symbol table or similar debug information.

请远离我 2024-10-13 07:29:50

IDA Pro 6.95 包含 PPC 反编译器。
但它有点贵(2350美元)

IDA Pro 6.95 includes PPC decompiler.
But it is bit costy ($2350)

甜扑 2024-10-13 07:29:50

Boomerang 声称支持 PPC 反编译。

Boomerang claims to support PPC decompilation.

飞烟轻若梦 2024-10-13 07:29:50

不,从来没有。反编译与取回 c 不同。你永远无法拿回c。您可以尝试对其进行逆向工程,尝试了解它在做什么,但某些信息会永久丢失。

这是来自回旋镖项目:

但是,通用反编译器不会尝试反转反编译器的每个操作,而是反复转换输入程序,直到结果是高级源代码。因此,它不会重新创建原始源文件; 可能没有什么比这更好的了。

因此它创建了一些可能(但永远不会知道)C 源代码的C 代码。

No. Not ever. Decompiling is not the same as getting c back. You can never get c back. You can try reverse engineer it, try to understand what it is doing, but some information is permanently lost.

This is from boomerang project:

However, a general decompiler does not attempt to reverse every action of the decompiler, rather it transforms the input program repeatedly until the result is high level source code. It therefore won't recreate the original source file; probably nothing like it.

So it creates some C code that could be (but will never know) the C source.

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