我的新笔记本电脑预装了Windows 8。天真地说,我只是格式化了硬盘并安装了老旧的Ubuntu系统。现在我想再次安装Windows 8以进行双系统启动,但我没有光盘,并且要下载ISO文件需要一个产品密钥。这个密钥不再在笔记本背面,而是在主板上的某个地方。
有没有办法在Ubuntu系统中从主板上恢复产品密钥?
有没有办法在Ubuntu系统中从主板上恢复产品密钥?
sudo acpidump -b -t MSDM | dd bs=1 skip=56 2>/dev/null;echo
acpidump -t MSDM
也可以实现相同的功能,但是密钥被分成多行,复制起来比较困难。
根据Lekensteyn的更新:
新版本的Ubuntu中发货的acpidump
与上述描述有所不同。-b标志使acpidump
在任何情况下都会写入文件,因此另一种方法是使用以下命令:
sudo tail -c+57 /sys/firmware/acpi/tables/MSDM
sudo dmidecode
/sys/firmware/acpi/tables/MSDM
中找到了它,正如下面另一个答案中的Chuck R所提到的。 - Luc sudo tail -c+57 /sys/firmware/acpi/tables/MSDM
$ ls /sys/firmware/acpi/tables
$ sudo hd /sys/firmware/acpi/tables/MSDM
00000000 ha ns oo lo oe at es ap pl le sa uc ef or li fe |Key in area|
00000010 cu si ca nb ro ha ms am cu si ca nb ro ha ms am |In key area|
00000020 it sj us ho wz ir ol lz it sj us ho wz ir ol lz |Area in key|
00000000 ha ns oo lo oe at es ap pl le sa uc ef or li fe |It is 5 x 5|
00000010 cu si ca nb ro ha ms am cu si ca nb ro ha ms am |Key in area|
00000020 it sj us ho wz ir ol lz it sj us ho wz ir ol lz |In key area|
00000050 ha ns oo lo ow az he re |Area in key|
00000055 |It is 5 x 5|
sudo hexdump -s 56 -e '"MSDM key: " /29 "%s\n"' /sys/firmware/acpi/tables/MSDM
strings /sys/firmware/acpi/tables/MSDM
winmount=/mnt
echo "hex \\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId\nq\nq" | chntpw -e ${winmount}/Windows/System32/config/SOFTWARE
/// <summary>
/// Decodes Windows Product Key from the DigitalProductId.
/// This method applies to DigitalProductId from Windows 7 or lower versions of Windows.
/// </summary>
/// <param name="digitalProductId">DigitalProductId to decode</param>
/// <returns>Decoded Windows Product Key as a string</returns>
private static string DecodeProductKey(byte[] digitalProductId)
{
const int keyStartIndex = 52;
const int keyEndIndex = keyStartIndex + 15;
var digits = new[]
{
'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R',
'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
};
const int decodeLength = 29;
const int decodeStringLength = 15;
var decodedChars = new char[decodeLength];
var hexPid = new ArrayList();
for (var i = keyStartIndex; i <= keyEndIndex; i++)
{
hexPid.Add(digitalProductId[i]);
}
for (var i = decodeLength - 1; i >= 0; i--)
{
// Every sixth char is a separator.
if ((i + 1) % 6 == 0)
{
decodedChars[i] = '-';
}
else
{
// Do the actual decoding.
var digitMapIndex = 0;
for (var j = decodeStringLength - 1; j >= 0; j--)
{
var byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
hexPid[j] = (byte)(byteValue / 24);
digitMapIndex = byteValue % 24;
decodedChars[i] = digits[digitMapIndex];
}
}
}
return new string(decodedChars);
}
/// <summary>
/// Decodes Windows Product Key from the DigitalProductId.
/// This method applies to DigitalProductId from Windows 8 or newer versions of Windows.
/// </summary>
/// <param name="digitalProductId">DigitalProductId to decode</param>
/// <returns>Decoded Windows Product Key as a string</returns>
public static string DecodeProductKeyWin8AndUp(byte[] digitalProductId)
{
var key = String.Empty;
const int keyOffset = 52;
var isWin8 = (byte)((digitalProductId[66] / 6) & 1);
digitalProductId[66] = (byte)((digitalProductId[66] & 0xf7) | (isWin8 & 2) * 4);
const string digits = "BCDFGHJKMPQRTVWXY2346789";
var last = 0;
for (var i = 24; i >= 0; i--)
{
var current = 0;
for (var j = 14; j >= 0; j--)
{
current = current*256;
current = digitalProductId[j + keyOffset] + current;
digitalProductId[j + keyOffset] = (byte)(current/24);
current = current%24;
last = current;
}
key = digits[current] + key;
}
var keypart1 = key.Substring(1, last);
var keypart2 = key.Substring(last + 1, key.Length - (last + 1));
key = keypart1 + "N" + keypart2;
for (var i = 5; i < key.Length; i += 6)
{
key = key.Insert(i, "-");
}
return key;
}
sudo acpidump -b -t MSDM | dd bs=1 skip=56 2>/dev/null;echo
,然后成功获取到完整的密钥。 - Andrew C