Forked from Spaceghost/DecryptWindowsProductKey.py
Last active
November 8, 2020 22:12
-
-
Save Faalagorn/afaa2a96ffa9b5221fa4af8c6ebdd067 to your computer and use it in GitHub Desktop.
A script to decrypt windows product keys written in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def DecodeKey(rpk): | |
rpkOffset = 52 | |
i = 28 | |
szPossibleChars = "BCDFGHJKMPQRTVWXY2346789" | |
szProductKey = "" | |
while i >= 0: | |
dwAccumulator = 0 | |
j = 14 | |
while j >= 0: | |
dwAccumulator = dwAccumulator * 256 | |
d = rpk[j+rpkOffset] | |
if isinstance(d, str): | |
d = ord(d) | |
dwAccumulator = d + dwAccumulator | |
rpk[j+rpkOffset] = (dwAccumulator / 24) if (dwAccumulator / 24) <= 255 else 255 | |
dwAccumulator = dwAccumulator % 24 | |
j = j - 1 | |
i = i - 1 | |
szProductKey = szPossibleChars[dwAccumulator] + szProductKey | |
if ((29 - i) % 6) == 0 and i != -1: | |
i = i - 1 | |
szProductKey = "-" + szProductKey | |
return szProductKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment