B4J Question time-based license

If I have an offline application whose license is time-based, for example, it will run for the user only for one month and after one month it will give a notice to purchase a subscription.
Let's assume that the method is to use the UNIX_timestamp of now and the UNIX_timestamp of one month later, how can I make sure that the user has not set the system clock back?
 
I have anti-virus software that I downloaded as a trial, but when I installed it I set my clock forward 20 years. Now the trial doesn't expire until 2043.
If you are supplying an app that uses a time based licence, how do you prevent the user from simply changing the clock to work around your licence terms?
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I had this problem many years ago. I solved it by saving the installation time-stamp in the Windows Registry - hiding it in the Microsoft hive. That solution is still working today, but unfortunately it is not one that you can use easily from Java.

In this same situation now in B4J I would construct a folder in the User\Roaming\Microsoft folder, give it some innocuous name, and put the installation date-stamp in there. How many users are going to examine their Roaming folder (how many know where or what it is?) and risk deleting some folder at random?
B4X:
    ' Save timestamp
    File.WriteString(File.DirData("Microsoft/Reference"), "Source", timestamp)

As a probably unnecessary further step to avoid detection I encoded the time stamp to look like a GUID.
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
I had this problem many years ago. I solved it by saving the installation time-stamp in the Windows Registry - hiding it in the Microsoft hive. That solution is still working today, but unfortunately it is not one that you can use easily from Java.

In this same situation now in B4J I would construct a folder in the User\Roaming\Microsoft folder, give it some innocuous name, and put the installation date-stamp in there. How many users are going to examine their Roaming folder (how many know where or what it is?) and risk deleting some folder at random?
B4X:
    ' Save timestamp
    File.WriteString(File.DirData("Microsoft/Reference"), "Source", timestamp)

As a probably unnecessary further step to avoid detection I encoded the time stamp to look like a GUID.
How Do you check this
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I had not really thought about that, but I don't think it is difficult. I would try and read the file in AppStart ...
B4X:
Dim s As String = ""
If File.exists(File.DirData("Microsoft/Reference"), "Reference") Then
    s = File.ReadString(File.DirData("Microsoft/Reference"), "Reference")
End If

If "s" is empty then I would assume that this was the first run and create the timestamp file. If "s" is not empty then I would extract the timestamp and compare with the current DateTime and decide if the trial period has expired.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
... how do you prevent the user from simply changing the clock to work around your licence terms?
I realise that my answer did not specifically address this question from the earlier post so, just to be clear, here are some further notes.

When the application is first installed it records an obfuscated expiry date (thirty days beyond the current system date) in a hidden location. On subsequent runs it retrieves that expiry date and compares it with the current system date. If the expiry date is earlier than the current date then the trial period has expired and a dialogue is shown. If the system date is more than thirty days prior to the expiry date then the user is trying to beat the system and again a dialogue is shown and the application is stopped.

The user could still try to fool this check by setting the system date back every time the application is started, but this is inconvenient. This ploy could be countered by testing the expiry date at regular intervals while the application is running, so that the user would have to keep the system running with the incorrect system date. This would affect other applications running at the same time, and specifically time stamps on any modified files, which could interfere with backup systems. If the user is prepared to risk that then maybe they deserve to get a free pass.

This technique has been used on an application priced at over one hundred UK pounds for more than fifteen years without any problem. I did go further and save the installation data in more than one hidden place so that if one was discovered and changed the tampering would be detected, but I doubt that this feature was ever exercised.
 
Upvote 0
Top