简体   繁体   English

C# - 可执行文件可以解密(可以进行逆向工程)?

[英]C# - Executables decompilable (can be reverse engineered)?

Is that right that C# can be reverse engineered? C#可以进行逆向工程吗? How is easy to do that? 怎么这么容易? Can we say the C# is not enough good from safety aspect? 我们可以说C#在安全方面不够好吗? And what about C++ compared with C# against decompiling? 那么C ++与C#相比反编译呢?

It's true! 这是真的!

Take a look at one of your own executables using Reflector . 使用Reflector查看您自己的可执行文件之一。

Does this mean that C# is "not enough good from safety aspect"? 这是否意味着C#“从安全方面来说还不够好”? No, it doesn't mean that. 不,这并不意味着。

There's nothing wrong with the safety of C#. C#的安全性没有任何问题。 You just need to ensure that you don't put any secrets in your published executables if you don't want the world to know about them. 如果您不希望全世界了解它们,您只需确保不在已发布的可执行文件中放置任何秘密。 (This applies to pretty much any language, not just C#. All executable code can be reverse-engineered, it's just that some languages/frameworks make it easier than others.) (这几乎适用于任何语言,而不仅仅是C#。所有可执行代码都可以进行逆向工程,只是某些语言/框架比其他语言更容易。)

Oh dear. 噢亲爱的。

Even if you write your program in C or whatever language, you can always extract the machine code from the executable (even if it's some weird self-modifying code) and then you can always get the assembly representation. 即使你用C语言或任何语言编写程序,你总是可以从可执行文件中提取机器代码(即使它是一些奇怪的自修改代码),然后你总是可以获得程序集表示。 This is necessary because CPUs can only execute machine code. 这是必要的,因为CPU只能执行机器代码。 This is inherently true for any program written for any Turing machine. 对于任何为图灵机编写的程序而言,这本质上都是正确的。

This fact is well illustrated by cracks popping up for any game or application a few days after their release no matter how hard the developers tried to obfuscate code. 无论开发人员多么努力地混淆代码,在发布后的几天内,任何游戏或应用程序都会出现裂缝,这充分说明了这一事实。 There are obfuscation techniques but in the end, it will be always possible to reverse engineer the machine code (or the IL code in the case of .NET). 有混淆技术,但最终,总是可以对机器代码(或.NET的情况下的IL代码)进行逆向工程。 There are also very good Assembly -> C decompilers out there. 那里还有非常好的Assembly - > C反编译器。

Just accept the fact that your code can be reverse engineered and will be if someone needs the source code enough and is willing to invest some time in it. 只需接受这样一个事实,即您的代码可以进行逆向工程,并且如果有人需要足够的源代码并愿意花一些时间在其中。 Design your software by keeping this in mind. 记住这一点来设计您的软件。

You can obviously use Reflactor to see its source code. 显然,您可以使用Reflactor查看其源代码。 But you can make it a bit difficult by using obfuscator like Dotfuscator 但是你可以通过使用像Dotfuscator这样的混淆器来使它变得有点困难

But as everyone is saying you cant make it impossible to reverse engineering it. 但正如每个人都说你不能让它逆向工程。

Yes, C# can be reverse engineer. 是的,C#可以是逆向工程师。 In fact it is trivially easy to do. 事实上,这很容易做到。 Take a look at Reflector. 看看Reflector。 To make it harder, but not impossible use an obfuscator. 使用混淆器变得更难,但并非不可能。

Keep in mind that applications written in C/C++ or any other language for that matter can be reverse engineered as well albeit not as easily as non-obfuscated C# or Java. 请记住,使用C / C ++或任何其他语言编写的应用程序可以进行逆向工程,尽管不像非混淆的C#或Java那样容易。

Each new version of C# is more difficult to reverse engineer. 每个新版本的C#都更难以进行逆向工程。 It's true that when C# was at 1.0, Reflector would practically reveal your source code however now we are at 3.0 and if you are using anonymous delegates, LINQ, anonymous classes etc. all that high-level syntax is being compiled down to "dumb" MSIL and it's no more easy to reverse engineer them back to its original source. 确实,当C#为1.0时,Reflector实际上会显示你的源代码,但现在我们处于3.0,如果你使用的是匿名委托,LINQ,匿名类等,所有高级语法都被编译成“哑” MSIL并没有更容易将它们反向工程回原始来源。

Any code written using the .NET framework can easily be reverse engineered. 使用.NET框架编写的任何代码都可以轻松进行逆向工程。 That's where the concept of obfuscation comes in. 这就是混淆概念的用武之地。

Obfuscation is a technique some tools use that take a .NET -based assembly output and attempts to encrypt strings, change flow control of method bodies, rename variable, parameter and method names, thereby making it harder for causal hackers to follow and "decompile" the code. 混淆是一种工具使用的技术,它采用基于.NET的程序集输出并尝试加密字符串,更改方法体的流控制,重命名变量,参数和方法名称,从而使因果黑客更难以遵循和“反编译”编码。

Obfuscation does not guarantee complete protection of your "proprietary" code. 混淆并不能保证完全保护您的“专有”代码。 To maintain the best security of your code, simply keep the code on your private servers. 要保持代码的最佳安全性,只需将代码保留在私有服务器上即可。 It's important to remember that all code can be reverse engineered given enough time and perseverance by the would-be "hacker". 重要的是要记住,所有代码都可以通过潜在的“黑客”给予足够的时间和坚持而进行逆向工程。

C# safety aspect C#安全方面
If you feel you have "sensitive" code you don't want other users to see and "decode", you should investigate developing those portions of code in a native Win32 environment (C++ or Delphi) and continue with the benefits afforded from the .NET framework. 如果你觉得你有“敏感”代码,你不希望其他用户看到和“解码”,你应该调查在本机Win32环境(C ++或Delphi)中开发这些代码部分,并继续从中获得的好处。 NET框架。

Google for "Red Gate Reflector" - http://www.red-gate.com/products/reflector/ 谷歌的“红门反射器” - http://www.red-gate.com/products/reflector/

If you want to prevent this then you need an obfuscator, or some other more advanced form of protection. 如果您想要防止这种情况,那么您需要一个混淆器或其他一些更高级的保护形式。

将Reflector与File Disassembler插件一起使用http://www.denisbauer.com/NETTools/FileDisassembler - 它将为您生成dll中的所有代码。

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

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