mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-17 16:45:15 -04:00
uploaded version 2018_11_15 for python2
This commit is contained in:
parent
73f66ea40f
commit
b0a8ff21fb
18 changed files with 1574 additions and 791 deletions
|
@ -4,122 +4,74 @@ import datetime
|
|||
import random
|
||||
import time
|
||||
import uuid
|
||||
from ast import literal_eval
|
||||
|
||||
APP_ID_WINDOWS = uuid.UUID("55C92734-D682-4D71-983E-D6EC3F16059F")
|
||||
APP_ID_OFFICE14 = uuid.UUID("59A52881-A989-479D-AF46-F275C6370663")
|
||||
APP_ID_OFFICE15 = uuid.UUID("0FF1CE15-A989-479D-AF46-F275C6370663")
|
||||
from kmsDB2Dict import kmsDB2Dict
|
||||
|
||||
|
||||
# KMS Host OS Type
|
||||
hostOsList = {}
|
||||
# Windows Server 2008 R2 SP1
|
||||
hostOsList["HOST_SERVER2008R2"] = {
|
||||
"type" : 55041,
|
||||
"osBuild" : 7601
|
||||
}
|
||||
# Windows Server 2012 RTM
|
||||
hostOsList["HOST_SERVER2012"] = {
|
||||
"type" : 5426,
|
||||
"osBuild" : 9200
|
||||
}
|
||||
# Windows Server 2012 R2 RTM
|
||||
hostOsList["HOST_SERVER2012R2"] = {
|
||||
"type" : 6401,
|
||||
"osBuild" : 9600
|
||||
}
|
||||
# Windows Server 2016 RTM
|
||||
hostOsList["HOST_SERVER2016"] = {
|
||||
"type" : 3612,
|
||||
"osBuild" : 14393
|
||||
}
|
||||
|
||||
|
||||
# Product Specific KeyConfig
|
||||
pkeyConfigList = {}
|
||||
# Windows Server KMS Host PID, actual PIDRangeMax = 191999999
|
||||
pkeyConfigList["windows"] = {
|
||||
"GroupID" : 206,
|
||||
"PIDRangeMin" : 152000000,
|
||||
"PIDRangeMax" : 191999999
|
||||
}
|
||||
# Windows Server 2012 R2 KMS Host PID, actual PIDRangeMax = 310999999
|
||||
pkeyConfigList["windows2012r2"] = {
|
||||
"GroupID" : 206,
|
||||
"PIDRangeMin" : 271000000,
|
||||
"PIDRangeMax" : 310999999
|
||||
}
|
||||
# Office 2010 KMSHost Class PID, actual PIDRangeMax = 217999999
|
||||
pkeyConfigList["office14"] = {
|
||||
"GroupID" : 96,
|
||||
"PIDRangeMin" : 199000000,
|
||||
"PIDRangeMax" : 217999999
|
||||
}
|
||||
# Office 2013 KMSHost Class PID, actual PIDRangeMax = 255999999
|
||||
pkeyConfigList["office15"] = {
|
||||
"GroupID" : 206,
|
||||
"PIDRangeMin" : 234000000,
|
||||
"PIDRangeMax" : 255999999
|
||||
}
|
||||
|
||||
|
||||
def epidGenerator(appId, version, lcid):
|
||||
# Generate Part 1 & 7: Host Type and KMS Server OS Build
|
||||
hostOsType = random.choice(hostOsList.keys())
|
||||
hostOsDict = hostOsList[hostOsType]
|
||||
def epidGenerator(kmsId, version, lcid):
|
||||
kmsdb = kmsDB2Dict()
|
||||
winbuilds, csvlkitems, appitems = kmsdb[0], kmsdb[1], kmsdb[2]
|
||||
hosts, pkeys = [ [] for _ in range(2) ]
|
||||
|
||||
# Product Specific Detection (Get all CSVLK GroupID and PIDRange good for EPID generation), then
|
||||
# Generate Part 2: Group ID and Product Key ID Range
|
||||
if appId == APP_ID_OFFICE14:
|
||||
keyConfig = pkeyConfigList["office14"]
|
||||
elif appId == APP_ID_OFFICE15:
|
||||
keyConfig = pkeyConfigList["office15"]
|
||||
else:
|
||||
# Default to Windows
|
||||
if hostOsDict['osBuild'] == 14393:
|
||||
keyConfig = pkeyConfigList["windows2012r2"]
|
||||
elif hostOsDict['osBuild'] == 9600:
|
||||
keyConfig = pkeyConfigList["windows2012r2"]
|
||||
else:
|
||||
keyConfig = pkeyConfigList["windows"]
|
||||
for csvlkitem in csvlkitems:
|
||||
try:
|
||||
if kmsId in [ uuid.UUID(kmsitem) for kmsitem in csvlkitem['Activate'] ]:
|
||||
pkeys.append( (csvlkitem['GroupId'], csvlkitem['MinKeyId'], csvlkitem['MaxKeyId'], csvlkitem['InvalidWinBuild']) )
|
||||
except IndexError:
|
||||
# fallback to Windows Server 2019 parameters.
|
||||
GroupId, MinKeyId, MaxKeyId, Invalid = 206, 551000000, 570999999, [0,1,2]
|
||||
|
||||
pkey = random.choice(pkeys)
|
||||
GroupId, MinKeyId, MaxKeyId, Invalid = int(pkey[0]), int(pkey[1]), int(pkey[2]), literal_eval(pkey[3])
|
||||
|
||||
# Get all KMS Server Host Builds good for EPID generation, then
|
||||
# Generate Part 1 & 7: Host Type and KMS Server OS Build
|
||||
# https://www.itprotoday.com/windows-78/volume-activation-server-2008
|
||||
# https://docs.microsoft.com/en-us/windows-server/get-started-19/activation-19
|
||||
# https://docs.microsoft.com/en-us/windows-server/get-started/windows-server-release-info
|
||||
# https://support.microsoft.com/en-us/help/13853/windows-lifecycle-fact-sheet
|
||||
for winbuild in winbuilds:
|
||||
try:
|
||||
# Check versus "InvalidWinBuild".
|
||||
if int(winbuild['WinBuildIndex']) not in Invalid:
|
||||
# Re-check versus "version" protocol.
|
||||
if ((version == 4 and int(winbuild['BuildNumber']) >= 7601) or
|
||||
(version == 5 and int(winbuild['BuildNumber']) >= 9200) or
|
||||
(version == 6 and int(winbuild['BuildNumber']) >= 9600)):
|
||||
hosts.append(winbuild)
|
||||
except KeyError:
|
||||
# fallback to Windows Server 2019 parameters.
|
||||
BuildNumber, PlatformId, MinDate = '17763', '3612', '02/10/2018'
|
||||
|
||||
host = random.choice(hosts)
|
||||
BuildNumber, PlatformId, MinDate = host['BuildNumber'], host['PlatformId'], host['MinDate']
|
||||
|
||||
# Generate Part 3 and Part 4: Product Key ID
|
||||
productKeyID = random.randint(keyConfig["PIDRangeMin"], keyConfig["PIDRangeMax"])
|
||||
productKeyID = random.randint(MinKeyId, MaxKeyId)
|
||||
|
||||
# Generate Part 5: License Channel (00=Retail, 01=Retail, 02=OEM,
|
||||
# 03=Volume(GVLK,MAK)) - always 03
|
||||
# Generate Part 5: License Channel (00=Retail, 01=Retail, 02=OEM, 03=Volume(GVLK,MAK)) - always 03
|
||||
licenseChannel = 3
|
||||
|
||||
# Generate Part 6: Language - use system default language
|
||||
# 1033 is en-us
|
||||
languageCode = lcid # C# CultureInfo.InstalledUICulture.LCID
|
||||
# Generate Part 6: Language - use system default language, 1033 is en-us
|
||||
languageCode = lcid # (C# CultureInfo.InstalledUICulture.LCID)
|
||||
|
||||
# Generate Part 8: KMS Host Activation Date
|
||||
# Get Minimum Possible Date: Newer Products first
|
||||
if hostOsType == "HOST_SERVER2016":
|
||||
# Microsoft Windows Server 2016 RTM
|
||||
minTime = datetime.date(2016, 7, 27)
|
||||
elif hostOsType == "HOST_SERVER2012R2" or version == 6:
|
||||
# Microsoft Windows Server 2012 R2 RTM (October 17, 2013)
|
||||
minTime = datetime.date(2013, 10, 17)
|
||||
elif appId == APP_ID_OFFICE15:
|
||||
# Microsoft Office 2013 RTM (October 24, 2012)
|
||||
minTime = datetime.date(2012, 10, 24)
|
||||
elif hostOsType == "HOST_SERVER2012" or version == 5:
|
||||
# Microsoft Windows Server 2012 RTM (September 4, 2012)
|
||||
minTime = datetime.date(2012, 9, 4)
|
||||
else:
|
||||
# Windows Server 2008 R2 SP1 (February 16, 2011)
|
||||
minTime = datetime.date(2011, 2, 16)
|
||||
d = datetime.datetime.strptime(MinDate, "%d/%m/%Y")
|
||||
minTime = datetime.date(d.year, d.month, d.day)
|
||||
|
||||
# Generate Year and Day Number
|
||||
randomDate = datetime.date.fromtimestamp(random.randint(time.mktime(minTime.timetuple()), time.mktime(datetime.datetime.now().timetuple())))
|
||||
firstOfYear = datetime.date(randomDate.year, 1, 1)
|
||||
randomDayNumber = int((time.mktime(randomDate.timetuple()) - time.mktime(firstOfYear.timetuple())) / 86400 + 0.5)
|
||||
|
||||
# generate the epid string
|
||||
# Generate the EPID string
|
||||
result = []
|
||||
result.append(str(hostOsDict["type"]).rjust(5, "0"))
|
||||
result.append(str(PlatformId).rjust(5, "0"))
|
||||
result.append("-")
|
||||
result.append(str(keyConfig["GroupID"]).rjust(5, "0"))
|
||||
result.append(str(GroupId).rjust(5, "0"))
|
||||
result.append("-")
|
||||
result.append(str(productKeyID / 1000000).rjust(3, "0"))
|
||||
result.append("-")
|
||||
|
@ -129,8 +81,9 @@ def epidGenerator(appId, version, lcid):
|
|||
result.append("-")
|
||||
result.append(str(languageCode))
|
||||
result.append("-")
|
||||
result.append(str(hostOsDict["osBuild"]).rjust(4, "0"))
|
||||
result.append(str(BuildNumber).rjust(4, "0"))
|
||||
result.append(".0000-")
|
||||
result.append(str(randomDayNumber).rjust(3, "0"))
|
||||
result.append(str(randomDate.year).rjust(4, "0"))
|
||||
|
||||
return "".join(result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue