Forked from Spaceghost/DecryptWindowsProductKey.py
Created
December 31, 2013 20:56
-
-
Save EntityReborn/8202160 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import _winreg | |
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 | |
def GetKeyFromRegLoc(key, value="DigitalProductID"): | |
key = _winreg.OpenKey( | |
_winreg.HKEY_LOCAL_MACHINE,key) | |
value, type = _winreg.QueryValueEx(key, value) | |
return DecodeKey(list(value)) | |
def GetIEKey(): | |
return GetKeyFromRegLoc("SOFTWARE\Microsoft\Internet Explorer\Registration") | |
def GetXPKey(): | |
return GetKeyFromRegLoc("SOFTWARE\Microsoft\Windows NT\CurrentVersion") | |
def GetWPAKey(): | |
return GetKeyFromRegLoc("SYSTEM\WPA\Key-4F3B2RFXKC9C637882MBM") | |
print "XP: %s" % GetXPKey() | |
print "IE: %s" % GetIEKey() | |
print "WPA: %s" % GetWPAKey() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment