getEightByteHash() protected method

protected getEightByteHash ( string s, int MUST_BE_LESS_THAN = 1000000000 ) : int
s string
MUST_BE_LESS_THAN int
return int
Ejemplo n.º 1
0
        private static int 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.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();
            }

            return(m.getEightByteHash(collectedInfo, 100000));
        }
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));
        }
Ejemplo n.º 3
0
        private bool _IsValid()
        {
            //Dim _a As New methods ' is only here to provide the geteighthashcode method
            try
            {
                if (Key.Contains("-"))
                {
                    if (Key.Length != 23)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (Key.Length != 20)
                    {
                        return(false);
                    }
                }
                decodeKeyToString();

                string _decodedHash    = _res.Substring(0, 9);
                string _calculatedHash = _a.getEightByteHash(_res.Substring(9, 19)).ToString().Substring(0, 9);
                // changed Math.Abs(_res.Substring(0, 17).GetHashCode).ToString.Substring(0, 8)

                //When the hashcode is calculated, it cannot be taken for sure,
                //that the same hash value will be generated.
                //learn more about this issue: http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx
                if (_decodedHash == _calculatedHash)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                //if something goes wrong, for example, when decrypting,
                //this function will return false, so that user knows that it is unvalid.
                //if the key is valid, there won't be any errors.
                return(false);
            }
        }
Ejemplo n.º 4
0
Archivo: SKGL.cs Proyecto: windygu/SKGL
        private static int 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.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();
            }

            return m.getEightByteHash(collectedInfo, 100000);
        }
Ejemplo n.º 5
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);
        }