Algorithm to decode Windows keys
Opened this issue · 0 comments
samrocketman commented
GetXPKey
/GetVistaKey
- Get key for a given operating system. It callsGetMSDPID3
.GetMSDPID3
- Get Microsoft Digital Product Identification number. It callsDecodeMSKey
.DecodeMSKey
- decodes MS product key.
Lines 1961 to 2006 in d8e5904
function TfrmMain.DecodeMSKey(const HexSrc: array of byte; const ID: boolean): string; | |
const | |
Digits: array[0..23] of 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'); | |
iDecodedLen: integer = 29; // Length of Decoded Product Key | |
iEncodedLen: integer = 15; | |
// Length of Encoded Product Key in Bytes (An total of 30 in chars) | |
var | |
HexDigitalPID: array of cardinal; | |
Des: array[0..30] of char; // Length of Decoded Product Key + 1 | |
iStartOffset: integer; | |
iEndOffset: integer; | |
I: integer; | |
N: integer; | |
HN: cardinal; | |
Value: cardinal; | |
begin | |
if ID then | |
iStartOffset := $328 | |
else | |
iStartOffset := $34; | |
iEndOffset := iStartOffset + 15; | |
Result := ''; | |
SetLength(HexDigitalPID, iDecodedLen); | |
for I := iStartOffset to iEndOffset do | |
HexDigitalPID[I - iStartOffSet] := HexSrc[I]; | |
for I := iDecodedLen - 1 downto 0 do | |
if (((I + 1) mod 6) = 0) then | |
Des[I] := '-' | |
else | |
begin | |
HN := 0; | |
for N := iEncodedLen - 1 downto 0 do | |
begin | |
Value := (HN shl 8) or HexDigitalPID[N]; | |
HexDigitalPID[N] := Value div 24; | |
HN := Value mod 24; | |
end; | |
Des[I] := Digits[HN]; | |
end; | |
Des[iDecodedLen] := Chr(0); | |
Result := StrPas(Des); | |
end; // TfrmMain.DecodeMSKey |