标签: 完整密钥

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

win7系统激活后,当前密钥没有明文保存,使用 1slmgr -dlv 只能查看部份密钥,如果查看完整的密钥呢?以下提供了四种语言取得完整的win7/8密钥,最简单的为第一种!win10/11的密钥在注册表的计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform右侧的BackupProductKeyDefault值,就是win10完整的密钥!所以相比来说,win10 win11的密钥取得要简单一些! vbs代码最简单,新建文本文件拷贝以下代码并保存为vbs,直接运行就可以获取win7当前使用的完整密钥!1234567891011121314151617181920212223242526Set 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 = KeyOutputEnd Function win7 win8 win10 win11通用取密钥的vbs代码 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364Option ExplicitDim objshell,path,DigitalID, ResultSet objshell = CreateObject("WScript.Shell")'Set registry key pathPath = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"'Registry key valueDigitalID = objshell.RegRead(Path & "DigitalProductId")Dim ProductName,ProductID,ProductKey,ProductData'Get ProductName, ProductID, ProductKeyProductName = "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 fileIf vbYes = MsgBox(ProductData & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "BackUp Windows Key Information") then Save ProductDataEnd If'Convert binary to charsFunction 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 fileFunction 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.CloseEnd Function c++代码先从注册表项中(HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId)读取ProductId的二进制值,再使用下面的函数就可以解密win7/8系统当前使用完整密钥,而不是部份密钥 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364char* 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; }} c#代码 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354RegistryKey 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);} vb代码仅解密函数,值仍然在注册表中获得,代入函数即可解密完整的win7密钥 12345678910111213141516171819202122232425262728293031323334Function 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