我正在尝试欺骗执行程序的计算机的MAC地址.现在我通过cmd使用'getmac'命令获取机器的当前MAC地址,然后我想通过'RegistryKey'类(windows.system32)更改它.
问题是我不知道传递给OpenSubKey方法的字符串.
例如,这是使用注册表项读取读取当前MAC的方法:
private string readMAC()
{
RegistryKey rkey;
string MAC;
rkey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\0012", true); //--->this is the string to change
MAC = (string)rkey.GetValue("NetworkAddress");
rkey.Close();
return MAC;
}
Run Code Online (Sandbox Code Playgroud) 我在执行此代码时遇到问题:
Process arp = new Process();
arp.StartInfo.UseShellExecute = false;
arp.StartInfo.RedirectStandardOutput = true;
arp.StartInfo.FileName = "C://Windows//System32//cmd.exe";
arp.StartInfo.Arguments = "arp -a";
arp.StartInfo.RedirectStandardOutput = true;
arp.Start();
arp.WaitForExit();
string output = arp.StandardOutput.ReadToEnd();
MessageBox.Show(output);
Run Code Online (Sandbox Code Playgroud)
该程序应该将 arp-a 的输出放入字符串输出中,但它却给了我这个:
Microsoft Windows [版本 6.1.7601]\r\n版权所有 (c) 2009 Microsoft Corporation。保留所有权利。\r\n\r\nC:\Users\user01\documents\visual studio 2012\Projects\freehotspotexploiter\freehotspotexploiter\bin\Debug>
有人知道如何修复它吗?