views:

1116

answers:

9

I have an assignment, and it has (amongst others) two demands:

  • make an installer
  • make it so that if it is installed on one computer, anyone trying to run the same files on another computer will fail.

I'm using VS9 (2008) express, I think I can do the installer part, but I'm not sure how to do the "security" part. I don't need any hard to crack safety, just a dumb condition that will stop most uses from copying the files to another computer. (Like checking the MAC address).

Any ideas?

EDIT: I would very much want to check the MAC address. The thing is, I want the program finalized during installation. Meaning that after I install I can't move the program to another machine. It also does not have to be a very smart or difficult condition, just bare minimum.

I just don't know how to do it in the installation.

EDIT:
sorry guys, the deadline is too close so I'm giving up on this. It's sad I don't have the complete VS then I would be able to do it easily. :\

+6  A: 

First of all, come up with some function to generate a unique PC signature, like Windows does for activation.

Your installer will be creating this signature and writing it to a local file (better encrypted). You can create a simple console executable to generate this file and include that executable into your installer package, setting it up to run silently after the successful installation.

Your program when starting will be creating the signature again using the same algorithm and comparing it to the one created during installation. If the new signature is different from the original one or the signature file is missing, then exit without loading the UI.

ADDED: If you don't need it very complex, you can just choose a few unique values like the MAC address you suggested, maybe the hard drive serial number, mainboard serial number, concatenate them into a single string and generate the hash out of it.

This approach will allow for an unlimited number of copies to run (but each installation will only be workable on one single machine where it was installed). If you stick to the identification by hardware (or OS product key as well), then the application can run on various OS installations on the same machine.

This strategy, however, implies that you control all installations (or perform them yourself) or absolutely trust your client not to install additional copies elsewhere or distribute your installer. If you need that kind of protection as well, then you should consider product activation. It can be quite complicated if you do it yourself. There are however third party products to help you. Some offer product activation services: Google: activation service

User
can't they just do copy the file too?
Nefzen
@Nefzen if the file is unique to the computer (i.e. generated by using hardware data), that will not match the computer it is copied to.
Serhat Özgel
The signature must be different for each PC (unique). When copied the check will fail, since the generated signature is different from the one in the file. The tricky part is to generate the unique signature.
Burkhard
They can, but the file will be unique for every hardware setup. And the file can only be generated by the installer. So if they can't copy the hardware and they don't have the installer, it's not gonna work. Then the only option left will be disassembling/cracking your executable.
User
ok then, how do I create the file for each installation?
Nefzen
you could do as BlodBath suggested, with the windows product key
Burkhard
+7  A: 

If you're looking for some way to mark the first computer as the "authorized" computer, then you need some external service you can ask for permission to launch.

The first person to ask permission would be allowed, the rest would be prevented.

You'll also need to come up with some way of identifying a particular instance of your application that's different for every install.

If your app needs to be authorized for the machine, then you will need to calculate some fingerprint for the machine it can use each time (eg across installs).

[Edit] This approach is useful when you're worried about copies of the installer being distributed as well. You did specify that its ok to install on multiple machines, so in that case MasterMind's approach is superior. It will work, and does not requires a 3rd party server

[Edit 2] If you're looking for info on how to build a custom installer, try here

Nader Shirazie
most useful, however I have the VS express edition. bah.
Nefzen
A: 

I like the idea of checking the MAC address.

I have also seen product key/online activation combinations where you enter the product key and the software contacts a web service that logs the product key and # of installs.

Andy Webb
+5  A: 

Once you have a decent fingerprint, the rest is easy. Personally I'd take something like the MAC address and the windows product ID (at HKLM\Software\Microsoft\Windows\CurrentVersion\ProductId) and use a hashing algorithm to get something reasonably obscure.

edit:

Here's a question that shows you how to get your MAC address as a string: http://stackoverflow.com/questions/218284/read-mac-address-from-network-adapter-in-net

Then grab your windows product ID (in case they don't have a network adapter) from the above registry key. Concatenate both strings and do a GetHashCode() (or use your favorite hashing algorithm) on the result. This is a simple way to get a UID for a computer.

Write the hash to a file or to a registry entry when your installer is executing and check it when your program starts up.

Ron Warholic
+2  A: 

Consider using two or more values that potentially identify the machine, e.g.

  • Windows product code
  • Volume serial number of the C: drive
  • MAC address of an ethernet interface

And if just one of these changes but the others match, update that one value in the registry and continue running normally. Hard drives get replaced (regularly), Windows gets upgraded (occasionally), Ethernet adapters get replaced (rarely but it does happen.) It can be very frustrating when old software stops working because of this.

finnw
+1 for considering maintenance and long term use of the software
Nader Shirazie
Goog points, but please, don't hardcode anything to a C-drive. Not every system has one. My current machine starts with drive H:. Big software packages handle it perfectly well, but it's mostly the small shareware programs that usually crap their pants when they can't do whatever they're trying to do on C:.
Wouter van Nifterick
A: 

This isn't the most secure option or anything but you did say it didn't have to be smart...

On install, you could set a program variable to be the machine name (or a hash of it if you like).

Like:

myProgram.Properties.Settings.Default.Machine = System.Environment.MachineName;
myProgram.Properties.Settings.Default.Save();

then check that on startup:

if (System.Environment.MachineName != myProgram.Properties.Settings.Default.Machine)
{
    MessageBox.Show("Can't run on this computer");
    this.Close();
}
SnOrfus
+2  A: 

Bare minimum answer, assuming the only requirement here is that the software should run if installed through the installer, and won't run if copied to another computer:

Write a simple key to the registry. Most likely your product's version number, incase they copy a newer version to the computer, it has a different number to check for.

In your software, just make sure this registry value exists.

For packaging installations, I enjoy using NSIS which has simple methods for writing to the registry.

Will Eddins
+1 for useful info on deployment
Nader Shirazie
+1 for providing the simplest, reasonable answer.
Brian
A: 

-1 for clinging to an antiquated license-restriction policy that is a poor practice in general. Hardware dongles and "device detection" are SO 1990.

People own more than one computer. They buy new computers. They upgrade their computers. Computers break, resulting in replacement of motherboards or network cards.

All of these, given your design, will result in honest, paying customers being locked out of what they've paid for and will have to call you for support to "reset" their activation.

And each time you do so, your overhead will increase by, very likely, more than the actual cost of a license.

I'm not suggesting you give up and just send your app off to the torrentverse, but you should think more creatively about how to allow customers the freedom to use what they paid for, keep your support costs low, and discourage pirates.

One creative solution would be to cache the user's settings on your server, keyed by their serial number, and synchronize them every time the application starts and is connected to the Net.

This will allow a user to install the app on, say, both a laptop and desktop, and will actually be a value-add for customers because their settings are synchronized between devices.

But it actively discourages users from sharing their license key, since doing so would mean they would be sharing their settings with every pirate user, or that they would have to remember to stay disconnected from the Interwebs when they open or close the app.

richardtallent
-1: It's a school project and those are his requirements.
SnOrfus
@richard: From a practical standpoint, allowing some types of programs to run after being moved is a bad idea even if it is not being done for licensing reasons. Of course, they'll usually just crash or otherwise fail with confusing errors when their configuration information is missing, but actually detecting it and providing an error message would be ideal. @SnOrfus: -1, Ditto.
Brian
A: 

To get the installer to only work for one machine, you'd pretty much have to build it for the target machine. I dont think it would be possible to make an installer that assumes the first machine it sees is it's mommy and is attached for life.

Neil N