tags:

views:

93

answers:

4

Using VB6

I want to compare the system date, if the exe should not work after 02/11/2009

vb6 code

Dim dte As Date
dte = DateValue(Now)
'MsgBox DateValue(Now)
If dte > DateValue("01/11/2009") Then
Unload Me
End If

But if the user change the system date, it will work, my exe should not work after 10 days. How to set.

Need VB6 CODE Help.

+3  A: 

There is no 100% secure way of doing this. Usually software doing that encrypts the date into some obscure registry key. But is not in accord with Kerkhoffs' principle.

Generally speaking you would have to persist the installation or first run date somewhere on the system (where users cannot easily modify or delete it) to compare it to the current system data. Beside this you shall protect your program against tampering attacks.

To protect against system time changes there is also no 100% good solution. An easy one would be to look at some files in the profile of the user and take the newest one. If this time is later than the current system time (with some delta), then someone manipulated the datetime settings.

All this is worth almost nothing, as it is really easy to workaround such a protection (even without deep programming knowledge). I would consider a solution in limiting the functionality of your program and protecting your code against tampering (what you have to do anyway, no matter what you choose as a solution).

jdehaan
I modify my question, please check
Gopal
A: 

I my opinion, it is possible just save time difference between your exe release date and future locking date. If user system clock is set back than release date give user to set it right and then simply check if exe is running before future locking date. I think you got it……

OliveOne
Yes even again you can save first instance of exe opening date with some encryption in file. also you need to some id (based on IP or network card physical address)
OliveOne
not if you set the date at the start of the valid range... then you just would have to reset the date all 9 or 10 days...
jdehaan
A: 

Software copy protection is a big subject, and there's many possible approaches, from commercial libraries and hardware keys, to "roll your own" like you're suggesting.

I advise you read some of the other discussions on copy protection on Stack Overflow. E.g. this or this or this.

MarkJ
A: 

The amount of effort to implement a truly robust date-based protection system is not proportional to the protection provided.

In any case, the last scheme I used seemed to work. I stored the last run date and number of days left in some obscure registry keys. Each time the app started I checked that last run date key was still in place and had a valid value and I checked the number of days left. Both these values were stored encrypted. To add a level of confusion I read and wrote a number of garbage keys in more obvious locations.

The trial expired if I found evidence of tampering such as changed garbage keys, a current date that was older than the last run date and a few other things.

To slow down users trying to hack the software I encrypted the names of the registry keys in the code so they wouldn't be obvious when the exe was viewed in a hex editor.

Was all that effort worth it? Probably not. I suspect a lot less would have detered most casual crackers and the serious ones, well, they would have cracked it anyway.

Corin