6 APP_ID_WINDOWS
= uuid
.UUID("55C92734-D682-4D71-983E-D6EC3F16059F")
7 APP_ID_OFFICE14
= uuid
.UUID("59A52881-A989-479D-AF46-F275C6370663")
8 APP_ID_OFFICE15
= uuid
.UUID("0FF1CE15-A989-479D-AF46-F275C6370663")
13 # Windows Server 2008 R2 SP1
14 hostOsList
["HOST_SERVER2008R2"] = {
18 # Windows Server 2012 RTM
19 hostOsList
["HOST_SERVER2012"] = {
23 # Windows Server 2012 R2 RTM
24 hostOsList
["HOST_SERVER2012R2"] = {
30 # Product Specific KeyConfig
32 # Windows Server KMS Host PID, actual PIDRangeMax = 191999999
33 pkeyConfigList
["windows"] = {
35 "PIDRangeMin" : 152000000,
36 "PIDRangeMax" : 152999999
38 # Windows Server 2012 R2 KMS Host PID, actual PIDRangeMax = 310999999
39 pkeyConfigList
["windows2012r2"] = {
41 "PIDRangeMin" : 271000000,
42 "PIDRangeMax" : 271999999
44 # Office 2010 KMSHost Class PID, actual PIDRangeMax = 217999999
45 pkeyConfigList
["office14"] = {
47 "PIDRangeMin" : 199000000,
48 "PIDRangeMax" : 201999999
50 # Office 2013 KMSHost Class PID, actual PIDRangeMax = 255999999
51 pkeyConfigList
["office15"] = {
53 "PIDRangeMin" : 234000000,
54 "PIDRangeMax" : 234999999
58 def epidGenerator(appId
, version
, lcid
):
59 # Generate Part 1 & 7: Host Type and KMS Server OS Build
60 hostOsType
= random
.choice(hostOsList
.keys())
61 hostOsDict
= hostOsList
[hostOsType
]
63 # Generate Part 2: Group ID and Product Key ID Range
64 if appId
== APP_ID_OFFICE14
:
65 keyConfig
= pkeyConfigList
["office14"]
66 elif appId
== APP_ID_OFFICE15
:
67 keyConfig
= pkeyConfigList
["office15"]
70 if hostOsDict
['osBuild'] == 9600:
71 keyConfig
= pkeyConfigList
["windows2012r2"]
73 keyConfig
= pkeyConfigList
["windows"]
75 # Generate Part 3 and Part 4: Product Key ID
76 productKeyID
= random
.randint(keyConfig
["PIDRangeMin"], keyConfig
["PIDRangeMax"])
78 # Generate Part 5: License Channel (00=Retail, 01=Retail, 02=OEM,
79 # 03=Volume(GVLK,MAK)) - always 03
82 # Generate Part 6: Language - use system default language
84 languageCode
= lcid
# C# CultureInfo.InstalledUICulture.LCID
86 # Generate Part 8: KMS Host Activation Date
87 # Get Minimum Possible Date: Newer Products first
88 if hostOsType
== "HOST_SERVER2012R2" or version
== 6:
89 # Microsoft Windows Server 2012 R2 RTM (October 17, 2013)
90 minTime
= datetime
.date(2013, 10, 17)
91 elif appId
== APP_ID_OFFICE15
:
92 # Microsoft Office 2013 RTM (October 24, 2012)
93 minTime
= datetime
.date(2012, 10, 24)
94 elif hostOsType
== "HOST_SERVER2012" or version
== 5:
95 # Microsoft Windows Server 2012 RTM (September 4, 2012)
96 minTime
= datetime
.date(2012, 9, 4)
98 # Windows Server 2008 R2 SP1 (February 16, 2011)
99 minTime
= datetime
.date(2011, 2, 16)
101 # Generate Year and Day Number
102 randomDate
= datetime
.date
.fromtimestamp(random
.randint(time
.mktime(minTime
.timetuple()), time
.mktime(datetime
.datetime
.now().timetuple())))
103 firstOfYear
= datetime
.date(randomDate
.year
, 1, 1)
104 randomDayNumber
= int((time
.mktime(randomDate
.timetuple()) - time
.mktime(firstOfYear
.timetuple())) / 86400 + 0.5)
106 # generate the epid string
108 result
.append(str(hostOsDict
["type"]).rjust(5, "0"))
110 result
.append(str(keyConfig
["GroupID"]).rjust(5, "0"))
112 result
.append(str(productKeyID
/ 1000000).rjust(3, "0"))
114 result
.append(str(productKeyID
% 1000000).rjust(6, "0"))
116 result
.append(str(licenseChannel
).rjust(2, "0"))
118 result
.append(str(languageCode
))
120 result
.append(str(hostOsDict
["osBuild"]).rjust(4, "0"))
121 result
.append(".0000-")
122 result
.append(str(randomDayNumber
).rjust(3, "0"))
123 result
.append(str(randomDate
.year
).rjust(4, "0"))
124 return "".join(result
)