 |
|
 |
Hi all, I want to use a Unique Id for my system, so that the software I am installing has only one user license. * It should avoid multi-installation on the same system. * I am using asp.net and vb.net as programming language Please advise.
|
|
|
|
 |
|
 |
I used the serial number of the mother board but it seems to be problematic when dealing with illegal windows machine, in which case the serial number you see is not the real serial number to cheat windows.
Anyway, I'd suggest using the MAC ADRS and not the mother board serial number
|
|
|
|
 |
|
|
 |
|
 |
You could use the MachineGUID value from the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid
This GUID is not actually universally unique and you will get duplicates. To get around this you can create and store your own. I ran into the same problem and wrote an article which covers the solution I found in detail :
http://www.eigo.co.uk/Machine-Universally-Unique-Identifier.aspx
I also pass my unique key to a central server to provide an unlock registration key to customers. It does not generate much support say 1 in 60 customers call up because then need to register off-line. We simply implemented a process to work around this where they need to read out a small hashed segment of the code for us to verify and then we send them an unlock code generated from it.
Hope this helps
Kurtz
|
|
|
|
 |
|
|
 |
|
 |
Hello guys,
I have created the following codeblock taking help from this article and elsewhere, may be it would be a good working version for getting a unique id for a machine ... check it and have some comments..
using System;
using System.Management;
using System.Net.NetworkInformation;
using System.Security.Cryptography;
using System.IO;
using System.Text;
namespace UniqueID
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine(GetUniqueID());
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
public static string GetCPUId()
{
string cpuInfo = String.Empty;
string temp = String.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == String.Empty)
{ cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
}
}
return cpuInfo;
}
public static string GetMotherBoardID()
{
ManagementObjectCollection mbCol = new ManagementClass("Win32_BaseBoard").GetInstances();
ManagementObjectCollection.ManagementObjectEnumerator mbEnum = mbCol.GetEnumerator();
mbEnum.MoveNext();
return ((ManagementObject)(mbEnum.Current)).Properties["SerialNumber"].Value.ToString();
}
public static string GetMacAddress()
{
string macs = "";
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in interfaces)
{
PhysicalAddress pa = ni.GetPhysicalAddress();
macs += pa.ToString();
}
return macs;
}
public static string GetVolumeSerial()
{
string strDriveLetter = "";
ManagementClass mc = new ManagementClass("Win32_PhysicalMedia");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
try
{
if ((UInt16)mo["MediaType"] == 29)
{
String serial = mo["SerialNumber"].ToString().Trim();
if (!String.IsNullOrEmpty(serial))
{
Console.WriteLine("Harddrive serial: " + (string)mo["SerialNumber"]);
strDriveLetter = (string)mo["SerialNumber"];
return strDriveLetter;
}
}
}
catch{}
}
return strDriveLetter;
}
public static string GetUniqueID()
{
string ID = GetCPUId() + GetMotherBoardID() + GetMacAddress() + GetVolumeSerial();
HMACSHA1 hmac = new HMACSHA1();
hmac.Key = Encoding.ASCII.GetBytes(GetMotherBoardID());
hmac.ComputeHash(Encoding.ASCII.GetBytes(ID));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hmac.Hash.Length; i++)
{
sb.Append(hmac.Hash[i].ToString("X2"));
}
return sb.ToString();
}
}
}
|
|
|
|
 |
|
 |
Hi,
I'm newbie in programming, so, forgive any mistakes
I've been working on this too. I needed to get a unique ID per machine that can't be changed.
I tried the CPUID, But it's not Uniue. The MAC can be changed.
The CPU Serial was good, but as I have read on the web, it's not there anymore after P3.
The Motherboard Serial Number seems fine. Here is the way:
The code above was inspired from:
- http://www.eggheadcafe.com/articles/20030511.asp
- http://bytes.com/forum/thread236091.html
|
|
|
|
 |
|
 |
Reliably identifying a given system is fraught with danger.
MAC addresses are unreliable for system ID. Even if the system contains one or more NICs, if ALL of the NICs are disabled, you won't be able to retrieve any MAC address. Besides that, they can be changed by the user.
The Win32_BaseBoard class contains the serial number of the board, but if the BIOS gets updated by the user, the chances are very good that the serial number property will be empty or null (the same goes for the Win32_BIOS class).
You also can't use Win32_ComputerSystemProduct class, because machines not built by a retail system builder (like Dell, Acer, Toshiba, HP, etc) will have a UUID of FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF.
I'm still looking for a reliable and repeatable way to identify a system.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Just FYI, this is not reliable. Most network administrators build machines based on a ghost image and windows API gathers this information from registry. Registry is only updated one time, on install of Windows. Therefore you will get the same "Unique ID", on every machine that has been created from a ghost.
--
Chizl
|
|
|
|
 |
