diff --git a/sources/etc/vlmcsd.ini b/sources/etc/vlmcsd.ini index 96ffa5c..bbb14bb 100644 --- a/sources/etc/vlmcsd.ini +++ b/sources/etc/vlmcsd.ini @@ -134,4 +134,7 @@ # Disable or enable the privacy mode (default is false) # Command line: -;PrivacyMode = false \ No newline at end of file +;PrivacyMode = false + +# Disable or enable the ability to count the request (default is false) +;CountingReq = false \ No newline at end of file diff --git a/sources/src/GNUmakefile b/sources/src/GNUmakefile index 4de1b7a..58c3a25 100644 --- a/sources/src/GNUmakefile +++ b/sources/src/GNUmakefile @@ -652,10 +652,10 @@ endif $(BUILDCOMMANDPREFIX)$(AR) rcs $@ $^ clean: - rm -f $(REAL_PROGRAM_NAME) $(REAL_MULTI_NAME) $(REAL_DLL_NAME) $(REAL_CLIENT_NAME) $(OBJ_NAME) $(REAL_A_NAME) ../bin/* ../build/* *.d + rm -rf $(REAL_PROGRAM_NAME) $(REAL_MULTI_NAME) $(REAL_DLL_NAME) $(REAL_CLIENT_NAME) $(OBJ_NAME) $(REAL_A_NAME) ../bin/* ../build/* *.d dnsclean: - rm -f ../build/dns_srv.o + rm -rf ../build/dns_srv.o help: @echo "Help is available by typing 'make help' in directory $(shell realpath `pwd`/..). Use 'cd ..' to get there." diff --git a/sources/src/config.h b/sources/src/config.h index a8df5c8..6f18cd1 100644 --- a/sources/src/config.h +++ b/sources/src/config.h @@ -10,19 +10,17 @@ * new version. */ - - - /* - * ---------------------------------------------------------------------------------------- - * Useful customizations. These options are mandatory. You cannot comment them out. - * Feel free to change them to fit your needs. - * ---------------------------------------------------------------------------------------- - */ +/* + * ---------------------------------------------------------------------------------------- + * Useful customizations. These options are mandatory. You cannot comment them out. + * Feel free to change them to fit your needs. + * ---------------------------------------------------------------------------------------- + */ #ifndef VERSION - /* - * Define your own version identifier here, e.g. '#define VERSION "my vlmcsd based on 1103"' - */ +/* + * Define your own version identifier here, e.g. '#define VERSION "my vlmcsd based on 1103"' + */ #define VERSION __DATE__ @@ -37,41 +35,32 @@ * uncomment one or more lines starting with "//#define" */ - - - /* - * ------------------------------- - * Defaults - * ------------------------------- - */ - - +/* + * ------------------------------- + * Defaults + * ------------------------------- + */ #ifndef INI_FILE - /* - * Uncomment and customize the following line if you want vlmcsd to look for an ini file - * at a default location. - */ +/* + * Uncomment and customize the following line if you want vlmcsd to look for an ini file + * at a default location. + */ - //#define INI_FILE "/etc/vlmcsd.ini" +#define INI_FILE "/etc/vlmcsd.ini" #endif // INI_FILE - - - - #ifndef DATA_FILE /* * Uncomment and customize the following line if you want vlmcsd to look for a KMS data file * at a custom default location. */ - //#define DATA_FILE "/etc/vlmcsd.kmd" +// #define DATA_FILE "/etc/vlmcsd.kmd" #endif // DATA_FILE - /* * ---------------------------------------------------------------------------------------- * Troubleshooting options. Please note that disabling features may also help troubleshooting. @@ -81,32 +70,29 @@ * ---------------------------------------------------------------------------------------- */ - #ifndef CHILD_HANDLER - /* - * Uncomment the following #define if you are compiling for a platform that does - * not correctly handle the SA_NOCLDWAIT flag when ignoring SIGCHLD, i.e. forked - * processes remain as "zombies" after dying. This option will add a SIGCHLD handler that - * "waits" for a child that has terminated. This is only required for a few - * unixoid OSses. - */ +/* + * Uncomment the following #define if you are compiling for a platform that does + * not correctly handle the SA_NOCLDWAIT flag when ignoring SIGCHLD, i.e. forked + * processes remain as "zombies" after dying. This option will add a SIGCHLD handler that + * "waits" for a child that has terminated. This is only required for a few + * unixoid OSses. + */ - //#define CHILD_HANDLER +// #define CHILD_HANDLER #endif // CHILD_HANDLER - #ifndef NO_TIMEOUT /* * Uncomment the following #define if you are compiling for a platform that does * not support custom socket send or receive timeouts. */ - //#define NO_TIMEOUT +// #define NO_TIMEOUT #endif // NO_TIMEOUT - #ifndef NO_DNS /* * Uncomment the following #define if you have trouble with accessing routines @@ -114,11 +100,10 @@ * detecting KMS servers via DNS. */ - //#define NO_DNS +// #define NO_DNS #endif // NO_DNS - #ifndef TERMINAL_FIXED_WIDTH /* * Uncomment the following #define and optionally change its value if you are compiling for @@ -126,13 +111,10 @@ * This affects the output of "vlmcsd -x" only. It should be rarely necessary to use this. */ - //#define TERMINAL_FIXED_WIDTH 80 +// #define TERMINAL_FIXED_WIDTH 80 #endif // TERMINAL_FIXED_WIDTH - - - #ifndef _PEDANTIC /* * Uncomment the following #define if you want to do vlmcs and vlmcsd more checks on the data @@ -140,13 +122,10 @@ * you are testing any KMS server or client emulator that may send malformed KMS packets. */ - //#define _PEDANTIC +// #define _PEDANTIC #endif // _PEDANTIC - - - #ifndef NO_PROCFS /* * Cygwin, Linux, Android, NetBSD, DragonflyBSD: @@ -163,13 +142,10 @@ * */ - //#define NO_PROCFS +// #define NO_PROCFS #endif // NO_PROCFS - - - #ifndef USE_AUXV /* * Linux only: @@ -186,13 +162,10 @@ * It is safe to try this by yourself. vlmcsd won't compile if your system doesn't support it. */ - //#define USE_AUXV +#define USE_AUXV #endif // USE_AUXV - - - #ifndef _OPENSSL_NO_HMAC /* * If you configured vlmcsd to use OpenSSL (which you shouldn't) you may use this option @@ -201,47 +174,40 @@ * This may be necessary for some embedded devices that have OpenSSL without HMAC support. */ - //#define _OPENSSL_NO_HMAC +// #define _OPENSSL_NO_HMAC #endif // _OPENSSL_NO_HMAC - - - /* * ---------------------------------------------------------------------------------------- * Modes of operation * ---------------------------------------------------------------------------------------- */ - #ifndef USE_THREADS - /* - * Do not use fork() but threads to serve your clients. - * - * Unix-like operarting systems: - * You may use this or not. Entirely your choice. Threads do not require explicitly allocating - * a shared memory segment which might be a problem on some systems. Using fork() is more robust - * although the threaded version of vlmcsd is rock solid too. - * - * Some older unixoid OSses may not have pthreads. Do NOT use USE_THREADS and define NO_SIGHUP - * and NO_LIMIT instead to disable use of the pthreads, shared memory and semaphores. - * - * Cygwin: - * It is recommended to use threads since fork() is extremely slow (no copy on write) and somewhat - * unstable. - * - * Windows: - * This option has no effect since fork() is not supported. - */ +/* + * Do not use fork() but threads to serve your clients. + * + * Unix-like operarting systems: + * You may use this or not. Entirely your choice. Threads do not require explicitly allocating + * a shared memory segment which might be a problem on some systems. Using fork() is more robust + * although the threaded version of vlmcsd is rock solid too. + * + * Some older unixoid OSses may not have pthreads. Do NOT use USE_THREADS and define NO_SIGHUP + * and NO_LIMIT instead to disable use of the pthreads, shared memory and semaphores. + * + * Cygwin: + * It is recommended to use threads since fork() is extremely slow (no copy on write) and somewhat + * unstable. + * + * Windows: + * This option has no effect since fork() is not supported. + */ - //#define USE_THREADS +// #define USE_THREADS #endif // USE_THREADS - - - #ifndef _CRYPTO_POLARSSL /* * Not available on native Windows. Can be used with Cygwin. @@ -256,13 +222,10 @@ * Do not define both _CRYPTO_OPENSSL and _CRYPTO_POLARSSL */ - //#define _CRYPTO_POLARSSL +// #define _CRYPTO_POLARSSL #endif // _CRYPTO_POLARSSL - - - #ifndef _CRYPTO_OPENSSL /* * Not available on native Windows. Can be used with Cygwin. @@ -277,13 +240,10 @@ * Do not define both _CRYPTO_OPENSSL and _CRYPTO_POLARSSL */ - //#define _CRYPTO_OPENSSL +// #define _CRYPTO_OPENSSL #endif // _CRYPTO_OPENSSL - - - #ifndef _USE_AES_FROM_OPENSSL /* * DANGEROUS: Tweak OpenSSL to perform KMSv4 CMAC and KMSv6 modified AES. This option creates the expanded @@ -297,14 +257,10 @@ * Don't use this except for your own research on the internals of OpenSSL. */ - //#define _USE_AES_FROM_OPENSSL +// #define _USE_AES_FROM_OPENSSL #endif // _USE_AES_FROM_OPENSSL - - - - #ifndef _OPENSSL_SOFTWARE /* * Use this only if you have defined _CRYPTO_OPENSSL and _USE_AES_FROM_OPENSSL. It has no effect otherwise. @@ -313,24 +269,19 @@ * compiled without support for hardware accelerated AES. It's worth a try if _USE_AES_FROM_OPENSSL doesn't work. */ - //#define _OPENSSL_SOFTWARE +// #define _OPENSSL_SOFTWARE #endif // _OPENSSL_SOFTWARE - - - #ifndef FULL_INTERNAL_DATA /* * Includes the full database in vlmcsd. */ - //#define FULL_INTERNAL_DATA +#define FULL_INTERNAL_DATA + #endif // FULL_INTERNAL_DATA - - - /* * ---------------------------------------------------------------------------------------- * Removal of features. Allows you to remove features of vlmcsd you do not need or want. @@ -338,58 +289,45 @@ * ---------------------------------------------------------------------------------------- */ - #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. - */ +/* + * 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 +// #define NO_FREEBIND #endif // NO_FREEBIND - - - #ifndef NO_TAP - /* - * Do not compile support for using a VPN adapter under Windows. Disables -O command line option. - */ +/* + * Do not compile support for using a VPN adapter under Windows. Disables -O command line option. + */ -//#define NO_TAP +#define NO_TAP #endif // NO_TAP - - - #ifndef NO_VERSION_INFORMATION /* * Removes the -V option from vlmcsd and vlmcs that displays the version information */ - //#define NO_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 * option in the vlmcs client. Disables ini file directive LogVerbose. */ - //#define NO_VERBOSE_LOG +// #define NO_VERBOSE_LOG #endif // NO_VERBOSE_LOG - - - #ifndef NO_LOG /* * Disables logging completely. You can neither log to a file nor to the console. -D and -f will @@ -397,13 +335,10 @@ * Implies NO_VERBOSE_LOG. */ - //#define NO_LOG +// #define NO_LOG #endif // NO_LOG - - - #ifndef NO_STRICT_MODES /* * Disables emulator detection protection. Removes -M0, -M1, -E0, -E1, -K0, -K1, -K2 and -K3 from @@ -411,106 +346,82 @@ * as if it was started with -K0, -M0. */ - //#define NO_STRICT_MODES +// #define NO_STRICT_MODES #endif // NO_STRICT_MODES - - - - #ifndef NO_CLIENT_LIST /* * Disables the ability to maintain a list of Client Machine IDs (CMIDs). Removes -M0, -M1, -E0 and -E1 * from vlmcsd command line options. */ - //#define NO_CLIENT_LIST +// #define NO_CLIENT_LIST #endif // !NO_CLIENT_LIST - - #ifndef NO_RANDOM_EPID - /* - * Disables the ability to generate random ePIDs. Useful if you managed to grab ePID/HWID from a - * real KMS server and want to use these. Removes -r from the vlmcsd command line and the ini - * file directive RandomizationLevel (The randomization level will be harcoded to 0). - */ +/* + * Disables the ability to generate random ePIDs. Useful if you managed to grab ePID/HWID from a + * real KMS server and want to use these. Removes -r from the vlmcsd command line and the ini + * file directive RandomizationLevel (The randomization level will be harcoded to 0). + */ - //#define NO_RANDOM_EPID +// #define NO_RANDOM_EPID #endif // NO_RANDOM_EPID - - - #ifndef NO_INI_FILE /* * Disables the ability to use a configuration file (aka ini file). Removes -i from the command line. */ - //#define NO_INI_FILE +// #define NO_INI_FILE #endif // NO_INI_FILE - - - #ifndef NO_PID_FILE - /* +/* * Disables the abilty to write a pid file containing the process id of vlmcsd. If your init system * does not need this feature, you can safely disables this but it won't save much space. Disables * the use of -p from the command line and PidFile from the ini file. */ - //#define NO_PID_FILE +// #define NO_PID_FILE #endif // NO_PID_FILE - - - #ifndef NO_EXTERNAL_DATA - /* +/* * Disables the abilty to load external KMS data from a file. Disables command line options -j * and ini file parameter KmsData. Implies UNSAFE_DATA_LOAD. */ - //#define NO_EXTERNAL_DATA +// #define NO_EXTERNAL_DATA #endif // NO_EXTERNAL_DATA - - - #ifndef NO_INTERNAL_DATA - /* +/* * Compiles vlmcsd and vlmcs without an internal database. If no database is found at * either the default location or the file specified with command line option -j., * the program exits with an error message. */ - //#define NO_INTERNAL_DATA +// #define NO_INTERNAL_DATA #endif // NO_INTERNAL_DATA - - - #ifndef UNSAFE_DATA_LOAD - /* +/* * Does not check an external KMS data file for integrity. * This save some bytes but it dangerous if you load a KMS data file from an unknown source. */ - //#define UNSAFE_DATA_LOAD +// #define UNSAFE_DATA_LOAD #endif // UNSAFE_DATA_LOAD - - - #ifndef NO_USER_SWITCH /* * Disables switching to another uid and/or gid after starting the program and setting up the sockets. @@ -522,26 +433,20 @@ * Cygwin. */ - //#define NO_USER_SWITCH +// #define NO_USER_SWITCH #endif // NO_USER_SWITCH - - - #ifndef NO_HELP /* * Disables display of help in both vlmcsd and vlmcs. Saves some bytes but only makes sense if you have * access to the man files vlmcsd.8 and vlmcs.1 */ - //#define NO_HELP +// #define NO_HELP #endif // NO_HELP - - - #ifndef NO_CUSTOM_INTERVALS /* * Disables the ability to specify custom interval for renewing and retrying activation. Newer versions of the Microsoft's @@ -549,26 +454,20 @@ * -A and -R from the command line as well as ActivationInterval and RenewalInterval in the ini file. */ - //#define NO_CUSTOM_INTERVALS +// #define NO_CUSTOM_INTERVALS #endif // NO_CUSTOM_INTERVALS - - - #ifndef NO_PRIVATE_IP_DETECT /* * Disables the ability to protect vlmcsd against KMS requests from public IP addresses. * Removes -o from the command line. */ - //#define NO_PRIVATE_IP_DETECT +// #define NO_PRIVATE_IP_DETECT #endif // NO_PRIVATE_IP_DETECT - - - #ifndef NO_SOCKETS /* * Disables standalone startup of vlmcsd. If you use this config directive, you must start vlmcsd from an internet @@ -576,26 +475,20 @@ * command line. Socket setup is the job of your superserver. */ - //#define NO_SOCKETS +// #define NO_SOCKETS #endif // NO_SOCKETS - - - #ifndef NO_CL_PIDS /* * Disables the ability to specify ePIDs and HWID at the command line. You still may use them in the ini file. * Removes -0, -3, -w and -H from the vlmcsd command line. */ - //#define NO_CL_PIDS +// #define NO_CL_PIDS #endif // NO_CL_PIDS - - - #ifndef NO_LIMIT /* * Disables the ability to limit the number of worker threads or processes that vlmcsd uses. While you should set a @@ -608,13 +501,10 @@ * and NO_LIMIT instead to disable use of the pthreads, shared memory and semaphores. */ - //#define NO_LIMIT +// #define NO_LIMIT #endif // NO_LIMIT - - - #ifndef NO_SIGHUP /* * Disables the ability to signal hangup (SIGHUP) to vlmcsd to restart it (rereading the ini file). The SIGHUP @@ -628,13 +518,10 @@ * This option has no effect on native Windows since Posix signaling is not supported. It can be used with Cygwin. */ - //#define NO_SIGHUP +// #define NO_SIGHUP #endif // NO_SIGHUP - - - #ifndef SIMPLE_RPC /* * Uses a simple version of the RPC protocol which does not support NDR64 and BTFN. @@ -642,36 +529,29 @@ * smaller binaries but makes emulator detection easier. */ - //#define SIMPLE_RPC +// #define SIMPLE_RPC #endif // !SIMPLE_RPC - - - #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 +// #define SIMPLE_SOCKETS #endif // SIMPLE_SOCKETS - - - #ifndef PRIVACY_ON /* - * This flag enables the ability to hide the incoming request information and outcoming request + * This flag enables the ability to hide the incoming request information and outcoming request * Reasons: to hide the client ID from the inspector, only display the least valuable info */ - //#define PRIVACY_ON +// #define PRIVACY_ON -#endif // PRIVACY_ON +#endif /* Don't change anything BELOW this line */ - #endif /* CONFIG_H_ */ diff --git a/sources/src/network.c b/sources/src/network.c index 33cc7da..d1eaf7e 100644 --- a/sources/src/network.c +++ b/sources/src/network.c @@ -51,6 +51,10 @@ typedef ssize_t(*sendrecv_t)(int, void*, size_t, int); typedef int (WINAPI *sendrecv_t)(SOCKET, void*, int, int); #endif +#ifndef NO_LOG +#include "output.h" +#include +#endif // NO_LOG // Send or receive a fixed number of bytes regardless if received in one or more chunks int_fast8_t sendrecv(SOCKET sock, BYTE *data, int len, int_fast8_t do_send) @@ -1045,6 +1049,10 @@ int runServer() serveClient(STDIN_FILENO, RpcAssocGroup); return 0; } +#ifndef NO_LOG + static uint32_t CountKMSReq = 0; + time_t startClock = time(NULL); +#endif // NO_LOG for (;;) { @@ -1085,6 +1093,24 @@ int runServer() # else // NO_LOG || !_PEDANTIC serveClientAsync(s_client, RpcAssocGroup); # endif // NO_LOG || !_PEDANTIC + +#ifndef NO_LOG + if (isCounting == TRUE) { + CountKMSReq++; + + time_t checkPointClock = time(NULL); + double uptimeReq = (double)(checkPointClock - startClock); + double reqRate = CountKMSReq / uptimeReq; + + logger( + "Total %d %s in %.2lf seconds (%.4lf reqs/sec)\n", + CountKMSReq, + (CountKMSReq == 1) ? "request" : "requests", + uptimeReq, + reqRate + ); + } +#endif // NO_LOG } # endif // NO_SOCKETS } diff --git a/sources/src/output.h b/sources/src/output.h index 96b0bc1..80783e4 100644 --- a/sources/src/output.h +++ b/sources/src/output.h @@ -26,7 +26,7 @@ void printClientFlags(); #ifndef NO_LOG int logger(const char *const fmt, ...); -#endif //NO_LOG +#endif // NO_LOG void uuid2StringLE(const GUID *const guid, char *const string); diff --git a/sources/src/shared_globals.c b/sources/src/shared_globals.c index 8891cd3..e16a1e8 100644 --- a/sources/src/shared_globals.c +++ b/sources/src/shared_globals.c @@ -78,7 +78,9 @@ int_fast8_t logverbose = 0; int_fast8_t isPrivacyOn = FALSE; #else int_fast8_t isPrivacyOn = TRUE; -#endif +#endif // PRIVACY_ON + +int_fast8_t isCounting = FALSE; #ifndef NO_SOCKETS int_fast8_t ExitLevel = 0; diff --git a/sources/src/shared_globals.h b/sources/src/shared_globals.h index 4112225..834e9ab 100644 --- a/sources/src/shared_globals.h +++ b/sources/src/shared_globals.h @@ -26,6 +26,7 @@ #endif // !defined(NO_LIMIT) && !__minix__ #else //#ifndef USE_MSRPC +#define WIN32_LEAN_AND_MEAN #include #include //#endif // USE_MSRPC @@ -220,4 +221,6 @@ extern int_fast8_t freebind; extern int_fast8_t isPrivacyOn; #endif +extern int_fast8_t isCounting; + #endif // INCLUDED_SHARED_GLOBALS_H diff --git a/sources/src/tap-windows.h b/sources/src/tap-windows.h index 9971534..1c88966 100644 --- a/sources/src/tap-windows.h +++ b/sources/src/tap-windows.h @@ -31,6 +31,10 @@ * ============= */ +#ifdef _WIN32 +#include +#endif // _WIN32 + #define TAP_WIN_CONTROL_CODE(request,method) \ CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) diff --git a/sources/src/types.h b/sources/src/types.h index a84997e..e9452d6 100644 --- a/sources/src/types.h +++ b/sources/src/types.h @@ -21,6 +21,7 @@ #if defined(_WIN32) //#ifndef USE_MSRPC +#define WIN32_LEAN_AND_MEAN #include //#include //#endif // USE_MSRPC diff --git a/sources/src/vlmcs.c b/sources/src/vlmcs.c index a164488..c281c7d 100644 --- a/sources/src/vlmcs.c +++ b/sources/src/vlmcs.c @@ -696,8 +696,9 @@ static void displayResponse(const RESPONSE_RESULT result, const REQUEST* request "\n\nResponse from KMS server\n========================\n\n" "Size of KMS Response : %u (0x%x)\n", result.effectiveResponseSize, result.effectiveResponseSize ); - +#ifndef NO_LOG logResponseVerbose(ePID, hwid, response, &printf); +#endif // NO_LOG printf("\n"); } # endif // NO_VERBOSE_LOG @@ -1387,7 +1388,9 @@ static void CreateRequestBase(REQUEST *Request) if (verbose) { printf("\nRequest Parameters\n==================\n\n"); +#ifndef NO_LOG logRequestVerbose(Request, &printf); +#endif // NO_LOG printf("\n"); } # endif // NO_VERBOSE_LOG @@ -1398,12 +1401,12 @@ int __stdcall WinStartUp(void) { WCHAR **szArgList; int argc; + szArgList = CommandLineToArgvW(GetCommandLineW(), &argc); - int i; char **argv = (char**)vlmcsd_malloc(sizeof(char*)*argc); - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { int size = WideCharToMultiByte(CP_UTF8, 0, szArgList[i], -1, argv[i], 0, NULL, NULL); argv[i] = (char*)vlmcsd_malloc(size); diff --git a/sources/src/vlmcs.h b/sources/src/vlmcs.h index 12b8ea4..31ce5a6 100644 --- a/sources/src/vlmcs.h +++ b/sources/src/vlmcs.h @@ -7,6 +7,7 @@ #include CONFIG #if !defined(USE_MSRPC) && defined(_WIN32) +#define WIN32_LEAN_AND_MEAN #include #endif // defined(USE_MSRPC) && defined(_WIN32) #include "types.h" @@ -17,6 +18,11 @@ #endif // USE_MSRPC #include "kms.h" +#if _MSC_VER +#include +#include +#endif + #if MULTI_CALL_BINARY < 1 #define client_main main #else diff --git a/sources/src/vlmcsd.c b/sources/src/vlmcsd.c index fdc337d..6f55c6b 100644 --- a/sources/src/vlmcsd.c +++ b/sources/src/vlmcsd.c @@ -88,7 +88,7 @@ Volume License Management Service DAEMON (vlmcsd) #include "wintap.h" #endif -static const char *const optstring = "a:N:B:m:t:A:R:u:g:L:p:i:H:P:l:r:U:W:C:c:F:O:o:x:T:K:E:M:j:SseDdVvqkZX"; +static const char *const optstring = "a:N:B:m:t:A:R:u:g:L:p:i:H:P:l:r:U:W:C:c:F:O:o:x:T:K:E:M:j:SseDdVvqkZXw"; #if !defined(NO_SOCKETS) && !defined(USE_MSRPC) && !defined(SIMPLE_SOCKETS) static uint_fast8_t maxsockets = 0; @@ -178,6 +178,7 @@ static IniFileParameter_t IniFileParameterList[] = {"LogDateAndTime", INI_PARAM_LOG_DATE_AND_TIME}, {"LogFile", INI_PARAM_LOG_FILE}, {"PrivacyMode", INI_PARAM_PRIVACY_MODE}, + {"CountingReq", INT_PARAM_COUNTING_REQ}, #ifndef NO_VERBOSE_LOG {"LogVerbose", INI_PARAM_LOG_VERBOSE}, #endif // NO_VERBOSE_LOG @@ -296,7 +297,7 @@ static __noreturn void usage() ///////////////////////////////////////////////////////////////////// //// ePID randomization level is used #ifndef NO_RANDOM_EPID - " -r (0|1|2)\t\tSet randomization level of the ePIDs (default is \"0\")\n\t\t\t\t\"0\" stands for no randomization, which also means VLMCSD will use the default ePID that is built-in. It is useful for emulating/replicating real KMS servers\n\t\t\t\t\"1\" stands for randomization of each KMS request, but it also poses a risk of being detected non-genuine KMS Server, causing clients to fail to be activated\n\t\t\t\t\"2\" is as same as the \"1\" option, but only for debugging\n" + " -r (0|1|2)\t\tSet randomization level of the ePIDs (default is \"0\")\n\t\t\t\t\"0\" stands for no randomization, which also means VLMCSD will use the default ePID that is built-in\n\t\t\t\t\"1\" stands for randomization of each KMS request, but it also poses a risk of being detected non-genuine KMS Server\n\t\t\t\t\"2\" is as same as the \"1\" option, but only for debugging\n" " -C \t\tUse fixed Windows Language Code Identifier in random ePIDs\n\t\t\t\tSee https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c for correct LCIDs\n" " -H \t\tUse fixed Windows build number for activation\n\t\t\t\tUseful when the client requires a proper KMS Server\n\t\t\t\tSee all build numbers here: https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions\n" #endif // NO_RANDOM_EPID @@ -362,8 +363,8 @@ static __noreturn void usage() " -K (0|1|2|3)\t\tSet white-listing level which product VLMCSD accepts or refuses (default 0)\n\t\t\t\t\"0\" Activate all products with an unknown, retail or beta/preview KMS IDs\n\t\t\t\t\"1\" Activate products with a retail or beta/preview KMS ID but refuse to activate products with an unknown KMS ID\n\t\t\t\t\"2\" Activate products with an unknown KMS ID but refuse products with a retail or beta/preview KMS ID\n\t\t\t\t\"3\" Activate only products with a known volume license RTM KMS ID and refuse all others\n" " -c (0|1)\t\tDisable (0)/Enable (1) client time checking\n\t\t\t\tIf the client time is different than 4 hours compare to the KMS Host, the host will deny the activation (default 0)\n\t\t\t\tNote: It is recommended that the VLMCSD has a reliable time service (e.g. sync the time with time.windows.com)\n" #ifndef NO_CLIENT_LIST - " -M (0|1)\t\tDisable (0)/Enable (1) maintaining clients (default 0)\n\t\t\t\tNote: Enabling this service is not recommended, except you have to do so to prevent the activation failling\n\t\t\t\tIt is because the VLMCSD can only keep maximum of 16777215 clients. If that number exceed, VLMCSD will no longer accept any new connect, nor activation requests\n" - " -E (0|1)\t\tDisable (0)/Enable (1) starting VLMCSD with empty client list (Default 0)\n\t\t\t\tNote: It is recommended to keep the default, because Office will not activate unless your KMS Host has at least 5 active clients.\n\t\t\t\tSee more: https://learn.microsoft.com/en-us/office/troubleshoot/administration/0xc004f038-computer-not-activate\n" + " -M (0|1)\t\tDisable (default, 0)/Enable (1) maintaining clients\n\t\t\t\tNote: Enabling this service is not recommended, except you have to do so to prevent the activation failling\n\t\t\t\tIt is because the VLMCSD can only keep maximum of 16777215 clients. If that number exceed, VLMCSD will no longer accept any new connect, nor activation requests\n" + " -E (0|1)\t\tDisable (default, 0)/Enable (1) starting VLMCSD with empty client list\n\t\t\t\tNote: It is recommended to keep the default, because Office will not activate unless your KMS Host has at least 5 active clients.\n\t\t\t\tSee more: https://learn.microsoft.com/en-us/office/troubleshoot/administration/0xc004f038-computer-not-activate\n" #endif // !NO_CLIENT_LIST #endif // !NO_STRICT_MODES ///////////////////////////////////////////////////////////////////// @@ -374,42 +375,42 @@ static __noreturn void usage() #if !defined(NO_TIMEOUT) && !__minix__ " -t \t\tDisconnect client after an amount of time of inactivity (default 30)\n" #endif // !defined(NO_TIMEOUT) && !__minix__ - " -d\t\t\tDisconnect each client after processing one activation request.\n" - " -k\t\t\tDo not disconnect clients after processing an activation request (default if \"-d\" defined in external VLMCSD configuration file).\n" + " -d\t\t\tDisconnect each client after processing one activation request\n" + " -k\t\t\tDo not disconnect clients after processing an activation request (default if \"-d\" defined in external VLMCSD configuration file)\n" #ifndef SIMPLE_RPC - " -N (0|1)\t\tDisable (0)/Enable (default, 1) NDR64. Only useful when on Windows Vista/7 32-bit, where enabling NDR64 will make VLMCSD by running higher Windows build number.\n" - " -B (0|1)\t\tDisable (0)/Enable (1) bind time feature negotiation in RPC protocol.\n" + " -N (0|1)\t\tDisable (0)/Enable (default, 1) NDR64. Only useful when on Windows Vista/7 32-bit, where enabling NDR64 will make VLMCSD by running higher Windows build number\n" + " -B (0|1)\t\tDisable (0)/Enable (1) bind time feature negotiation in RPC protocol\n" #endif // !SIMPLE_RPC #endif // USE_MSRPC #ifndef NO_PID_FILE - " -p \t\tCreate pid file filename. This is used by standard init scripts (typically found in \"/etc/init.d\").\n" + " -p \t\tCreate pid file filename. This is used by standard init scripts (typically found in \"/etc/init.d\")\n" #endif // NO_PID_FILE #ifndef NO_INI_FILE - " -i \t\tUse external VLMCSD configuration file. Default name of that file is \"vlmcsd.ini\".\n" + " -i \t\tUse external VLMCSD configuration file. Default name of that file is \"vlmcsd.ini\"\n" #endif // NO_INI_FILE #ifndef NO_EXTERNAL_DATA - " -j \t\tUse external VLMCSD ePID database. Default name of that file is \"vlmcsd.kmd\".\n" + " -j \t\tUse external VLMCSD ePID database. Default name of that file is \"vlmcsd.kmd\"\n" #endif // !NO_EXTERNAL_DATA #ifndef NO_CUSTOM_INTERVALS - " -R \t\tRenew activation every (default 1w).\n" - " -A \t\tRetry activation every , if the previous activation/reactivation is failed (default 2h).\n" + " -R \t\tRenew activation every (default 1w)\n" + " -A \t\tRetry activation every , if the previous activation/reactivation is failed (default 2h)\n" #endif // NO_CUSTOM_INTERVALS #ifndef NO_LOG - " -l \t\tWrites VLMCSD log into a file. Note: Make sure you have read+write access to that file.\n" - " -T0, -T1\t\tDisable (0)/Enable logging client connection with time and date (default 1).\n" + " -l \t\tWrites VLMCSD log into a file. Note: Make sure you have rw access to that file\n" + " -T0, -T1\t\tDisable (0)/Enable (default, 1) logging client connection with time and date\n" #ifndef PRIVACY_ON - " -X\t\t\tAllow running in Privacy Mode (experiment).\n" + " -X\t\t\tAllow running in Privacy Mode (hide detail of incoming and response requests)\n" #endif // PRIVACY_ON + " -w\t\t\tDisplay total KMS requests\n" #ifndef NO_VERBOSE_LOG - " -v\t\t\tAllow logging verbose.\n" - " -q\t\t\tDon't allow log verbose (default).\n" + " -v\t\t\tAllow logging verbose\n" + " -q\t\t\tDon't allow log verbose (default)\n" #endif // NO_VERBOSE_LOG #endif // NO_LOG #ifndef NO_VERSION_INFORMATION " -V\t\t\tDisplay version information and exit\n" #endif // NO_VERSION_INFORMATION - , - Version, global_argv[0]); + ,Version, global_argv[0]); exit(VLMCSD_EINVAL); } #endif // HELP @@ -681,6 +682,10 @@ static BOOL setIniFileParameter(uint_fast8_t id, const char *const iniarg) break; #endif // PRIVACY_ON + case INT_PARAM_COUNTING_REQ: + isCounting = getIniFileArgumentBool(&isCounting, iniarg); + break; + case INI_PARAM_LOG_FILE: fn_log = vlmcsd_strdup(iniarg); break; @@ -1293,6 +1298,11 @@ static void parseGeneralArguments() break; #endif // PRIVACY_ON + case 'w': + isCounting = TRUE; + ignoreIniFileParameter(INT_PARAM_COUNTING_REQ); + break; + #ifndef NO_SOCKETS #if !defined(USE_MSRPC) && !defined(SIMPLE_SOCKETS) case 'L': @@ -2027,6 +2037,10 @@ int newmain() logger("Privacy mode is turned on\n"); #endif //PRIVACY_ON + if (isCounting == TRUE) { + logger("Counting request is turned on\n"); + } + #endif // !defined(NO_LOG) && !defined(NO_SOCKETS) && !defined(USE_MSRPC) #if defined(_NTSERVICE) && !defined(USE_MSRPC) @@ -2053,17 +2067,17 @@ int newmain() #if _MSC_VER && !defined(_DEBUG) && !MULTI_CALL_BINARY int __stdcall WinStartUp(void) { - WCHAR **szArgList; + WCHAR** szArgList; int argc; + szArgList = CommandLineToArgvW(GetCommandLineW(), &argc); - int i; - char **argv = (char **)vlmcsd_malloc(sizeof(char *) * argc); + char** argv = (char**)vlmcsd_malloc(sizeof(char*) * argc); - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { int size = WideCharToMultiByte(CP_UTF8, 0, szArgList[i], -1, argv[i], 0, NULL, NULL); - argv[i] = (char *)vlmcsd_malloc(size); + argv[i] = (char*)vlmcsd_malloc(size); WideCharToMultiByte(CP_UTF8, 0, szArgList[i], -1, argv[i], size, NULL, NULL); } diff --git a/sources/src/vlmcsd.h b/sources/src/vlmcsd.h index 553f7cf..9f516f5 100644 --- a/sources/src/vlmcsd.h +++ b/sources/src/vlmcsd.h @@ -13,6 +13,11 @@ extern char *fn_log; #include "types.h" +#if _MSC_VER +#include +#include +#endif + //int main(int argc, CARGV); extern void cleanup(); @@ -57,6 +62,7 @@ int server_main(int argc, CARGV argv); #define INI_PARAM_VPN 29 #define INI_PARAM_EXIT_LEVEL 30 #define INI_PARAM_PRIVACY_MODE 31 +#define INT_PARAM_COUNTING_REQ 32 #define INI_FILE_PASS_1 1 #define INI_FILE_PASS_2 2 diff --git a/sources/src/vlmcsdmulti.c b/sources/src/vlmcsdmulti.c index 5181b7a..99e8604 100644 --- a/sources/src/vlmcsdmulti.c +++ b/sources/src/vlmcsdmulti.c @@ -106,14 +106,14 @@ int main(int argc, CARGV argv) #if _MSC_VER && !defined(_DEBUG) int __stdcall WinStartUp(void) { - WCHAR **szArgList; + WCHAR** szArgList; int argc; + szArgList = CommandLineToArgvW(GetCommandLineW(), &argc); - int i; - char **argv = (char**)vlmcsd_malloc(sizeof(char*)*argc); + char** argv = (char**)vlmcsd_malloc(sizeof(char*) * argc); - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { int size = WideCharToMultiByte(CP_UTF8, 0, szArgList[i], -1, argv[i], 0, NULL, NULL); argv[i] = (char*)vlmcsd_malloc(size);