Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
vlmcsd-svn906-2016-06-05-Hotbird64
Browse files Browse the repository at this point in the history
  • Loading branch information
Wind4 committed Jun 6, 2016
1 parent 1c86f7a commit c479a67
Show file tree
Hide file tree
Showing 55 changed files with 5,724 additions and 21,769 deletions.
246 changes: 150 additions & 96 deletions GNUmakefile

Large diffs are not rendered by default.

64 changes: 61 additions & 3 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
*/

#ifndef EPID_WINDOWS
#define EPID_WINDOWS "06401-00206-271-298329-03-1033-9600.0000-0452015"
#define EPID_WINDOWS "06401-00206-271-398432-03-1033-9600.0000-1422016"
#endif

#ifndef EPID_OFFICE2010
#define EPID_OFFICE2010 "06401-00096-199-198322-03-1033-9600.0000-0452015"
#define EPID_OFFICE2010 "06401-00096-199-198384-03-1033-9600.0000-1422016"
#endif

#ifndef EPID_OFFICE2013
#define EPID_OFFICE2013 "06401-00206-234-398213-03-1033-9600.0000-0452015"
#define EPID_OFFICE2013 "06401-00206-234-384729-03-1033-9600.0000-1422016"
#endif

#ifndef HWID // HwId from the Ratiborus VM
Expand Down Expand Up @@ -82,6 +82,25 @@



/*
* -------------------------------
* Backward compatibility
* -------------------------------
*/


#if !defined(ENABLE_DEPRECATED_OPTIONS)
/*
* comment out the following line if you want vlmcsd no to support command line options
* that have been present in previous versions of vlmcsd and are now obsolete
*/

//#define ENABLE_DEPRECATED_OPTIONS

#endif // ENABLE_DEPRECATED_OPTIONS




/*
* ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -366,6 +385,20 @@
*/


#ifndef NO_FREEBIND
/*
* Do not compile support for FREEBIND (Linux) and IP_BINDANY (FreeBSD). This disables the -F1 command
* line option and you can bind only to (listen on) IP addresses that are currently up and running on
* your system.
*/

//#define NO_FREEBIND

#endif // NO_FREEBIND




#ifndef NO_EXTENDED_PRODUCT_LIST
/*
* Do not compile the extended product list. Removes the list of Activation GUIDs (aka
Expand Down Expand Up @@ -399,6 +432,18 @@



#ifndef NO_VERSION_INFORMATION
/*
* Removes the -V option from vlmcsd and vlmcs that displays the version information
*/

//#define NO_VERSION_INFORMATION

#endif // NO_VERSION_INFORMATION




#ifndef NO_VERBOSE_LOG
/*
* Removes the ability to do verbose logging and disables -v and -q in vlmcsd. It does not remove the -v
Expand Down Expand Up @@ -577,6 +622,19 @@



#ifndef SIMPLE_SOCKETS
/*
* Disables the ability to choose IP addresses using the -L option in vlmcsd. vlmcsd will listen on all IP addresses.
* It still supports IPv4 and IPv6.
*/

//#define SIMPLE_SOCKETS

#endif // SIMPLE_SOCKETS




/* Don't change anything BELOW this line */


Expand Down
Binary file modified floppy144.vfd
Binary file not shown.
26 changes: 19 additions & 7 deletions kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const KmsIdList ProductList[] = {
};
#endif

