小标
2018-07-31
来源 :
阅读 1365
评论 0
摘要:本文主要向大家介绍了Windows运维之提高Windows 产品密钥安全性,通过具体的内容向大家展现,希望对大家学习Windows运维有所帮助。
本文主要向大家介绍了Windows运维之提高Windows 产品密钥安全性,通过具体的内容向大家展现,希望对大家学习Windows运维有所帮助。
今天无意中在CodePlex 发现一个叫Windows Product Key Finder 的项目,从名字就可以看出它的用途。通过这款软件可以轻松的获取本地Windows 的产品密钥。当然对于找不到密钥光盘的人来说这当然是款实用的工具,但如果到了某些图谋不轨的人手里那您的产品密钥必定要受到威胁。
阅读了项目源代码后,其实程序的核心也是最有价值的部分就是去解码\\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion 中的DigitalProductId 值。如下代码所示:
public static string DecodeProductKey(byte[] digitalProductId)
{
// Offset of first byte of encoded product key in
// 'DigitalProductIdxxx" REG_BINARY value. Offset = 34H.
const int keyStartIndex = 52;
// Offset of last byte of encoded product key in
// 'DigitalProductIdxxx" REG_BINARY value. Offset = 43H.
const int keyEndIndex = keyStartIndex + 15;
// Possible alpha-numeric characters in product key.
char[] digits = new char[]
{
'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R',
'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
};
// Length of decoded product key
const int decodeLength = 29;
// Length of decoded product key in byte-form.
// Each byte represents 2 chars.
const int decodeStringLength = 15;
// Array of containing the decoded product key.
char[] decodedChars = new char[decodeLength];
// Extract byte 52 to 67 inclusive.
ArrayList hexPid = new ArrayList();
for (int i = keyStartIndex; i <= keyEndIndex; i++)
{
hexPid.Add(digitalProductId[i]);
}
for (int i = decodeLength - 1; i >= 0; i--)
{
// Every sixth char is a separator.
if ((i + 1) % 6 == 0)
{
decodedChars[i] = '-';
}
else
{
// Do the actual decoding.
int digitMapIndex = 0;
for (int j = decodeStringLength - 1; j >= 0; j--)
{
int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
hexPid[j] = (byte)(byteValue / 24);
digitMapIndex = byteValue % 24;
decodedChars[i] = digits[digitMapIndex];
}
}
}
return new string(decodedChars);
}
最后将读取出的DigitalProductId 值(Byte)赋给DecodeProductKey 方法即可算出Windows 产品密钥。项目描述中提到该程序在XP、Vista、Windows 7 系统上均可运行。
RegistryKey hklm = Registry.LocalMachine;
hklm = hklm.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");byte[] digitalProductId = hklm.GetValue("DigitalProductId") as byte[];
textBox1.Text = DecodeProductKey(digitalProductId);
由此可见简单几行代码就可以使产品密钥落入他人之手,并且这类程序在网上还有很多。对于Vista、Windows 7 用户来说建议使用slmgr /cpky 命令对产品密钥进行一下处理,详细内容请参考《Windows 7 产品密钥是否安全》。从注册表清除产品密钥信息后,再运行该程序便会出现下图效果,产品密钥将全部显示为字母“B”,这样您就不必担心产品密钥的安全性了。
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注系统运维windows频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号