【发布时间】:2012-03-21 17:16:11
【问题描述】:
我们正在使用以下代码来检索 windows pc 的活动 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,是的。我最初的问题是“真的有任何方法可以唯一地识别任何计算机”吗?我得到了一些建议,即 MAC 地址可以用作唯一标识符。这就引出了这个问题。
-
这里有一些其他想法:stackoverflow.com/questions/671876/…
-
你最坏的情况是什么?为什么担心 MAC 地址被更改的可能性?
-
如果有人想尝试构建一个可行的解决方案,应该可以使用 IOCTL_NDIS_QUERY_GLOBAL_STATS 和 OID_FDDI_LONG_PERMANENT_ADDR 检索硬件 MAC。
标签: c# windows networking uniqueidentifier spoofing