#ifndef IS_LIBRARY
// Application ID is used by KMS server to count KeyManagementServiceCurrentCount
// Do not change the order of this list. Append items as necessary
const KmsIdList AppList[] = {
Expand All @@ -59,6 +60,7 @@ const KmsIdList AppList[] = {
/* 002 */ { { 0x0FF1CE15, 0xA989, 0x479D, { 0xaf, 0x46, 0xf2, 0x75, 0xc6, 0x37, 0x06, 0x63 } } /*"0FF1CE15-A989-479D-AF46-F275C6370663"*/, FRIENDLY_NAME_OFFICE2013, EPID_OFFICE2013, 0, 0},
/* 003 */ { { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, NULL, NULL, 0, 0 }
};
#endif // IS_LIBRARY

#ifndef NO_EXTENDED_PRODUCT_LIST
const KmsIdList ExtendedProductList [] = {
Expand Down Expand Up @@ -258,7 +260,7 @@ static const struct KMSHostOS { uint16_t Type; uint16_t Build; } HostOS[] =
{ 55041, 7601 }, // Windows Server 2008 R2 SP1
{ 5426, 9200 }, // Windows Server 2012
{ 6401, 9600 }, // Windows Server 2012 R2
{ 3612, 10240}, // Windows Server 2016
//{ 3612, 10240}, // Windows Server 2016
};

// GroupID and PIDRange
Expand Down Expand Up @@ -377,9 +379,10 @@ static int getRandomServerType()
# ifndef USE_MSRPC
else
{
// return 9200/9600/10240 if NDR64 is in use, otherwise 6002/7601
if (UseRpcNDR64) return (rand() % 3) + 2;
return (rand() % 2);
// return 9200/9600 if NDR64 is in use, otherwise 6002/7601
return (rand() % 2) + (UseRpcNDR64 ? 2 : 0);
// if (UseRpcNDR64) return (rand() % 3) + 2;
// return (rand() % 2);
}
# endif // USE_MSRPC
}
Expand Down Expand Up @@ -424,12 +427,12 @@ static void generateRandomPid(const int index, char *const szPid, int serverType
strcat(szPid, itoc(numberBuffer, HostOS[serverType].Build, 0));
strcat(szPid, ".0000-");

# define minTime ((time_t)1436958000) // Release Date Windows 10 RTM Escrow
# define minTime ((time_t)1382029200) // Release Date Win 2012R2

time_t maxTime, kmsTime;
time(&maxTime);

if (maxTime < minTime) // Just in case the system time is < 07/15/2015 1:00 pm
if (maxTime < (time_t)BUILD_TIME) // Just in case the system time is < 10/17/2013 1:00 pm
maxTime = (time_t)BUILD_TIME;

kmsTime = (rand32() % (maxTime - minTime)) + minTime;
Expand Down Expand Up @@ -519,6 +522,7 @@ static void logRequest(const REQUEST *const baseRequest)
/*
* Converts a utf-8 ePID string to UCS-2 and writes it to a RESPONSE struct
*/
#ifndef IS_LIBRARY
static void getEpidFromString(RESPONSE *const Response, const char *const pid)
{
size_t length = utf8_to_ucs2(Response->KmsPID, pid, PID_BUFFER_SIZE, PID_BUFFER_SIZE * 3);
Expand Down Expand Up @@ -567,6 +571,7 @@ static void getEpid(RESPONSE *const baseResponse, const char** EpidSource, const
}
getEpidFromString(baseResponse, pid);
}
#endif // IS_LIBRARY


#if !defined(NO_LOG) && defined(_PEDANTIC)
Expand Down Expand Up @@ -627,6 +632,7 @@ static void logResponse(const RESPONSE *const baseResponse, const BYTE *const hw
/*
* Creates the unencrypted base response
*/
#ifndef IS_LIBRARY
static BOOL __stdcall CreateResponseBaseCallback(const REQUEST *const baseRequest, RESPONSE *const baseResponse, BYTE *const hwId, const char* const ipstr)
{
const char* EpidSource;
Expand Down Expand Up @@ -663,14 +669,20 @@ static BOOL __stdcall CreateResponseBaseCallback(const REQUEST *const baseReques

RequestCallback_t CreateResponseBase = &CreateResponseBaseCallback;

#else // IS_LIBRARY

RequestCallback_t CreateResponseBase = NULL;

#endif // IS_LIBRARY


////TODO: Move to helpers.c
void get16RandomBytes(void* ptr)
{
int i;
for (i = 0; i < 4; i++) ((DWORD*)ptr)[i] = rand32();
}


/*
* Creates v4 response
*/
Expand Down
9 changes: 8 additions & 1 deletion libkms-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ __stdcall BOOL KmsCallBack(const REQUEST *const baseRequest, RESPONSE *const bas

int main(int argc, char** argv)
{
printf("libvlmcs-test.c: Program start\n");
int version = GetLibKmsVersion();

if (version < 0x30001)
{
fprintf(stderr, "KMS library version %u.%u or greater required\n", (unsigned int)(version >> 16), (unsigned int)(version & 0xffff));
}

printf("%s: Program start\n", GetEmulatorVersion());
StartKmsServer(1688, KmsCallBack);
return 0;
}
54 changes: 53 additions & 1 deletion libkms.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
#endif // CONFIG
#include CONFIG

#ifdef EXTERNAL
#undef EXTERNAL
#endif

#define EXTERNAL dllexport

#define DLLVERSION 0x30000
#define DLLVERSION 0x30001

#include "libkms.h"
#include "shared_globals.h"
Expand All @@ -24,6 +28,10 @@
#include <netinet/in.h>
#endif // WIN32

#ifdef IS_LIBRARY
char ErrorMessage[MESSAGE_BUFFER_SIZE];
#endif // IS_LIBRARY

static int_fast8_t IsServerStarted = FALSE;


Expand All @@ -42,6 +50,7 @@ EXTERNC __declspec(EXTERNAL) DWORD __cdecl SendActivationRequest

EXTERNC __declspec(EXTERNAL) DWORD __cdecl StartKmsServer(const int port, RequestCallback_t requestCallback)
{
#ifndef SIMPLE_SOCKETS
char listenAddress[64];

if (IsServerStarted) return !0;
Expand Down Expand Up @@ -97,6 +106,39 @@ EXTERNC __declspec(EXTERNAL) DWORD __cdecl StartKmsServer(const int port, Reques

IsServerStarted = FALSE;
return 0;

# else // SIMPLE_SOCKETS

if (IsServerStarted) return !0;
int error;

# ifdef _WIN32
# ifndef USE_MSRPC
// Windows Sockets must be initialized
WSADATA wsadata;

if ((error = WSAStartup(0x0202, &wsadata)))
{
return error;
}
# endif // USE_MSRPC
# endif // _WIN32

defaultport = vlmcsd_malloc(16);
snprintf((char*)defaultport, (size_t)16, "%i", port);

CreateResponseBase = requestCallback;
error = listenOnAllAddresses();
if (error) return error;

IsServerStarted = TRUE;
runServer();
IsServerStarted = FALSE;

return 0;


# endif // SIMPLE_SOCKETS
}


Expand All @@ -105,7 +147,11 @@ EXTERNC __declspec(EXTERNAL) DWORD __cdecl StopKmsServer()
if (!IsServerStarted) return !0;

closeAllListeningSockets();

# ifndef SIMPLE_SOCKETS
if (SocketList) free(SocketList);
# endif

return 0;
}

Expand All @@ -115,3 +161,9 @@ EXTERNC __declspec(EXTERNAL) int __cdecl GetLibKmsVersion()
return DLLVERSION;
}


EXTERNC __declspec(EXTERNAL) const char* const __cdecl GetEmulatorVersion()
{
return VERSION;
}

11 changes: 3 additions & 8 deletions libkms.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@
#include "kms.h"
#include "rpc.h"

#ifndef EXTERNC
#ifdef __cplusplus
#define EXTERNC extern "C"
#define EXTERNC EXTERN "C"
#else
#define EXTERNC
#endif

#if !defined(_WIN32) && !__CYGWIN__
#define __declspec(x) __attribute__((__visibility__("default")))
#endif

#if !defined(EXTERNAL)
#define EXTERNAL dllimport
#endif

EXTERNC __declspec(EXTERNAL) DWORD __cdecl SendActivationRequest(const char* const hostname, const int port, RESPONSE* baseResponse, const REQUEST* const baseRequest, RESPONSE_RESULT* result, BYTE *hwid);
EXTERNC __declspec(EXTERNAL) DWORD __cdecl StartKmsServer(const int port, RequestCallback_t requestCallback);
EXTERNC __declspec(EXTERNAL) DWORD __cdecl StopKmsServer();
EXTERNC __declspec(EXTERNAL) int __cdecl GetLibKmsVersion();
EXTERNC __declspec(EXTERNAL) const char* const __cdecl GetEmulatorVersion();
//EXTERN_C __declspec(EXTERNAL) unsigned int __cdecl GetRandom32();


Expand Down
1 change: 1 addition & 0 deletions make_dragonfly
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CF45="-static-libgcc -pipe -fno-common -fno-exceptions -fno-stack-protector -fno
CFCLANG="-pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants"
LF="-Wl,-z,norelro -Wl,--hash-style=sysv -Wl,--build-id=none"
LFCLANG="-Wl,-z,norelro -Wl,--hash-style=sysv"
export CC=gcc5

gmake $MAKEFLAGS PROGRAM_NAME=vlmcsd-DragonFly-x64 CLIENT_NAME=vlmcs-DragonFly-x64 CFLAGS="$CF" LDFLAGS="$LF"
rm vlmcsd.o vlmcs.o
Expand Down
Loading

0 comments on commit c479a67

Please sign in to comment.