如何使软件在 Windows 上的某个日期到期?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1211817/
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
How to make software expire on a certain date on Windows?
提问by Paul
I have a piece of Windows/C++ application which includes a hard coded expiry date, so that the release expires and stops running on a certain date like, 30 of august 2009.
我有一个 Windows/C++ 应用程序,其中包含一个硬编码的到期日期,以便该版本在某个日期到期并停止运行,例如 2009 年 8 月 30 日。
Obviously the user can take back the system time to work around this limitation.
显然,用户可以收回系统时间来解决此限制。
Is there a good way to stop my application running if the date has passed even though the user has taken the system date back ?
即使用户已将系统日期取回,如果日期已过,是否有一种好方法可以停止我的应用程序运行?
P.S. I can not make use of an internet connection for this purpose. And I believe writing the last execution time to a file/registry would also be too easy to break.
PS 我不能为此目的使用互联网连接。而且我相信将上次执行时间写入文件/注册表也太容易破坏了。
Thanks.
谢谢。
Paul
保罗
回答by DanDan
Whatever you do will be cracked, so you are better off concentrating on your software rather than the protection. Keep it simple. If people are determined to get around your protection they will. They could even virtual machine it, so day trials are not really a limitation that can be enforced.
无论你做什么都会被破解,所以你最好专注于你的软件而不是保护。把事情简单化。如果人们决心绕过您的保护,他们就会这样做。他们甚至可以对其进行虚拟机处理,因此日间试验并不是真正可以强制执行的限制。
回答by Timbo
To make the expiration date a little bit more difficult to avoid, you could store the time of the most recent execution somewhere "hidden" and make sure the user can not go back in time. Any decent "hacker" will get around this, but for joe the average user it will be too much of a hassle.
为了使到期日期更难避免,您可以将最近执行的时间存储在“隐藏”的某个地方,并确保用户无法及时返回。任何体面的“黑客”都会解决这个问题,但对于普通用户来说,这太麻烦了。
Working with a wrong date has some bad side effects when using other programs that rely on the correct date/time. So when the user is desperate enough to change his date/time every time he starts your software, he wont buy it anyway...
当使用依赖正确日期/时间的其他程序时,使用错误日期会产生一些不良副作用。因此,当用户每次启动您的软件时都非常渴望更改他的日期/时间时,他无论如何都不会购买......
Improving the expiration mechanism further is just like copy protection for games at this point. Good games sell anyway, bad ones don't.
在这一点上,进一步完善过期机制就像游戏的版权保护一样。不管怎样,好游戏卖,坏游戏卖不出去。
回答by Vargas
You can store the first and last execution date in a file and also store a salted checksum of it. As @Timbo said, any decent hacker will get around this (as he would with practically any other method).
您可以将第一个和最后一个执行日期存储在一个文件中,还可以存储它的加盐校验和。正如@Timbo 所说,任何体面的黑客都会解决这个问题(就像他几乎使用任何其他方法一样)。
Like this, you can store something like this in a file anywhere (maybe in the register)
像这样,您可以将这样的内容存储在任何位置的文件中(可能在寄存器中)
20090801:20090815:20090901
ca5579e3bacb7557b6ed22b5f553f9d5
being:
存在:
20090801 - the start date
20090815 - the last execution date
20090901 - the final date
ca5579e3bacb7557b6ed22b5f553f9d5 - the salted MD5 checksum
this way you can check the validness of the checksum using an algorithm like this
这样你就可以使用这样的算法检查校验和的有效性
bool CheckExpiry()
{
string SecretSalt = "Y*##d3F!@g^hk";
string InitialDate = FetchInitialDate();
string LastExecutionDate = FetchLastExecutionDate();
string FinalDate = FetchFinalDate();
int Checksum = FetchChecksum();
string FinalString = InitialDate + ":" + SecretSalt + ":" + LastExecutionDate + ":" + FinalDate;
int InternalCheckSum = md5sum( FinalString );
return InternalCheckSum == CheckSum;
}
of course you can use SHA-1 or any other digest algorithm you like more. Just make sure you use a not easily guessable SecretSalt
.
当然,您可以使用 SHA-1 或您更喜欢的任何其他摘要算法。只要确保您使用不易猜到的SecretSalt
.
And you can check the LastExecutionDate
against the current date to check if the date was changed backwards.
您可以检查LastExecutionDate
当前日期以检查日期是否向后更改。
回答by Chathuranga Chandrasekara
In this case you can make some change in system when the application expires. In other words to get the application running the system date and not the system change should be there.
在这种情况下,您可以在应用程序到期时对系统进行一些更改。换句话说,让应用程序运行系统日期而不是系统更改应该在那里。
You can add a registry entry when it gets expired. or may be a deletion of a file.
您可以在注册表项过期时添加它。或者可能是删除文件。
And this is a previoud discussion initiated by me addressing a simillar problem. It will be possibly useful..
这是我针对类似问题发起的先前讨论。它可能会很有用..
回答by fnurglewitz
you can try to store (inside the code, not in a file) the expiration date md5summed, this may add some more "protection" from disassemblers. Hide the date check code inside some other critical function, don't write a specific function to do it. You could also edit the exe file on expiration, just to avoid the "change date" trick.
您可以尝试存储(在代码中,而不是在文件中)过期日期 md5summed,这可能会为反汇编程序添加更多“保护”。将日期检查代码隐藏在其他一些关键函数中,不要编写特定的函数来执行此操作。您还可以在到期时编辑 exe 文件,以避免“更改日期”技巧。