1

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.

Gopal
  • 10,888
  • 47
  • 141
  • 225

4 Answers4

3

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
  • 19,108
  • 6
  • 54
  • 94
1

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
  • 1,909
  • 2
  • 30
  • 41
0

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
  • 226
  • 1
  • 6
  • 23
  • 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 Nov 03 '09 at 12:32
  • 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 Nov 03 '09 at 12:32
  • so in this system, i can set the system date to one day after the exe release data, and run the software indefinitely? – Ross Jul 21 '14 at 14:51
0

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.

Community
  • 1
  • 1
MarkJ
  • 29,252
  • 4
  • 60
  • 104