diff --git a/py-kms/KmsDataBase.xml b/py-kms/KmsDataBase.xml index 511afba..ccedad7 100644 --- a/py-kms/KmsDataBase.xml +++ b/py-kms/KmsDataBase.xml @@ -1,10 +1,15 @@ - - + + + - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + - + @@ -121,14 +223,14 @@ - + - + @@ -150,9 +252,10 @@ + - + @@ -171,7 +274,7 @@ - + @@ -193,7 +296,7 @@ - + @@ -204,7 +307,7 @@ - + @@ -213,7 +316,7 @@ - + @@ -223,7 +326,7 @@ - + @@ -233,9 +336,10 @@ + - + @@ -247,9 +351,10 @@ + - + @@ -260,9 +365,10 @@ + - + @@ -272,7 +378,7 @@ - + @@ -293,21 +399,24 @@ + + + - + @@ -324,7 +433,7 @@ - + @@ -344,14 +453,14 @@ - + - + @@ -360,7 +469,7 @@ - + @@ -375,7 +484,7 @@ - + @@ -392,20 +501,20 @@ - + - + - + @@ -418,7 +527,7 @@ - + @@ -432,15 +541,17 @@ - + + + @@ -448,18 +559,20 @@ + - + + - + @@ -470,7 +583,7 @@ - + @@ -479,43 +592,45 @@ - + - + - + + - + - + - + + @@ -523,41 +638,45 @@ + + - + - + - + - + + - + + @@ -566,82 +685,99 @@ - + - + + - + + + + - + + + + + - + + - - - - - - + + - + + + + + + + - + + - - - + + + + + - + + - - - - - - - - - - - + + + + + + + + + + + + + @@ -654,7 +790,7 @@ - + @@ -666,34 +802,39 @@ - + + - - - - + + + + + + - + - - + + + + - + - + @@ -702,7 +843,7 @@ - + @@ -716,12 +857,14 @@ - - - - - - + + + + + + + + @@ -741,79 +884,85 @@ - + - + - + - + - + - + - + - + - + - + - + - + + + - + + + + - + - + + @@ -823,21 +972,25 @@ + + + + @@ -845,10 +998,12 @@ + + @@ -856,24 +1011,28 @@ + + + - + + @@ -883,12 +1042,13 @@ - + + - + - + @@ -896,124 +1056,175 @@ - + - + + + - + + - + - - + - + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + - - + + - + - - - + + + - + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/py-kms/pykms_Client.py b/py-kms/pykms_Client.py index d2fe1b5..142b316 100644 --- a/py-kms/pykms_Client.py +++ b/py-kms/pykms_Client.py @@ -184,7 +184,7 @@ def client_update(): if sName == name + 'Enterprise' or \ sName == name[:6] + 'ProfessionalPlus' + name[6:]: clt_config['KMSClientSkuID'] = skuitem['Id'] - clt_config['RequiredClientCount'] = int(kmsitem['NCountPolicy']) + clt_config['RequiredClientCount'] = int(kmsitem.get('NCountPolicy', 25)) # if not given default to 25 clt_config['KMSProtocolMajorVersion'] = int(float(kmsitem['DefaultKmsProtocol'])) clt_config['KMSProtocolMinorVersion'] = 0 clt_config['KMSClientLicenseStatus'] = 2 diff --git a/py-kms/pykms_PidGenerator.py b/py-kms/pykms_PidGenerator.py index bf84187..134bfb4 100644 --- a/py-kms/pykms_PidGenerator.py +++ b/py-kms/pykms_PidGenerator.py @@ -20,7 +20,7 @@ def epidGenerator(kmsId, version, lcid): 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']) ) + pkeys.append( (csvlkitem['GroupId'], csvlkitem['MinKeyId'], csvlkitem['MaxKeyId'], csvlkitem.get('InvalidWinBuild', '[]')) ) else: # fallback to Windows Server 2019 parameters. pkeys.append( ('206', '551000000', '570999999', '[0,1,2]') ) @@ -40,10 +40,11 @@ def epidGenerator(kmsId, version, lcid): hosts.append(winbuild) except KeyError: # fallback to Windows Server 2019 parameters. - hosts.append( {'BuildNumber':'17763', 'PlatformId':'3612', 'MinDate':'02/10/2018'} ) + hosts.append( {'BuildNumber':'17763', 'PlatformId':'3612', 'ReleaseDate':'2018-10-02T00:00:00Z'} ) host = random.choice(hosts) - BuildNumber, PlatformId, MinDate = host['BuildNumber'], host['PlatformId'], host['MinDate'] + + BuildNumber, PlatformId, ReleaseDate = host['BuildNumber'], host['PlatformId'], host['ReleaseDate'].rstrip("Z") # Generate Part 3 and Part 4: Product Key ID productKeyID = random.randint(MinKeyId, MaxKeyId) @@ -55,7 +56,7 @@ def epidGenerator(kmsId, version, lcid): languageCode = lcid # (C# CultureInfo.InstalledUICulture.LCID) # Generate Part 8: KMS Host Activation Date - d = datetime.datetime.strptime(MinDate, "%d/%m/%Y") + d = datetime.datetime.fromisoformat(ReleaseDate) minTime = datetime.date(d.year, d.month, d.day) # Generate Year and Day Number diff --git a/py-kms/pykms_WebUI.py b/py-kms/pykms_WebUI.py index 43285a5..06b7d7e 100644 --- a/py-kms/pykms_WebUI.py +++ b/py-kms/pykms_WebUI.py @@ -15,33 +15,34 @@ def _get_serve_count(): return _serve_count _kms_items = None -_kms_items_ignored = None +_kms_items_noglvk = None def _get_kms_items_cache(): - global _kms_items, _kms_items_ignored + global _kms_items, _kms_items_noglvk if _kms_items is None: - _kms_items = {} - _kms_items_ignored = 0 - queue = [kmsDB2Dict()] - while len(queue): - item = queue.pop(0) - if isinstance(item, list): - for i in item: - queue.append(i) - elif isinstance(item, dict): - if 'KmsItems' in item: - queue.append(item['KmsItems']) - elif 'SkuItems' in item: - queue.append(item['SkuItems']) - elif 'Gvlk' in item: - if len(item['Gvlk']): - _kms_items[item['DisplayName']] = item['Gvlk'] - else: - _kms_items_ignored += 1 - #else: - # print(item) - else: - raise NotImplementedError(f'Unknown type: {type(item)}') - return _kms_items, _kms_items_ignored + _kms_items = {} # {group: str -> {product: str -> gvlk: str}} + _kms_items_noglvk = 0 + for section in kmsDB2Dict(): + for element in section: + if "KmsItems" in element: + for product in element["KmsItems"]: + group_name = product["DisplayName"] + items = {} + for item in product["SkuItems"]: + items[item["DisplayName"]] = item["Gvlk"] + if not item["Gvlk"]: + _kms_items_noglvk += 1 + if len(items) == 0: + continue + if group_name not in _kms_items: + _kms_items[group_name] = {} + _kms_items[group_name].update(items) + elif "DisplayName" in element and "BuildNumber" in element and "PlatformId" in element: + pass # these are WinBuilds + elif "DisplayName" in element and "Activate" in element: + pass # these are CsvlkItems + else: + raise NotImplementedError(f'Unknown element: {element}') + return _kms_items, _kms_items_noglvk app = Flask('pykms_webui') app.jinja_env.globals['start_time'] = datetime.datetime.now() @@ -90,7 +91,7 @@ def root(): count_clients=countClients, count_clients_windows=countClientsWindows, count_clients_office=countClientsOffice, - count_projects=len(_get_kms_items_cache()[0]) + count_projects=sum([len(entries) for entries in _get_kms_items_cache()[0].values()]) ), 200 if error is None else 500 @app.route('/readyz') @@ -125,15 +126,15 @@ def license(): @app.route('/products') def products(): _increase_serve_count() - items, ignored = _get_kms_items_cache() - countProducts = len(items) - countProductsWindows = len([i for i in items if 'windows' in i.lower()]) - countProductsOffice = len([i for i in items if 'office' in i.lower()]) + items, noglvk = _get_kms_items_cache() + countProducts = sum([len(entries) for entries in items.values()]) + countProductsWindows = sum([len(entries) for (name, entries) in items.items() if 'windows' in name.lower()]) + countProductsOffice = sum([len(entries) for (name, entries) in items.items() if 'office' in name.lower()]) return render_template( 'products.html', path='/products/', products=items, - filtered=ignored, + filtered=noglvk, count_products=countProducts, count_products_windows=countProductsWindows, count_products_office=countProductsOffice diff --git a/py-kms/templates/products.html b/py-kms/templates/products.html index 9665304..d106ed1 100644 --- a/py-kms/templates/products.html +++ b/py-kms/templates/products.html @@ -32,22 +32,36 @@
+ + +{% for group_name, group_products in products | dictsort %} +

{{ group_name }}

- - + + - {% for name, gvlk in products | dictsort %} - {% if gvlk %} - - - - - {% endif %} - {% endfor %} + {% for name, gvlk in group_products | dictsort %} + + + + + {% endfor %}
NameGVLKNameGVLK
{{ name }}
{{ gvlk }}
{{ name }} + {% if gvlk %} +
{{ gvlk }}
{% endif %} +
-{% endblock %} \ No newline at end of file +{% endfor %} +{% endblock %}