mac地址是怎么变的?
本文关键字:地址 mac | 更新日期: 2023-09-27 18:17:54
我的软件有一个相当粗糙的许可证密钥,它可以找到一台机器的所有mac地址并对它们进行加密,然后将它们与注册表中保存的加密值进行比较。如果注册表中的值与我刚刚找到的任何值匹配,则软件将加载。我希望我总是得到相同的MAC地址值,但对于一些机器,这不是真的。谁能解释为什么他们的MAC地址不是固定的,或者如何克服这个问题?
感谢 //// GET MAC ADDRESS
String sMacAddress = String.Empty;
ManagementScope theScope = new ManagementScope("''''" +Environment.MachineName + "''root''cimv2");
DGCSLogger.log.Trace("Management scope");
StringBuilder theQueryBuilder = new StringBuilder();
theQueryBuilder.Append("SELECT MACAddress FROM Win32_NetworkAdapter");
ObjectQuery theQuery = new ObjectQuery(theQueryBuilder.ToString());
DGCSLogger.log.Trace("Creating searcher");
ManagementObjectSearcher theSearcher = new ManagementObjectSearcher(theScope, theQuery);
DGCSLogger.log.Trace("Creating collection");
ManagementObjectCollection theCollectionOfResults = theSearcher.Get();
DGCSLogger.log.Trace("Got management objects");
//// GET VALUE FROM REGISTRY
String sSavedScrambled = RegistryHelper.GetCurrentUserValue(@"Software'VB and VBA Program Settings'FMPos'settings", "LicenceKey");
String sSavedLicenceKey = String.Empty;
if (sSavedScrambled != null)
sSavedLicenceKey = DGCS.Common.Password.UnScramblePassword(sSavedScrambled);
String sMacNoLicenceKey = String.Empty;
String sMacNo = String.Empty;
///// COMPARE VALUES WITH REGISTRY VALUE
foreach (ManagementObject theCurrentObject in theCollectionOfResults)
{
DGCSLogger.log.Trace("foreach object");
if (theCurrentObject["MACAddress"] != null)
{
DGCSLogger.log.Trace("foreach object: " + theCurrentObject["MACAddress"].ToString().Substring(0, 5));
String macAdd = theCurrentObject["MACAddress"].ToString();
sMacNo = DGCS.Common.Password.ScrambleMacNumber(theCurrentObject["MACAddress"].ToString());
sMacNoLicenceKey = DGCS.Common.Password.CreateMacNoPassword(sMacNo);
DGCSLogger.log.Trace(": " + theCurrentObject["MACAddress"].ToString().Substring(0, 5));
if (sMacNoLicenceKey.Trim() == sSavedLicenceKey.Trim())
lkCheck.HasLicenceKey = true;
}
}
各种可能的原因:
- 他们可能已经更换了网卡
- WMI枚举可能以不同的顺序返回它们(我没有看到任何排序)
- 他们可能会改变MAC地址(是的,这是可能的)
- …
这就是为什么MAC地址实际上不是创建许可密钥的好参考。