我一直在思考如何保护我的C/ c++代码不被反汇编和逆向工程破坏。通常情况下,在我的代码中,我绝不会宽恕这种行为;然而,为了各种人的安全,我目前正在研究的协议决不能被检查或理解。

现在这对我来说是一个新的主题,互联网并没有真正的资源来防止逆向工程,而是描述了大量关于如何逆向工程的信息

到目前为止我想到的一些事情是:

Code injection (calling dummy functions before and after actual function calls) Code obfustication (mangles the disassembly of the binary) Write my own startup routines (harder for debuggers to bind to) void startup(); int _start() { startup( ); exit (0) } void startup() { /* code here */ } Runtime check for debuggers (and force exit if detected) Function trampolines void trampoline(void (*fnptr)(), bool ping = false) { if(ping) fnptr(); else trampoline(fnptr, true); } Pointless allocations and deallocations (stack changes a lot) Pointless dummy calls and trampolines (tons of jumping in disassembly output) Tons of casting (for obfuscated disassembly)

我的意思是,这些是我想过的一些事情,但它们都可以在适当的时间框架内由代码分析师解决。我还有别的选择吗?


当前回答

通过不公开来保证安全并不像比他聪明得多的人所证明的那样有效 我们两个。如果你必须保护你的客户的通信协议,那么你是 道德上有义务使用最好的代码,这些代码是公开的,并由专家全面审查。

这适用于人们可以检查代码的情况。如果您的应用程序是在嵌入式微处理器上运行的,那么您可以选择一个具有密封功能的微处理器,这使得在运行时不可能检查代码或观察更多的琐碎参数,例如当前使用情况。(是的,除了硬件入侵技术,你要小心地拆卸芯片,使用先进的设备来检查单个晶体管上的电流。)

我是x86逆向工程汇编程序的作者。如果你准备感冒的话 惊喜,寄给我你竭尽全力的结果。(通过我的网站联系我。) 在我所看到的答案中,很少有人会给我带来实质性的障碍。如果你想看的话 如何复杂的逆向工程代码工作,你真的应该研究网站 逆向工程挑战。

你的问题需要澄清一下。你怎么能保守协议的秘密,如果 计算机代码可以进行逆向工程吗?如果我的协议是发送一个RSA加密消息(甚至是公钥),通过保持协议的秘密,你能得到什么? 出于所有实际目的,检查器将面对一系列随机比特。

问候阿尔伯特

其他回答

很多时候,担心你的产品被逆向工程是多余的。是的,它可以被逆向工程;但它是否会在短时间内变得如此出名,以至于黑客们会发现它值得逆转。它吗?(对于大量的代码行来说,这项工作不是一个小时间活动)。

如果它真的能赚钱,那么你就应该筹集足够的资金,通过专利或版权等合法途径来保护它。

恕我直言,采取你将要采取的基本预防措施,然后释放它。如果它成为逆向工程的一个点,这意味着你已经做得非常好,你自己会找到更好的方法来克服它。祝你好运。

有人试过codemoth: http://www.sourceformat.com/code-obfuscator.htm吗? 或者Themida: http://www.oreans.com/themida_features.php ?

晚一点看起来更有希望。

正如很多人已经说过的:在一个普通的CPU上,你不能阻止它们,你只能延迟它们。就像我以前的密码学老师告诉我的那样:你不需要完美的加密,破解密码的代价肯定比获得的代价更大。你的困惑也是一样。

但还有3个注意事项:

It is possible to make reverse engineering impossible, BUT (and this is a very very big but), you cant do it on a conventional cpu. I did also much hardware development, and often FPGA are used. E.g. the Virtex 5 FX have a PowerPC CPU on them, and you can use the APU to implement own CPU opcodes in your hardware. You could use this facility to really decrypt incstuctions for the PowerPC, that is not accessible by the outside or other software, or even execute the command in the hardware. As the FPGA has builtin AES encryption for its configuration bitstream, you could not reverse engineer it (except someone manages to break AES, but then I guess we have other problems...). This ways vendors of hardware IP also protect their work. You speak from protocol. You dont say what kind of protocol it is, but when it is a network protocol you should at least protect it against network sniffing. This can you indeed do by encryption. But if you want to protect the en/decryption from an owner of the software, you are back to the obfuscation. Do make your programm undebuggable/unrunnable. Try to use some kind of detection of debugging and apply it e.g. in some formula oder adding a debug register content to a magic constant. It is much harder if your program looks in debug mode is if it where running normal, but makes a complete wrong computation, operation, or some other. E.g. I know some eco games, that had a really nasty copy-protection (I know you dont want copyprotection, but it is similar): The stolen version altered the mined resources after 30 mins of game play, and suddenly you got just a single resource. The pirate just cracked it (i.e. reverse engineered it) - checked if it run, and volia released it. Such slight behaviour changings are very hard to detect, esp. if they do not appear instantly to detection, but only delayed.

所以最后我想建议: 估算逆向工程人员的收益,将其转化为一些时间(例如,使用最便宜的印度工资),并进行逆向工程,使时间成本更大。

不行,你不能保护你的代码不被反汇编。你所能做的就是为业务逻辑设置服务器,并使用webservice为你的应用程序提供它。当然,这种情况并不总是可行的。

可能最好的选择仍然是使用虚拟化,这引入了另一层需要绕过的间接/混淆,但正如SSpoke在他的回答中所说,这种技术也不是100%安全的。


关键是你不会得到终极保护,因为根本就没有这种东西,即使有,也不会持续太久,这意味着它一开始就不是终极保护。

凡是人组装起来的东西,都可以拆卸。

通常情况下,(正确的)拆卸通常是(一点或更多)更困难的任务,所以你的对手必须更熟练,但你可以假设总有这样的人,这是一个安全的赌注。

如果您希望保护某些内容不受REs的影响,那么您必须至少了解REs使用的常见技术。

这样的话

互联网并不是真正的资源预防逆向工程,而是描述了大量关于如何逆向工程的信息

表现出你的坏态度。我并不是说要使用或嵌入保护,你必须知道如何打破它,但要明智地使用它,你应该知道它的弱点和陷阱。你应该明白这一点。

(有一些软件以错误的方式使用保护,使得这种保护实际上不存在。为了避免含糊,我给你举一个在网上简单描述的例子:牛津英语词典第二版CD-ROM - v4。您可以在以下页面了解SecuROM使用失败的原因:16、32或64位Windows环境下CD-ROM上的牛津英语词典(OED):硬盘安装、错误、字处理宏、网络、字体等)

每件事都需要时间。

如果你是这门学科的新手,没有几个月甚至几年的时间来学习正则表达式,那么就使用其他人提供的可用解决方案。这里的问题很明显,它们已经在那里了,所以你已经知道它们不是100%安全的,但制作自己的新保护只会给你一种被保护的错误感觉,除非你非常了解逆向工程和保护的艺术状态(但你不知道,至少目前不知道)。

软件保护的目的是吓唬新手,拖延常见的正则,并让经验丰富的正则在她/他(希望很有趣)到达应用程序中心后面带微笑。

在商业谈话中,你可能会说这都是为了尽可能地推迟竞争。

(看看Philippe Biondi和Fabrice Desclaux在Black Hat 2006上展示的Skype中的银针)。


你知道有很多关于RE的东西,所以开始阅读吧。:)

我说过虚拟化,所以我将给你一个链接到EXETOOLS论坛的一个示例线程:最佳软件保护:Themida还是Enigma protector ?这可能会对你进一步的搜索有所帮助。