|
 |
This seems to me to be something that could be easily worked around.
My Blog[^] FFRF[^]
|
|
|
|
 |
|
 |
Yes it's definitely not unique since all the parameters used can be changed easily to match a valid configuration...
Try to use some physical fixed strings, like the mac address of the network adapter, or the processor serial number, and some strings to identify the user. Tip: Generate a hash of a string composed of all the parameters used to identify the machine and the user. Using this technique, all your ids will have the same length and are not human readable, nor reversible (theoretically).
Ex (.NET 2.0) :
using System.Net.NetworkInformation;
using System.Text;
using System.Security.Cryptography;
...
private string GetUniqueId()
{
string macs = "";
// get network interfaces physical addresses
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in interfaces)
{
PhysicalAddress pa = ni.GetPhysicalAddress();
macs += pa.ToString();
}
// generate hash
HMACSHA1 hmac = new HMACSHA1();
hmac.Key = Encoding.ASCII.GetBytes("dummy key");
hmac.ComputeHash(Encoding.ASCII.GetBytes(macs));
// convert hash to hex string
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hmac.Hash.Length; i++)
{
sb.Append(hmac.Hash[i].ToString("X2"));
}
// the the final hash as a string
returb sb.ToString();
}
|
|
|
|
 |
|
 |
The problem with this method is that the MACs can also be changed (quite easily, through device manager), and that a change in network hardware will invalidate the license.
The processor serial number is a really nice idea though! How do you get that? Maybe I can improve the article...
Thanks for the feedback!
|
|
|
|
 |
|
 |
You're right, I wasn't expecting that changing the MAC address would be so easy!
Concerning the CPU id string, I've found this nice piece of code from By Peter A. Bromberg:
public string GetCPUId()
{
string cpuInfo = String.Empty;
string temp = String.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == String.Empty)
{// only return cpuInfo from first CPU
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
}
}
return cpuInfo;
}
I've tested it and it works perfectly. His code also refers to some other hardware identifiers, like disk serial number, I think this can be of value for your licensing scheme.
|
|
|
|
 |
|
 |
Fabrice Vergnenegre wrote: I think this can be of value for your licensing scheme
The scheme is already implemented, but I will probably make use of this next time.
Thanks a lot for the response! I think that this will be useful to many.
|
|
|
|
 |
|
 |
The CPU ID + primary hard drive serial # used to work good for me. However, these guys are changing too. Want 100% security - use USB dongle.
|
|
|
|
 |
|
 |
hi, nice idea but how can use the USB key?
Thanks you.
|
|
|
|
 |
|
 |
hi again, we have two unique hidden serial numbers additional:
1 microprocessor, and
2 hard disk...
i believe this can be useful
|
|
|
|
 |
|
 |
I think that the contents of the USB can be copied.....
My Instructor someday said to me that it is impossible to make a software uncrackable as long as it is at last converted to assembly.. and i think this is very true...
Visit Me
www.engibrahim.tk
|
|
|
|
 |
|
 |
It is indeed, as I mentiond in "Points of Interest".
The idea was to show how the number of processors can be easily retrieved, the username, domain, and computer name, etc.
|
|
|
|
 |
|
 |
Indeed, as I mentioned in "Points of Interest", it is not really unique.
But, as I also mentioned, it is just enough for the licensing scheme which I used.
|
|
|
|
 |
|
 |
Should have opted for easir yet robust mechanism...
Win32_ComputerSystemProduct.UUID ? This is unique
before c# there was darkness
|
|
|
|
 |
|
 |
hk11 wrote: Win32_ComputerSystemProduct.UUID ? This is unique
NOT on home-made machines...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Does removable drives (pen drives) count as logical drives? In a more controlled environment (corporate, small business) this maybe a good alternative but when you have a global scope of users maybe the use of a username/password system allowing only one session foreach user might be a better solution.
|
|
|
|
 |
|
 |
Felipe Amorim wrote: Does removable drives (pen drives) count as logical drives? In a more controlled environment (corporate, small business) this maybe a good alternative but when you have a global scope of users maybe the use of a username/password system allowing only one session foreach user might be a better solution.
The problem in my specific case was that I had to give the users the ability to run several sessions at once, while keeping the sessions to the same user.
I am not sure about removable drives, maybe somebody can find out?
The thing I wanted to show is how to generate an ID, which may also just be used for some randomness (who knows???), but also how to retrieve the username and computer name for those who may be interested.
|
|
|
|
 |