<commit_before>#!/usr/bin/env python

import binascii
import logging
import datetime
import os
import struct
import sys
import time
import uuid

from structure import Structure
import kmsPidGenerator
import filetimes
from formatText import justify, shell_message

# sqlite3 is optional
try:
	import sqlite3
except:
	pass


class UUID(Structure):
	commonHdr = ()
	structure = (
		('raw', '16s'),
	)

	def get(self):
		return uuid.UUID(bytes_le=str(self))

class kmsBase:
	class kmsRequestStruct(Structure):
		commonHdr = ()
		structure = (
			('versionMinor',            '<H'),
			('versionMajor',            '<H'),
			('isClientVm',              '<I'),
			('licenseStatus',           '<I'),
			('graceTime',               '<I'),
			('applicationId',           ':', UUID),
			('skuId',                   ':', UUID),
			('kmsCountedId' ,           ':', UUID),
			('clientMachineId',         ':', UUID),
			('requiredClientCount',     '<I'),
			('requestTime',             '<Q'),
			('previousClientMachineId', ':', UUID),
			('machineName',             'u'),
			('_mnPad',                  '_-mnPad', '126-len(machineName)'),
			('mnPad',                   ':'),
		)

		def getMachineName(self):
			return self['machineName'].decode('utf-16le')

		def getLicenseStatus(self):
			return kmsBase.licenseStates[self['licenseStatus']] or "Unknown"

	class kmsResponseStruct(Structure):
		commonHdr = ()
		structure = (
			('versionMinor',         '<H'),
			('versionMajor',         '<H'),
			('epidLen',              '<I=len(kmsEpid)+2'),
			('kmsEpid',              'u'),
			('clientMachineId',      ':', UUID),
			('responseTime',         '<Q'),
			('currentClientCount',   '<I'),
			('vLActivationInterval', '<I'),
			('vLRenewalInterval',    '<I'),
		)

	class GenericRequestHeader(Structure):
		commonHdr = ()
		structure = (
			('bodyLength1',  '<I'),
			('bodyLength2',  '<I'),
			('versionMinor', '<H'),
			('versionMajor', '<H'),
			('remainder',    '_'),
		)

	appIds = {
                uuid.UUID("55C92734-D682-4D71-983E-D6EC3F16059F") : "Windows",
                uuid.UUID("59A52881-A989-479D-AF46-F275C6370663") : "Office 14 (2010)",
                uuid.UUID("0FF1CE15-A989-479D-AF46-F275C6370663") : "Office 15 (2013) / Office 16 (2016)"
        }

	skuIds = {
                #########################
                ## Windows Server 2016 ##
                #########################
                uuid.UUID("21c56779-b449-4d20-adfc-eece0e1ad74b") : "Windows Server 2016 Datacenter",
                uuid.UUID("8c1c5410-9f39-4805-8c9d-63a07706358f") : "Windows Server 2016 Standard",
                uuid.UUID("2b5a1b0f-a5ab-4c54-ac2f-a6d94824a283") : "Windows Server 2016 Essentials",
                uuid.UUID("7b4433f4-b1e7-4788-895a-c45378d38253") : "Windows Server 2016 Cloud Storage",
                uuid.UUID("3dbf341b-5f6c-4fa7-b936-699dce9e263f") : "Windows Server 2016 Azure Core",
                ################
                ## Windows 10 ##
                ################
                uuid.UUID("2de67392-b7a7-462a-b1ca-108dd189f588") : "Windows 10 Professional",<commit_msg>Add Server 2019 SKUs to py2<commit_after>#!/usr/bin/env python

import binascii
import logging
import datetime
import os
import struct
import sys
import time
import uuid

from structure import Structure
import kmsPidGenerator
import filetimes
from formatText import justify, shell_message

# sqlite3 is optional
try:
	import sqlite3
except:
	pass


class UUID(Structure):
	commonHdr = ()
	structure = (
		('raw', '16s'),
	)

	def get(self):
		return uuid.UUID(bytes_le=str(self))

class kmsBase:
	class kmsRequestStruct(Structure):
		commonHdr = ()
		structure = (
			('versionMinor',            '<H'),
			('versionMajor',            '<H'),
			('isClientVm',              '<I'),
			('licenseStatus',           '<I'),
			('graceTime',               '<I'),
			('applicationId',           ':', UUID),
			('skuId',                   ':', UUID),
			('kmsCountedId' ,           ':', UUID),
			('clientMachineId',         ':', UUID),
			('requiredClientCount',     '<I'),
			('requestTime',             '<Q'),
			('previousClientMachineId', ':', UUID),
			('machineName',             'u'),
			('_mnPad',                  '_-mnPad', '126-len(machineName)'),
			('mnPad',                   ':'),
		)

		def getMachineName(self):
			return self['machineName'].decode('utf-16le')

		def getLicenseStatus(self):
			return kmsBase.licenseStates[self['licenseStatus']] or "Unknown"

	class kmsResponseStruct(Structure):
		commonHdr = ()
		structure = (
			('versionMinor',         '<H'),
			('versionMajor',         '<H'),
			('epidLen',              '<I=len(kmsEpid)+2'),
			('kmsEpid',              'u'),
			('clientMachineId',      ':', UUID),
			('responseTime',         '<Q'),
			('currentClientCount',   '<I'),
			('vLActivationInterval', '<I'),
			('vLRenewalInterval',    '<I'),
		)

	class GenericRequestHeader(Structure):
		commonHdr = ()
		structure = (
			('bodyLength1',  '<I'),
			('bodyLength2',  '<I'),
			('versionMinor', '<H'),
			('versionMajor', '<H'),
			('remainder',    '_'),
		)

	appIds = {
                uuid.UUID("55C92734-D682-4D71-983E-D6EC3F16059F") : "Windows",
                uuid.UUID("59A52881-A989-479D-AF46-F275C6370663") : "Office 14 (2010)",
                uuid.UUID("0FF1CE15-A989-479D-AF46-F275C6370663") : "Office 15 (2013) / Office 16 (2016)"
        }

	skuIds = {
                #########################
                ## Windows Server 2019 ##
                #########################
                uuid.UUID("34e1ae55-27f8-4950-8877-7a03be5fb181") : "Windows Server 2019 Datacenter",
                uuid.UUID("de32eafd-aaee-4662-9444-c1befb41bde2") : "Windows Server 2019 Standard",
                uuid.UUID("034d3cbb-5d4b-4245-b3f8-f84571314078") : "Windows Server 2019 Essentials",
                uuid.UUID("a99cc1f0-7719-4306-9645-294102fbff95") : "Windows Server 2019 Azure Core",
                #########################
                ## Windows Server 2016 ##
                #########################
                uuid.UUID("21c56779-b449-4d20-adfc-eece0e1ad74b") : "Windows Server 2016 Datacenter",
                uuid.UUID("8c1c5410-9f39-4805-8c9d-63a07706358f") : "Windows Server 2016 Standard",
                uuid.UUID("2b5a1b0f-a5ab-4c54-ac2f-a6d94824a283") : "Windows Server 2016 Essentials",
                uuid.UUID("7b4433f4-b1e7-4788-895a-c45378d38253") : "Windows Server 2016 Cloud Storage",
                uuid.UUID("3dbf341b-5f6c-4fa7-b936-699dce9e263f") : "Windows Server 2016 Azure Core",
                ################
                ## Windows 10 ##
                ################
                uuid.UUID("2de67392-b7a7-462a-b1ca-108dd189f588") : "Windows 10 Professional",
{'fraction_non_alphanumeric': 0.18777679362267494, 'fraction_numerical': 0.09049306170652495, 'mean_word_length': 2.397693079237713, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4357726', 'n_tokens_mistral': 2815, 'n_tokens_neox': 2271, 'n_words': 390}