如何对编译器进行逆向工程?
我有一个编译器,可以为未记录的虚拟机编译为未记录的字节码。我希望能够编译到同一个虚拟机,但我不知道如何去做。我如何学习做到这一点?有没有人发表过他们做同样事情的日志或日记?
编辑:我忘记提及这是 LEGO Mindstorms 的 RobotC 3.0 编译器。在有人提出其他建议之前,我了解有关 nXc 和类似项目的所有信息,而且它们不是一个选择,因为我正在帮助 FIRST FTC 机器人团队,该团队只允许使用 RobotC 或 LabView。
至于那些建议我以编译器语言为目标的人,我还没有这样做,因为我希望编译器未公开的硬件的某些功能将由固件公开,并且因为我想要进行比 RobotC 允许的更多的自定义内存管理。
I have a compiler that compiles to undocumented bytecode for an undocumented VM. I'd like to be able to compile to the same VM, but I'm not sure how to go about doing this. How do I learn to do this? Has anyone published a log or journal of them doing the same thing?
EDIT: I neglected to mention that this is the RobotC 3.0 compiler for LEGO Mindstorms. Before anyone suggests something else, I know all about nXc and similar projects, and they aren't an option since I'm helping out a FIRST FTC robotics team, which is only allowed to use RobotC or LabView.
As for those of you who suggested that I target the language of the compiler, I'm not doing that yet because I hope that certain features of the hardware that aren't exposed by the compiler will be exposed by the firmware, and because I want to do more custom memory management than permitted by RobotC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的倾向是反汇编编译器。如果它是用 .NET(C#、VB.NET 等)或 Java 编写的,则反编译器将为您提供非常接近原始源代码的内容(除非经过混淆)。即使它是 C++ 并且您只能获得汇编,库调用也可能会为您指明正确的方向。
如果字节码很小,另一个选择是从“Hello world”程序开始,编译它,进行一些小更改,编译它,然后比较两个字节码结果。
如果您可以发布有关特定编译器/VM 的更多信息,也许其他人有这方面的经验。
编辑:鉴于这是一个商业产品,通过反编译对其进行逆向工程很可能会违反其许可协议。重新编译字节码可能不会(我不是律师)。不过,听起来你好像陷入了第 22 条军规。如果成功,则说明您使用的不是 RobotC 或 LabView。如果竞赛仅指定代码必须在 RobotC VM 上运行,则可能是可行的。但请记住,一旦您重新生成了字节码,您仍然必须编写自己的编译器,然后任何人都可以编写任何软件。如果你这样做是为了好玩,那就太好了;否则可能不可行。
我确实找到了一个基于硕士论文的有趣链接:软件逆向工程
My inclination would be to disassemble the compiler. If it's written in .NET (C#, VB.NET, etc.) or Java, there are decompilers that will give you something very close to the original source code (unless it's obfuscated). Even if it's C++ and you can only get assembly, the library calls might point you in the right direction.
If the bytecode is small, another option is to start with a "Hello world" program, compile it, make a small change, compile that, then diff the two bytecode results.
If you can post some more information on the specific compiler/VM, perhaps someone else has experience with that.
Edit: Given that this is a commercial product, it's likely that reverse-engineering it through decompilation will violate its license agreement. RE'ing the bytecode might not (I'm no lawyer). It sounds like you're in a Catch-22, though. If you succeed, you're not using RobotC or LabView. If the contest only specifies that the code must run on the RobotC VM, it might be doable. Remember, though, that once you RE the bytecode you still have to write your own compiler before anyone can write any software. If you're doing this for fun, great; otherwise it might not be feasible.
I did find one interesting link based on a Master's Thesis: Software Reverse Engineering
您可以在这里查看大量资源:
http://en.wikipedia。 org/wiki/Lego_Mindstorms_NXT_2.0
There appears to be a ton of resources that you can look at here:
http://en.wikipedia.org/wiki/Lego_Mindstorms_NXT_2.0