我们使用下面的代码来检索Windows PC的活动MAC地址。如何检测原始MAC地址被欺骗后?
private static string macId()
{
return identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled");
}
private static string identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue)
{
string result = "";
System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass);
System.Management.ManagementObjectCollection moc = mc.GetInstances();
foreach (System.Management.ManagementObject mo in moc)
{
if (mo[wmiMustBeTrue].ToString() == "True")
{
//Only get the first one
if (result == "")
{
try
{
result = mo[wmiProperty].ToString();
break;
}
catch
{
}
}
}
}
return result;
}
//Return a hardware identifier
private static string identifier(string wmiClass, string wmiProperty)
{
string result = "";
System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass);
System.Management.ManagementObjectCollection moc = mc.GetInstances();
foreach (System.Management.ManagementObject mo in moc)
{
//Only get the first one
if (result == "")
{
try
{
result = mo[wmiProperty].ToString();
break;
}
catch
{
}
}
}
return result;
}
它工作正常,检索MAC地址。问题是当MAC地址被欺骗时,它返回伪造的MAC地址。我们想以某种方式检索出厂时唯一和分配的原始MAC地址。有没有办法做到这一点?
欺骗MAC的全部意义在于,使计算机(和软件就此)相信这是正确的MAC。 – Joe 2012-03-03 12:53:45
@Joe,是的。我原来的问题是“是否真的有办法唯一识别任何计算机”?我得到了一些建议,可以将MAC地址用作唯一标识符。这导致了这个问题。 – 2012-03-03 13:17:56
这里有一些其他的想法:http://stackoverflow.com/questions/671876/whats-a-good-way-to-uniquely-identify-a-computer – Joe 2012-03-03 14:05:40