在缓存之外生成本机图像
我想在创建安装程序之前使用 NGEN.EXE
生成程序集的本机映像。 我希望这将保留我的二进制文件 Reflector
-证明。 我的说法正确吗?
我刚刚了解到所有本机图像现在都存储在本机图像缓存中。 有没有办法获取本机二进制文件,然后将其与安装程序打包? 另一方面,生成本机映像后是否可以删除原始程序集?
编辑:我正在使用一个应用程序,该应用程序在与服务器通信时使用硬编码密钥进行加密。 有了.NET,人们就可以轻而易举地拿到钥匙。
I would like to use NGEN.EXE
in order to generate native images of my assemblies before I create my installer. I am hoping this will keep my binaries Reflector
-proof. Am I correct about this?
I have just come to understand that all native images are now being stored in the Native Image Cache. Is there a way to get native binaries which I can then package with an installer? On the other hand, is it possible to get rid of the original assemblies after generating the native images?
EDIT: I am using an application which uses a hard-coded key for encryption when talking to a server. With .NET, it becomes ridiculously easy for folks to lay their hands on the key.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我可以看到你想要实现的目标存在几个问题。
1)正如 @Mehrdad 所提到的,即使存在本机映像,元数据仍然需要程序集。
2) 原生镜像仅在编译它的机器上有效。 JIT 编译器可以进行通常无法完成的优化,因为它确切地知道代码需要在什么硬件上运行。
3) 即使是原生镜像也可以被反编译。 使用托管 dll 稍微容易一些。
您介意告诉我们为什么要隐藏源代码吗?
编辑:
从 WGA 的每个新版本被黑客攻击的速度来看,我怀疑,如果您的软件远程有用,那么在您的软件每个新版本发布后的几个小时内,就会有人在互联网(或 p2p 或其他)上获取密钥,并且他们将是那些非常乐意拆解原生图像的人。 或者也许只是阅读机器代码:)
我个人的方法是确保您的应用程序运行良好并且价格合理。 诚实的人不会偷,不诚实的人无论做什么都会找到办法。 最终,如果他们要运行您的应用程序,您将无能为力来完全控制他们用它做什么,尽管您可以先使用混淆器使他们使用反射器变得稍微困难,但最终就像现实生活一样确实,锁只会挡住诚实的人。
当然,如果您可以将应用程序功能的某些重要部分从客户端移出并转移到 Web 服务中,那么您的机会就更大。 您可以使用客户端的用户名和密码创建帐户,应用程序在运行时会请求此帐户,并使用它对 Web 服务进行身份验证。 如果他们对该应用程序的使用已过期,则网络服务将拒绝他们的请求。
I can see several problems with what you trying to achive.
1) As has been mentioned by @Mehrdad the assembly is still required for metadata, even if a native image exists.
2) A native image is only valid on the machine it was compiled on. The JIT compiler does optimisations that normally cannot be done because it knows EXACTLY what hardware the code will need to run on.
3) Even a native image can be de-compiled. It is just slightly easier to take appart a managed dll.
Do you mind telling us why do you want to hide your source code?
EDIT:
Judging by how quickly each new version of WGA gets hacked, i suspect, if your software is remotely useful, someone will have the key out and on the internet (or p2p or whatever) within hours of each new version of your software, and they are going to be the people that are quite happy to disassemble a native image. Or maybe just read the machine code :)
My personal approch would be to make sure your application works well and is fairly priced. The honest people will not steal it, the dishonest will find a way regardless of what you do. Ultimatly if they have your application to run there is nothing you can do to completly control what they do with it, although you can make it slightly harder for them to use reflector by using an obfuscator first, but in the end its just like real life really, locks only keep out honest people.
Of course, if you can move some important part of your applications functionality out of the client and into a web service then you stand more chance. You can create accounts with usernames and passwords for clients, the application requests this when it is run and uses it to authenticate to the web service. If their use of this application has expired then the web service refuses their request.
NGEN 和 .net 框架非常不支持这一点,但有第 3 方工具可以做到这一点,谷歌搜索“.net linker”。
我建议不要这样做,微软有充分的理由不支持这一点。
This is very much not supported by NGEN and the .net framework, but there are 3rd party tools that can do this, google for ".net linker".
I recommend not doing it, MS have valid reasons for not supporting this.
您不能仅传送程序集的 ngen 映像。 即使它具有本机映像,运行时仍然需要实际程序集存在。 原因是程序集元数据未转移到本机映像。
You cannot ship only the ngen image of the assembly. The runtime still requires the actual assembly to exist even when it has a native image of it. The reason is the assembly metadata is not carried over to the native image.
获取软件列表:
这些是混淆器+链接器。
Get this list of software:
These are obfuscators+linkers.
没有理由应该使用本机映像。 这个工具是为了加快开发速度而设计的。 它不是一个应用程序,它是一个映像,因此更改计算机 CPU、点网配置将使您的映像无效,因此它实际上不可用。
破解你的软件是可能的,任何软件都可以破解,还有哪些软件不能破解?
不要关心盗版,假设它存在:)
There's no reason why you should use Native image. This tool is made for developement to speed up things. It's not an application, it's an image so changing Computer CPU, Dot net configuration will make your image non valid, so it's not really usable.
Cracking your software is possible, any software is cracked, there is ones that weren't?
Don't care about piracy, suppose it exists :)