win7/8取得当前系统完整激活密钥的代码

win7系统激活后,当前密钥没有明文保存,使用

1
slmgr -dlv

只能查看部份密钥,如果查看完整的密钥呢?以下提供了四种语言取得完整的win7/8密钥,最简单的为第一种!
win10/11的密钥在注册表的
计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform
右侧的BackupProductKeyDefault值,就是win10完整的密钥!
所以相比来说,win10 win11的密钥取得要简单一些!
取得win7/8系统完整的密钥,而不是部份

  1. vbs代码最简单,新建文本文件拷贝以下代码并保存为vbs,直接运行就可以获取win7当前使用的完整密钥!
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    Set WshShell = CreateObject("WScript.Shell")
    MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))

    Function ConvertToKey(Key)
    Const KeyOffset = 52
    i = 28
    Chars = "BCDFGHJKMPQRTVWXY2346789"
    Do
    Cur = 0
    x = 14
    Do
    Cur = Cur * 256
    Cur = Key(x + KeyOffset) + Cur
    Key(x + KeyOffset) = (Cur \ 24) And 255
    Cur = Cur Mod 24
    x = x -1
    Loop While x >= 0
    i = i -1
    KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
    If (((29 - i) Mod 6) = 0) And (i <> -1) Then
    i = i -1
    KeyOutput = "-" & KeyOutput
    End If
    Loop While i >= 0
    ConvertToKey = KeyOutput
    End Function

win7 win8 win10 win11通用取密钥的vbs代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Option Explicit
Dim objshell,path,DigitalID, Result
Set objshell = CreateObject("WScript.Shell")
'Set registry key path
Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
'Registry key value
DigitalID = objshell.RegRead(Path & "DigitalProductId")
Dim ProductName,ProductID,ProductKey,ProductData
'Get ProductName, ProductID, ProductKey
ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName")
ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID")
ProductKey = "Installed Key: " & ConvertToKey(DigitalID)
ProductData = ProductName & vbNewLine & ProductID & vbNewLine & ProductKey
'Show messbox if save to a file
If vbYes = MsgBox(ProductData & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "BackUp Windows Key Information") then
Save ProductData
End If

'Convert binary to chars
Function ConvertToKey(Key)
Const KeyOffset = 52
Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
'Check if OS is Windows 8
isWin8 = (Key(66)\6) And 1
Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
i = 24
Maps = "BCDFGHJKMPQRTVWXY2346789"
Do
Current= 0
j = 14
Do
Current = Current* 256
Current = Key(j + KeyOffset) + Current
Key(j + KeyOffset) = (Current\24)
Current=Current Mod 24
j = j -1
Loop While j >= 0
i = i -1
KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput
Last = Current
Loop While i >= 0
If (isWin8 = 1) Then
keypart1 = Mid(KeyOutput, 2, Last)
insert = "N"
KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
If Last = 0 Then KeyOutput = insert & KeyOutput
End If
ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5)
End Function

'Save data to a file

Function Save(Data)
Dim fso, fName, txt,objshell,UserName
Set objshell = CreateObject("wscript.shell")
'Get current user name
UserName = objshell.ExpandEnvironmentStrings("%UserName%")
'Create a text file on desktop
fName = "C:Users" & UserName & "DesktopWindowsKeyInfo.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set txt = fso.CreateTextFile(fName)
txt.Writeline Data
txt.Close
End Function
  1. c++代码
    先从注册表项中(HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId)读取ProductId的二进制值,再使用下面的函数就可以解密win7/8系统当前使用完整密钥,而不是部份密钥

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    char* DecodeMicrosoftKey( BYTE* digitalProductId )
    {

    /* NULL is a valid byte value, so check for it. */
    if ( digitalProductId )
    {
    /* Offset first value to 34H. */
    const int keyStartIndex = 52;
    /* Offset last value to 43H. */
    const int keyEndIndex = keyStartIndex + 15;
    /* Valid Product Key Characters. */
    char digits[] =
    {
    '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 key in byte-form (each byte = 2 chars). */
    const int decodeStringLength = 15;
    /* Array to contain decoded key. */
    char* pDecodedChars = new char[ decodeLength + 1 ];

    memset( pDecodedChars, 0, decodeLength + 1 );

    /* Extract byte 52 to 67 inclusive. */
    byte hexPid[ keyEndIndex - keyStartIndex + 1 ];

    for ( int i = keyStartIndex; i <= keyEndIndex; i++ )
    {
    hexPid[ i - keyStartIndex ] = digitalProductId[ i ];
    }

    for ( int i = decodeLength - 1; i >= 0; i-- )
    {
    /* Every 6th character is a seperator. */
    if ( ( i + 1 ) % 6 == 0 )
    {
    *( pDecodedChars + i ) = '-';
    }
    else
    {
    /* Do the actual decoding. */
    int digitMapIndex = 0;
    for ( int j = decodeStringLength - 1; j >= 0; j-- )
    {
    int byteValue = ( digitMapIndex << 8 ) | hexPid[ j ];
    hexPid[ j ] = ( byte )( byteValue / 24 );
    digitMapIndex = byteValue % 24;
    *( pDecodedChars + i ) = digits[ digitMapIndex ];
    }
    }
    }
    /*
    * Return the decoded product key.
    */
    return pDecodedChars;
    }
    /* digitalProductID was passed as a NULL value, return NULL. */
    else
    {
    return NULL;
    }
    }
  2. c#代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    RegistryKey hklm = Registry.LocalMachine;
    hklm = hklm.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
    byte[] digitalProductId = hklm.GetValue("DigitalProductId") as byte[];
    textBox1.Text = DecodeProductKey(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);
    }
  3. vb代码
    仅解密函数,值仍然在注册表中获得,代入函数即可解密完整的win7密钥

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    Function ConvertToKey(Key) 
        Const KeyOffset = 52
        Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
        'Check if OS is Windows 8
        isWin8 = (Key(66) \ 6) And 1
        Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
        i = 24
        Maps = "BCDFGHJKMPQRTVWXY2346789"
        Do
               Current= 0
            j = 14
            Do
               Current = Current* 256
               Current = Key(j + KeyOffset) + Current
               Key(j + KeyOffset) = (Current \ 24)
               Current=Current Mod 24
                j = j -1
            Loop While j >= 0
            i = i -1
            KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput
            Last = Current
        Loop While i >= 0  
         
        If (isWin8 = 1) Then
            keypart1 = Mid(KeyOutput, 2, Last)
            insert = "N"
            KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
            If Last = 0 Then KeyOutput = insert & KeyOutput
        End If     
         

        ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5)
         
    End Function
-------------本文已结束赏个小钱吧-------------
×

感谢您的支持,我们会一直保持!

扫码支持
请土豪扫码随意打赏

打开微信扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

64.7K

相关文章推荐