From c1f38fc76aa12f6960f42a4df7bf1bea09bb75c4 Mon Sep 17 00:00:00 2001 From: lightbulblighter <59720715+lightbulblighter@users.noreply.github.com> Date: Tue, 7 Jun 2022 01:47:49 -0700 Subject: [PATCH] polishing up everything --- PolygonClientUtilities/Application.cpp | 6 +- PolygonClientUtilities/Application.h | 6 +- PolygonClientUtilities/CRoblox.cpp | 6 +- PolygonClientUtilities/CRoblox.h | 44 +++++++++- PolygonClientUtilities/Classes.h | 80 +------------------ PolygonClientUtilities/Config.h | 5 +- PolygonClientUtilities/Context.cpp | 6 +- PolygonClientUtilities/Context.h | 8 +- PolygonClientUtilities/Crypt.cpp | 8 +- PolygonClientUtilities/Http.h | 10 +++ PolygonClientUtilities/Patches.cpp | 2 + .../PolygonClientUtilities.vcxproj | 6 +- .../PolygonClientUtilities.vcxproj.filters | 10 +-- PolygonClientUtilities/ScriptContext.cpp | 9 --- PolygonClientUtilities/ScriptContext.h | 7 -- ...catorSecurity.cpp => ServerReplicator.cpp} | 8 +- ...eplicatorSecurity.h => ServerReplicator.h} | 24 +++++- PolygonClientUtilities/StandardOut.cpp | 28 +++---- PolygonClientUtilities/Util.cpp | 31 ++++++- PolygonClientUtilities/Util.h | 6 +- PolygonClientUtilities/dllmain.cpp | 37 ++++----- 21 files changed, 187 insertions(+), 160 deletions(-) delete mode 100644 PolygonClientUtilities/ScriptContext.cpp delete mode 100644 PolygonClientUtilities/ScriptContext.h rename PolygonClientUtilities/{ReplicatorSecurity.cpp => ServerReplicator.cpp} (95%) rename PolygonClientUtilities/{ReplicatorSecurity.h => ServerReplicator.h} (57%) diff --git a/PolygonClientUtilities/Application.cpp b/PolygonClientUtilities/Application.cpp index c573034..a92e1ab 100644 --- a/PolygonClientUtilities/Application.cpp +++ b/PolygonClientUtilities/Application.cpp @@ -3,6 +3,8 @@ #include "Patches.h" #include "Util.h" +#if defined(ARBITERBUILD) && defined(PLAYER2012) + Application__ParseArguments_t Application__ParseArguments = (Application__ParseArguments_t)ADDRESS_APPLICATION__PARSEARGUMENTS; BOOL __fastcall Application__ParseArguments_hook(int _this, void*, int a2, const char* argv) @@ -25,4 +27,6 @@ BOOL __fastcall Application__ParseArguments_hook(int _this, void*, int a2, const } return Application__ParseArguments(_this, a2, argv); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/Application.h b/PolygonClientUtilities/Application.h index 14d963d..5b4eee5 100644 --- a/PolygonClientUtilities/Application.h +++ b/PolygonClientUtilities/Application.h @@ -1,7 +1,11 @@ #pragma once +#if defined(ARBITERBUILD) && defined(PLAYER2012) + #include "Classes.h" typedef BOOL(__thiscall* Application__ParseArguments_t)(int _this, int a2, const char* argv); BOOL __fastcall Application__ParseArguments_hook(int _this, void*, int a2, const char* argv); -extern Application__ParseArguments_t Application__ParseArguments; \ No newline at end of file +extern Application__ParseArguments_t Application__ParseArguments; + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/CRoblox.cpp b/PolygonClientUtilities/CRoblox.cpp index c32ad8b..a7fd2e4 100644 --- a/PolygonClientUtilities/CRoblox.cpp +++ b/PolygonClientUtilities/CRoblox.cpp @@ -1,6 +1,8 @@ #include "pch.h" #include "CRoblox.h" +#if defined(MFC2010) || defined(MFC2011) + static bool hasAuthUrlArg = false; static bool hasAuthTicketArg = false; static bool hasJoinArg = false; @@ -115,4 +117,6 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* #endif CRobloxCommandLineInfo__ParseParam(_this, pszParam, bFlag, bLast); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/CRoblox.h b/PolygonClientUtilities/CRoblox.h index 5435934..87d5b15 100644 --- a/PolygonClientUtilities/CRoblox.h +++ b/PolygonClientUtilities/CRoblox.h @@ -2,6 +2,46 @@ #include "Classes.h" +#if defined(MFC2010) || defined(MFC2011) + +// 2010 struct definitions: +// 0x47E010: CWorkspace->DoExecScript() +// 0x47EC10: CWorkspace->ExecUrlScript() + +class CWorkspace; + +const auto CWorkspace__ExecUrlScript = (HRESULT(__stdcall*)(CWorkspace * workspace, LPCWSTR, VARIANTARG, VARIANTARG, VARIANTARG, VARIANTARG, LPVOID))ADDRESS_CWORKSPACE__EXECURLSCRIPT; + +struct CRobloxDoc +{ + void* padding1[CLASSPADDING_CROBLOXDOC__WORKSPACE]; + CWorkspace* workspace; +}; + +struct CApp; + +// const auto CApp__CreateGame = (CWorkspace * (__thiscall*)(CApp * _this, int, LPCWSTR))ADDRESS_CAPP__CREATEGAME; +const auto CApp__RobloxAuthenticate = (void* (__thiscall*)(CApp * _this, LPVOID, LPCWSTR, LPCWSTR))ADDRESS_CAPP__ROBLOXAUTHENTICATE; + +// 2010 struct definitions: +// 0x405D20: CRobloxApp->CreateDocument() +// 0x44F6F0: CRobloxApp->ExitInstance() +// 0x452900: CRobloxApp->InitInstance() + +struct CRobloxApp; + +const auto CRobloxApp__CreateDocument = (CRobloxDoc * (__thiscall*)(CRobloxApp * _this))ADDRESS_CROBLOXAPP__CREATEDOCUMENT; + +struct CCommandLineInfo +{ + void* padding1[3]; + BOOL m_bRunAutomated; +}; + +class CRobloxCommandLineInfo : public CCommandLineInfo {}; + +const auto CCommandLineInfo__ParseLast = (void(__thiscall*)(CCommandLineInfo * _this, BOOL bLast))ADDRESS_CCOMMANDLINEINFO__PARSELAST; + typedef BOOL(__thiscall* CRobloxApp__InitInstance_t)(CRobloxApp* _this); typedef void(__thiscall* CRobloxCommandLineInfo__ParseParam_t)(CRobloxCommandLineInfo* _this, const char* pszParam, BOOL bFlag, BOOL bLast); @@ -9,4 +49,6 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this); void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* _this, void*, const char* pszParam, BOOL bFlag, BOOL bLast); extern CRobloxApp__InitInstance_t CRobloxApp__InitInstance; -extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam; \ No newline at end of file +extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam; + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/Classes.h b/PolygonClientUtilities/Classes.h index 5fdda41..d6aeff1 100644 --- a/PolygonClientUtilities/Classes.h +++ b/PolygonClientUtilities/Classes.h @@ -3,14 +3,7 @@ #include "Config.h" #include -// TODO: Split everything here into individual files - -struct Tuple -{ - void* padding1[4]; - bool padding2; - bool padding3; -}; +// TODO: These need a place struct DataModel { @@ -30,75 +23,6 @@ const auto Game__initializeClass = (Game * (__thiscall*)(Game* _this, int a2))0x const auto Game__construct = (int(__thiscall*)(Game* _this))0x47DBF0; const auto ServiceProvider__createScriptContext = (void * (__thiscall*)(void* _this))0x4282E0; -// const auto ScriptContext__execute = (void * (__thiscall*)(void* _this, void* a1, int identity, const char* script, const char* name, int arguments))0x617CF0; const auto ScriptContext__execute = (void (__thiscall*)(void* _this, int identity, const char* script, const char* name))0x617C80; -const auto Context__isInRole = (bool (__cdecl*)(int identity, int permission))ADDRESS_CONTEXT__ISINROLE; - -struct Http -{ -#if PADDING_STRUCT != 0 - void* padding1[1]; -#endif - std::string alternateUrl; - void* padding2[3 + PADDING_STRUCT]; - std::string url; -}; - -// const auto DataModel__createDataModel = (std::shared_ptr(__thiscall*)(bool startHeartbeat))ADDRESS_DATAMODEL__CREATEDATAMODEL; - -struct Packet -{ - void* padding1[7]; - unsigned int length; - void* padding2[1]; - unsigned char* data; -}; - -struct ConcurrentRakPeer {}; -struct RakPeerInterface {}; - -struct ServerReplicator -{ - void* padding1[1869]; // offset of 0 -> 7476 - bool padding2; // offset of 7476 -> 7477 - bool isAuthenticated; // offset of 7477 -> 7478 -}; - -// 2010 struct definitions: -// 0x47E010: CWorkspace->DoExecScript() -// 0x47EC10: CWorkspace->ExecUrlScript() - -class CWorkspace; - -const auto CWorkspace__ExecUrlScript = (HRESULT(__stdcall*)(CWorkspace * workspace, LPCWSTR, VARIANTARG, VARIANTARG, VARIANTARG, VARIANTARG, LPVOID))ADDRESS_CWORKSPACE__EXECURLSCRIPT; - -struct CRobloxDoc -{ - void* padding1[CLASSPADDING_CROBLOXDOC__WORKSPACE]; - CWorkspace* workspace; -}; - -struct CApp; - -// const auto CApp__CreateGame = (CWorkspace * (__thiscall*)(CApp * _this, int, LPCWSTR))ADDRESS_CAPP__CREATEGAME; -const auto CApp__RobloxAuthenticate = (void * (__thiscall*)(CApp * _this, LPVOID, LPCWSTR, LPCWSTR))ADDRESS_CAPP__ROBLOXAUTHENTICATE; - -// 2010 struct definitions: -// 0x405D20: CRobloxApp->CreateDocument() -// 0x44F6F0: CRobloxApp->ExitInstance() -// 0x452900: CRobloxApp->InitInstance() - -struct CRobloxApp; - -const auto CRobloxApp__CreateDocument = (CRobloxDoc * (__thiscall*)(CRobloxApp * _this))ADDRESS_CROBLOXAPP__CREATEDOCUMENT; - -struct CCommandLineInfo -{ - void* padding1[3]; - BOOL m_bRunAutomated; -}; - -class CRobloxCommandLineInfo : public CCommandLineInfo {}; - -const auto CCommandLineInfo__ParseLast = (void(__thiscall*)(CCommandLineInfo * _this, BOOL bLast))ADDRESS_CCOMMANDLINEINFO__PARSELAST; \ No newline at end of file +// const auto DataModel__createDataModel = (std::shared_ptr(__thiscall*)(bool startHeartbeat))ADDRESS_DATAMODEL__CREATEDATAMODEL; \ No newline at end of file diff --git a/PolygonClientUtilities/Config.h b/PolygonClientUtilities/Config.h index a9929fa..8363c01 100644 --- a/PolygonClientUtilities/Config.h +++ b/PolygonClientUtilities/Config.h @@ -23,14 +23,11 @@ #define CLASSPADDING_DATAMODEL__JOBID 728 -// #define ADDRESS_DATAMODEL__GETJOBID 0x005CACC0 #define ADDRESS_STANDARDOUT__PRINT 0x0059F340 -// #define ADDRESS_NETWORK__RAKNETADDRESSTOSTRING 0x004FC1A0 #define ADDRESS_CRYPT__VERIFYSIGNATUREBASE64 0x0079ECF0 #define ADDRESS_SERVERREPLICATOR__SENDTOP 0x00506910 #define ADDRESS_SERVERREPLICATOR__PROCESSPACKET 0x00507420 #define ADDRESS_SERVERREPLICATOR__PROCESSTICKET 0x0 -// #define ADDRESS_DATAMODEL__CREATEDATAMODEL 0x005DC150 #define ADDRESS_GAME__CONSTRUCT 0x0047DBF0 #define ADDRESS_HTTP__HTTPGETPOSTWININET 0x006A9210 #define ADDRESS_HTTP__TRUSTCHECK 0x005A2680 @@ -174,7 +171,7 @@ #define RR_CONTINUE_PROCESSING 1 #define RR_STOP_PROCESSING 2 -#ifdef NDEBUG +#ifndef _DEBUG #define PADDING_STRUCT 1 #else #define PADDING_STRUCT 0 diff --git a/PolygonClientUtilities/Context.cpp b/PolygonClientUtilities/Context.cpp index deb5996..562e433 100644 --- a/PolygonClientUtilities/Context.cpp +++ b/PolygonClientUtilities/Context.cpp @@ -2,6 +2,8 @@ #include "Context.h" #include "Util.h" +#ifdef _DEBUG + Context__requirePermission_t Context__requirePermission = (Context__requirePermission_t)ADDRESS_CONTEXT__REQUIREPERMISSION; void __fastcall Context__requirePermission_hook(void* _this, void*, int permission, const char* operation) @@ -15,4 +17,6 @@ void __fastcall Context__requirePermission_hook(void* _this, void*, int permissi else throw std::runtime_error("The current identity (" + std::to_string(identity) + ") cannot perform the requested operation (requires " + std::to_string(permission) + ")"); } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/Context.h b/PolygonClientUtilities/Context.h index 08aa688..80782c1 100644 --- a/PolygonClientUtilities/Context.h +++ b/PolygonClientUtilities/Context.h @@ -2,6 +2,12 @@ #include "Classes.h" +#ifdef _DEBUG + +const auto Context__isInRole = (bool(__cdecl*)(int identity, int permission))ADDRESS_CONTEXT__ISINROLE; + typedef void (__thiscall* Context__requirePermission_t)(void* _this, int permission, const char* operation); void __fastcall Context__requirePermission_hook(void* _this, void*, int permission, const char* operation); -extern Context__requirePermission_t Context__requirePermission; \ No newline at end of file +extern Context__requirePermission_t Context__requirePermission; + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/Crypt.cpp b/PolygonClientUtilities/Crypt.cpp index 4b8e85b..b35253f 100644 --- a/PolygonClientUtilities/Crypt.cpp +++ b/PolygonClientUtilities/Crypt.cpp @@ -3,7 +3,6 @@ #include "Patches.h" #include "Util.h" - Crypt::Crypt() { if (!CryptAcquireContext(&context, NULL, MS_ENH_RSA_AES_PROV, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) @@ -21,9 +20,13 @@ Crypt::Crypt() } } +#ifdef _DEBUG std::vector publicKey = Util::base64Decode(Util::publicKey); - BYTE* blob = new BYTE[publicKey.size()]; +#else + std::vector publicKey = Util::publicKey; +#endif + BYTE* blob = new BYTE[publicKey.size()]; std::copy(publicKey.begin(), publicKey.end(), blob); if (!CryptImportKey(context, blob, publicKey.size(), 0, 0, &key)) @@ -127,6 +130,7 @@ void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, int // Verify signature if (!Crypt().verifySignatureBase64(message, signatureBase64, CALG_SHA_256)) { + // backwards compatibility for sha1 signatures if (!Crypt().verifySignatureBase64(message, signatureBase64, CALG_SHA1)) { throw std::runtime_error(""); diff --git a/PolygonClientUtilities/Http.h b/PolygonClientUtilities/Http.h index b62cc9d..ddce661 100644 --- a/PolygonClientUtilities/Http.h +++ b/PolygonClientUtilities/Http.h @@ -4,6 +4,16 @@ #include #include +struct Http +{ +#if PADDING_STRUCT != 0 + void* padding1[1]; +#endif + std::string alternateUrl; + void* padding2[3 + PADDING_STRUCT]; + std::string url; +}; + typedef void (__thiscall* Http__httpGetPostWinInet_t)(Http* _this, bool isPost, int a3, bool compressData, LPCSTR additionalHeaders, int a6); typedef bool(__thiscall* Http__trustCheck_t)(const char* url); diff --git a/PolygonClientUtilities/Patches.cpp b/PolygonClientUtilities/Patches.cpp index ca6bba4..01023a2 100644 --- a/PolygonClientUtilities/Patches.cpp +++ b/PolygonClientUtilities/Patches.cpp @@ -10,7 +10,9 @@ LONG Patches::Apply() DetourTransactionBegin(); for (Patch patch : patchList) + { DetourAttach(&(PVOID&)*patch.first, patch.second); + } return DetourTransactionCommit(); } diff --git a/PolygonClientUtilities/PolygonClientUtilities.vcxproj b/PolygonClientUtilities/PolygonClientUtilities.vcxproj index 0d0cbdc..8a57075 100644 --- a/PolygonClientUtilities/PolygonClientUtilities.vcxproj +++ b/PolygonClientUtilities/PolygonClientUtilities.vcxproj @@ -113,11 +113,10 @@ - - + @@ -127,7 +126,6 @@ - @@ -139,7 +137,7 @@ - + diff --git a/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters b/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters index 54cef0f..5ffa257 100644 --- a/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters +++ b/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters @@ -45,7 +45,7 @@ Header Files\Hooks - + Header Files\Hooks @@ -54,9 +54,6 @@ Header Files\Hooks - - Header Files\Hooks - Header Files\Hooks @@ -83,7 +80,7 @@ Source Files\Hooks - + Source Files\Hooks @@ -92,9 +89,6 @@ Source Files\Hooks - - Source Files\Hooks - Source Files\Hooks diff --git a/PolygonClientUtilities/ScriptContext.cpp b/PolygonClientUtilities/ScriptContext.cpp deleted file mode 100644 index 19904c2..0000000 --- a/PolygonClientUtilities/ScriptContext.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "pch.h" -#include "ScriptContext.h" - -// ScriptContext__execute_t ScriptContext__execute = (ScriptContext__execute_t)0x617CF0; -// -// void* __fastcall ScriptContext__execute_hook(void* _this, void*, void* a1, int identity, const char* script, const char* name, void* arguments) -// { -// return ScriptContext__execute(_this, a1, identity, script, name, arguments); -// } \ No newline at end of file diff --git a/PolygonClientUtilities/ScriptContext.h b/PolygonClientUtilities/ScriptContext.h deleted file mode 100644 index fee0e83..0000000 --- a/PolygonClientUtilities/ScriptContext.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "Classes.h" - -// typedef void* (__thiscall* ScriptContext__execute_t)(void* _this, void* a1, int identity, const char* script, const char* name, void* arguments); -// void* __fastcall ScriptContext__execute_hook(void* _this, void*, void* a1, int identity, const char* script, const char* name, void* arguments); -// extern ScriptContext__execute_t ScriptContext__execute; \ No newline at end of file diff --git a/PolygonClientUtilities/ReplicatorSecurity.cpp b/PolygonClientUtilities/ServerReplicator.cpp similarity index 95% rename from PolygonClientUtilities/ReplicatorSecurity.cpp rename to PolygonClientUtilities/ServerReplicator.cpp index cd8bd69..9cff61d 100644 --- a/PolygonClientUtilities/ReplicatorSecurity.cpp +++ b/PolygonClientUtilities/ServerReplicator.cpp @@ -1,5 +1,7 @@ #include "pch.h" -#include "ReplicatorSecurity.h" +#include "ServerReplicator.h" + +#if defined(ARBITERBUILD) && defined(MFC2011) static std::map rakPeers; @@ -43,4 +45,6 @@ void __fastcall ServerReplicator__processTicket_hook(ServerReplicator* _this, vo { // printf("ServerReplicator::sendTop called: player is not authenticated\n"); } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/ReplicatorSecurity.h b/PolygonClientUtilities/ServerReplicator.h similarity index 57% rename from PolygonClientUtilities/ReplicatorSecurity.h rename to PolygonClientUtilities/ServerReplicator.h index d5f655b..001b751 100644 --- a/PolygonClientUtilities/ReplicatorSecurity.h +++ b/PolygonClientUtilities/ServerReplicator.h @@ -2,6 +2,26 @@ #include "Classes.h" +#if defined(ARBITERBUILD) && defined(MFC2011) + +struct Packet +{ + void* padding1[7]; + unsigned int length; + void* padding2[1]; + unsigned char* data; +}; + +struct ConcurrentRakPeer {}; +struct RakPeerInterface {}; + +struct ServerReplicator +{ + void* padding1[1869]; // offset of 0 -> 7476 + bool padding2; // offset of 7476 -> 7477 + bool isAuthenticated; // offset of 7477 -> 7478 +}; + typedef void(__thiscall* ServerReplicator__sendTop_t)(ServerReplicator* _this, RakPeerInterface* peer); typedef void(__thiscall* ServerReplicator__processTicket_t)(ServerReplicator* _this, Packet* packet); @@ -9,4 +29,6 @@ void __fastcall ServerReplicator__sendTop_hook(ServerReplicator* _this, void*, R void __fastcall ServerReplicator__processTicket_hook(ServerReplicator* _this, void*, Packet* packet); extern ServerReplicator__sendTop_t ServerReplicator__sendTop; -extern ServerReplicator__processTicket_t ServerReplicator__processTicket; \ No newline at end of file +extern ServerReplicator__processTicket_t ServerReplicator__processTicket; + +#endif \ No newline at end of file diff --git a/PolygonClientUtilities/StandardOut.cpp b/PolygonClientUtilities/StandardOut.cpp index f701de7..a294aa5 100644 --- a/PolygonClientUtilities/StandardOut.cpp +++ b/PolygonClientUtilities/StandardOut.cpp @@ -11,7 +11,7 @@ void InitializeOutput() outputHandle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); SetStdHandle(STD_OUTPUT_HANDLE, outputHandle); -#ifndef NDEBUG +#ifdef _DEBUG printf("[[[ DLL COMPILED AS DEBUG ]]]\n"); #endif @@ -29,7 +29,7 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* { StandardOut__print(_this, type, message); -#ifdef NDEBUG +#ifndef _DEBUG // Message pointer is offset 4 bytes when the DLL is compiled as release message = reinterpret_cast((int)message + 4); #endif @@ -64,18 +64,18 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* switch (type) { - case RBX__MESSAGE_OUTPUT: - SetConsoleTextAttribute(outputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY); - break; - case RBX__MESSAGE_INFO: - SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); - break; - case RBX__MESSAGE_WARNING: - SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN); - break; - case RBX__MESSAGE_ERROR: - SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY); - break; + case RBX__MESSAGE_OUTPUT: + SetConsoleTextAttribute(outputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY); + break; + case RBX__MESSAGE_INFO: + SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + break; + case RBX__MESSAGE_WARNING: + SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN); + break; + case RBX__MESSAGE_ERROR: + SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY); + break; } printf("%s\n", message->c_str()); diff --git a/PolygonClientUtilities/Util.cpp b/PolygonClientUtilities/Util.cpp index e78a7e3..d931c1b 100644 --- a/PolygonClientUtilities/Util.cpp +++ b/PolygonClientUtilities/Util.cpp @@ -1,8 +1,35 @@ #include "pch.h" #include "Util.h" -#include -const std::string Util::publicKey = "BgIAAACkAABSU0ExAAQAAAEAAQABmKy9m0NxBRoXTuQPZU8BeMfwBisHcYBy93KSlQB3emeiW/pEMj9YWn2k7JkHiqcjuH+XE5PWK+q9s8oLQsnXTdTYa2l+1BhypP5jefgq0ZHITTIMBfE7rTI39ppzs0ayXKINQMIsBzXaJm25v5gP+vlz4cupJPq+jy9De+kcyw=="; +// this is ifdef guarded so that the public key cannot easily be replaced +// the std::vector variant is the base64 blob decoded into its byte form (https://cryptii.com/pipes/base64-to-hex) +// for ease of development, the string is retained to easily swap keys +// currently the key is the Project Polygon key + +#ifdef _DEBUG + +const std::string Util::publicKey = + "BgIAAACkAABSU0ExAAQAAAEAAQABmKy9m0NxBRoXTuQPZU8BeM" + "fwBisHcYBy93KSlQB3emeiW/pEMj9YWn2k7JkHiqcjuH+XE5PW" + "K+q9s8oLQsnXTdTYa2l+1BhypP5jefgq0ZHITTIMBfE7rTI39p" + "pzs0ayXKINQMIsBzXaJm25v5gP+vlz4cupJPq+jy9De+kcyw=="; + +#else + +const std::vector Util::publicKey = { + 0x06, 0x02, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x98, 0xac, 0xbd, 0x9b, 0x43, 0x71, 0x05, 0x1a, 0x17, + 0x4e, 0xe4, 0x0f, 0x65, 0x4f, 0x01, 0x78, 0xc7, 0xf0, 0x06, 0x2b, 0x07, 0x71, 0x80, 0x72, + 0xf7, 0x72, 0x92, 0x95, 0x00, 0x77, 0x7a, 0x67, 0xa2, 0x5b, 0xfa, 0x44, 0x32, 0x3f, 0x58, + 0x5a, 0x7d, 0xa4, 0xec, 0x99, 0x07, 0x8a, 0xa7, 0x23, 0xb8, 0x7f, 0x97, 0x13, 0x93, 0xd6, + 0x2b, 0xea, 0xbd, 0xb3, 0xca, 0x0b, 0x42, 0xc9, 0xd7, 0x4d, 0xd4, 0xd8, 0x6b, 0x69, 0x7e, + 0xd4, 0x18, 0x72, 0xa4, 0xfe, 0x63, 0x79, 0xf8, 0x2a, 0xd1, 0x91, 0xc8, 0x4d, 0x32, 0x0c, + 0x05, 0xf1, 0x3b, 0xad, 0x32, 0x37, 0xf6, 0x9a, 0x73, 0xb3, 0x46, 0xb2, 0x5c, 0xa2, 0x0d, + 0x40, 0xc2, 0x2c, 0x07, 0x35, 0xda, 0x26, 0x6d, 0xb9, 0xbf, 0x98, 0x0f, 0xfa, 0xf9, 0x73, + 0xe1, 0xcb, 0xa9, 0x24, 0xfa, 0xbe, 0x8f, 0x2f, 0x43, 0x7b, 0xe9, 0x1c, 0xcb +}; + +#endif const std::vector Util::allowedHosts { diff --git a/PolygonClientUtilities/Util.h b/PolygonClientUtilities/Util.h index 724f8db..8c671fd 100644 --- a/PolygonClientUtilities/Util.h +++ b/PolygonClientUtilities/Util.h @@ -1,15 +1,19 @@ #pragma once #include "pch.h" +#include class Util { public: +#ifdef _DEBUG static const std::string publicKey; +#else + static const std::vector publicKey; +#endif static const std::vector allowedHosts; static const std::vector allowedSchemes; static const std::vector allowedEmbeddedSchemes; - static std::vector split(std::string s, std::string delimiter); static std::map parseArgs(std::string args); static bool isASCII(const std::string& s); static std::string toLower(std::string s); diff --git a/PolygonClientUtilities/dllmain.cpp b/PolygonClientUtilities/dllmain.cpp index 0426858..0ce651a 100644 --- a/PolygonClientUtilities/dllmain.cpp +++ b/PolygonClientUtilities/dllmain.cpp @@ -2,7 +2,6 @@ #include "Config.h" #include "Patches.h" -#include "ScriptContext.h" #include "Http.h" #include "Crypt.h" @@ -10,27 +9,27 @@ #include "Context.h" #endif -#ifdef ARBITERBUILD +#if defined(ARBITERBUILD) #include "StandardOut.h" +#endif -#ifdef MFC2011 +#if defined(ARBITERBUILD) && defined(MFC2011) #include "ReplicatorSecurity.h" #endif -#ifdef PLAYER2012 +#if defined(ARBITERBUILD) && defined(PLAYER2012) #include "Application.h" #endif -#endif #if defined(MFC2010) || defined(MFC2011) #include "CRoblox.h" #endif START_PATCH_LIST() -// ADD_PATCH(ScriptContext__execute, ScriptContext__execute_hook) -ADD_PATCH(Http__httpGetPostWinInet, Http__httpGetPostWinInet_hook) +ADD_PATCH(Http__httpGetPostWinInet, Http__httpGetPostWinInet_hook) ADD_PATCH(Http__trustCheck, Http__trustCheck_hook) + ADD_PATCH(Crypt__verifySignatureBase64, Crypt__verifySignatureBase64_hook) #ifdef _DEBUG @@ -38,29 +37,23 @@ ADD_PATCH(Context__requirePermission, Context__requirePermission_hook) #endif #ifdef ARBITERBUILD -// ADD_PATCH(DataModel__getJobId, DataModel__getJobId_hook) ADD_PATCH(StandardOut__print, StandardOut__print_hook) -// ADD_PATCH(Network__RakNetAddressToString, Network__RakNetAddressToString_hook) +#endif -#ifdef MFC2011 +#if defined(ARBITERBUILD) && defined(MFC2011) ADD_PATCH(ServerReplicator__sendTop, ServerReplicator__sendTop_hook) ADD_PATCH(ServerReplicator__processTicket, ServerReplicator__processTicket_hook) #endif -#ifdef PLAYER2012 +#if defined(ARBITERBUILD) && defined(PLAYER2012) ADD_PATCH(Application__ParseArguments, Application__ParseArguments_hook) #endif -#endif #if defined(MFC2010) || defined(MFC2011) -// ADD_PATCH(CApp__CreateGame, CApp__CreateGame_hook) ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook) ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook) #endif -#ifdef DEBUG_SERVERREPLICATOR__PROCESSPACKET -// ADD_PATCH(ServerReplicator__processPacket, ServerReplicator__processPacket_hook) -#endif END_PATCH_LIST() // DLLs for release will be loaded with VMProtect, so this isn't necessary @@ -77,22 +70,22 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv InitializeOutput(); #endif - LONG error = Patches::Apply(); - if (error != NO_ERROR) + LONG patchesError = Patches::Apply(); + if (patchesError != NO_ERROR) { #ifdef _DEBUG - std::string message = "Patches::Apply returned " + std::to_string(error); + std::string message = "Patches::Apply returned " + std::to_string(patchesError); MessageBoxA(nullptr, message.c_str(), nullptr, MB_ICONERROR); #endif ExitProcess(EXIT_FAILURE); } - CURLcode error = curl_global_init(CURL_GLOBAL_DEFAULT); - if (error != CURLE_OK) + CURLcode curlError = curl_global_init(CURL_GLOBAL_DEFAULT); + if (curlError != CURLE_OK) { #ifdef _DEBUG - std::string message = "curl_global_init returned " + std::to_string(error); + std::string message = "curl_global_init returned " + std::to_string(curlError); MessageBoxA(nullptr, message.c_str(), nullptr, MB_ICONERROR); #endif