Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithm to decode Windows keys #16

Open
samrocketman opened this issue Oct 26, 2016 · 0 comments
Open

Algorithm to decode Windows keys #16

samrocketman opened this issue Oct 26, 2016 · 0 comments

Comments

@samrocketman
Copy link
Owner

samrocketman commented Oct 26, 2016

  • GetXPKey / GetVistaKey - Get key for a given operating system. It calls GetMSDPID3.
  • GetMSDPID3 - Get Microsoft Digital Product Identification number. It calls DecodeMSKey.
  • DecodeMSKey - decodes MS product key.

ekeyfinder/Main.pas

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant