Skip to content

Instantly share code, notes, and snippets.

@EntityReborn
Created March 25, 2011 03:57
Show Gist options
  • Save EntityReborn/886341 to your computer and use it in GitHub Desktop.
Save EntityReborn/886341 to your computer and use it in GitHub Desktop.
When used with the Windows Multi-Keygen, this will render retail XP fully activated, and Microsoft sees it as genuine!
import _winreg, os, sys
import win32api, win32con
import subprocess
from pywinauto import application
def deactivate():
windir = os.getenv("windir", "C:\Windows")
if os.path.exists(windir + "\system32\WPA.dbl"):
if os.path.exists(windir + "\system32\wpa.old"):
os.remove(windir + "\system32\wpa.old")
os.rename(windir + "\system32\WPA.dbl", windir + "\system32\wpa.old")
loc = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WPAEvents"
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, loc, 0, _winreg.KEY_ALL_ACCESS)
value, type = _winreg.QueryValueEx(key, "OOBETimer")
if value:
end = value[-1:]
if end == "\x00":
end = "\x01"
else:
end = "\x00"
value = value[:-1] + end
_winreg.SetValueEx(key, "OOBETimer", 0, _winreg.REG_BINARY, value)
sysroot = os.getenv("systemroot", "C:\Windows")
if os.path.exists(r"{path}\system32\AntiWPA.dll".format(path=sysroot)):
dehactivate()
def getProdKey(num=1):
if not os.path.exists("%s\keygen\keygen.exe" % sys.path[0]):
return False
app = application.Application.start("%s\keygen\keygen.exe" % sys.path[0])
window = app["Windows Keygen"]
for i in range(0, num):
window.Generate.Click()
keys = window.Edit5.WindowText()
app.kill_()
return list([x for x in keys.split("\r\n") if x])
def setProdKey(key):
if isinstance(key, list):
key = key[0]
key = "".join(key.split("-")) # Remove hyphens
import wmi
c = wmi.WMI()
activate = c.Win32_WindowsProductActivation()
for item in activate:
item.SetProductKey(key)
def patchHosts():
file='c:\windows\system32\drivers\etc\hosts'
win32api.SetFileAttributes(file, win32con.FILE_ATTRIBUTE_NORMAL)
needpatch = True
with open(file, "r") as f:
for line in f:
if "mpa.one.microsoft.com" in line:
needpatch = False
break
if needpatch:
win32api.SetFileAttributes(file, win32con.FILE_ATTRIBUTE_NORMAL)
with open(file, "a") as f:
f.write("\n127.0.0.1\tmpa.one.microsoft.com")
return needpatch
def hactivate():
arch = os.getenv("PROCESSOR_ARCHITECTURE", "X86")
proc = subprocess.Popen(r'regsvr32 /s "{path}\hactivation\{arch}\antiwpa.dll"'.format(path=sys.path[0], arch=arch))
proc.wait()
def dehactivate():
arch = os.getenv("PROCESSOR_ARCHITECTURE", "X86")
proc = subprocess.Popen(r'regsvr32 /s /u "{path}\hactivation\{arch}\antiwpa.dll"'.format(path=sys.path[0], arch=arch))
proc.wait()
sysroot = os.getenv("systemroot", "C:\Windows")
if os.path.exists(r"{path}\system32\AntiWPA.dll".format(path=sysroot)):
os.remove("%s\system32\AntiWPA.dll" % sysroot)
def genKeysFile(file, num=100, mode="a"):
with open(file, mode) as f:
lines = "\n".join(getProdKey(num))
f.write(lines)
if __name__ == "__main__":
print "Assuring that XP is deactivated."
deactivate()
print "Grabbing a key."
key = getProdKey(1)
if key:
print "Using {key} for product key.".format(key=key[0])
setProdKey(key)
print "Patching HOSTS file."
patchHosts()
print "Hacktivating."
hactivate()
print "Done! Enjoy!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment