7

How can I make a 30-day trial for my application? I need to allow users to use an application only 30 days. How to count these days?

I keep the first and the last date in registry. But if to change a system time - no protection will be. I need to count these 30 days.

bummi
  • 27,123
  • 14
  • 62
  • 101
maxfax
  • 4,281
  • 12
  • 74
  • 120
  • 1
    Maybe you should read about how some of the actual 3rd-party softwares do that. Try find something about ASProtect, Armadillo, WinLicense, etc... – EMBarbosa Aug 05 '11 at 17:47
  • I found this article if it will help anyone else http://edn.embarcadero.com/article/27385 – Dave Apr 11 '19 at 12:25

10 Answers10

7

You could probably come up with a system that requires an internet connection, but without something that the user can't tamper with, I don't see a solution.

Any solutions that rely on an untrusted element (an element of the protection that is under the user's control) is critically weak.

The simplest way I can think of to protect against the user moving the clock back is to limit the total number of launches.

However, attempts to limit the number of launches requires persistence -- saving data to the disk, perhaps encrypting and storing a modified version of your activation data file -

Imagine that you count one of the 30 days as "used up" once the app has been launched, on a unique occasion, even when the same date is re-used. In order to avoid using up more than 1 "activation time day" when launched, the user must allow your software to re-save its activation file each time it runs.

To block that approach, the user needs only to keep the apparent date from changing, plus they must either prevent you from storing anything to disk; or they can simply track and record your changes and reverse them out, either using a monitoring process, or using VMWare snapshots. About VMWare snapshots, you can do nothing. The virtual machine's disk is not under your control.

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • +1; to protect the 30-day trial expiration locally is really needed to have a magic wand or have a sophisticated hardware key licensing. –  Aug 02 '11 at 21:20
4

You can protect your app of users setting the clock back simply by storing in the registry the date of last execution.

Each time the app is started you need to do the following:

  • Check current date (as reported by the system clock) against the stored last execution date and, if current date is earlier than the last execution one, consider that the trial period has expired (or whatever you prefer).
  • If the previous check is ok, save the current date in the registry and continue execution.

As WarrenP says, any technique storing information locally can be easily circumvented using VMware snapshots.

And anyone, including those who check via internet, can be skipped via assembler level hacking.

JRL
  • 3,363
  • 24
  • 36
4

Here's a discussion on Shareware trial enforcement with Delphi: Best Shareware lock for Delphi Win32 Along with discussions on various 3rd-party solutions, techniques for DIY, etc..

IMO, DIY is feasible if your app produces data that the user will want to keep around, then you can simply embed a copy of the usage/day counter in the database in such a way that they can't wipe it without destroying their data. I also like watermarking (printing "trial" on reports, etc..), escalating nag severity, but I do not recommend or condone "drop-dead" crippling until WAY past the expiration data. I also like to measure "days of actual use", instead of using a calendar.

Registry manipulation works, and many of the 3rd-party protectors use it. But you need to be stealthy, and keep backups in several locations simultaneously.

You should also consider having separate trial and registered versions. But also consider that pirates will buy the registered version with a stolen card, and put it on Rapidshare, BitTorrent, etc..

Also note that elaborate defenses lead to support headaches. Sometimes PCs crash and the clock gets set backwards. They install new harware. PCs get rebuilt, restored from backup, etc.. If a user is running a debugger, he may be a software developer, not a pirate. If your app looks like it has been patched, it may be an overly-aggressive antivirus. And at any time, a shoddy patch for Windows may cause your program to think that it's being attacked, hacked, or reverse-engineered. You have been warned...

Community
  • 1
  • 1
Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
3

Encrypt a date and store it in registry the best way to do it is that date to be stored by the installer itself and if the date doesn't exist the application should quit.

opc0de
  • 11,557
  • 14
  • 94
  • 187
  • Thanks! I do it already! If to change a system time - no protection will be! I need to count these 30 days too – maxfax Aug 02 '11 at 17:47
2

There is an open source project (which was a commercial product before):

TurboPower OnGuard is a library to create demo versions of your Borland Delphi & C++Builder applications. Create demo versions that are time-limited, feature-limited, limited to a certain number of uses, or limited to a certain # of concurrent network users.

I have not checked which Delphi versions are supported.

mjn
  • 36,362
  • 28
  • 176
  • 378
  • Thanks! I have it :) It works for Delphi 2010. I have own specificity, and I have written my protection. I need only to count days. – maxfax Aug 02 '11 at 18:23
  • There is a OgDaysCode component in TurboPower OnGuard. But it is not really good (it counts days wrongly), and it uses INI, I use registry – maxfax Aug 02 '11 at 18:42
  • And it is trivial to defeat either INI or Registry based day counting systems. – Warren P Aug 02 '11 at 20:13
1

If you keep your trial info in registry, the registry could be deleted by the user. Evey one expects to find the registration info there.

There is one place where the user might not think to look into: your own app (EXE file). Put an ANSI string constant (MUST by ansi/ascii or other 1 byte string, static array, etc) into your program, like 'xyxyxyxyxyxy'. Compile your app. Open your complied app with a hex editor. Search for that string. Now your program could use that area to store the trial info into itself.

Use this method in conjunction with others: store your info in registry also, on disk, etc.

Anyway, the best would be to get the registration info from your server. The big drawback: 1. The server must be ALWAYS online! 2. The user must be connected to internet (when it uses your app).

Also use a Delphi license management library to help you encrypt the license info and generate a string-based key that you can send to your customers upon registration.

Anyway, whatever you send to your server needs to be based on the hardware fingerprint of that computer. Otherwise your license key will leak out on some warez website and everyone will be able to use that key. But if the key is hardware-based it would be useless if it is leaked on Internet.

Just remember: don't over do it! There is no such thing as unbreakable software protection. Microsoft could not do it!

Gabriel
  • 20,797
  • 27
  • 159
  • 293
1

For this kind of "protection" and some others, I have used TmxProtector (open source) from MaxComponents in the past with good results. From the link provided:

The TmxProtector is a software protection component. It was designed for quick implementation of application protection functions. You can create time-trial and password protected applications. You can set the maximum number of execution, and it can work with registration keys as well.

This compoment uses very simple encryption to store the expiration date in the registry and it provides some simple detection for tampering on the system date.

yms
  • 10,361
  • 3
  • 38
  • 68
1

It sounds like you need to store the date the last registry entry was written. Then inside your program, test if the current date is less than the date last registry entry was made. If true display a message that the trial period has expired and the program must be purchased.

  • Except that the OP has realized that this is easily avoided by playing with the clock, plus reverting the changes to the registry. Try it yourself. Anything you can come up with that relies on local persistence, can easily be circumvented. – Warren P Aug 03 '11 at 13:37
  • I did. I installed Delphi 2010 and then two days later set my clock back. Nex time I launch Delphi, it said my trial period had expired. and wouldn't run. Setting my clock back to todays date had no effect. If you try this with one of Embarcader's products, I recommend you do it on a non production machine. – Michael Riley - AKA Gunny Aug 03 '11 at 17:54
  • So Embarcadero gets full marks for making trials as good as they can be made. I expect they use a hidden registry key to mark the trial as "bogus". – Warren P Aug 04 '11 at 02:04
  • But did you revert the changes in the registry? I just disagree with @Warren only in one word: _easily_. – EMBarbosa Aug 04 '11 at 12:02
  • @EMBarbosa - No. From now on I intend to take a snapshot of the registry before I install software and then take another snapshot after the install. Then I can do a file compare to find out what differences exist. Warren - They must do something like that. – Michael Riley - AKA Gunny Aug 04 '11 at 12:38
1

Here are some ideas on how to deal with clock changes during the trial period:

  1. Save both the date of first and the date of the last program start. If the date of the last program start is greater than the current date, then the user has moved the clock back. I simply increase a day and save the new date as the date of last start. You can of course decide to just end the trial.

  2. To try to defeat trial bypass programs (RunAsDate for example) which run your application by setting the date and time to a specific value, you can instead of getting the date via the usual Delphi way (Date, Now), get, for example, the last modification date of NTUSER.DAT.

  3. Save your trial data on two separate locations, either two registry locations, or file and registry. This way even if the user deletes one of the trial data locations, you'll still have a backup one to use.

smartins
  • 3,808
  • 7
  • 42
  • 54
0

As the thread pointed to mentioned, I encourage you to look into WinLicense: http://www.oreans.com.

I've been using it for quite some time and it handles trial periods quite well. It also handles licensing, customer lists, etc.

Tom

RobertFrank
  • 7,332
  • 11
  • 53
  • 99