1

I have a license file that I wish to invalidate if any program other than ours reads the file. My idea is to use File.GetLastAccessedTime(string) and save this value off to the file to be checked when we read the file back in.

However, I am afraid that aside from anti-virus (customers will have to exclude our license file from a scan, I know), there might be windows services or programs that might touch the files and cause the LastAccessed attribute on the file to be updated outside the context of our program, but without malicious intent.

What Windows' programs or services might access this file in the background? Is this a legitimate problem I need to worry about? And if this is something I should be worrying about, are there any common techniques to reliably achieve my end goal?

I am looking for a solution in the .NET 4 world. Thanks in advance for any help with this.

codewario
  • 19,553
  • 20
  • 90
  • 159
  • Backup software? Explorer's properties page? – Gabe Jan 24 '13 at 21:57
  • Yeah after some more deliberation with other team members, we might just cut our losses with this. Our customers aren't the type to mess around with installation files anyways, they just want the software to work. 9/10 times if they screw with the file anyways they will just end up breaking the license, this is something I wanted to take care of for one obscure use case. – codewario Jan 25 '13 at 19:02

1 Answers1

5

ANy desktop search app. Any virus they get. WIndow's find in files application. All anti-virus and anti-malware tools. A better idea is to cryptographically sign the file to detect alteration of contents, or not to leave a file you're that worried about on the client's machine (download it and use it in ram only).

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • 3
    +1. You can add "any app they want to write that will set the last accessed time to a value they want" to your list. Such a program is trivial to write, and would easily bypass this protection technique. – Ken White Jan 24 '13 at 21:23
  • 2
    I have that program on my hdd right now, it is called AttributeMagic – Kitet Jan 24 '13 at 21:26
  • Well I already protect against modifying the contents of the file, and encrypt its contents. My concern is stopping someone from copy/pasting in an older version of the license file after the file has been modified. In this case, the file should invalidate but under certain circumstances when copying files, the FileCreated and LastModified attributes will still match up with what is stored off in the file. This does answer my question though, it seems I'm attacking this issue all wrong. – codewario Jan 24 '13 at 21:40