Ejemplo n.º 1
1
    private  string getMachineCode()
    {
        //      * Copyright (C) 2012 Artem Los, All rights reserved.
        //      * 
        //      * This code will generate a 5 digits long key, finger print, of the system
        //      * where this method is being executed. However, that might be changed in the
        //      * hash function "GetStableHash", by changing the amount of zeroes in
        //      * MUST_BE_LESS_OR_EQUAL_TO to the one you want to have. Ex 1000 will return 
        //      * 3 digits long hash.
        //      * 
        //      * Please note, that you might also adjust the order of these, but remember to
        //      * keep them there because as it is stated at 
        //      * (http://www.codeproject.com/Articles/17973/How-To-Get-Hardware-Information-CPU-ID-MainBoard-I)
        //      * the processorID might be the same at some machines, which will generate same
        //      * hashes for several machines.
        //      * 
        //      * The function will probably be implemented into SKGL Project at http://skgl.codeplex.com/
        //      * and Software Protector at http://softwareprotector.codeplex.com/, so I 
        //      * release this code under the same terms and conditions as stated here:
        //      * http://skgl.codeplex.com/license
        //      * 
        //      * Any questions, please contact me at
        //      *  * [email protected]
        //      
        methods m = new methods();

        ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor");
        string collectedInfo = "";
        // here we will put the informa
        foreach (ManagementObject share in searcher.Get())
        {
            // first of all, the processorid
            collectedInfo += share["ProcessorId"];
        }

        searcher.Query = new ObjectQuery("select * from Win32_BIOS");
        foreach (ManagementObject share in searcher.Get())
        {
            //then, the serial number of BIOS
            collectedInfo += share["SerialNumber"];
        }

        searcher.Query = new ObjectQuery("select * from Win32_BaseBoard");
        foreach (ManagementObject share in searcher.Get())
        {
            //finally, the serial number of motherboard
            collectedInfo += share["SerialNumber"];
        }

        // patch luca bernardini
        if (string.IsNullOrEmpty(collectedInfo) | collectedInfo == "00" | collectedInfo.Length <= 3)
        {
            collectedInfo += getHddSerialNumber();
        }

        return m.getEightByteHash(collectedInfo, 100000).ToString();
    }
Ejemplo n.º 2
0
        private static int getMachineCode()
        {
            // please see https://skgl.codeplex.com/workitem/2246 for a list of developers of this code.

            methods m = new methods();

            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor");
            string collectedInfo = "";

            // here we will put the informa
            foreach (ManagementObject share in searcher.Get())
            {
                // first of all, the processorid
                collectedInfo += share.GetPropertyValue("ProcessorId");
            }

            searcher.Query = new ObjectQuery("select * from Win32_BIOS");
            foreach (ManagementObject share in searcher.Get())
            {
                //then, the serial number of BIOS
                collectedInfo += share.GetPropertyValue("SerialNumber");
            }

            searcher.Query = new ObjectQuery("select * from Win32_BaseBoard");
            foreach (ManagementObject share in searcher.Get())
            {
                //finally, the serial number of motherboard
                collectedInfo += share.GetPropertyValue("SerialNumber");
            }

            // patch luca bernardini
            if (string.IsNullOrEmpty(collectedInfo) | collectedInfo == "00" | collectedInfo.Length <= 3)
            {
                collectedInfo += getHddSerialNumber();
            }

            // In case we have message "To be filled by O.E.M." - there is incorrect motherboard/BIOS serial number
            // - we should relay to NIC
            if (collectedInfo.Contains("To be filled by O.E.M."))
            {
                var nic = GetNicInfo();

                if (!string.IsNullOrWhiteSpace(nic))
                {
                    collectedInfo += nic;
                }
            }

            return(m.getEightByteHash(collectedInfo, 100000));
        }