Windows DLL 是否经过 Microsoft 签名? 我可以检测它们是否被第三方篡改吗?
我正在为我的软件实现锁定和复制保护系统。 我已经堵住了所有可能让别人破解我的锁的漏洞(嗯,这有点太乐观了,我知道!)但最后一件事是:
我听说破解者可以更改 Windows DLL,如 Kernel32.dll,其方式是我使用的 API 返回一个由破解者指定的值。 我需要阻止这种情况。
起初,我认为可以为我使用的每个 DLL 生成一个哈希值,然后根据客户端 DLL 的计算哈希值检查该哈希值,以查看文件是否已更改。 这是行不通的,因为不同版本的 Windows 有许多不同版本的 DLL,并且 Microsoft 提供的每个修补程序和 Service Pack 都可能更改该文件。
然后我意识到我可以检查文件的签名以确保它具有有效的 Microsoft 签名。 现在有两个问题:
- Microsoft 是否对 Windows DLL 进行签名? 我如何找到有关此签名的一些信息?
- 是否提供公钥来验证签名? 如何使用此密钥来验证文件?
任何演练都非常感谢。 我的应用程序是使用 Visual Basic.NET 编写的。
多谢你们。
I'm implementing a locking and copy protection system for my software. I've shut every hole that would allow someone to break my lock (well, that's a little too optimistic, I know!) but the last thing is this:
I hear crackers can change Windows DLLs like Kernel32.dll in a way that the API I use returns a value which is specified by the cracker. I need to prevent this.
At first I thought I could make a hash value for every DLL I use, and check that hash against the calculated hash of the client DLL to see if the file is changed. That won't work since there are many different versions of the DLL for different versions of Windows, and every hotfix and Service Pack provided by Microsoft could change the file.
Then I realized I could check the signature of the file to make sure it has a valid Microsoft signature. Now there are 2 questions:
- Does Microsoft sign Windows DLLs? How can I find some info on this signature?
- Is a Public key provided to validate the signature? How do I use this key to validate the file?
Any walkthroughs are greatly appreciated. My app is written using Visual Basic.NET.
Thanks guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
MS 确实对某些系统二进制文件进行了签名,具体取决于 Windows 和二进制文件的版本。 例如,如果您在 Windows XP 上检查 kernel32.dll:
您可以还使用 sigcheck 来执行诸如查找特定文件夹中所有未签名的二进制文件之类的操作,例如
我相信您的第二个问题的答案是“否”,尽管 MS 确实使用 根证书用于某些验证目的。 它不会在其 Windows 系统二进制文件中发布公钥,因为密钥对可以而且确实会发生变化。
但从根本上来说,如果你不信任操作系统,那么无论如何你都是fubar。
面对现实吧,您的应用将会被破解。 我的建议是只花 1% 的精力来减慢破解过程,99% 的精力花在创造值得破解的东西上。
MS does sign some system binaries, depending on the version of Windows and the binary. For example, if you check kernel32.dll on Windows XP:
You can also use sigcheck to do stuff like find all unsigned binaries in a specific folder, e.g.
I believe that the answer to your second question is "no", although MS does use root certificates for some validation purposes. It doesn't publish public keys in its Windows system binaries because the key pairs can and do change.
But fundamentally if you don't trust the OS, then you're fubar anyway.
Just face it, your app will be cracked. My advice would be to spend only 1% of your effort on slowing down the cracking process, and 99% on creating something that's worth cracking.
您是否要编写自己的加密例程以便自己验证签名,或者您是否要信任加密 API? 您打算使用加密 dll 上的签名来验证加密 dll 吗?
谁监视观察者?
您将想要编写自己的操作系统,并且您最好确保它不能在虚拟机中运行! 也许您也应该制作自己的硬件。
最终,你必须相信某些东西。 真的。 如果您不准备信任用户,请信任操作系统,因为如果您不信任它,您最终将滚动自己的硬件以使其“安全”。 是的,有人会破解你的软件——这几乎是不可避免的。 无论如何都要让它变得困难,但请记住,回报会减少(迅速!)
Are you going to write your own crypto routines so you can validate the signature yourself, or are you going to trust the Crypto API? Are you going to use signatures on the crypto dlls to validate the crypto dlls?
Who watches the watchers?
You'll be wanting to write your own operating system, and you'd better make sure it can't be run in a virtual machine! Perhaps you should make your own hardware hardware too.
Ultimately, you have to trust something. Really. If you're not prepared to trust the user, trust the OS because if you don't trust that, you're going to end up rolling your own hardware to make it 'secure'. Yes, someone will hack your software - it's pretty much inevitable. Make it difficult by all means, but remember that returns diminish (rapidly!)
其他答案说您可以检查磁盘上的副本是否未被修改。 您对内存中副本非常满意。
Other answers say that you can check that the on-disk copies haven't been modified. You're SOL for the in-memory copies.
不幸的是,检查 Microsoft 自己的 DLL 的数字签名,无论理论上是多么伟大的想法,在实践中都是完全没有意义的。 为什么? 你会问。 因为微软似乎并不愿意签署大量他们自己的系统DLL。
理论上,您可以使用 的版本这个C代码来检查可执行文件是否经过数字签名以及可执行文件是否完整/未更改,但是如果您实现它并检查可能加载到您的进程中的所有系统DLL,您将会非常失望。
例如,从加载到我的进程中的大约 50 个系统 DLL 中,以下主要库未签名!
Windows 8.1:
Windows 10:
正如您所见,他们短期内没有希望这样做。
所以是的......微软真为你感到羞耻!
PS。 错误代码
0x800B0100
=“主题中不存在签名。”
Unfortunately checking digital signatures of Microsoft's own DLLs, however great of an idea it could be in theory, is a totally moot point in practice. Why? You would ask. Because Microsoft don't seem to care to sign a big number of their own system DLLs.
You can theoretically use a version of this C code to check if an executable file is digitally signed and if the executable is intact/unchanged, but if you implement it and go through all system DLLs that may be loaded into your process you'll be greatly disappointed.
For instance, from about 50 system DLLs loaded into my process the following major libraries were not signed!
Windows 8.1:
Windows 10:
So as you see, there's no hope in them doing it any time soon.
So yeah.... SHAME ON YOU, MICROSOFT!
PS. Error code
0x800B0100
="No signature was present in the subject."