简体   繁体   English

一些嵌入式代码的逆向工程的可行性

[英]Feasability of reverse engineering some embedded code

All, 所有,

My company is in the situation where we are using an embedded control system from another company in another country. 我公司正处于使用其他国家其他公司的嵌入式控制系统的情况。 We do not have the source code or the schematics to this system, and the manufacturer doesn't want to release them, seemingly at any price or under any terms. 我们没有此系统的源代码或原理图,制造商不希望以任何价格或任何条款发布它们。 We are thus stuck with a 6 month turn around to get even a small modification done, and they can basically charge any amount they want. 因此,我们坚持了6个月的转身以完成一个小的修改,他们基本上可以收取任何他们想要的金额。

Legal aspects aside, would it be at all feasible to reverse engineer the embedded code back into C? 除法律方面之外,将嵌入式代码反向工程改为C是否完全可行? Do any companies exist that could do this for us? 是否存在可以为我们做到这一点的公司?

Thank you, Fred 谢谢你,弗雷德

只要您了解系统的要求,就有很多公司会重新实施嵌入式控制系统而无需对您现在使用的系统进行逆向工程。

Quite a big "it depends". 相当大的“它取决于”。

The mapping from source -> object code is (mathematically speaking) not reversible, so you can't recover the source code. 从源映射- >目标代码(从数学上讲)不可逆的,所以不能恢复源代码。 But if you have the object code it's not all that hard to come up with some kind of source that compiles to the same object code, or at least which has the same effect - that's just disassembly/assembly. 但是如果你有目标代码,那么编译同一个目标代码的某种源代码并不是那么难,或者至少具有相同的效果 - 这只是反汇编/汇编。

Depending how creative your decompilation process is, though, the C code might come out looking a lot like assembler. 但是,根据反编译过程的创造性,C代码可能看起来很像汇编程序。 So I'd question the quality of code I'd likely get back from a third-party - "C code" doesn't mean "C code that's easily maintainable by our C programmers", and it might be really quite hard to produce the latter. 所以我会质疑我可能从第三方获得的代码质量 - “C代码”并不意味着“我们的C程序员可以轻松维护的C代码”,而且可能真的很难生成后者。

Also note that an embedded controller "written in C" might actually have quite a lot of assembler in it in their source code. 另请注意,“用C语言编写”的嵌入式控制器实际上可能在其源代码中包含了相当多的汇编程序。 So either you allow assembler in your reverse-engineered version or you don't. 所以要么你允许在反向工程版本中使用汇编程序,要么你不允许。 If you don't it may be impossible to reproduce the functionality in C. If you do, then where do you draw the line - in the extreme you could just disassemble their source and not have any proper C code at all. 如果不这样做,可能无法在C中重现功能。如果你这样做,那么你在哪里绘制线 - 在极端情况下你可以反汇编它们的源代码而根本没有任何合适的C代码。 You can't necessarily tell from examining the object code which bits were written in C and which weren't. 您无法通过检查目标代码来判断哪些位是用C编写的,哪些不是。

All this of course leaving aside the legal issues. 所有这一切当然都抛弃了法律问题。 It's probably unwise to leave aside the legal issues, especially as it seems you're buying this system as a physical object, and you possibly have no legal basis to separate the code from the hardware at all. 抛开法律问题可能是不明智的,特别是因为您似乎将此系统作为物理对象购买,并且您可能没有法律依据将代码与硬件分开。

See answers to reverse engineering c programs 查看逆向工程c程序的答案

In particular, see my answer referencing "Pigs to Sausages". 特别是,请参阅我的回答“猪到香肠”。 The company behind that paper can do a quite good job of converting assembler back to C, if the assembler in question doesn't do things you can't state in C (such as, "Set the Stack Pointer Register..."). 该文件背后的公司可以很好地将汇编程序转换回C,如果有问题的汇编程序没有做你不能在C中说明的事情(例如,“设置堆栈指针寄存器......”) 。

[I have nothing to do with the Pigs-to-Sausages guys except having met and having a great deal of respect for their technical lead.] [我与Pigs-to-Sausages家伙没有任何关系,除非他们遇到并非常尊重他们的技术领导。]

Assuming you are able to retrieve the binary code out of the system, disassembling and combing through it should be no problem. 假设您能够从系统中检索二进制代码,则反汇编和梳理它应该没有问题。 Actually turning the assembler code into maintainable C code poses a big problem. 实际上将汇编代码转换为可维护的 C代码是一个很大的问题。 Depending on the size of the system, this will take a lot of time manually (re-)writing the code into something useable. 根据系统的大小,这将花费大量时间手动(重新)将代码写入可用的东西。

To my knowledge, in some countries, it is legal to reverse engineer a system to ensure compatibility with your software. 据我所知,在某些国家/地区,对系统进行反向工程以确保与您的软件兼容是合法的。 But this may require clean-room reverse engineering. 但这可能需要洁净室逆向工程。

If you are looking for companies to help reverse engineer, you might want to sniff around who publishes in the Working Conference on Reverse Engineering . 如果您正在寻找可以帮助逆向工程的公司,您可能想要了解在逆向工程工作会议上发布的人员 Find some work there that impresses you and ask those people whom to hire. 在那里找一些令你印象深刻的工作,并问那些雇用​​的人。

You might be better off starting an embedded team in house. 你可能最好在内部创建一个嵌入式团队。 In the same time it'd take you to do 4-5 software changes, with the right team you could have fully owned hardware and software designs, plus in-house expertise that can implement changes quickly. 与此同时,它可以让您进行4-5次软件更改,拥有合适的团队,您可以拥有完全拥有的硬件和软件设计,以及可以快速实施变更的内部专业知识。

... not to mention the amount of money you'd save on markup if the product has any considerable volume. ...更不用说如果产品有相当大的数量,你会在标记上节省的金额。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM