Friday, 1 June 2012

Tagged under: , , , ,

Generating a Unique Hardware Fingerprint for Software Licensing

Generating a hardware fingerprint is the most commonly sought technique to ensure security in case of softwares. There can be various methods of generating the hardware fingerprint, using different languages. However, the important thing to decide is, which devices to consider while generating the fingerprint.

For licensing purposes, the best and secure way is to generate a unique key for the client's machine and provide a corresponding license key for that key. The key can be generated using the unique id of the client's computer motherboard, BIOS and processor. When you get these IDs, you can generate any key of your preferable format.

In this post, I will get into the details of generating the unique fingerprint for the user's system.

Step I: Adding References:

First of all, you need to add the following references to your project.
1. System.Drawing
2. System.Management
3. System.Windows.Forms
For doing this, navigate to Project in the Menu Bar--> Add References-->.Net

Step II: Starting to Code

Add the following code at the start.
using System;
using System.Threading;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Resources;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Data;
using System.Drawing;


namespace Aj_fingerprint
{
    public class Aj_fp
    {
        public static void Main(string[] args)
        {
            Aj_Fingerprint f = new Aj_Fingerprint();
            string fp = f.Value();
            Console.WriteLine(fp);
            Console.ReadLine();
        }
    }


    public class Aj_Fingerprint
    {
        public string Value()
        {
            return pack(cpuId()+ biosId()+ diskId()+ baseId()+ videoId()+ macId());
        }
        
        private string biosId()
        {
            return identifier("Win32_BIOS", "Manufacturer")
            + identifier("Win32_BIOS", "SMBIOSBIOSVersion")
            + identifier("Win32_BIOS", "IdentificationCode")
            + identifier("Win32_BIOS", "SerialNumber")
            + identifier("Win32_BIOS", "ReleaseDate")
            + identifier("Win32_BIOS", "Version");
        }

        private string cpuId()
        {
            string retVal = identifier("Win32_Processor", "UniqueId");
            if (retVal == "")
            {
                retVal = identifier("Win32_Processor", "ProcessorId");

                if (retVal == "")
                {
                    retVal = identifier("Win32_Processor", "Name");


                    if (retVal == "")
                    {
                        retVal = identifier("Win32_Processor", "Manufacturer");
                    }

                    retVal += identifier("Win32_Processor", "MaxClockSpeed");
                }
            }

            return retVal;

        }

        private string diskId()
        {
            return identifier("Win32_DiskDrive", "Model")
            + identifier("Win32_DiskDrive", "Manufacturer")
            + identifier("Win32_DiskDrive", "Signature")
            + identifier("Win32_DiskDrive", "TotalHeads");
        }

        private string pack(string text)
        {
            string retVal;
            int x = 0;
            int y = 0;
            foreach (char n in text)
            {
                y++;
                x += (n * y);
            }

            retVal = x.ToString() + "00000000";

            return retVal.Substring(0, 8);
        }

        private string videoId()
        {
            return identifier("Win32_VideoController", "DriverVersion")
            + identifier("Win32_VideoController", "Name");
        }

        private string baseId()
        {
            return identifier("Win32_BaseBoard", "Model")
            + identifier("Win32_BaseBoard", "Manufacturer")
            + identifier("Win32_BaseBoard", "Name")
            + identifier("Win32_BaseBoard", "SerialNumber");
        }

        private string macId()
        {
            return identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled");
        }

        private string identifier(string wmiClass, string wmiProperty)
        {
            string fprint = "";
            System.Management.ManagementClass aj_mc = new System.Management.ManagementClass(wmiClass);
            System.Management.ManagementObjectCollection aj_moc = aj_mc.GetInstances();
            foreach (System.Management.ManagementObject aj_mo in aj_moc)
            {
                if (fprint == "")
                {
                    try
                    {
                        fprint = aj_mo[wmiProperty].ToString();
                        break;
                    }
                    catch
                    { }
                }
            }
            return fprint;
        }

        private string identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue)
        {
            string fprint = "";
            System.Management.ManagementClass aj_mc = new System.Management.ManagementClass(wmiClass);
            System.Management.ManagementObjectCollection aj_moc = aj_mc.GetInstances();
            foreach (System.Management.ManagementObject aj_mo in aj_moc)
            {
                if (aj_mo[wmiMustBeTrue].ToString() == "True")
                {
                    if (fprint == "")
                    {
                        try
                        {
                            fprint = aj_mo[wmiProperty].ToString();
                            break;
                        }
                        catch
                        { }
                    }

                }
            }
            return fprint;
        }


    }
}



Now, you can use this unique hardware fingerprint in further hashing, to authenticate the user system!!



You can for further assistance.

Kindly Bookmark and Share it:

2 comments:

  1. If your looking for Online Illinois license plate sticker renewals then you have need to come to the right place.We offer the fastest Illinois license plate sticker renewals in the state. antminer s5+ tutorial

    ReplyDelete
  2. Generating A Unique Hardware Fingerprint For Software Licensing ~ Ajinkya Mandhare >>>>> Download Now

    >>>>> Download Full

    Generating A Unique Hardware Fingerprint For Software Licensing ~ Ajinkya Mandhare >>>>> Download LINK

    >>>>> Download Now

    Generating A Unique Hardware Fingerprint For Software Licensing ~ Ajinkya Mandhare >>>>> Download Full

    >>>>> Download LINK nu

    ReplyDelete