我怎样才能proctect我对DLL劫持.NET应用程序?我对、应用程序、proctect、NET

2023-09-04 01:41:21 作者:清风冷月

我们有一个.NET 3.5的应用程序,注册扩展。我们如何保护它不受DLL劫持攻击?

We have a .NET 3.5 application with registered extensions. How can we protect it against DLL Hijacking attacks?

由于遗产和放大器;设计问题强命名/签名是不是现在的选项的

额外的信息,如果你不知道什么是DLL劫持是:

Extra Information if you don't know what DLL Hijacking is:

什么是DLL劫持 - SO DLL劫持漏洞 What's DLL Hijacking - SO DLL hijacking vulnerabilities

推荐答案

我曾碰到过类似的问题,我已经结束了写我自己的逻辑来验证该dll。对我来说,我只是使用DLL在LGPL的方式(我不能修改DLL),但希望确保我的应用程序使用真正的DLL(不喜劫持之一)。

I had came across similar issue, I had ended up writing my own logic for verifying the dll. For me I was just using that dll in LGPL fashion (I can't modify the dll), but wanted to make sure that my application uses the genuine dll (not the hi-jacked one).

简单的解决方案:

在开发应用程序在应用程序中创建DLL和硬code中的散列的MD5校验和 在每次启动该应用程序使用相同的逻辑来生成的dll文件的MD5校验和,并与硬codeD一比较。 您可能已经知道,但这里是如何有效地生成一个文件的校验和(请参阅回答: HTTP://计算器。 COM / A /三十九万二千八百五十〇分之一百十七万七千七百四十四)

更好的解决方案:

生成散列的dll,具有较强的散列算法和盐 在生成RSA键值对(私钥和公钥) 加密的DLL的哈希值与私钥 嵌入的公共密钥,加密散列和盐在应用程序 当应用程序启动时,加密散列解密用你的公钥 再次在运行时具有相同的盐生成散列,并比较使用公开密钥与解密的哈希

如果你从如Verisign信任的CA任何证书,您可以使用使用RSA密钥值对认定证书来代替。

If you have any certificate from trusted CA like verisign, you can use that certificate instead of using RSA key value pair.

这样即使有人用破解的DLL替换您的dll,哈希将不匹配,你的应​​用程序就会知道劫机企图。

This way even if someone replaces your dll with cracked dll, the hash will not match and your application will know the Hijacking attempt.

此方法可能比只给DLL好强的名字,因为,可能是强名称验证可以通过运行禁用

This approach could is better than only giving dll a strong name because, may be strong name verification can be disabled by running

SN -Vr HijackedAssembly

希望这可以帮助你,或某人谁想要了解的东西签名的数字是如何在内部工作。

Hope this helps you, or someone who wants to understand how digital signature things work internally.