Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get something unique about a computer in order to create a free trial

Tags:

c#

I know there are several ways of creating a free trials. My algorithm that I have thought is as follows:

  1. get something that identifies the computer where the application is installed. lets say I chose to get the windows product ID which may look something like: 00247-OEM-8992485-00078.

  2. then hash that string and say I end up with the string: ckeer34kijr9f09uswcojskdfjsdk

  3. then create a file with random letters and numbers something that looks like:

    ksfjksdfjs98w73899wf89u289uf9289frmu2f98um98ry723tyr98re812y89897982433mc98lpokojiaytfwhjdegwdehjhdjwhbdwhdiwhd78ey8378er83r78rhy378wrgt37678er827yhe8162e682eg8gt66gt.....etc

  4. then on the file that was random generated find the second number (in this case is 8) also find the last number (in this case it is 6) now multiply those numbers and you get 48: then that will be the position where I will start putting the hash string that I got which if you recall was: ckeer34kijr9f09uswcojskdfjsdk so the 48 character of the file happens to be a 'f' so replace that 'f' with the first character of the hash string which is c. so replace the f for c. then move two characters to the right to possition 50 and place the next hash string character etc...

  5. I could also encrypt the file and unencrypt it in order to be more secure.

  6. every time the user opens the program check that file and see if it follows the algorith. if it does not follow the algorithm then it means it is not a full version program.

so as you can see I just need to get something unique about the computer. I thought about getting the windows product key which that I think will be unique but I don't know how to get that. Another thing that I thought was getting the mac address. But I don't think that it is efficient because if the user changes it's nic card then the program will not work. Any information that is unique about the computer will help me a lot.

like image 222
Tono Nam Avatar asked Aug 30 '11 13:08

Tono Nam


People also ask

How do trial programs know they have been on your computer before?

Typically using the computer's HWID (Hardware ID). An HWID is a unique ID based on a computer's specifications, such as its CPU model, OS, GPU model etc. All these factors combined, and more, create a unique ID based on the computer's hardware. One of the software in my computer is not being unstalled perfectly.

How does trial version software work?

A trial version is a fully-functioning copy of the product, but will only run for some period of time (frequently 30 days). At the expiration date it stops running or degrades in performance.


2 Answers

Everything just described is easily bypassed by someone willing to spend an hour working through it and writing a "hack".

Also, the Windows Product ID is not unique. Quite frankly, there is not a "unique id" for any computer. ( How to get ID of computer? )

I'd say, keep it simple. Just create a reg key with an encrypted date / time for expiration. Read the key on each program launch to determine when it should expire. Yes, this is just as easily hacked as before. However you won't spend a lot of time coming up with an uber complicated algorithm that is just as easy.

The point is, the Trial method is there to simply keep honest people honest. Those who are going to steal your application will do so regardless. So don't waste your time.

All of that said, I'd recommend that you don't even bother. Again, people who want to steal your app will. People who will pay for it will go ahead and pay. Instead of a time limited trial, change it to a feature limited app and give it away. If people want the additional features, they can pay for and download the unlocked version. At which point you give them some type of ID to put into the installer.

like image 194
NotMe Avatar answered Nov 08 '22 11:11

NotMe


I know a lot of companies use the MAC address for this. I'm not sure what pros and cons there are to this approach, but it's worth looking into.

I believe you can use a method like this to get the MAC address:

/// <summary>
/// returns the mac address of the first operation nic found.
/// </summary>
/// <returns></returns>
private string GetMacAddress()
{
    string macAddresses = "";

    foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
    {
        if (nic.OperationalStatus == OperationalStatus.Up)
        {
            macAddresses += nic.GetPhysicalAddress().ToString();
            break;
        }
    }
    return macAddresses;
}

This SO question discusses it in detail: Reliable method to get machine's MAC address in C#

EDIT

As others have pointed out, MAC address is not guaranteed to be unique. After doing a little more research, there are a couple of other options which might work better. The two that stuck out to me are:

  • Processor Serial Number
  • Hard Drive Volume Serial Number (VSN)

Get processor serial number:

using System.Management;

public string GetProcessorSerial()
{
    ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
    ManagementObjectCollection managementObjects = searcher.Get();

    foreach (ManagementObject obj in managementObjects)
    {
        if (obj["SerialNumber"] != null)
            return obj["SerialNumber"].Value.ToString();
    }

    return String.Empty;
}

Get HDD serial number:

using System.Management;

public string GetHDDSerial()
{
    ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");    
    ManagementObjectCollection managementObjects = searcher.Get();

    foreach (ManagementObject obj in managementObjects)
    {
        if (obj["SerialNumber"] != null)
            return obj["SerialNumber"].ToString();
    }

    return string.Empty;
}
like image 5
James Johnson Avatar answered Nov 08 '22 12:11

James Johnson