kms.c 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
  1. #ifndef CONFIG
  2. #define CONFIG "config.h"
  3. #endif // CONFIG
  4. #include CONFIG
  5. #ifndef _CRT_SECURE_NO_WARNINGS
  6. #define _CRT_SECURE_NO_WARNINGS
  7. #endif
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <stdint.h>
  11. #include <ctype.h>
  12. #include <time.h>
  13. #if !defined(_WIN32)
  14. #if !__ANDROID__
  15. #include <sys/shm.h>
  16. #endif // !__ANDROID__
  17. #include <sys/socket.h>
  18. #include <sys/ipc.h>
  19. #endif // !defined(_WIN32)
  20. #include "output.h"
  21. #include "crypto.h"
  22. #include "endian.h"
  23. #include "kms.h"
  24. #include "shared_globals.h"
  25. #include "helpers.h"
  26. #define FRIENDLY_NAME_WINDOWS "Windows"
  27. #define FRIENDLY_NAME_OFFICE2010 "Office 2010"
  28. #define FRIENDLY_NAME_OFFICE2013 "Office 2013+"
  29. #ifndef IS_LIBRARY
  30. #ifdef NO_LOG
  31. #define LOGTEXT(x) ""
  32. #else //!NO_LOG
  33. #define LOGTEXT(x) x
  34. #endif // !NO_LOG
  35. // Do not change the order of this list. Append items as necessary
  36. const KmsIdList ProductList[] = {
  37. /* 000 */ { { 0xe85af946, 0x2e25, 0x47b7, { 0x83, 0xe1, 0xbe, 0xbc, 0xeb, 0xea, 0xc6, 0x11, } } /*e85af946-2e25-47b7-83e1-bebcebeac611*/, LOGTEXT("Office 2010"), EPID_OFFICE2010, 4, 5 },
  38. /* 001 */ { { 0xe6a6f1bf, 0x9d40, 0x40c3, { 0xaa, 0x9f, 0xc7, 0x7b, 0xa2, 0x15, 0x78, 0xc0, } } /*e6a6f1bf-9d40-40c3-aa9f-c77ba21578c0*/, LOGTEXT("Office 2013"), EPID_OFFICE2013, 5, 5 },
  39. /* 002 */ { { 0xaa4c7968, 0xb9da, 0x4680, { 0x92, 0xb6, 0xac, 0xb2, 0x5e, 0x2f, 0x86, 0x6c, } } /*aa4c7968-b9da-4680-92b6-acb25e2f866c*/, LOGTEXT("Office 2013 (Pre-Release)"), EPID_OFFICE2013, 5, 5 },
  40. /* 003 */ { { 0x85b5f61b, 0x320b, 0x4be3, { 0x81, 0x4a, 0xb7, 0x6b, 0x2b, 0xfa, 0xfc, 0x82, } } /*85b5f61b-320b-4be3-814a-b76b2bfafc82*/, LOGTEXT("Office 2016"), EPID_OFFICE2016, 6, 5 },
  41. # ifndef NO_BASIC_PRODUCT_LIST
  42. /* 004 */ { { 0x212a64dc, 0x43b1, 0x4d3d, { 0xa3, 0x0c, 0x2f, 0xc6, 0x9d, 0x20, 0x95, 0xc6, } } /*212a64dc-43b1-4d3d-a30c-2fc69d2095c6*/, LOGTEXT("Windows Vista"), EPID_WINDOWS, 4, 25 },
  43. /* 005 */ { { 0x7fde5219, 0xfbfa, 0x484a, { 0x82, 0xc9, 0x34, 0xd1, 0xad, 0x53, 0xe8, 0x56, } } /*7fde5219-fbfa-484a-82c9-34d1ad53e856*/, LOGTEXT("Windows 7"), EPID_WINDOWS, 4, 25 },
  44. /* 006 */ { { 0x3c40b358, 0x5948, 0x45af, { 0x92, 0x3b, 0x53, 0xd2, 0x1f, 0xcc, 0x7e, 0x79, } } /*3c40b358-5948-45af-923b-53d21fcc7e79*/, LOGTEXT("Windows 8 (Volume)"), EPID_WINDOWS, 5, 25 },
  45. /* 007 */ { { 0x5f94a0bb, 0xd5a0, 0x4081, { 0xa6, 0x85, 0x58, 0x19, 0x41, 0x8b, 0x2f, 0xe0, } } /*5f94a0bb-d5a0-4081-a685-5819418b2fe0*/, LOGTEXT("Windows Preview"), EPID_WINDOWS, 5, 25 },
  46. /* 008 */ { { 0xbbb97b3b, 0x8ca4, 0x4a28, { 0x97, 0x17, 0x89, 0xfa, 0xbd, 0x42, 0xc4, 0xac, } } /*bbb97b3b-8ca4-4a28-9717-89fabd42c4ac*/, LOGTEXT("Windows 8 (Retail)"), EPID_WINDOWS, 5, 25 },
  47. /* 009 */ { { 0xcb8fc780, 0x2c05, 0x495a, { 0x97, 0x10, 0x85, 0xaf, 0xff, 0xc9, 0x04, 0xd7, } } /*cb8fc780-2c05-495a-9710-85afffc904d7*/, LOGTEXT("Windows 8.1 (Volume)"), EPID_WINDOWS, 6, 25 },
  48. /* 010 */ { { 0x6d646890, 0x3606, 0x461a, { 0x86, 0xab, 0x59, 0x8b, 0xb8, 0x4a, 0xce, 0x82, } } /*6d646890-3606-461a-86ab-598bb84ace82*/, LOGTEXT("Windows 8.1 (Retail)"), EPID_WINDOWS, 6, 25 },
  49. /* 011 */ { { 0x33e156e4, 0xb76f, 0x4a52, { 0x9f, 0x91, 0xf6, 0x41, 0xdd, 0x95, 0xac, 0x48, } } /*33e156e4-b76f-4a52-9f91-f641dd95ac48*/, LOGTEXT("Windows Server 2008 A (Web and HPC)"), EPID_WINDOWS, 4, 5 },
  50. /* 012 */ { { 0x8fe53387, 0x3087, 0x4447, { 0x89, 0x85, 0xf7, 0x51, 0x32, 0x21, 0x5a, 0xc9, } } /*8fe53387-3087-4447-8985-f75132215ac9*/, LOGTEXT("Windows Server 2008 B (Standard and Enterprise)"), EPID_WINDOWS, 4, 5 },
  51. /* 013 */ { { 0x8a21fdf3, 0xcbc5, 0x44eb, { 0x83, 0xf3, 0xfe, 0x28, 0x4e, 0x66, 0x80, 0xa7, } } /*8a21fdf3-cbc5-44eb-83f3-fe284e6680a7*/, LOGTEXT("Windows Server 2008 C (Datacenter)"), EPID_WINDOWS, 4, 5 },
  52. /* 014 */ { { 0x0fc6ccaf, 0xff0e, 0x4fae, { 0x9d, 0x08, 0x43, 0x70, 0x78, 0x5b, 0xf7, 0xed, } } /*0fc6ccaf-ff0e-4fae-9d08-4370785bf7ed*/, LOGTEXT("Windows Server 2008 R2 A (Web and HPC)"), EPID_WINDOWS, 4, 5 },
  53. /* 015 */ { { 0xca87f5b6, 0xcd46, 0x40c0, { 0xb0, 0x6d, 0x8e, 0xcd, 0x57, 0xa4, 0x37, 0x3f, } } /*ca87f5b6-cd46-40c0-b06d-8ecd57a4373f*/, LOGTEXT("Windows Server 2008 R2 B (Standard and Enterprise)"), EPID_WINDOWS, 4, 5 },
  54. /* 016 */ { { 0xb2ca2689, 0xa9a8, 0x42d7, { 0x93, 0x8d, 0xcf, 0x8e, 0x9f, 0x20, 0x19, 0x58, } } /*b2ca2689-a9a8-42d7-938d-cf8e9f201958*/, LOGTEXT("Windows Server 2008 R2 C (Datacenter)"), EPID_WINDOWS, 4, 5 },
  55. /* 017 */ { { 0x8665cb71, 0x468c, 0x4aa3, { 0xa3, 0x37, 0xcb, 0x9b, 0xc9, 0xd5, 0xea, 0xac, } } /*8665cb71-468c-4aa3-a337-cb9bc9d5eaac*/, LOGTEXT("Windows Server 2012"), EPID_WINDOWS, 5, 5 },
  56. /* 018 */ { { 0x8456efd3, 0x0c04, 0x4089, { 0x87, 0x40, 0x5b, 0x72, 0x38, 0x53, 0x5a, 0x65, } } /*8456efd3-0c04-4089-8740-5b7238535a65*/, LOGTEXT("Windows Server 2012 R2"), EPID_WINDOWS, 6, 5 },
  57. /* 019 */ { { 0x6d5f5270, 0x31ac, 0x433e, { 0xb9, 0x0a, 0x39, 0x89, 0x29, 0x23, 0xc6, 0x57, } } /*6d5f5270-31ac-433e-b90a-39892923c657*/, LOGTEXT("Windows Server Preview"), EPID_WINDOWS, 6, 5 },
  58. /* 020 */ { { 0x58e2134f, 0x8e11, 0x4d17, { 0x9c, 0xb2, 0x91, 0x06, 0x9c, 0x15, 0x11, 0x48, } } /*58e2134f-8e11-4d17-9cb2-91069c151148*/, LOGTEXT("Windows 10 2015 (Volume)"), EPID_WINDOWS, 6, 25 },
  59. /* 021 */ { { 0xe1c51358, 0xfe3e, 0x4203, { 0xa4, 0xa2, 0x3b, 0x6b, 0x20, 0xc9, 0x73, 0x4e, } } /*e1c51358-fe3e-4203-a4a2-3b6b20c9734e*/, LOGTEXT("Windows 10 (Retail)"), EPID_WINDOWS, 6, 25 },
  60. /* 022 */ { { 0x6e9fc069, 0x257d, 0x4bc4, { 0xb4, 0xa7, 0x75, 0x05, 0x14, 0xd3, 0x27, 0x43, } } /*6e9fc069-257d-4bc4-b4a7-750514d32743*/, LOGTEXT("Windows Server 2016"), EPID_WINDOWS, 6, 5 },
  61. /* 023 */ { { 0x969fe3c0, 0xa3ec, 0x491a, { 0x9f, 0x25, 0x42, 0x36, 0x05, 0xde, 0xb3, 0x65, } } /*969fe3c0-a3ec-491a-9f25-423605deb365*/, LOGTEXT("Windows 10 2016 (Volume)"), EPID_WINDOWS, 6, 25 },
  62. # endif // NO_BASIC_PRODUCT_LIST
  63. };
  64. #ifndef NO_STRICT_MODES
  65. const ProdListIndex_t RetailAndBetaProducts[] = { KMS_ID_WIN10_RETAIL, KMS_ID_WIN81_RETAIL, KMS_ID_WIN8_RETAIL, KMS_ID_WIN_BETA, KMS_ID_WIN_SRV_BETA, KMS_ID_OFFICE2013_BETA };
  66. #endif // !NO_STRICT_MODES
  67. #if !defined(NO_LOG) || !defined(NO_STRICT_MODES)
  68. // Application ID is used by KMS server to count KeyManagementServiceCurrentCount
  69. // Do not change the order of this list. Append items as necessary
  70. const KmsIdList AppList[] = {
  71. /* 000 */ { { 0x55c92734, 0xd682, 0x4d71, { 0x98, 0x3e, 0xd6, 0xec, 0x3f, 0x16, 0x05, 0x9f } } /*"55C92734-D682-4D71-983E-D6EC3F16059F"*/, LOGTEXT(FRIENDLY_NAME_WINDOWS), EPID_WINDOWS, 0, 0},
  72. /* 001 */ { { 0x59A52881, 0xa989, 0x479d, { 0xaf, 0x46, 0xf2, 0x75, 0xc6, 0x37, 0x06, 0x63 } } /*"59A52881-A989-479D-AF46-F275C6370663"*/, LOGTEXT(FRIENDLY_NAME_OFFICE2010), EPID_OFFICE2010, 0, 0},
  73. /* 002 */ { { 0x0FF1CE15, 0xA989, 0x479D, { 0xaf, 0x46, 0xf2, 0x75, 0xc6, 0x37, 0x06, 0x63 } } /*"0FF1CE15-A989-479D-AF46-F275C6370663"*/, LOGTEXT(FRIENDLY_NAME_OFFICE2013), EPID_OFFICE2013, 0, 0},
  74. };
  75. #endif // !defined(NO_LOG) || !defined(NO_STRICT_MODES)
  76. #ifndef NO_EXTENDED_PRODUCT_LIST
  77. const KmsIdList ExtendedProductList[] = {
  78. // Windows 10 (Retail)
  79. { { 0x58e97c99, 0xf377, 0x4ef1, { 0x81, 0xd5, 0x4a, 0xd5, 0x52, 0x2b, 0x5f, 0xd8, } } /*58e97c99-f377-4ef1-81d5-4ad5522b5fd8*/, LOGTEXT("Windows 10 Home"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_RETAIL },
  80. { { 0xa9107544, 0xf4a0, 0x4053, { 0xa9, 0x6a, 0x14, 0x79, 0xab, 0xde, 0xf9, 0x12, } } /*a9107544-f4a0-4053-a96a-1479abdef912*/, LOGTEXT("Windows 10 Home Country Specific"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_RETAIL },
  81. { { 0x7b9e1751, 0xa8da, 0x4f75, { 0x95, 0x60, 0x5f, 0xad, 0xfe, 0x3d, 0x8e, 0x38, } } /*7b9e1751-a8da-4f75-9560-5fadfe3d8e38*/, LOGTEXT("Windows 10 Home N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_RETAIL },
  82. { { 0xcd918a57, 0xa41b, 0x4c82, { 0x8d, 0xce, 0x1a, 0x53, 0x8e, 0x22, 0x1a, 0x83, } } /*cd918a57-a41b-4c82-8dce-1a538e221a83*/, LOGTEXT("Windows 10 Home Single Language"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_RETAIL },
  83. // Windows 10 2015 (Volume)
  84. { { 0xe0c42288, 0x980c, 0x4788, { 0xa0, 0x14, 0xc0, 0x80, 0xd2, 0xe1, 0x92, 0x6e, } } /*e0c42288-980c-4788-a014-c080d2e1926e*/, LOGTEXT("Windows 10 Education"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  85. { { 0x3c102355, 0xd027, 0x42c6, { 0xad, 0x23, 0x2e, 0x7e, 0xf8, 0xa0, 0x25, 0x85, } } /*3c102355-d027-42c6-ad23-2e7ef8a02585*/, LOGTEXT("Windows 10 Education N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  86. { { 0x73111121, 0x5638, 0x40f6, { 0xbc, 0x11, 0xf1, 0xd7, 0xb0, 0xd6, 0x43, 0x00, } } /*73111121-5638-40f6-bc11-f1d7b0d64300*/, LOGTEXT("Windows 10 Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  87. { { 0x7b51a46c, 0x0c04, 0x4e8f, { 0x9a, 0xf4, 0x84, 0x96, 0xcc, 0xa9, 0x0d, 0x5e, } } /*7b51a46c-0c04-4e8f-9af4-8496cca90d5e*/, LOGTEXT("Windows 10 Enterprise 2015 LTSB"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  88. { { 0x87b838b7, 0x41b6, 0x4590, { 0x83, 0x18, 0x57, 0x97, 0x95, 0x1d, 0x85, 0x29, } } /*87b838b7-41b6-4590-8318-5797951d8529*/, LOGTEXT("Windows 10 Enterprise 2015 LTSB N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  89. { { 0xe272e3e2, 0x732f, 0x4c65, { 0xa8, 0xf0, 0x48, 0x47, 0x47, 0xd0, 0xd9, 0x47, } } /*e272e3e2-732f-4c65-a8f0-484747d0d947*/, LOGTEXT("Windows 10 Enterprise N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  90. { { 0x43f2ab05, 0x7c87, 0x4d56, { 0xb2, 0x7c, 0x44, 0xd0, 0xf9, 0xa3, 0xda, 0xbd, } } /*43f2ab05-7c87-4d56-b27c-44d0f9a3dabd*/, LOGTEXT("Windows 10 Enterprise Preview"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  91. { { 0x2de67392, 0xb7a7, 0x462a, { 0xb1, 0xca, 0x10, 0x8d, 0xd1, 0x89, 0xf5, 0x88, } } /*2de67392-b7a7-462a-b1ca-108dd189f588*/, LOGTEXT("Windows 10 Professional"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  92. { { 0x3f1afc82, 0xf8ac, 0x4f6c, { 0x80, 0x05, 0x1d, 0x23, 0x3e, 0x60, 0x6e, 0xee, } } /*3f1afc82-f8ac-4f6c-8005-1d233e606eee*/, LOGTEXT("Windows 10 Professional Education"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  93. { { 0x5300b18c, 0x2e33, 0x4dc2, { 0x82, 0x91, 0x47, 0xff, 0xce, 0xc7, 0x46, 0xdd, } } /*5300b18c-2e33-4dc2-8291-47ffcec746dd*/, LOGTEXT("Windows 10 Professional Education N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  94. { { 0xa80b5abf, 0x76ad, 0x428b, { 0xb0, 0x5d, 0xa4, 0x7d, 0x2d, 0xff, 0xee, 0xbf, } } /*a80b5abf-76ad-428b-b05d-a47d2dffeebf*/, LOGTEXT("Windows 10 Professional N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  95. { { 0xff808201, 0xfec6, 0x4fd4, { 0xae, 0x16, 0xab, 0xbd, 0xda, 0xde, 0x57, 0x06, } } /*ff808201-fec6-4fd4-ae16-abbddade5706*/, LOGTEXT("Windows 10 Professional Preview"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_VL },
  96. // Windows 10 2016 (Volume)
  97. { { 0x2d5a5a60, 0x3040, 0x48bf, { 0xbe, 0xb0, 0xfc, 0xd7, 0x70, 0xc2, 0x0c, 0xe0, } } /*2d5a5a60-3040-48bf-beb0-fcd770c20ce0*/, LOGTEXT("Windows 10 Enterprise 2016 LTSB"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_LTSB2016 },
  98. { { 0x9f776d83, 0x7156, 0x45b2, { 0x8a, 0x5c, 0x35, 0x9b, 0x9c, 0x9f, 0x22, 0xa3, } } /*9f776d83-7156-45b2-8a5c-359b9c9f22a3*/, LOGTEXT("Windows 10 Enterprise 2016 LTSB N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN10_LTSB2016 },
  99. // Windows 10 Unknown (Volume)
  100. // Windows 7
  101. { { 0xdb537896, 0x376f, 0x48ae, { 0xa4, 0x92, 0x53, 0xd0, 0x54, 0x77, 0x73, 0xd0, } } /*db537896-376f-48ae-a492-53d0547773d0*/, LOGTEXT("Windows 7 Embedded POSReady"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  102. { { 0xe1a8296a, 0xdb37, 0x44d1, { 0x8c, 0xce, 0x7b, 0xc9, 0x61, 0xd5, 0x9c, 0x54, } } /*e1a8296a-db37-44d1-8cce-7bc961d59c54*/, LOGTEXT("Windows 7 Embedded Standard"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  103. { { 0xae2ee509, 0x1b34, 0x41c0, { 0xac, 0xb7, 0x6d, 0x46, 0x50, 0x16, 0x89, 0x15, } } /*ae2ee509-1b34-41c0-acb7-6d4650168915*/, LOGTEXT("Windows 7 Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  104. { { 0x46bbed08, 0x9c7b, 0x48fc, { 0xa6, 0x14, 0x95, 0x25, 0x05, 0x73, 0xf4, 0xea, } } /*46bbed08-9c7b-48fc-a614-95250573f4ea*/, LOGTEXT("Windows 7 Enterprise E"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  105. { { 0x1cb6d605, 0x11b3, 0x4e14, { 0xbb, 0x30, 0xda, 0x91, 0xc8, 0xe3, 0x98, 0x3a, } } /*1cb6d605-11b3-4e14-bb30-da91c8e3983a*/, LOGTEXT("Windows 7 Enterprise N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  106. { { 0xb92e9980, 0xb9d5, 0x4821, { 0x9c, 0x94, 0x14, 0x0f, 0x63, 0x2f, 0x63, 0x12, } } /*b92e9980-b9d5-4821-9c94-140f632f6312*/, LOGTEXT("Windows 7 Professional"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  107. { { 0x5a041529, 0xfef8, 0x4d07, { 0xb0, 0x6f, 0xb5, 0x9b, 0x57, 0x3b, 0x32, 0xd2, } } /*5a041529-fef8-4d07-b06f-b59b573b32d2*/, LOGTEXT("Windows 7 Professional E"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  108. { { 0x54a09a0d, 0xd57b, 0x4c10, { 0x8b, 0x69, 0xa8, 0x42, 0xd6, 0x59, 0x0a, 0xd5, } } /*54a09a0d-d57b-4c10-8b69-a842d6590ad5*/, LOGTEXT("Windows 7 Professional N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  109. { { 0xaa6dd3aa, 0xc2b4, 0x40e2, { 0xa5, 0x44, 0xa6, 0xbb, 0xb3, 0xf5, 0xc3, 0x95, } } /*aa6dd3aa-c2b4-40e2-a544-a6bbb3f5c395*/, LOGTEXT("Windows 7 ThinPC"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN7 },
  110. // Windows 8 (Retail)
  111. { { 0xc04ed6bf, 0x55c8, 0x4b47, { 0x9f, 0x8e, 0x5a, 0x1f, 0x31, 0xce, 0xee, 0x60, } } /*c04ed6bf-55c8-4b47-9f8e-5a1f31ceee60*/, LOGTEXT("Windows 8 Core"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_RETAIL },
  112. { { 0x9d5584a2, 0x2d85, 0x419a, { 0x98, 0x2c, 0xa0, 0x08, 0x88, 0xbb, 0x9d, 0xdf, } } /*9d5584a2-2d85-419a-982c-a00888bb9ddf*/, LOGTEXT("Windows 8 Core Country Specific"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_RETAIL },
  113. { { 0x197390a0, 0x65f6, 0x4a95, { 0xbd, 0xc4, 0x55, 0xd5, 0x8a, 0x3b, 0x02, 0x53, } } /*197390a0-65f6-4a95-bdc4-55d58a3b0253*/, LOGTEXT("Windows 8 Core N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_RETAIL },
  114. { { 0x8860fcd4, 0xa77b, 0x4a20, { 0x90, 0x45, 0xa1, 0x50, 0xff, 0x11, 0xd6, 0x09, } } /*8860fcd4-a77b-4a20-9045-a150ff11d609*/, LOGTEXT("Windows 8 Core Single Language"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_RETAIL },
  115. { { 0xa00018a3, 0xf20f, 0x4632, { 0xbf, 0x7c, 0x8d, 0xaa, 0x53, 0x51, 0xc9, 0x14, } } /*a00018a3-f20f-4632-bf7c-8daa5351c914*/, LOGTEXT("Windows 8 Professional WMC"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_RETAIL },
  116. // Windows 8 (Volume)
  117. { { 0x18db1848, 0x12e0, 0x4167, { 0xb9, 0xd7, 0xda, 0x7f, 0xcd, 0xa5, 0x07, 0xdb, } } /*18db1848-12e0-4167-b9d7-da7fcda507db*/, LOGTEXT("Windows 8 Embedded Industry Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_VL },
  118. { { 0x10018baf, 0xce21, 0x4060, { 0x80, 0xbd, 0x47, 0xfe, 0x74, 0xed, 0x4d, 0xab, } } /*10018baf-ce21-4060-80bd-47fe74ed4dab*/, LOGTEXT("Windows 8 Embedded Industry Professional"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_VL },
  119. { { 0x458e1bec, 0x837a, 0x45f6, { 0xb9, 0xd5, 0x92, 0x5e, 0xd5, 0xd2, 0x99, 0xde, } } /*458e1bec-837a-45f6-b9d5-925ed5d299de*/, LOGTEXT("Windows 8 Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_VL },
  120. { { 0xe14997e7, 0x800a, 0x4cf7, { 0xad, 0x10, 0xde, 0x4b, 0x45, 0xb5, 0x78, 0xdb, } } /*e14997e7-800a-4cf7-ad10-de4b45b578db*/, LOGTEXT("Windows 8 Enterprise N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_VL },
  121. { { 0xa98bcd6d, 0x5343, 0x4603, { 0x8a, 0xfe, 0x59, 0x08, 0xe4, 0x61, 0x11, 0x12, } } /*a98bcd6d-5343-4603-8afe-5908e4611112*/, LOGTEXT("Windows 8 Professional"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_VL },
  122. { { 0xebf245c1, 0x29a8, 0x4daf, { 0x9c, 0xb1, 0x38, 0xdf, 0xc6, 0x08, 0xa8, 0xc8, } } /*ebf245c1-29a8-4daf-9cb1-38dfc608a8c8*/, LOGTEXT("Windows 8 Professional N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN8_VL },
  123. // Windows 8.1 (Retail)
  124. { { 0xfe1c3238, 0x432a, 0x43a1, { 0x8e, 0x25, 0x97, 0xe7, 0xd1, 0xef, 0x10, 0xf3, } } /*fe1c3238-432a-43a1-8e25-97e7d1ef10f3*/, LOGTEXT("Windows 8.1 Core"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  125. { { 0xffee456a, 0xcd87, 0x4390, { 0x8e, 0x07, 0x16, 0x14, 0x6c, 0x67, 0x2f, 0xd0, } } /*ffee456a-cd87-4390-8e07-16146c672fd0*/, LOGTEXT("Windows 8.1 Core ARM"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  126. { { 0xdb78b74f, 0xef1c, 0x4892, { 0xab, 0xfe, 0x1e, 0x66, 0xb8, 0x23, 0x1d, 0xf6, } } /*db78b74f-ef1c-4892-abfe-1e66b8231df6*/, LOGTEXT("Windows 8.1 Core Country Specific"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  127. { { 0x78558a64, 0xdc19, 0x43fe, { 0xa0, 0xd0, 0x80, 0x75, 0xb2, 0xa3, 0x70, 0xa3, } } /*78558a64-dc19-43fe-a0d0-8075b2a370a3*/, LOGTEXT("Windows 8.1 Core N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  128. { { 0xc72c6a1d, 0xf252, 0x4e7e, { 0xbd, 0xd1, 0x3f, 0xca, 0x34, 0x2a, 0xcb, 0x35, } } /*c72c6a1d-f252-4e7e-bdd1-3fca342acb35*/, LOGTEXT("Windows 8.1 Core Single Language"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  129. { { 0xe58d87b5, 0x8126, 0x4580, { 0x80, 0xfb, 0x86, 0x1b, 0x22, 0xf7, 0x92, 0x96, } } /*e58d87b5-8126-4580-80fb-861b22f79296*/, LOGTEXT("Windows 8.1 Professional Student"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  130. { { 0xcab491c7, 0xa918, 0x4f60, { 0xb5, 0x02, 0xda, 0xb7, 0x5e, 0x33, 0x4f, 0x40, } } /*cab491c7-a918-4f60-b502-dab75e334f40*/, LOGTEXT("Windows 8.1 Professional Student N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  131. { { 0x096ce63d, 0x4fac, 0x48a9, { 0x82, 0xa9, 0x61, 0xae, 0x9e, 0x80, 0x0e, 0x5f, } } /*096ce63d-4fac-48a9-82a9-61ae9e800e5f*/, LOGTEXT("Windows 8.1 Professional WMC"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_RETAIL },
  132. // Windows 8.1 (Volume)
  133. { { 0xe9942b32, 0x2e55, 0x4197, { 0xb0, 0xbd, 0x5f, 0xf5, 0x8c, 0xba, 0x88, 0x60, } } /*e9942b32-2e55-4197-b0bd-5ff58cba8860*/, LOGTEXT("Windows 8.1 Core Connected"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  134. { { 0xba998212, 0x460a, 0x44db, { 0xbf, 0xb5, 0x71, 0xbf, 0x09, 0xd1, 0xc6, 0x8b, } } /*ba998212-460a-44db-bfb5-71bf09d1c68b*/, LOGTEXT("Windows 8.1 Core Connected Country Specific"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  135. { { 0xc6ddecd6, 0x2354, 0x4c19, { 0x90, 0x9b, 0x30, 0x6a, 0x30, 0x58, 0x48, 0x4e, } } /*c6ddecd6-2354-4c19-909b-306a3058484e*/, LOGTEXT("Windows 8.1 Core Connected N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  136. { { 0xb8f5e3a3, 0xed33, 0x4608, { 0x81, 0xe1, 0x37, 0xd6, 0xc9, 0xdc, 0xfd, 0x9c, } } /*b8f5e3a3-ed33-4608-81e1-37d6c9dcfd9c*/, LOGTEXT("Windows 8.1 Core Connected Single Language"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  137. { { 0xf7e88590, 0xdfc7, 0x4c78, { 0xbc, 0xcb, 0x6f, 0x38, 0x65, 0xb9, 0x9d, 0x1a, } } /*f7e88590-dfc7-4c78-bccb-6f3865b99d1a*/, LOGTEXT("Windows 8.1 Embedded Industry Automotive"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  138. { { 0xcd4e2d9f, 0x5059, 0x4a50, { 0xa9, 0x2d, 0x05, 0xd5, 0xbb, 0x12, 0x67, 0xc7, } } /*cd4e2d9f-5059-4a50-a92d-05d5bb1267c7*/, LOGTEXT("Windows 8.1 Embedded Industry Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  139. { { 0x0ab82d54, 0x47f4, 0x4acb, { 0x81, 0x8c, 0xcc, 0x5b, 0xf0, 0xec, 0xb6, 0x49, } } /*0ab82d54-47f4-4acb-818c-cc5bf0ecb649*/, LOGTEXT("Windows 8.1 Embedded Industry Professional"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  140. { { 0x81671aaf, 0x79d1, 0x4eb1, { 0xb0, 0x04, 0x8c, 0xbb, 0xe1, 0x73, 0xaf, 0xea, } } /*81671aaf-79d1-4eb1-b004-8cbbe173afea*/, LOGTEXT("Windows 8.1 Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  141. { { 0x113e705c, 0xfa49, 0x48a4, { 0xbe, 0xea, 0x7d, 0xd8, 0x79, 0xb4, 0x6b, 0x14, } } /*113e705c-fa49-48a4-beea-7dd879b46b14*/, LOGTEXT("Windows 8.1 Enterprise N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  142. { { 0xc06b6981, 0xd7fd, 0x4a35, { 0xb7, 0xb4, 0x05, 0x47, 0x42, 0xb7, 0xaf, 0x67, } } /*c06b6981-d7fd-4a35-b7b4-054742b7af67*/, LOGTEXT("Windows 8.1 Professional"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  143. { { 0x7476d79f, 0x8e48, 0x49b4, { 0xab, 0x63, 0x4d, 0x0b, 0x81, 0x3a, 0x16, 0xe4, } } /*7476d79f-8e48-49b4-ab63-4d0b813a16e4*/, LOGTEXT("Windows 8.1 Professional N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN81_VL },
  144. // Windows Preview
  145. # ifdef INCLUDE_BETAS
  146. { { 0xcde952c7, 0x2f96, 0x4d9d, { 0x8f, 0x2b, 0x2d, 0x34, 0x9f, 0x64, 0xfc, 0x51, } } /*cde952c7-2f96-4d9d-8f2b-2d349f64fc51*/, LOGTEXT("Windows 10 Enterprise Preview"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN_BETA },
  147. { { 0xa4383e6b, 0xdada, 0x423d, { 0xa4, 0x3d, 0xf2, 0x56, 0x78, 0x42, 0x96, 0x76, } } /*a4383e6b-dada-423d-a43d-f25678429676*/, LOGTEXT("Windows 10 Professional Preview"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN_BETA },
  148. { { 0xcf59a07b, 0x1a2a, 0x4be0, { 0xbf, 0xe0, 0x42, 0x3b, 0x58, 0x23, 0xe6, 0x63, } } /*cf59a07b-1a2a-4be0-bfe0-423b5823e663*/, LOGTEXT("Windows 10 Professional WMC Preview"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN_BETA },
  149. { { 0x2b9c337f, 0x7a1d, 0x4271, { 0x90, 0xa3, 0xc6, 0x85, 0x5a, 0x2b, 0x8a, 0x1c, } } /*2b9c337f-7a1d-4271-90a3-c6855a2b8a1c*/, LOGTEXT("Windows 8.x Preview"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN_BETA },
  150. { { 0x631ead72, 0xa8ab, 0x4df8, { 0xbb, 0xdf, 0x37, 0x20, 0x29, 0x98, 0x9b, 0xdd, } } /*631ead72-a8ab-4df8-bbdf-372029989bdd*/, LOGTEXT("Windows 8.x Preview ARM"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN_BETA },
  151. # endif // INCLUDE_BETAS
  152. // Windows Server 2008 A (Web and HPC)
  153. { { 0x7afb1156, 0x2c1d, 0x40fc, { 0xb2, 0x60, 0xaa, 0xb7, 0x44, 0x2b, 0x62, 0xfe, } } /*7afb1156-2c1d-40fc-b260-aab7442b62fe*/, LOGTEXT("Windows Server 2008 Compute Cluster"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008A },
  154. { { 0xddfa9f7c, 0xf09e, 0x40b9, { 0x8c, 0x1a, 0xbe, 0x87, 0x7a, 0x9a, 0x7f, 0x4b, } } /*ddfa9f7c-f09e-40b9-8c1a-be877a9a7f4b*/, LOGTEXT("Windows Server 2008 Web"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008A },
  155. // Windows Server 2008 B (Standard and Enterprise)
  156. { { 0xc1af4d90, 0xd1bc, 0x44ca, { 0x85, 0xd4, 0x00, 0x3b, 0xa3, 0x3d, 0xb3, 0xb9, } } /*c1af4d90-d1bc-44ca-85d4-003ba33db3b9*/, LOGTEXT("Windows Server 2008 Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008B },
  157. { { 0x8198490a, 0xadd0, 0x47b2, { 0xb3, 0xba, 0x31, 0x6b, 0x12, 0xd6, 0x47, 0xb4, } } /*8198490a-add0-47b2-b3ba-316b12d647b4*/, LOGTEXT("Windows Server 2008 Enterprise without Hyper-V"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008B },
  158. { { 0xad2542d4, 0x9154, 0x4c6d, { 0x8a, 0x44, 0x30, 0xf1, 0x1e, 0xe9, 0x69, 0x89, } } /*ad2542d4-9154-4c6d-8a44-30f11ee96989*/, LOGTEXT("Windows Server 2008 Standard"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008B },
  159. { { 0x2401e3d0, 0xc50a, 0x4b58, { 0x87, 0xb2, 0x7e, 0x79, 0x4b, 0x7d, 0x26, 0x07, } } /*2401e3d0-c50a-4b58-87b2-7e794b7d2607*/, LOGTEXT("Windows Server 2008 Standard without Hyper-V"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008B },
  160. // Windows Server 2008 C (Datacenter)
  161. { { 0x68b6e220, 0xcf09, 0x466b, { 0x92, 0xd3, 0x45, 0xcd, 0x96, 0x4b, 0x95, 0x09, } } /*68b6e220-cf09-466b-92d3-45cd964b9509*/, LOGTEXT("Windows Server 2008 Datacenter"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008C },
  162. { { 0xfd09ef77, 0x5647, 0x4eff, { 0x80, 0x9c, 0xaf, 0x2b, 0x64, 0x65, 0x9a, 0x45, } } /*fd09ef77-5647-4eff-809c-af2b64659a45*/, LOGTEXT("Windows Server 2008 Datacenter without Hyper-V"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008C },
  163. { { 0x01ef176b, 0x3e0d, 0x422a, { 0xb4, 0xf8, 0x4e, 0xa8, 0x80, 0x03, 0x5e, 0x8f, } } /*01ef176b-3e0d-422a-b4f8-4ea880035e8f*/, LOGTEXT("Windows Server 2008 for Itanium"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008C },
  164. // Windows Server 2008 R2 A (Web and HPC)
  165. { { 0xf772515c, 0x0e87, 0x48d5, { 0xa6, 0x76, 0xe6, 0x96, 0x2c, 0x3e, 0x11, 0x95, } } /*f772515c-0e87-48d5-a676-e6962c3e1195*/, LOGTEXT("Windows MultiPoint Server 2010"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008R2A },
  166. { { 0xcda18cf3, 0xc196, 0x46ad, { 0xb2, 0x89, 0x60, 0xc0, 0x72, 0x86, 0x99, 0x94, } } /*cda18cf3-c196-46ad-b289-60c072869994*/, LOGTEXT("Windows Server 2008 R2 HPC Edition"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008R2A },
  167. { { 0xa78b8bd9, 0x8017, 0x4df5, { 0xb8, 0x6a, 0x09, 0xf7, 0x56, 0xaf, 0xfa, 0x7c, } } /*a78b8bd9-8017-4df5-b86a-09f756affa7c*/, LOGTEXT("Windows Server 2008 R2 Web"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008R2A },
  168. // Windows Server 2008 R2 B (Standard and Enterprise)
  169. { { 0x620e2b3d, 0x09e7, 0x42fd, { 0x80, 0x2a, 0x17, 0xa1, 0x36, 0x52, 0xfe, 0x7a, } } /*620e2b3d-09e7-42fd-802a-17a13652fe7a*/, LOGTEXT("Windows Server 2008 R2 Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008R2B },
  170. { { 0x68531fb9, 0x5511, 0x4989, { 0x97, 0xbe, 0xd1, 0x1a, 0x0f, 0x55, 0x63, 0x3f, } } /*68531fb9-5511-4989-97be-d11a0f55633f*/, LOGTEXT("Windows Server 2008 R2 Standard"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008R2B },
  171. // Windows Server 2008 R2 C (Datacenter)
  172. { { 0x7482e61b, 0xc589, 0x4b7f, { 0x8e, 0xcc, 0x46, 0xd4, 0x55, 0xac, 0x3b, 0x87, } } /*7482e61b-c589-4b7f-8ecc-46d455ac3b87*/, LOGTEXT("Windows Server 2008 R2 Datacenter"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008R2C },
  173. { { 0x8a26851c, 0x1c7e, 0x48d3, { 0xa6, 0x87, 0xfb, 0xca, 0x9b, 0x9a, 0xc1, 0x6b, } } /*8a26851c-1c7e-48d3-a687-fbca9b9ac16b*/, LOGTEXT("Windows Server 2008 R2 for Itanium Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2008R2C },
  174. // Windows Server 2012
  175. { { 0xd3643d60, 0x0c42, 0x412d, { 0xa7, 0xd6, 0x52, 0xe6, 0x63, 0x53, 0x27, 0xf6, } } /*d3643d60-0c42-412d-a7d6-52e6635327f6*/, LOGTEXT("Windows Server 2012 Datacenter"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012 },
  176. { { 0x95fd1c83, 0x7df5, 0x494a, { 0xbe, 0x8b, 0x13, 0x00, 0xe1, 0xc9, 0xd1, 0xcd, } } /*95fd1c83-7df5-494a-be8b-1300e1c9d1cd*/, LOGTEXT("Windows Server 2012 MultiPoint Premium"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012 },
  177. { { 0x7d5486c7, 0xe120, 0x4771, { 0xb7, 0xf1, 0x7b, 0x56, 0xc6, 0xd3, 0x17, 0x0c, } } /*7d5486c7-e120-4771-b7f1-7b56c6d3170c*/, LOGTEXT("Windows Server 2012 MultiPoint Standard"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012 },
  178. { { 0xf0f5ec41, 0x0d55, 0x4732, { 0xaf, 0x02, 0x44, 0x0a, 0x44, 0xa3, 0xcf, 0x0f, } } /*f0f5ec41-0d55-4732-af02-440a44a3cf0f*/, LOGTEXT("Windows Server 2012 Standard"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012 },
  179. // Windows Server 2012 R2
  180. { { 0xb743a2be, 0x68d4, 0x4dd3, { 0xaf, 0x32, 0x92, 0x42, 0x5b, 0x7b, 0xb6, 0x23, } } /*b743a2be-68d4-4dd3-af32-92425b7bb623*/, LOGTEXT("Windows Server 2012 R2 Cloud Storage"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012R2 },
  181. { { 0x00091344, 0x1ea4, 0x4f37, { 0xb7, 0x89, 0x01, 0x75, 0x0b, 0xa6, 0x98, 0x8c, } } /*00091344-1ea4-4f37-b789-01750ba6988c*/, LOGTEXT("Windows Server 2012 R2 Datacenter"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012R2 },
  182. { { 0x21db6ba4, 0x9a7b, 0x4a14, { 0x9e, 0x29, 0x64, 0xa6, 0x0c, 0x59, 0x30, 0x1d, } } /*21db6ba4-9a7b-4a14-9e29-64a60c59301d*/, LOGTEXT("Windows Server 2012 R2 Essentials"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012R2 },
  183. { { 0xb3ca044e, 0xa358, 0x4d68, { 0x98, 0x83, 0xaa, 0xa2, 0x94, 0x1a, 0xca, 0x99, } } /*b3ca044e-a358-4d68-9883-aaa2941aca99*/, LOGTEXT("Windows Server 2012 R2 Standard"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2012R2 },
  184. // Windows Server 2016
  185. { { 0x3dbf341b, 0x5f6c, 0x4fa7, { 0xb9, 0x36, 0x69, 0x9d, 0xce, 0x9e, 0x26, 0x3f, } } /*3dbf341b-5f6c-4fa7-b936-699dce9e263f*/, LOGTEXT("Windows Server 2016 Azure Core"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2016 },
  186. { { 0x7b4433f4, 0xb1e7, 0x4788, { 0x89, 0x5a, 0xc4, 0x53, 0x78, 0xd3, 0x82, 0x53, } } /*7b4433f4-b1e7-4788-895a-c45378d38253*/, LOGTEXT("Windows Server 2016 Cloud Storage"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2016 },
  187. { { 0x21c56779, 0xb449, 0x4d20, { 0xad, 0xfc, 0xee, 0xce, 0x0e, 0x1a, 0xd7, 0x4b, } } /*21c56779-b449-4d20-adfc-eece0e1ad74b*/, LOGTEXT("Windows Server 2016 Datacenter"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2016 },
  188. { { 0x2b5a1b0f, 0xa5ab, 0x4c54, { 0xac, 0x2f, 0xa6, 0xd9, 0x48, 0x24, 0xa2, 0x83, } } /*2b5a1b0f-a5ab-4c54-ac2f-a6d94824a283*/, LOGTEXT("Windows Server 2016 Essentials"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2016 },
  189. { { 0x8c1c5410, 0x9f39, 0x4805, { 0x8c, 0x9d, 0x63, 0xa0, 0x77, 0x06, 0x35, 0x8f, } } /*8c1c5410-9f39-4805-8c9d-63a07706358f*/, LOGTEXT("Windows Server 2016 Standard"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN2016 },
  190. // Windows Server Preview
  191. # ifdef INCLUDE_BETAS
  192. { { 0xba947c44, 0xd19d, 0x4786, { 0xb6, 0xae, 0x22, 0x77, 0x0b, 0xc9, 0x4c, 0x54, } } /*ba947c44-d19d-4786-b6ae-22770bc94c54*/, LOGTEXT("Windows Server 2016 Datacenter Preview"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_WIN_SRV_BETA },
  193. # endif // INCLUDE_BETAS
  194. // Windows Vista
  195. { { 0x4f3d1606, 0x3fea, 0x4c01, { 0xbe, 0x3c, 0x8d, 0x67, 0x1c, 0x40, 0x1e, 0x3b, } } /*4f3d1606-3fea-4c01-be3c-8d671c401e3b*/, LOGTEXT("Windows Vista Business"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_VISTA },
  196. { { 0x2c682dc2, 0x8b68, 0x4f63, { 0xa1, 0x65, 0xae, 0x29, 0x1d, 0x4c, 0xf1, 0x38, } } /*2c682dc2-8b68-4f63-a165-ae291d4cf138*/, LOGTEXT("Windows Vista Business N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_VISTA },
  197. { { 0xcfd8ff08, 0xc0d7, 0x452b, { 0x9f, 0x60, 0xef, 0x5c, 0x70, 0xc3, 0x20, 0x94, } } /*cfd8ff08-c0d7-452b-9f60-ef5c70c32094*/, LOGTEXT("Windows Vista Enterprise"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_VISTA },
  198. { { 0xd4f54950, 0x26f2, 0x4fb4, { 0xba, 0x21, 0xff, 0xab, 0x16, 0xaf, 0xca, 0xde, } } /*d4f54950-26f2-4fb4-ba21-ffab16afcade*/, LOGTEXT("Windows Vista Enterprise N"), EPID_WINDOWS, APP_ID_WINDOWS, KMS_ID_VISTA },
  199. // Office 2010
  200. { { 0x8ce7e872, 0x188c, 0x4b98, { 0x9d, 0x90, 0xf8, 0xf9, 0x0b, 0x7a, 0xad, 0x02, } } /*8ce7e872-188c-4b98-9d90-f8f90b7aad02*/, LOGTEXT("Office Access 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  201. { { 0xcee5d470, 0x6e3b, 0x4fcc, { 0x8c, 0x2b, 0xd1, 0x74, 0x28, 0x56, 0x8a, 0x9f, } } /*cee5d470-6e3b-4fcc-8c2b-d17428568a9f*/, LOGTEXT("Office Excel 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  202. { { 0x8947d0b8, 0xc33b, 0x43e1, { 0x8c, 0x56, 0x9b, 0x67, 0x4c, 0x05, 0x28, 0x32, } } /*8947d0b8-c33b-43e1-8c56-9b674c052832*/, LOGTEXT("Office Groove 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  203. { { 0xca6b6639, 0x4ad6, 0x40ae, { 0xa5, 0x75, 0x14, 0xde, 0xe0, 0x7f, 0x64, 0x30, } } /*ca6b6639-4ad6-40ae-a575-14dee07f6430*/, LOGTEXT("Office InfoPath 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  204. { { 0x09ed9640, 0xf020, 0x400a, { 0xac, 0xd8, 0xd7, 0xd8, 0x67, 0xdf, 0xd9, 0xc2, } } /*09ed9640-f020-400a-acd8-d7d867dfd9c2*/, LOGTEXT("Office Mondo 1 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  205. { { 0xef3d4e49, 0xa53d, 0x4d81, { 0xa2, 0xb1, 0x2c, 0xa6, 0xc2, 0x55, 0x6b, 0x2c, } } /*ef3d4e49-a53d-4d81-a2b1-2ca6c2556b2c*/, LOGTEXT("Office Mondo 2 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  206. { { 0xab586f5c, 0x5256, 0x4632, { 0x96, 0x2f, 0xfe, 0xfd, 0x8b, 0x49, 0xe6, 0xf4, } } /*ab586f5c-5256-4632-962f-fefd8b49e6f4*/, LOGTEXT("Office OneNote 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  207. { { 0xecb7c192, 0x73ab, 0x4ded, { 0xac, 0xf4, 0x23, 0x99, 0xb0, 0x95, 0xd0, 0xcc, } } /*ecb7c192-73ab-4ded-acf4-2399b095d0cc*/, LOGTEXT("Office OutLook 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  208. { { 0x45593b1d, 0xdfb1, 0x4e91, { 0xbb, 0xfb, 0x2d, 0x5d, 0x0c, 0xe2, 0x22, 0x7a, } } /*45593b1d-dfb1-4e91-bbfb-2d5d0ce2227a*/, LOGTEXT("Office PowerPoint 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  209. { { 0x6f327760, 0x8c5c, 0x417c, { 0x9b, 0x61, 0x83, 0x6a, 0x98, 0x28, 0x7e, 0x0c, } } /*6f327760-8c5c-417c-9b61-836a98287e0c*/, LOGTEXT("Office Professional Plus 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  210. { { 0xdf133ff7, 0xbf14, 0x4f95, { 0xaf, 0xe3, 0x7b, 0x48, 0xe7, 0xe3, 0x31, 0xef, } } /*df133ff7-bf14-4f95-afe3-7b48e7e331ef*/, LOGTEXT("Office Project Pro 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  211. { { 0x5dc7bf61, 0x5ec9, 0x4996, { 0x9c, 0xcb, 0xdf, 0x80, 0x6a, 0x2d, 0x0e, 0xfe, } } /*5dc7bf61-5ec9-4996-9ccb-df806a2d0efe*/, LOGTEXT("Office Project Standard 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  212. { { 0xb50c4f75, 0x599b, 0x43e8, { 0x8d, 0xcd, 0x10, 0x81, 0xa7, 0x96, 0x72, 0x41, } } /*b50c4f75-599b-43e8-8dcd-1081a7967241*/, LOGTEXT("Office Publisher 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  213. { { 0xea509e87, 0x07a1, 0x4a45, { 0x9e, 0xdc, 0xeb, 0xa5, 0xa3, 0x9f, 0x36, 0xaf, } } /*ea509e87-07a1-4a45-9edc-eba5a39f36af*/, LOGTEXT("Office Small Business Basics 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  214. { { 0x9da2a678, 0xfb6b, 0x4e67, { 0xab, 0x84, 0x60, 0xdd, 0x6a, 0x9c, 0x81, 0x9a, } } /*9da2a678-fb6b-4e67-ab84-60dd6a9c819a*/, LOGTEXT("Office Standard 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  215. { { 0x92236105, 0xbb67, 0x494f, { 0x94, 0xc7, 0x7f, 0x7a, 0x60, 0x79, 0x29, 0xbd, } } /*92236105-bb67-494f-94c7-7f7a607929bd*/, LOGTEXT("Office Visio Premium 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  216. { { 0xe558389c, 0x83c3, 0x4b29, { 0xad, 0xfe, 0x5e, 0x4d, 0x7f, 0x46, 0xc3, 0x58, } } /*e558389c-83c3-4b29-adfe-5e4d7f46c358*/, LOGTEXT("Office Visio Pro 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  217. { { 0x9ed833ff, 0x4f92, 0x4f36, { 0xb3, 0x70, 0x86, 0x83, 0xa4, 0xf1, 0x32, 0x75, } } /*9ed833ff-4f92-4f36-b370-8683a4f13275*/, LOGTEXT("Office Visio Standard 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  218. { { 0x2d0882e7, 0xa4e7, 0x423b, { 0x8c, 0xcc, 0x70, 0xd9, 0x1e, 0x01, 0x58, 0xb1, } } /*2d0882e7-a4e7-423b-8ccc-70d91e0158b1*/, LOGTEXT("Office Word 2010"), EPID_OFFICE2010, APP_ID_OFFICE2010, KMS_ID_OFFICE2010 },
  219. // Office 2013
  220. { { 0x6ee7622c, 0x18d8, 0x4005, { 0x9f, 0xb7, 0x92, 0xdb, 0x64, 0x4a, 0x27, 0x9b, } } /*6ee7622c-18d8-4005-9fb7-92db644a279b*/, LOGTEXT("Office Access 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  221. { { 0xf7461d52, 0x7c2b, 0x43b2, { 0x87, 0x44, 0xea, 0x95, 0x8e, 0x0b, 0xd0, 0x9a, } } /*f7461d52-7c2b-43b2-8744-ea958e0bd09a*/, LOGTEXT("Office Excel 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  222. { { 0xa30b8040, 0xd68a, 0x423f, { 0xb0, 0xb5, 0x9c, 0xe2, 0x92, 0xea, 0x5a, 0x8f, } } /*a30b8040-d68a-423f-b0b5-9ce292ea5a8f*/, LOGTEXT("Office InfoPath 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  223. { { 0x1b9f11e3, 0xc85c, 0x4e1b, { 0xbb, 0x29, 0x87, 0x9a, 0xd2, 0xc9, 0x09, 0xe3, } } /*1b9f11e3-c85c-4e1b-bb29-879ad2c909e3*/, LOGTEXT("Office Lync 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  224. { { 0xdc981c6b, 0xfc8e, 0x420f, { 0xaa, 0x43, 0xf8, 0xf3, 0x3e, 0x5c, 0x09, 0x23, } } /*dc981c6b-fc8e-420f-aa43-f8f33e5c0923*/, LOGTEXT("Office Mondo 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  225. { { 0xefe1f3e6, 0xaea2, 0x4144, { 0xa2, 0x08, 0x32, 0xaa, 0x87, 0x2b, 0x65, 0x45, } } /*efe1f3e6-aea2-4144-a208-32aa872b6545*/, LOGTEXT("Office OneNote 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  226. { { 0x771c3afa, 0x50c5, 0x443f, { 0xb1, 0x51, 0xff, 0x25, 0x46, 0xd8, 0x63, 0xa0, } } /*771c3afa-50c5-443f-b151-ff2546d863a0*/, LOGTEXT("Office OutLook 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  227. { { 0x8c762649, 0x97d1, 0x4953, { 0xad, 0x27, 0xb7, 0xe2, 0xc2, 0x5b, 0x97, 0x2e, } } /*8c762649-97d1-4953-ad27-b7e2c25b972e*/, LOGTEXT("Office PowerPoint 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  228. { { 0xb322da9c, 0xa2e2, 0x4058, { 0x9e, 0x4e, 0xf5, 0x9a, 0x69, 0x70, 0xbd, 0x69, } } /*b322da9c-a2e2-4058-9e4e-f59a6970bd69*/, LOGTEXT("Office Professional Plus 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  229. { { 0x4a5d124a, 0xe620, 0x44ba, { 0xb6, 0xff, 0x65, 0x89, 0x61, 0xb3, 0x3b, 0x9a, } } /*4a5d124a-e620-44ba-b6ff-658961b33b9a*/, LOGTEXT("Office Project Pro 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  230. { { 0x427a28d1, 0xd17c, 0x4abf, { 0xb7, 0x17, 0x32, 0xc7, 0x80, 0xba, 0x6f, 0x07, } } /*427a28d1-d17c-4abf-b717-32c780ba6f07*/, LOGTEXT("Office Project Standard 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  231. { { 0x00c79ff1, 0x6850, 0x443d, { 0xbf, 0x61, 0x71, 0xcd, 0xe0, 0xde, 0x30, 0x5f, } } /*00c79ff1-6850-443d-bf61-71cde0de305f*/, LOGTEXT("Office Publisher 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  232. { { 0xb13afb38, 0xcd79, 0x4ae5, { 0x9f, 0x7f, 0xee, 0xd0, 0x58, 0xd7, 0x50, 0xca, } } /*b13afb38-cd79-4ae5-9f7f-eed058d750ca*/, LOGTEXT("Office Standard 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  233. { { 0xe13ac10e, 0x75d0, 0x4aff, { 0xa0, 0xcd, 0x76, 0x49, 0x82, 0xcf, 0x54, 0x1c, } } /*e13ac10e-75d0-4aff-a0cd-764982cf541c*/, LOGTEXT("Office Visio Pro 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  234. { { 0xac4efaf0, 0xf81f, 0x4f61, { 0xbd, 0xf7, 0xea, 0x32, 0xb0, 0x2a, 0xb1, 0x17, } } /*ac4efaf0-f81f-4f61-bdf7-ea32b02ab117*/, LOGTEXT("Office Visio Standard 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  235. { { 0xd9f5b1c6, 0x5386, 0x495a, { 0x88, 0xf9, 0x9a, 0xd6, 0xb4, 0x1a, 0xc9, 0xb3, } } /*d9f5b1c6-5386-495a-88f9-9ad6b41ac9b3*/, LOGTEXT("Office Word 2013"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013 },
  236. // Office 2013 (Pre-Release)
  237. # ifdef INCLUDE_BETAS
  238. { { 0x44b538e2, 0xfb34, 0x4732, { 0x81, 0xe4, 0x64, 0x4c, 0x17, 0xd2, 0xe7, 0x46, } } /*44b538e2-fb34-4732-81e4-644c17d2e746*/, LOGTEXT("Office Access 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  239. { { 0x9373bfa0, 0x97b3, 0x4587, { 0xab, 0x73, 0x30, 0x93, 0x44, 0x61, 0xd5, 0x5c, } } /*9373bfa0-97b3-4587-ab73-30934461d55c*/, LOGTEXT("Office Excel 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  240. { { 0xaa286eb4, 0x556f, 0x4eeb, { 0x96, 0x7c, 0xc1, 0xb7, 0x71, 0xb7, 0x67, 0x3e, } } /*aa286eb4-556f-4eeb-967c-c1b771b7673e*/, LOGTEXT("Office Groove 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  241. { { 0x7ccc8256, 0xfbaa, 0x49c6, { 0xb2, 0xa9, 0xf5, 0xaf, 0xb4, 0x25, 0x7c, 0xd2, } } /*7ccc8256-fbaa-49c6-b2a9-f5afb4257cd2*/, LOGTEXT("Office InfoPath 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  242. { { 0xc53dfe17, 0xcc00, 0x4967, { 0xb1, 0x88, 0xa0, 0x88, 0xa9, 0x65, 0x49, 0x4d, } } /*c53dfe17-cc00-4967-b188-a088a965494d*/, LOGTEXT("Office Lync 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  243. { { 0x2816a87d, 0xe1ed, 0x4097, { 0xb3, 0x11, 0xe2, 0x34, 0x1c, 0x57, 0xb1, 0x79, } } /*2816a87d-e1ed-4097-b311-e2341c57b179*/, LOGTEXT("Office Mondo 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  244. { { 0x67c0f908, 0x184f, 0x4f64, { 0x82, 0x50, 0x12, 0xdb, 0x79, 0x7a, 0xb3, 0xc3, } } /*67c0f908-184f-4f64-8250-12db797ab3c3*/, LOGTEXT("Office OneNote 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  245. { { 0x7bce4e7a, 0xdd80, 0x4682, { 0x98, 0xfa, 0xf9, 0x93, 0x72, 0x58, 0x03, 0xd2, } } /*7bce4e7a-dd80-4682-98fa-f993725803d2*/, LOGTEXT("Office Outlook 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  246. { { 0x1ec10c0a, 0x54f6, 0x453e, { 0xb8, 0x5a, 0x6f, 0xa1, 0xbb, 0xfe, 0xa9, 0xb7, } } /*1ec10c0a-54f6-453e-b85a-6fa1bbfea9b7*/, LOGTEXT("Office PowerPoint 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  247. { { 0x87d2b5bf, 0xd47b, 0x41fb, { 0xaf, 0x62, 0x71, 0xc3, 0x82, 0xf5, 0xcc, 0x85, } } /*87d2b5bf-d47b-41fb-af62-71c382f5cc85*/, LOGTEXT("Office Professional Plus 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  248. { { 0x3cfe50a9, 0x0e03, 0x4b29, { 0x97, 0x54, 0x9f, 0x19, 0x3f, 0x07, 0xb7, 0x1f, } } /*3cfe50a9-0e03-4b29-9754-9f193f07b71f*/, LOGTEXT("Office Project Pro 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  249. { { 0x39e49e57, 0xae68, 0x4ee3, { 0xb0, 0x98, 0x26, 0x48, 0x0d, 0xf3, 0xda, 0x96, } } /*39e49e57-ae68-4ee3-b098-26480df3da96*/, LOGTEXT("Office Project Standard 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  250. { { 0x15aa2117, 0x8f79, 0x49a8, { 0x83, 0x17, 0x75, 0x30, 0x26, 0xd6, 0xa0, 0x54, } } /*15aa2117-8f79-49a8-8317-753026d6a054*/, LOGTEXT("Office Publisher 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  251. { { 0xcfbfd60e, 0x0b5f, 0x427d, { 0x91, 0x7c, 0xa4, 0xdf, 0x42, 0xa8, 0x0e, 0x44, } } /*cfbfd60e-0b5f-427d-917c-a4df42a80e44*/, LOGTEXT("Office Visio Pro 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  252. { { 0x7012cc81, 0x8887, 0x42e9, { 0xb1, 0x7d, 0x4e, 0x5e, 0x42, 0x76, 0x0f, 0x0d, } } /*7012cc81-8887-42e9-b17d-4e5e42760f0d*/, LOGTEXT("Office Visio Standard 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  253. { { 0xde9c7eb6, 0x5a85, 0x420d, { 0x97, 0x03, 0xff, 0xf1, 0x1b, 0xdd, 0x4d, 0x43, } } /*de9c7eb6-5a85-420d-9703-fff11bdd4d43*/, LOGTEXT("Office Word 2013 (Pre-Release)"), EPID_OFFICE2013, APP_ID_OFFICE2013, KMS_ID_OFFICE2013_BETA },
  254. # endif // INCLUDE_BETAS
  255. // Office 2016
  256. { { 0x67c0fc0c, 0xdeba, 0x401b, { 0xbf, 0x8b, 0x9c, 0x8a, 0xd8, 0x39, 0x58, 0x04, } } /*67c0fc0c-deba-401b-bf8b-9c8ad8395804*/, LOGTEXT("Office Access 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  257. { { 0xc3e65d36, 0x141f, 0x4d2f, { 0xa3, 0x03, 0xa8, 0x42, 0xee, 0x75, 0x6a, 0x29, } } /*c3e65d36-141f-4d2f-a303-a842ee756a29*/, LOGTEXT("Office Excel 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  258. { { 0x9caabccb, 0x61b1, 0x4b4b, { 0x8b, 0xec, 0xd1, 0x0a, 0x3c, 0x3a, 0xc2, 0xce, } } /*9caabccb-61b1-4b4b-8bec-d10a3c3ac2ce*/, LOGTEXT("Office Mondo 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  259. { { 0xe914ea6e, 0xa5fa, 0x4439, { 0xa3, 0x94, 0xa9, 0xbb, 0x32, 0x93, 0xca, 0x09, } } /*e914ea6e-a5fa-4439-a394-a9bb3293ca09*/, LOGTEXT("Office Mondo R 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  260. { { 0xd8cace59, 0x33d2, 0x4ac7, { 0x9b, 0x1b, 0x9b, 0x72, 0x33, 0x9c, 0x51, 0xc8, } } /*d8cace59-33d2-4ac7-9b1b-9b72339c51c8*/, LOGTEXT("Office OneNote 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  261. { { 0xec9d9265, 0x9d1e, 0x4ed0, { 0x83, 0x8a, 0xcd, 0xc2, 0x0f, 0x25, 0x51, 0xa1, } } /*ec9d9265-9d1e-4ed0-838a-cdc20f2551a1*/, LOGTEXT("Office Outlook 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  262. { { 0xd70b1bba, 0xb893, 0x4544, { 0x96, 0xe2, 0xb7, 0xa3, 0x18, 0x09, 0x1c, 0x33, } } /*d70b1bba-b893-4544-96e2-b7a318091c33*/, LOGTEXT("Office Powerpoint 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  263. { { 0xd450596f, 0x894d, 0x49e0, { 0x96, 0x6a, 0xfd, 0x39, 0xed, 0x4c, 0x4c, 0x64, } } /*d450596f-894d-49e0-966a-fd39ed4c4c64*/, LOGTEXT("Office Professional Plus 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  264. { { 0x4f414197, 0x0fc2, 0x4c01, { 0xb6, 0x8a, 0x86, 0xcb, 0xb9, 0xac, 0x25, 0x4c, } } /*4f414197-0fc2-4c01-b68a-86cbb9ac254c*/, LOGTEXT("Office Project Pro 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  265. { { 0x829b8110, 0x0e6f, 0x4349, { 0xbc, 0xa4, 0x42, 0x80, 0x35, 0x77, 0x78, 0x8d, } } /*829b8110-0e6f-4349-bca4-42803577788d*/, LOGTEXT("Office Project Pro 2016 XC2R"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  266. { { 0xda7ddabc, 0x3fbe, 0x4447, { 0x9e, 0x01, 0x6a, 0xb7, 0x44, 0x0b, 0x4c, 0xd4, } } /*da7ddabc-3fbe-4447-9e01-6ab7440b4cd4*/, LOGTEXT("Office Project Standard 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  267. { { 0xcbbaca45, 0x556a, 0x4416, { 0xad, 0x03, 0xbd, 0xa5, 0x98, 0xea, 0xa7, 0xc8, } } /*cbbaca45-556a-4416-ad03-bda598eaa7c8*/, LOGTEXT("Office Project Standard 2016 XC2R"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  268. { { 0x041a06cb, 0xc5b8, 0x4772, { 0x80, 0x9f, 0x41, 0x6d, 0x03, 0xd1, 0x66, 0x54, } } /*041a06cb-c5b8-4772-809f-416d03d16654*/, LOGTEXT("Office Publisher 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  269. { { 0x83e04ee1, 0xfa8d, 0x436d, { 0x89, 0x94, 0xd3, 0x1a, 0x86, 0x2c, 0xab, 0x77, } } /*83e04ee1-fa8d-436d-8994-d31a862cab77*/, LOGTEXT("Office Skype for Business 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  270. { { 0xdedfa23d, 0x6ed1, 0x45a6, { 0x85, 0xdc, 0x63, 0xca, 0xe0, 0x54, 0x6d, 0xe6, } } /*dedfa23d-6ed1-45a6-85dc-63cae0546de6*/, LOGTEXT("Office Standard 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  271. { { 0x6bf301c1, 0xb94a, 0x43e9, { 0xba, 0x31, 0xd4, 0x94, 0x59, 0x8c, 0x47, 0xfb, } } /*6bf301c1-b94a-43e9-ba31-d494598c47fb*/, LOGTEXT("Office Visio Pro 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  272. { { 0xb234abe3, 0x0857, 0x4f9c, { 0xb0, 0x5a, 0x4d, 0xc3, 0x14, 0xf8, 0x55, 0x57, } } /*b234abe3-0857-4f9c-b05a-4dc314f85557*/, LOGTEXT("Office Visio Pro 2016 XC2R"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  273. { { 0xaa2a7821, 0x1827, 0x4c2c, { 0x8f, 0x1d, 0x45, 0x13, 0xa3, 0x4d, 0xda, 0x97, } } /*aa2a7821-1827-4c2c-8f1d-4513a34dda97*/, LOGTEXT("Office Visio Standard 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  274. { { 0x361fe620, 0x64f4, 0x41b5, { 0xba, 0x77, 0x84, 0xf8, 0xe0, 0x79, 0xb1, 0xf7, } } /*361fe620-64f4-41b5-ba77-84f8e079b1f7*/, LOGTEXT("Office Visio Standard 2016 XC2R"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  275. { { 0xbb11badf, 0xd8aa, 0x470e, { 0x93, 0x11, 0x20, 0xea, 0xf8, 0x0f, 0xe5, 0xcc, } } /*bb11badf-d8aa-470e-9311-20eaf80fe5cc*/, LOGTEXT("Office Word 2016"), EPID_OFFICE2016, APP_ID_OFFICE2013, KMS_ID_OFFICE2016 },
  276. };
  277. // necessary because other .c files cannot access _countof()
  278. __pure ProdListIndex_t getExtendedProductListSize(void)
  279. {
  280. return _countof(ExtendedProductList);
  281. }
  282. #endif // NO_EXTENDED_PRODUCT_LIST
  283. #if !defined(NO_LOG) || !defined(NO_STRICT_MODES)
  284. __pure ProdListIndex_t getAppListSize(void)
  285. {
  286. return _countof(AppList);
  287. }
  288. #endif // !defined(NO_LOG) || !defined(NO_STRICT_MODES)
  289. __pure ProdListIndex_t getProductListSize(void)
  290. {
  291. return _countof(ProductList);
  292. }
  293. #endif // IS_LIBRARY
  294. #ifndef NO_RANDOM_EPID
  295. // HostType and OSBuild
  296. static const struct KMSHostOS { uint16_t Type; uint16_t Build; } HostOS[] =
  297. {
  298. { 55041, 6002 }, // Windows Server 2008 SP2
  299. { 55041, 7601 }, // Windows Server 2008 R2 SP1
  300. { 5426, 9200 }, // Windows Server 2012
  301. { 6401, 9600 }, // Windows Server 2012 R2
  302. { 3612, 14393 }, // Windows Server 2016
  303. };
  304. // GroupID and PIDRange
  305. static const struct PKEYCONFIG { uint16_t GroupID; uint32_t RangeMin; uint32_t RangeMax; } pkeyconfig[] = {
  306. { 206, 471000000, 530999999 }, // Windows Server 2016
  307. { 96, 199000000, 217999999 }, // Office2010
  308. { 206, 234000000, 255999999 }, // Office2013
  309. { 206, 437000000, 458999999 }, // Office2016
  310. };
  311. // Valid language identifiers to be used in the ePID
  312. static const uint16_t LcidList[] = {
  313. 1078, 1052, 1025, 2049, 3073, 4097, 5121, 6145, 7169, 8193, 9217, 10241, 11265, 12289, 13313, 14337, 15361, 16385,
  314. 1067, 1068, 2092, 1069, 1059, 1093, 5146, 1026, 1027, 1028, 2052, 3076, 4100, 5124, 1050, 4122, 1029, 1030, 1125, 1043, 2067,
  315. 1033, 2057, 3081, 4105, 5129, 6153, 7177, 8201, 9225, 10249, 11273, 12297, 13321, 1061, 1080, 1065, 1035, 1036, 2060,
  316. 3084, 4108, 5132, 6156, 1079, 1110, 1031, 2055, 3079, 4103, 5127, 1032, 1095, 1037, 1081, 1038, 1039, 1057, 1040, 2064, 1041, 1099,
  317. 1087, 1111, 1042, 1088, 1062, 1063, 1071, 1086, 2110, 1100, 1082, 1153, 1102, 1104, 1044, 2068, 1045, 1046, 2070,
  318. 1094, 1131, 2155, 3179, 1048, 1049, 9275, 4155, 5179, 3131, 1083, 2107, 8251, 6203, 7227, 1103, 2074, 6170, 3098,
  319. 7194, 1051, 1060, 1034, 2058, 3082, 4106, 5130, 6154, 7178, 8202, 9226, 10250, 11274, 12298, 13322, 14346, 15370, 16394,
  320. 17418, 18442, 19466, 20490, 1089, 1053, 2077, 1114, 1097, 1092, 1098, 1054, 1074, 1058, 1056, 1091, 2115, 1066, 1106, 1076, 1077
  321. };
  322. #ifdef _PEDANTIC
  323. uint16_t IsValidLcid(const uint16_t Lcid)
  324. {
  325. uint16_t i;
  326. for (i = 0; i < _countof(LcidList); i++)
  327. {
  328. if (Lcid == LcidList[i]) return Lcid;
  329. }
  330. return 0;
  331. }
  332. #endif // _PEDANTIC
  333. #endif // NO_RANDOM_EPID
  334. // Unix time is seconds from 1970-01-01. Should be 64 bits to avoid Year 2038 overflow bug.
  335. // FILETIME is 100 nanoseconds from 1601-01-01. Must be 64 bits.
  336. void getUnixTimeAsFileTime(FILETIME *const ts)
  337. {
  338. int64_t unixtime = (int64_t)time(NULL);
  339. int64_t *filetime = (int64_t*)ts;
  340. //*filetime = LE64((unixtime + 11644473600LL) * 10000000LL);
  341. PUT_UA64LE(filetime, (unixtime + 11644473600LL) * 10000000LL);
  342. }
  343. __pure int64_t fileTimeToUnixTime(const FILETIME *const ts)
  344. {
  345. return GET_UA64LE(ts) / 10000000LL - 11644473600LL;
  346. }
  347. /*
  348. * Get's a product name with a GUID in host-endian order.
  349. * List can be any list defined above.
  350. */
  351. const char* getProductNameHE(const GUID *const guid, const KmsIdList *const List, ProdListIndex_t maxList, ProdListIndex_t *const i)
  352. {
  353. for (*i = 0; *i < maxList; (*i)++)
  354. {
  355. if (IsEqualGUID(guid, &List[*i].guid))
  356. return List[*i].name;
  357. }
  358. return "Unknown";
  359. }
  360. /*
  361. * same as getProductnameHE except GUID is in little-endian (network) order
  362. */
  363. const char* getProductNameLE(const GUID *const guid, const KmsIdList *const List, ProdListIndex_t maxList, ProdListIndex_t *const i)
  364. {
  365. #if __BYTE_ORDER != __LITTLE_ENDIAN
  366. GUID HeGUID;
  367. LEGUID(&HeGUID, guid);
  368. return getProductNameHE(&HeGUID, List, maxList, i);
  369. #else
  370. return getProductNameHE(guid, List, maxList, i);
  371. #endif
  372. }
  373. #ifndef NO_STRICT_MODES
  374. #ifndef NO_CLIENT_LIST
  375. static PClientList_t ClientLists;
  376. static BYTE ZeroGuid[16] = { 0 };
  377. #if !defined(_WIN32) && !defined(__CYGWIN__)
  378. pthread_mutex_t* mutex;
  379. #define mutex_size (((sizeof(pthread_mutex_t)+7)>>3)<<3)
  380. #else
  381. CRITICAL_SECTION* mutex;
  382. #define mutex_size (((sizeof(CRITICAL_SECTION)+7)>>3)<<3)
  383. #endif // _WIN32
  384. #ifndef USE_THREADS
  385. static int shmid_clients = -1;
  386. #endif // USE_THREADS
  387. #if !defined(_WIN32) && !defined(__CYGWIN__)
  388. #define lock_client_lists() pthread_mutex_lock(mutex)
  389. #define unlock_client_lists() pthread_mutex_unlock(mutex)
  390. #define mutex_t pthread_mutex_t
  391. #else
  392. #define lock_client_lists() EnterCriticalSection(mutex)
  393. #define unlock_client_lists() LeaveCriticalSection(mutex)
  394. #define mutex_t CRITICAL_SECTION
  395. #endif
  396. void CleanUpClientLists()
  397. {
  398. # ifndef USE_THREADS
  399. shmctl(shmid_clients, IPC_RMID, NULL);
  400. # endif // !USE_THREADS
  401. }
  402. void InitializeClientLists()
  403. {
  404. int_fast8_t i;
  405. int_fast16_t j;
  406. # ifndef USE_THREADS
  407. if (
  408. (shmid_clients = shmget(IPC_PRIVATE, sizeof(ClientList_t) * _countof(AppList) + mutex_size, IPC_CREAT | 0600)) < 0 ||
  409. (mutex = (mutex_t*)shmat(shmid_clients, NULL, 0)) == (mutex_t*)-1
  410. )
  411. {
  412. int errno_save = errno;
  413. printerrorf("Warning: CMID lists disabled. Could not create shared memory: %s\n", vlmcsd_strerror(errno_save));
  414. if (shmid_clients >= 0) shmctl(shmid_clients, IPC_RMID, NULL);
  415. MaintainClients = FALSE;
  416. return;
  417. }
  418. ClientLists = (PClientList_t)((BYTE*)mutex + mutex_size);
  419. # if __CYGWIN__
  420. InitializeCriticalSection(mutex);
  421. # else // !__CYGWIN__
  422. pthread_mutexattr_t mutex_attr;
  423. pthread_mutexattr_init(&mutex_attr);
  424. pthread_mutexattr_setpshared(&mutex_attr, PTHREAD_PROCESS_SHARED);
  425. pthread_mutex_init(mutex, &mutex_attr);
  426. # endif // !__CYGWIN__
  427. # else // USE_THREADS
  428. ClientLists = (PClientList_t)vlmcsd_malloc(sizeof(ClientList_t) * _countof(AppList));
  429. mutex = (mutex_t*)vlmcsd_malloc(sizeof(mutex_t));
  430. # if !_WIN32 && !__CYGWIN__
  431. pthread_mutex_init(mutex, NULL);
  432. # else //_WIN32 || __CYGWIN__
  433. InitializeCriticalSection(mutex);
  434. # endif //_WIN32 || __CYGWIN__
  435. # endif // USE_THREADS
  436. memset(ClientLists, 0, sizeof(ClientList_t) * _countof(AppList));
  437. if (!StartEmpty)
  438. {
  439. ClientLists[APP_ID_WINDOWS].CurrentCount = 24; ClientLists[APP_ID_WINDOWS].MaxCount = 50;
  440. ClientLists[APP_ID_OFFICE2010].CurrentCount = ClientLists[APP_ID_OFFICE2013].CurrentCount = 4;
  441. ClientLists[APP_ID_OFFICE2010].MaxCount = ClientLists[APP_ID_OFFICE2013].MaxCount = 10;
  442. for (i = 0; i < 3; i++)
  443. {
  444. for (j = 0; j < ClientLists[i].CurrentCount; j++)
  445. {
  446. get16RandomBytes(&ClientLists[i].Guid[j]);
  447. }
  448. }
  449. }
  450. }
  451. #endif // NO_CLIENT_LIST
  452. #endif // !NO_STRICT_MODES
  453. #ifndef NO_RANDOM_EPID
  454. // formats an int with a fixed number of digits with leading zeros (helper for ePID generation)
  455. static char* itoc(char *const c, const int i, uint_fast8_t digits)
  456. {
  457. char formatString[8];
  458. if (digits > 9) digits = 0;
  459. strcpy(formatString, "%");
  460. if (digits)
  461. {
  462. formatString[1] = '0';
  463. formatString[2] = digits | 0x30;
  464. formatString[3] = 0;
  465. }
  466. strcat(formatString, "u");
  467. sprintf(c, formatString, i);
  468. return c;
  469. }
  470. static int getRandomServerType()
  471. {
  472. # if defined(USE_MSRPC) || defined(SIMPLE_RPC)
  473. return rand() % (int)_countof(HostOS);
  474. # else // !defined(USE_MSRPC) && !defined(SIMPLE_RPC)
  475. if (!UseServerRpcBTFN)
  476. {
  477. // This isn't possible at all, e.g. KMS host on XP
  478. return rand() % (int)_countof(HostOS);
  479. }
  480. // return 9200/9600/14393 if NDR64 is in use, otherwise 6002/7601
  481. if (UseServerRpcNDR64) return (rand() % 3) + 2;
  482. return (rand() % 2);
  483. # endif // !defined(USE_MSRPC) && !defined(SIMPLE_RPC)
  484. }
  485. /*
  486. * Generates a random ePID
  487. */
  488. static void generateRandomPid(int index, char *const szPid, int serverType, int16_t lang)
  489. {
  490. char numberBuffer[12];
  491. if (serverType < 0 || serverType >= (int)_countof(HostOS))
  492. {
  493. serverType = getRandomServerType();
  494. }
  495. strcpy(szPid, itoc(numberBuffer, HostOS[serverType].Type, 5));
  496. strcat(szPid, "-");
  497. if (index > 3) index = 0;
  498. strcat(szPid, itoc(numberBuffer, pkeyconfig[index].GroupID, 5));
  499. strcat(szPid, "-");
  500. int keyId = (rand32() % (pkeyconfig[index].RangeMax - pkeyconfig[index].RangeMin)) + pkeyconfig[index].RangeMin;
  501. strcat(szPid, itoc(numberBuffer, keyId / 1000000, 3));
  502. strcat(szPid, "-");
  503. strcat(szPid, itoc(numberBuffer, keyId % 1000000, 6));
  504. strcat(szPid, "-03-");
  505. if (lang < 0) lang = LcidList[rand() % _countof(LcidList)];
  506. strcat(szPid, itoc(numberBuffer, lang, 0));
  507. strcat(szPid, "-");
  508. strcat(szPid, itoc(numberBuffer, HostOS[serverType].Build, 0));
  509. strcat(szPid, ".0000-");
  510. # define minTime ((time_t)1470175200) /* Release Date Win 2016 */
  511. time_t maxTime, kmsTime;
  512. time(&maxTime);
  513. # ifndef BUILD_TIME
  514. # define BUILD_TIME 1474752907
  515. # endif
  516. if (maxTime < (time_t)BUILD_TIME) // Just in case the system time is < 10/17/2013 1:00 pm
  517. maxTime = (time_t)BUILD_TIME;
  518. kmsTime = (rand32() % (maxTime - minTime)) + minTime;
  519. struct tm *pidTime;
  520. pidTime = gmtime(&kmsTime);
  521. strcat(szPid, itoc(numberBuffer, pidTime->tm_yday, 3));
  522. strcat(szPid, itoc(numberBuffer, pidTime->tm_year + 1900, 4));
  523. }
  524. /*
  525. * Generates random ePIDs and stores them if not already read from ini file.
  526. * For use with randomization level 1
  527. */
  528. void randomPidInit()
  529. {
  530. ProdListIndex_t i;
  531. int serverType = getRandomServerType();
  532. int16_t lang = Lcid ? Lcid : LcidList[rand() % _countof(LcidList)];
  533. for (i = 0; i < MAX_KMSAPPS; i++)
  534. {
  535. if (KmsResponseParameters[i].Epid) continue;
  536. char Epid[PID_BUFFER_SIZE];
  537. generateRandomPid(i, Epid, serverType, lang);
  538. KmsResponseParameters[i].Epid = (const char*)vlmcsd_malloc(strlen(Epid) + 1);
  539. strcpy((char*)KmsResponseParameters[i].Epid, Epid);
  540. #ifndef NO_LOG
  541. KmsResponseParameters[i].EpidSource = "randomized at program start";
  542. #endif // NO_LOG
  543. }
  544. }
  545. #endif // NO_RANDOM_EPID
  546. #ifndef NO_LOG
  547. /*
  548. * Logs a Request
  549. */
  550. static void logRequest(const REQUEST *const baseRequest)
  551. {
  552. const char *productName;
  553. char clientname[64];
  554. ProdListIndex_t index;
  555. #ifndef NO_EXTENDED_PRODUCT_LIST
  556. productName = getProductNameLE(&baseRequest->ActID, ExtendedProductList, _countof(ExtendedProductList), &index);
  557. if (index >= (int)_countof(ExtendedProductList))
  558. #endif // NO_EXTENDED_PRODUCT_LIST
  559. {
  560. productName = getProductNameLE(&baseRequest->KMSID, ProductList, _countof(ProductList), &index);
  561. if (index >= (int)_countof(ProductList))
  562. {
  563. productName = getProductNameLE(&baseRequest->AppID, AppList, _countof(AppList), &index);
  564. }
  565. }
  566. #ifndef NO_VERBOSE_LOG
  567. if (logverbose)
  568. {
  569. logger("<<< Incoming KMS request\n");
  570. logRequestVerbose(baseRequest, &logger);
  571. }
  572. else
  573. {
  574. #endif // NO_VERBOSE_LOG
  575. ucs2_to_utf8(baseRequest->WorkstationName, clientname, 64, 64);
  576. logger("KMS v%i.%i request from %s for %s\n", LE16(baseRequest->MajorVer), LE16(baseRequest->MinorVer), clientname, productName);
  577. #ifndef NO_VERBOSE_LOG
  578. }
  579. #endif // NO_VERBOSE_LOG
  580. }
  581. #endif // NO_LOG
  582. /*
  583. * Converts a utf-8 ePID string to UCS-2 and writes it to a RESPONSE struct
  584. */
  585. #ifndef IS_LIBRARY
  586. static void getEpidFromString(RESPONSE *const Response, const char *const pid)
  587. {
  588. size_t length = utf8_to_ucs2(Response->KmsPID, pid, PID_BUFFER_SIZE, PID_BUFFER_SIZE * 3);
  589. Response->PIDSize = LE32(((unsigned int)length + 1) << 1);
  590. }
  591. /*
  592. * get ePID from appropriate source
  593. */
  594. static void getEpid(RESPONSE *const baseResponse, const char** EpidSource, const ProdListIndex_t index, BYTE *const HwId)
  595. {
  596. const char* pid;
  597. if (KmsResponseParameters[index].Epid == NULL)
  598. {
  599. #ifndef NO_RANDOM_EPID
  600. if (RandomizationLevel == 2)
  601. {
  602. char szPid[PID_BUFFER_SIZE];
  603. generateRandomPid(index, szPid, -1, Lcid ? Lcid : -1);
  604. pid = szPid;
  605. #ifndef NO_LOG
  606. *EpidSource = "randomized on every request";
  607. #endif // NO_LOG
  608. }
  609. else
  610. #endif // NO_RANDOM_EPID
  611. {
  612. switch (index)
  613. {
  614. case EPID_INDEX_OFFICE2016:
  615. pid = EPID_OFFICE2016;
  616. break;
  617. case EPID_INDEX_OFFICE2013:
  618. pid = EPID_OFFICE2013;
  619. break;
  620. case EPID_INDEX_OFFICE2010:
  621. pid = EPID_OFFICE2010;
  622. break;
  623. default:
  624. pid = EPID_WINDOWS;
  625. break;
  626. }
  627. #ifndef NO_LOG
  628. *EpidSource = "vlmcsd default";
  629. #endif // NO_LOG
  630. }
  631. }
  632. else
  633. {
  634. pid = KmsResponseParameters[index].Epid;
  635. if (HwId && KmsResponseParameters[index].HwId != NULL)
  636. memcpy(HwId, KmsResponseParameters[index].HwId, sizeof(((RESPONSE_V6 *)0)->HwId));
  637. #ifndef NO_LOG
  638. *EpidSource = KmsResponseParameters[index].EpidSource;
  639. #endif // NO_LOG
  640. }
  641. getEpidFromString(baseResponse, pid);
  642. }
  643. #endif // IS_LIBRARY
  644. #if !defined(NO_LOG) && defined(_PEDANTIC)
  645. static BOOL CheckVersion4Uuid(const GUID *const guid, const char *const szGuidName)
  646. {
  647. if (LE16(guid->Data3) >> 12 != 4 || guid->Data4[0] >> 6 != 2)
  648. {
  649. logger("Warning: %s does not conform to version 4 UUID according to RFC 4122\n", szGuidName);
  650. return FALSE;
  651. }
  652. return TRUE;
  653. }
  654. static void CheckRequest(const REQUEST *const Request)
  655. {
  656. CheckVersion4Uuid(&Request->CMID, "Client machine ID");
  657. CheckVersion4Uuid(&Request->AppID, "Application ID");
  658. CheckVersion4Uuid(&Request->KMSID, "Server SKU ID");
  659. CheckVersion4Uuid(&Request->ActID, "Client SKU ID");
  660. if (LE32(Request->IsClientVM) > 1)
  661. logger("Warning: Virtual Machine field in request must be 0 or 1 but is %u\n", LE32(Request->IsClientVM));
  662. if (LE32(Request->LicenseStatus) > 6)
  663. logger("Warning: License status must be between 0 and 6 but is %u\n", LE32(Request->LicenseStatus));
  664. }
  665. #endif // !defined(NO_LOG) && defined(_PEDANTIC)
  666. #ifndef NO_LOG
  667. /*
  668. * Logs the Response
  669. */
  670. static void logResponse(const RESPONSE *const baseResponse, const BYTE *const hwId, const char *const EpidSource)
  671. {
  672. char utf8pid[PID_BUFFER_SIZE * 3];
  673. ucs2_to_utf8(baseResponse->KmsPID, utf8pid, PID_BUFFER_SIZE, PID_BUFFER_SIZE * 3);
  674. #ifndef NO_VERBOSE_LOG
  675. if (!logverbose)
  676. {
  677. #endif // NO_VERBOSE_LOG
  678. logger("Sending ePID (%s): %s\n", EpidSource, utf8pid);
  679. #ifndef NO_VERBOSE_LOG
  680. }
  681. else
  682. {
  683. logger(">>> Sending response, ePID source = %s\n", EpidSource);
  684. logResponseVerbose(utf8pid, hwId, baseResponse, &logger);
  685. }
  686. #endif // NO_VERBOSE_LOG
  687. }
  688. #endif
  689. #if __UCLIBC__ && !defined(NO_STRICT_MODES)
  690. long long int llabs(long long int j);
  691. #endif
  692. /*
  693. * Creates the unencrypted base response
  694. */
  695. #ifndef IS_LIBRARY
  696. static HRESULT __stdcall CreateResponseBaseCallback(const REQUEST *const baseRequest, RESPONSE *const baseResponse, BYTE *const hwId, const char* const ipstr)
  697. {
  698. const char* EpidSource;
  699. #ifndef NO_LOG
  700. logRequest(baseRequest);
  701. #ifdef _PEDANTIC
  702. CheckRequest(baseRequest);
  703. #endif // _PEDANTIC
  704. #endif // NO_LOG
  705. ProdListIndex_t index;
  706. getProductNameLE(&baseRequest->KMSID, ProductList, _countof(ProductList), &index);
  707. DWORD minClients = LE32(baseRequest->N_Policy);
  708. DWORD required_clients = minClients < 1 ? 1 : minClients << 1;
  709. # ifndef NO_STRICT_MODES
  710. if (required_clients > 2000)
  711. {
  712. # ifndef NO_LOG
  713. logger("Rejecting request with more than 1000 minimum clients (0x8007000D)\n");
  714. # endif
  715. return 0x8007000D;
  716. }
  717. if (CheckClientTime)
  718. {
  719. time_t requestTime = (time_t)fileTimeToUnixTime(&baseRequest->ClientTime);
  720. if (llabs(requestTime - time(NULL)) > 60 * 60 * 4)
  721. {
  722. # ifndef NO_LOG
  723. logger("Client time differs more than 4 hours from system time (0xC004F06C)\n");
  724. # endif // !NO_LOG
  725. return 0xC004F06C;
  726. }
  727. }
  728. if (WhitelistingLevel & 2)
  729. {
  730. uint_fast8_t i;
  731. for (i = 0; i < _countof(RetailAndBetaProducts); i++)
  732. {
  733. if (IsEqualGuidLE(&ProductList[RetailAndBetaProducts[i]].guid, &baseRequest->KMSID))
  734. {
  735. # ifndef NO_LOG
  736. logger("Refusing retail or beta product (0xC004F042)\n");
  737. # endif // !NO_LOG
  738. return 0xC004F042;
  739. }
  740. }
  741. }
  742. if ((WhitelistingLevel & 1) && index >= _countof(ProductList))
  743. {
  744. # ifndef NO_LOG
  745. logger("Refusing unknown product (0xC004F042)\n");
  746. # endif // !NO_LOG
  747. return 0xC004F042;
  748. }
  749. # endif // !NO_STRICT_MODES
  750. switch (index)
  751. {
  752. case KMS_ID_OFFICE2016:
  753. index = EPID_INDEX_OFFICE2016;
  754. break;
  755. case KMS_ID_OFFICE2013:
  756. case KMS_ID_OFFICE2013_BETA:
  757. index = EPID_INDEX_OFFICE2013;
  758. break;
  759. case KMS_ID_OFFICE2010:
  760. index = EPID_INDEX_OFFICE2010;
  761. break;
  762. default:
  763. index = EPID_INDEX_WINDOWS;
  764. break;
  765. }
  766. # if !defined(NO_STRICT_MODES)
  767. ProdListIndex_t appIndex = index >= _countof(AppList) ? _countof(AppList) - 1 : index;
  768. if ((WhitelistingLevel & 1) && !IsEqualGuidLE(&AppList[appIndex].guid, &baseRequest->AppID))
  769. {
  770. # ifndef NO_LOG
  771. logger("Refusing product with incorrect Application ID (0xC004F042)\n");
  772. # endif // NO_LOG
  773. return 0xC004F042;
  774. }
  775. # ifndef NO_CLIENT_LIST
  776. if (MaintainClients)
  777. {
  778. lock_client_lists();
  779. int_fast16_t i;
  780. int_fast8_t isKnownClient = FALSE;
  781. if (required_clients > (DWORD)ClientLists[appIndex].MaxCount) ClientLists[appIndex].MaxCount = required_clients;
  782. for (i = 0; i < ClientLists[appIndex].MaxCount; i++)
  783. {
  784. if (IsEqualGUID(&ClientLists[appIndex].Guid[i], &baseRequest->CMID))
  785. {
  786. isKnownClient = TRUE;
  787. break;
  788. }
  789. }
  790. if (isKnownClient)
  791. {
  792. baseResponse->Count = LE32(ClientLists[appIndex].CurrentCount);
  793. }
  794. else
  795. {
  796. for (i = 0; i < ClientLists[appIndex].MaxCount; i++)
  797. {
  798. if (IsEqualGUID(ZeroGuid, &ClientLists[appIndex].Guid[i]))
  799. {
  800. if (ClientLists[appIndex].CurrentCount >= MAX_CLIENTS)
  801. {
  802. # ifndef NO_LOG
  803. logger("Rejecting more than 671 clients (0xC004D104)\n");
  804. # endif // !NO_LOG
  805. unlock_client_lists();
  806. return 0xC004D104;
  807. }
  808. baseResponse->Count = LE32(++ClientLists[appIndex].CurrentCount);
  809. memcpy(&ClientLists[appIndex].Guid[i], &baseRequest->CMID, sizeof(GUID));
  810. break;
  811. }
  812. }
  813. if (i >= ClientLists[appIndex].MaxCount)
  814. {
  815. memcpy(&ClientLists[appIndex].Guid[ClientLists[appIndex].CurrentPosition], &baseRequest->CMID, sizeof(GUID));
  816. ClientLists[appIndex].CurrentPosition = (ClientLists[appIndex].CurrentPosition + 1) % (ClientLists[appIndex].MaxCount > MAX_CLIENTS ? MAX_CLIENTS : ClientLists[appIndex].MaxCount);
  817. baseResponse->Count = LE32(ClientLists[appIndex].CurrentCount);
  818. }
  819. }
  820. unlock_client_lists();
  821. }
  822. else
  823. # endif // !NO_CLIENT_LIST
  824. # endif // !defined(NO_STRICT_MODES)
  825. {
  826. DWORD minimum_answer_clients = index > 0 && index < 4 ? 10 : 50;
  827. baseResponse->Count = LE32(required_clients > minimum_answer_clients ? required_clients : minimum_answer_clients);
  828. //if (LE32(baseRequest->N_Policy) > LE32(baseResponse->Count)) baseResponse->Count = LE32(LE32(baseRequest->N_Policy) << 1);
  829. }
  830. getEpid(baseResponse, &EpidSource, index, hwId);
  831. baseResponse->Version = baseRequest->Version;
  832. memcpy(&baseResponse->CMID, &baseRequest->CMID, sizeof(GUID));
  833. memcpy(&baseResponse->ClientTime, &baseRequest->ClientTime, sizeof(FILETIME));
  834. baseResponse->VLActivationInterval = LE32(VLActivationInterval);
  835. baseResponse->VLRenewalInterval = LE32(VLRenewalInterval);
  836. #ifndef NO_LOG
  837. logResponse(baseResponse, hwId, EpidSource);
  838. #endif // NO_LOG
  839. return S_OK;
  840. }
  841. RequestCallback_t CreateResponseBase = &CreateResponseBaseCallback;
  842. #else // IS_LIBRARY
  843. RequestCallback_t CreateResponseBase = NULL;
  844. #endif // IS_LIBRARY
  845. ////TODO: Move to helpers.c
  846. void get16RandomBytes(void* ptr)
  847. {
  848. int i;
  849. for (i = 0; i < 4; i++) ((DWORD*)ptr)[i] = rand32();
  850. }
  851. /*
  852. * Creates v4 response
  853. */
  854. size_t CreateResponseV4(REQUEST_V4 *const request_v4, BYTE *const responseBuffer, const char* const ipstr)
  855. {
  856. RESPONSE_V4* Response = (RESPONSE_V4*)responseBuffer;
  857. HRESULT hResult;
  858. if (FAILED(hResult = CreateResponseBase(&request_v4->RequestBase, &Response->ResponseBase, NULL, ipstr))) return hResult;
  859. DWORD pidSize = LE32(Response->ResponseBase.PIDSize);
  860. BYTE* postEpidPtr = responseBuffer + V4_PRE_EPID_SIZE + pidSize;
  861. memmove(postEpidPtr, &Response->ResponseBase.CMID, V4_POST_EPID_SIZE);
  862. size_t encryptSize = V4_PRE_EPID_SIZE + V4_POST_EPID_SIZE + pidSize;
  863. AesCmacV4(responseBuffer, encryptSize, responseBuffer + encryptSize);
  864. return encryptSize + sizeof(Response->MAC);
  865. }
  866. /*
  867. // Workaround for buggy GCC 4.2/4.3
  868. #if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 4)
  869. __attribute__((noinline))
  870. #endif
  871. __pure static uint64_t TimestampInterval(void *ts)
  872. {
  873. return ( GET_UA64LE(ts) / TIME_C1 ) * TIME_C2 + TIME_C3;
  874. }*/
  875. /*
  876. * Creates the HMAC for v6
  877. */
  878. static int_fast8_t CreateV6Hmac(BYTE *const encrypt_start, const size_t encryptSize, int_fast8_t tolerance)
  879. {
  880. BYTE hash[32];
  881. # define halfHashSize (sizeof(hash) >> 1)
  882. uint64_t timeSlot;
  883. BYTE *responseEnd = encrypt_start + encryptSize;
  884. // This is the time from the response
  885. FILETIME* ft = (FILETIME*)(responseEnd - V6_POST_EPID_SIZE + sizeof(((RESPONSE*)0)->CMID));
  886. // Generate a time slot that changes every 4.11 hours.
  887. // Request and repsonse time must match +/- 1 slot.
  888. // When generating a response tolerance must be 0.
  889. // If verifying the hash, try tolerance -1, 0 and +1. One of them must match.
  890. timeSlot = LE64((GET_UA64LE(ft) / TIME_C1 * TIME_C2 + TIME_C3) + (tolerance * TIME_C1));
  891. // The time slot is hashed with SHA256 so it is not so obvious that it is time
  892. Sha256((BYTE*)&timeSlot, sizeof(timeSlot), hash);
  893. // The last 16 bytes of the hashed time slot are the actual HMAC key
  894. if (!Sha256Hmac
  895. (
  896. hash + halfHashSize, // Use last 16 bytes of SHA256 as HMAC key
  897. encrypt_start, // hash only the encrypted part of the v6 response
  898. (DWORD)(encryptSize - sizeof(((RESPONSE_V6*)0)->HMAC)), // encryptSize minus the HMAC itself
  899. hash // use same buffer for resulting hash where the key came from
  900. ))
  901. {
  902. return FALSE;
  903. }
  904. memcpy(responseEnd - sizeof(((RESPONSE_V6*)0)->HMAC), hash + halfHashSize, halfHashSize);
  905. return TRUE;
  906. # undef halfHashSize
  907. }
  908. /*
  909. * Creates v5 or v6 response
  910. */
  911. size_t CreateResponseV6(REQUEST_V6 *restrict request_v6, BYTE *const responseBuffer, const char* const ipstr)
  912. {
  913. // The response will be created in a fixed sized struct to
  914. // avoid unaligned access macros and packed structs on RISC systems
  915. // which largely increase code size.
  916. //
  917. // The fixed sized struct with 64 WCHARs for the ePID will be converted
  918. // to a variable sized struct later and requires unaligned access macros.
  919. RESPONSE_V6* Response = (RESPONSE_V6*)responseBuffer;
  920. RESPONSE* baseResponse = &Response->ResponseBase;
  921. #ifdef _DEBUG
  922. // ReSharper disable once CppEntityNeverUsed
  923. RESPONSE_V6_DEBUG* xxx = (RESPONSE_V6_DEBUG*)responseBuffer;
  924. #endif
  925. static const BYTE DefaultHwid[8] = { HWID };
  926. int_fast8_t v6 = LE16(request_v6->MajorVer) > 5;
  927. AesCtx aesCtx;
  928. AesInitKey(&aesCtx, v6 ? AesKeyV6 : AesKeyV5, v6, AES_KEY_BYTES);
  929. AesDecryptCbc(&aesCtx, NULL, request_v6->IV, V6_DECRYPT_SIZE);
  930. // get random salt and SHA256 it
  931. get16RandomBytes(Response->RandomXoredIVs);
  932. Sha256(Response->RandomXoredIVs, sizeof(Response->RandomXoredIVs), Response->Hash);
  933. if (v6) // V6 specific stuff
  934. {
  935. // In v6 a random IV is generated
  936. Response->Version = request_v6->Version;
  937. get16RandomBytes(Response->IV);
  938. // pre-fill with default HwId (not required for v5)
  939. memcpy(Response->HwId, DefaultHwid, sizeof(Response->HwId));
  940. // Just copy decrypted request IV (using Null IV) here. Note this is identical
  941. // to XORing non-decrypted request and reponse IVs
  942. memcpy(Response->XoredIVs, request_v6->IV, sizeof(Response->XoredIVs));
  943. }
  944. else // V5 specific stuff
  945. {
  946. // In v5 IVs of request and response must be identical (MS client checks this)
  947. // The following memcpy copies Version and IVs at once
  948. memcpy(Response, request_v6, V6_UNENCRYPTED_SIZE);
  949. }
  950. // Xor Random bytes with decrypted request IV
  951. XorBlock(request_v6->IV, Response->RandomXoredIVs);
  952. // Get the base response
  953. HRESULT hResult;
  954. if (FAILED(hResult = CreateResponseBase(&request_v6->RequestBase, baseResponse, Response->HwId, ipstr))) return hResult;
  955. // Convert the fixed sized struct into variable sized
  956. DWORD pidSize = LE32(baseResponse->PIDSize);
  957. BYTE* postEpidPtr = responseBuffer + V6_PRE_EPID_SIZE + pidSize;
  958. size_t post_epid_size = v6 ? V6_POST_EPID_SIZE : V5_POST_EPID_SIZE;
  959. memmove(postEpidPtr, &baseResponse->CMID, post_epid_size);
  960. // number of bytes to encrypt
  961. size_t encryptSize =
  962. V6_PRE_EPID_SIZE
  963. - sizeof(Response->Version)
  964. + pidSize
  965. + post_epid_size;
  966. //AesDecryptBlock(&aesCtx, Response->IV);
  967. if (v6 && !CreateV6Hmac(Response->IV, encryptSize, 0)) return 0;
  968. // Padding auto handled by encryption func
  969. AesEncryptCbc(&aesCtx, NULL, Response->IV, &encryptSize);
  970. return encryptSize + sizeof(Response->Version);
  971. }
  972. // Create Hashed KMS Client Request Data for KMS Protocol Version 4
  973. BYTE *CreateRequestV4(size_t *size, const REQUEST* requestBase)
  974. {
  975. *size = sizeof(REQUEST_V4);
  976. // Build a proper KMS client request data
  977. BYTE *request = (BYTE *)vlmcsd_malloc(sizeof(REQUEST_V4));
  978. // Temporary Pointer for access to REQUEST_V4 structure
  979. REQUEST_V4 *request_v4 = (REQUEST_V4 *)request;
  980. // Set KMS Client Request Base
  981. memcpy(&request_v4->RequestBase, requestBase, sizeof(REQUEST));
  982. // Generate Hash Signature
  983. AesCmacV4(request, sizeof(REQUEST), request_v4->MAC);
  984. // Return Request Data
  985. return request;
  986. }
  987. // Create Encrypted KMS Client Request Data for KMS Protocol Version 6
  988. BYTE* CreateRequestV6(size_t *size, const REQUEST* requestBase)
  989. {
  990. *size = sizeof(REQUEST_V6);
  991. // Temporary Pointer for access to REQUEST_V5 structure
  992. REQUEST_V6 *request = (REQUEST_V6 *)vlmcsd_malloc(sizeof(REQUEST_V6));
  993. // KMS Protocol Version
  994. request->Version = requestBase->Version;
  995. // Initialize the IV
  996. get16RandomBytes(request->IV);
  997. // Set KMS Client Request Base
  998. memcpy(&request->RequestBase, requestBase, sizeof(REQUEST));
  999. // Encrypt KMS Client Request
  1000. size_t encryptSize = sizeof(request->RequestBase);
  1001. AesCtx Ctx;
  1002. int_fast8_t v6 = LE16(request->MajorVer) > 5;
  1003. AesInitKey(&Ctx, v6 ? AesKeyV6 : AesKeyV5, v6, 16);
  1004. AesEncryptCbc(&Ctx, request->IV, (BYTE*)(&request->RequestBase), &encryptSize);
  1005. // Return Proper Request Data
  1006. return (BYTE*)request;
  1007. }
  1008. /*
  1009. * Checks whether Length of ePID is valid
  1010. */
  1011. static uint8_t checkPidLength(const RESPONSE *const responseBase)
  1012. {
  1013. unsigned int i;
  1014. if (LE32(responseBase->PIDSize) > (PID_BUFFER_SIZE << 1)) return FALSE;
  1015. if (responseBase->KmsPID[(LE32(responseBase->PIDSize) >> 1) - 1]) return FALSE;
  1016. for (i = 0; i < (LE32(responseBase->PIDSize) >> 1) - 2; i++)
  1017. {
  1018. if (!responseBase->KmsPID[i]) return FALSE;
  1019. }
  1020. return TRUE;
  1021. }
  1022. /*
  1023. * "Decrypts" a KMS v4 response. Actually just copies to a fixed size buffer
  1024. */
  1025. RESPONSE_RESULT DecryptResponseV4(RESPONSE_V4* response_v4, const int responseSize, BYTE* const rawResponse, const BYTE* const rawRequest)
  1026. {
  1027. int copySize =
  1028. V4_PRE_EPID_SIZE +
  1029. (LE32(((RESPONSE_V4*)rawResponse)->ResponseBase.PIDSize) <= PID_BUFFER_SIZE << 1 ?
  1030. LE32(((RESPONSE_V4*)rawResponse)->ResponseBase.PIDSize) :
  1031. PID_BUFFER_SIZE << 1);
  1032. int messageSize = copySize + V4_POST_EPID_SIZE;
  1033. memcpy(response_v4, rawResponse, copySize);
  1034. memcpy(&response_v4->ResponseBase.CMID, rawResponse + copySize, responseSize - copySize);
  1035. // ensure PID is null terminated
  1036. response_v4->ResponseBase.KmsPID[PID_BUFFER_SIZE - 1] = 0;
  1037. uint8_t* mac = rawResponse + messageSize;
  1038. AesCmacV4(rawResponse, messageSize, mac);
  1039. REQUEST_V4* request_v4 = (REQUEST_V4*)rawRequest;
  1040. RESPONSE_RESULT result;
  1041. result.mask = (DWORD)~0;
  1042. result.PidLengthOK = checkPidLength((RESPONSE*)rawResponse);
  1043. result.VersionOK = response_v4->ResponseBase.Version == request_v4->RequestBase.Version;
  1044. result.HashOK = !memcmp(&response_v4->MAC, mac, sizeof(response_v4->MAC));
  1045. result.TimeStampOK = !memcmp(&response_v4->ResponseBase.ClientTime, &request_v4->RequestBase.ClientTime, sizeof(FILETIME));
  1046. result.ClientMachineIDOK = !memcmp(&response_v4->ResponseBase.CMID, &request_v4->RequestBase.CMID, sizeof(GUID));
  1047. result.effectiveResponseSize = responseSize;
  1048. result.correctResponseSize = sizeof(RESPONSE_V4) - sizeof(response_v4->ResponseBase.KmsPID) + LE32(response_v4->ResponseBase.PIDSize);
  1049. return result;
  1050. }
  1051. static RESPONSE_RESULT VerifyResponseV6(RESPONSE_RESULT result, const AesCtx* Ctx, RESPONSE_V6* response_v6, REQUEST_V6* request_v6, BYTE* const rawResponse)
  1052. {
  1053. // Check IVs
  1054. result.IVsOK = !memcmp // In V6 the XoredIV is actually the request IV
  1055. (
  1056. response_v6->XoredIVs,
  1057. request_v6->IV,
  1058. sizeof(response_v6->XoredIVs)
  1059. );
  1060. result.IVnotSuspicious = !!memcmp // If IVs are identical, it is obviously an emulator
  1061. (
  1062. request_v6->IV,
  1063. response_v6->IV,
  1064. sizeof(request_v6->IV)
  1065. );
  1066. // Check Hmac
  1067. int_fast8_t tolerance;
  1068. BYTE OldHmac[sizeof(response_v6->HMAC)];
  1069. result.HmacSha256OK = FALSE;
  1070. memcpy // Save received HMAC to compare with calculated HMAC later
  1071. (
  1072. OldHmac,
  1073. response_v6->HMAC,
  1074. sizeof(response_v6->HMAC)
  1075. );
  1076. //AesEncryptBlock(Ctx, Response_v6->IV); // CreateV6Hmac needs original IV as received over the network
  1077. for (tolerance = -1; tolerance < 2; tolerance++)
  1078. {
  1079. CreateV6Hmac
  1080. (
  1081. rawResponse + sizeof(response_v6->Version), // Pointer to start of the encrypted part of the response
  1082. (size_t)result.correctResponseSize - sizeof(response_v6->Version), // size of the encrypted part
  1083. tolerance // tolerance -1, 0, or +1
  1084. );
  1085. result.HmacSha256OK = !memcmp // Compare both HMACs
  1086. (
  1087. OldHmac,
  1088. rawResponse + (size_t)result.correctResponseSize - sizeof(response_v6->HMAC),
  1089. sizeof(OldHmac)
  1090. );
  1091. if (result.HmacSha256OK) break;
  1092. }
  1093. return result;
  1094. }
  1095. static RESPONSE_RESULT VerifyResponseV5(RESPONSE_RESULT result, REQUEST_V5* request_v5, RESPONSE_V5* response_v5)
  1096. {
  1097. // Check IVs: in V5 (and only v5) request and response IVs must match
  1098. result.IVsOK = !memcmp(request_v5->IV, response_v5->IV, sizeof(request_v5->IV));
  1099. // V5 has no Hmac, always set to TRUE
  1100. result.HmacSha256OK = TRUE;
  1101. return result;
  1102. }
  1103. /*
  1104. * Decrypts a KMS v5 or v6 response received from a server.
  1105. * hwid must supply a valid 16 byte buffer for v6. hwid is ignored in v5
  1106. */
  1107. RESPONSE_RESULT DecryptResponseV6(RESPONSE_V6* response_v6, int responseSize, BYTE* const response, const BYTE* const rawRequest, BYTE* hwid)
  1108. {
  1109. RESPONSE_RESULT result;
  1110. result.mask = ~0; // Set all bits in the results mask to 1. Assume success first.
  1111. result.effectiveResponseSize = responseSize;
  1112. int copySize1 =
  1113. sizeof(response_v6->Version);
  1114. // Decrypt KMS Server Response (encrypted part starts after RequestIV)
  1115. responseSize -= copySize1;
  1116. AesCtx Ctx;
  1117. int_fast8_t v6 = LE16(((RESPONSE_V6*)response)->MajorVer) > 5;
  1118. AesInitKey(&Ctx, v6 ? AesKeyV6 : AesKeyV5, v6, AES_KEY_BYTES);
  1119. AesDecryptCbc(&Ctx, NULL, response + copySize1, responseSize);
  1120. // Check padding
  1121. BYTE* lastPadByte = response + (size_t)result.effectiveResponseSize - 1;
  1122. // Must be from 1 to 16
  1123. if (!*lastPadByte || *lastPadByte > AES_BLOCK_BYTES)
  1124. {
  1125. result.DecryptSuccess = FALSE;
  1126. return result;
  1127. }
  1128. // Check if pad bytes are all the same
  1129. BYTE* padByte;
  1130. for (padByte = lastPadByte - *lastPadByte + 1; padByte < lastPadByte; padByte++)
  1131. if (*padByte != *lastPadByte)
  1132. {
  1133. result.DecryptSuccess = FALSE;
  1134. return result;
  1135. }
  1136. // Add size of Version, KmsPIDLen and variable size PID
  1137. DWORD pidSize = LE32(((RESPONSE_V6*)response)->ResponseBase.PIDSize);
  1138. copySize1 +=
  1139. V6_UNENCRYPTED_SIZE +
  1140. sizeof(response_v6->ResponseBase.PIDSize) +
  1141. (pidSize <= PID_BUFFER_SIZE << 1 ? pidSize : PID_BUFFER_SIZE << 1);
  1142. // Copy part 1 of response up to variable sized PID
  1143. memcpy(response_v6, response, copySize1);
  1144. // ensure PID is null terminated
  1145. response_v6->ResponseBase.KmsPID[PID_BUFFER_SIZE - 1] = 0;
  1146. // Copy part 2
  1147. size_t copySize2 = v6 ? V6_POST_EPID_SIZE : V5_POST_EPID_SIZE;
  1148. memcpy(&response_v6->ResponseBase.CMID, response + copySize1, copySize2);
  1149. // Decrypting the response is finished here. Now we check the results for validity
  1150. // A basic client doesn't need the stuff below this comment but we want to use vlmcs
  1151. // as a debug tool for KMS emulators.
  1152. REQUEST_V6* request_v6 = (REQUEST_V6*)rawRequest;
  1153. DWORD decryptSize = sizeof(request_v6->IV) + sizeof(request_v6->RequestBase) + sizeof(request_v6->Pad);
  1154. AesDecryptCbc(&Ctx, NULL, request_v6->IV, decryptSize);
  1155. // Check that all version informations are the same
  1156. result.VersionOK =
  1157. request_v6->Version == response_v6->ResponseBase.Version &&
  1158. request_v6->Version == response_v6->Version &&
  1159. request_v6->Version == request_v6->RequestBase.Version;
  1160. // Check Base Request
  1161. result.PidLengthOK = checkPidLength(&((RESPONSE_V6*)response)->ResponseBase);
  1162. result.TimeStampOK = !memcmp(&response_v6->ResponseBase.ClientTime, &request_v6->RequestBase.ClientTime, sizeof(FILETIME));
  1163. result.ClientMachineIDOK = IsEqualGUID(&response_v6->ResponseBase.CMID, &request_v6->RequestBase.CMID);
  1164. // Rebuild Random Key and Sha256 Hash
  1165. BYTE HashVerify[sizeof(response_v6->Hash)];
  1166. BYTE RandomKey[sizeof(response_v6->RandomXoredIVs)];
  1167. memcpy(RandomKey, request_v6->IV, sizeof(RandomKey));
  1168. XorBlock(response_v6->RandomXoredIVs, RandomKey);
  1169. Sha256(RandomKey, sizeof(RandomKey), HashVerify);
  1170. result.HashOK = !memcmp(response_v6->Hash, HashVerify, sizeof(HashVerify));
  1171. // size before encryption (padding not included)
  1172. result.correctResponseSize =
  1173. (v6 ? sizeof(RESPONSE_V6) : sizeof(RESPONSE_V5))
  1174. - sizeof(response_v6->ResponseBase.KmsPID)
  1175. + LE32(response_v6->ResponseBase.PIDSize);
  1176. // Version specific stuff
  1177. if (v6)
  1178. {
  1179. // Copy the HwId
  1180. memcpy(hwid, response_v6->HwId, sizeof(response_v6->HwId));
  1181. // Verify the V6 specific part of the response
  1182. result = VerifyResponseV6(result, &Ctx, response_v6, request_v6, response);
  1183. }
  1184. else // V5
  1185. {
  1186. // Verify the V5 specific part of the response
  1187. result = VerifyResponseV5(result, request_v6, (RESPONSE_V5*)response_v6);
  1188. }
  1189. // padded size after encryption
  1190. result.correctResponseSize += (~(result.correctResponseSize - sizeof(response_v6->ResponseBase.Version)) & 0xf) + 1;
  1191. return result;
  1192. }