如何从 c/c++ 中的 windows pc 获取唯一的硬件/软件签名

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/534215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:56:51  来源:igfitidea点击:

How to get unique hardware/software signature from a windows pc in c/c++

c++windowscopy-protection

提问by daniels

I'm developing a small windows app using c++ and i would like to get some kind of fingerprint of the software/hardware on a pc so that i can allow the app to be run only on certain pc's.

我正在使用 C++ 开发一个小型 Windows 应用程序,我想在 PC 上获得某种软件/硬件的指纹,以便我可以允许该应用程序仅在某些 PC 上运行。

I am aware that the app can be cracked but i'm really interested in implementing something like this.
Any ideas how could i achieve this?

我知道该应用程序可以破解,但我真的很想实现这样的东西。
任何想法我怎么能做到这一点?

回答by newgre

It basically depends on how tight you want to couple your software to the underlying hardware. For example you could get some hardware information from the registry, read out the MAC address from the LAN card, retrieve the gfx manufacturer, the CPU id, etc. and hash all these data.
You could then use this hash as a challengecode which is sent to your company. The customer then receives the signed (with your private key) version of this hash.
Upon start up your application is able to check if the signature of the hash is good or bad (i.e. has been signed by your company).
This not only binds your software to a certain hardware configuration, but also forces the crackers to patch your application (because they would need to patch the public key from your executable and replace it in order to write a keygen). Many people consider twice installing a crack obtained from various sources in contrast to just entering a valid serial copied from a keygen.

这基本上取决于您希望将软件与底层硬件耦合的紧密程度。例如,您可以从注册表中获取一些硬件信息,从 LAN 卡中读取 MAC 地址,检索 gfx 制造商、CPU id 等,并对所有这些数据进行哈希处理。
然后,您可以将此哈希用作发送给您公司的质询代码。然后客户收到此哈希的签名(使用您的私钥)版本。
启动时,您的应用程序能够检查散列的签名是好是坏(即已由您的公司签名)。
这不仅将您的软件绑定到特定的硬件配置,而且还迫使破解者修补您的应用程序(因为他们需要从您的可执行文件中修补公钥并替换它以编写密钥生成器)。与仅输入从密钥生成器复制的有效序列相比,许多人考虑两次安装从各种来源获得的破解。

Edit:
In order to check the signature of the hash, anything from RSAover DSAto ECCcan be used. I can recommend Crypto++or libTomCryptfor that.

编辑:
为了检查散列的签名,可以使用从RSAover DSAECC 的任何内容。我可以为此推荐Crypto++libTomCrypt

回答by Charlie Martin

There's no reliable way known to do this in a vanilla PC; people have been trying for years. The problem is that you might change any component at any time, including the CPU and the BIOS ROMs. The closest people have come is using a cryptographically protected "dongle" but that has proven both to be unsatisfactory in operation, and not very secure.

在普通 PC 中没有已知的可靠方法可以做到这一点。人们多年来一直在努力。问题是您可能随时更改任何组件,包括 CPU 和 BIOS ROM。最接近的人是使用受密码保护的“加密狗”,但事实证明,这两种方法在操作中都不能令人满意,而且也不是很安全。

If you come up with something, patent it; it would be very valuable.

如果你想出什么东西,就申请专利;这将是非常有价值的。

回答by Tim

As the others have said there is nothing perfect for what you want. I made a half-hearted attempt for a similar issue and ended up with a mix of drive volume ID (not good because it can be reformatted) and the OS key (from windows).

正如其他人所说,没有什么是完美的。我对类似的问题做了半心半意的尝试,结果混合了驱动器卷 ID(不好,因为它可以重新格式化)和操作系统密钥(来自 Windows)。

In the end I didn't spend much time on it as if people really want to crack your software they'll probably be able to do it. I left the dinky licensing "protection", but it is pretty poor.

最后我没有花太多时间在上面,好像人们真的想破解你的软件他们可能能够做到。我留下了极小的许可“保护”,但它很差。

Spend the time/effort on making them want to buy it by making it outstanding.

花时间/努力让他们想购买它,让它出类拔萃。