Add hook for setting game.jobId

This commit is contained in:
pizzaboxer 2022-01-21 23:47:50 +00:00
parent f1a565327e
commit 21820beb55
10 changed files with 101 additions and 43 deletions

View File

@ -5,6 +5,9 @@
// RobloxApp (2010) // RobloxApp (2010)
#ifdef MFC2010 #ifdef MFC2010
#define STRUCTOFFSET_DATAMODEL__JOBID 2912
#define ADDRESS_DATAMODEL__GETJOBID 0x005CACC0
#define ADDRESS_STANDARDOUT__PRINT 0x0059F340 #define ADDRESS_STANDARDOUT__PRINT 0x0059F340
#define ADDRESS_NETWORK__RAKNETADDRESSTOSTRING 0x004FC1A0 #define ADDRESS_NETWORK__RAKNETADDRESSTOSTRING 0x004FC1A0
#define ADDRESS_HTTP__TRUSTCHECK 0x005A2680 #define ADDRESS_HTTP__TRUSTCHECK 0x005A2680
@ -20,10 +23,13 @@
// RobloxApp (2011) // RobloxApp (2011)
#ifdef MFC2011 #ifdef MFC2011
#define STRUCTOFFSET_DATAMODEL__JOBID 2956
#define ADDRESS_DATAMODEL__GETJOBID 0x005E70C0
#define ADDRESS_STANDARDOUT__PRINT 0x005B25E0 #define ADDRESS_STANDARDOUT__PRINT 0x005B25E0
#define ADDRESS_NETWORK__RAKNETADDRESSTOSTRING 0x0 #define ADDRESS_NETWORK__RAKNETADDRESSTOSTRING 0x0
#define ADDRESS_HTTP__TRUSTCHECK 0x005B7050 #define ADDRESS_HTTP__TRUSTCHECK 0x005B7050
#define ADDRESS_HTTP__VERIFYSIGNATUREBASE64 0x00809EC0 #define ADDRESS_CRYPT__VERIFYSIGNATUREBASE64 0x00809EC0
#define ADDRESS_CAPP__CREATEGAME 0x0 #define ADDRESS_CAPP__CREATEGAME 0x0
#define ADDRESS_CAPP__ROBLOXAUTHENTICATE 0x0 #define ADDRESS_CAPP__ROBLOXAUTHENTICATE 0x0
#define ADDRESS_CROBLOXAPP__INITINSTANCE 0x004613C0 #define ADDRESS_CROBLOXAPP__INITINSTANCE 0x004613C0

View File

@ -14,12 +14,16 @@ void Logger::Initialize(const std::string jobId)
Logger::handle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); Logger::handle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
SetStdHandle(STD_OUTPUT_HANDLE, Logger::handle); SetStdHandle(STD_OUTPUT_HANDLE, Logger::handle);
#ifndef NDEBUG
printf("[[[ DLL COMPILED AS DEBUG ]]]\n");
#endif
// lol // lol
printf("Access key read: \n"); // printf("Access key read: \n");
printf("Current Access key: \n"); // printf("Current Access key: \n");
printf("Service starting...\n"); // printf("Service starting...\n");
printf("Intializing Roblox Web Service\n"); // printf("Intializing Roblox Web Service\n");
printf("Service Started on port 64989\n"); // printf("Service Started on port 64989\n");
Logger::outputLog = std::ofstream(jobId + std::string("-Output.txt")); Logger::outputLog = std::ofstream(jobId + std::string("-Output.txt"));
Logger::httpLog = std::ofstream(jobId + std::string("-Http.txt")); Logger::httpLog = std::ofstream(jobId + std::string("-Http.txt"));

View File

@ -167,6 +167,7 @@
<ClInclude Include="pch.h" /> <ClInclude Include="pch.h" />
<ClInclude Include="RobloxMFCClasses.h" /> <ClInclude Include="RobloxMFCClasses.h" />
<ClInclude Include="RobloxMFCHooks.h" /> <ClInclude Include="RobloxMFCHooks.h" />
<ClInclude Include="Util.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp" /> <ClCompile Include="dllmain.cpp" />
@ -183,6 +184,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="RobloxMFCHooks.cpp" /> <ClCompile Include="RobloxMFCHooks.cpp" />
<ClCompile Include="Util.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -36,6 +36,9 @@
<ClInclude Include="Logger.h"> <ClInclude Include="Logger.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Util.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
@ -56,5 +59,8 @@
<ClCompile Include="Logger.cpp"> <ClCompile Include="Logger.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,13 +1,15 @@
#include "pch.h" #include "pch.h"
#include "RobloxMFCHooks.h" #include "RobloxMFCHooks.h"
#include "Logger.h"
#include "Config.h" #include "Config.h"
#include "Util.h"
#include "Logger.h"
#include "LUrlParser.h" #include "LUrlParser.h"
static bool hasAuthUrlArg = false; static bool hasAuthUrlArg = false;
static bool hasAuthTicketArg = false; static bool hasAuthTicketArg = false;
static bool hasJoinArg = false; static bool hasJoinArg = false;
static bool hasJobId = false; static bool hasJobId = false;
static bool setJobId = false;
static std::wstring authenticationUrl; static std::wstring authenticationUrl;
static std::wstring authenticationTicket; static std::wstring authenticationTicket;
@ -19,6 +21,7 @@ static std::string jobId;
Http__trustCheck_t Http__trustCheck = (Http__trustCheck_t)ADDRESS_HTTP__TRUSTCHECK; Http__trustCheck_t Http__trustCheck = (Http__trustCheck_t)ADDRESS_HTTP__TRUSTCHECK;
Crypt__verifySignatureBase64_t Crypt__verifySignatureBase64 = (Crypt__verifySignatureBase64_t)ADDRESS_CRYPT__VERIFYSIGNATUREBASE64; Crypt__verifySignatureBase64_t Crypt__verifySignatureBase64 = (Crypt__verifySignatureBase64_t)ADDRESS_CRYPT__VERIFYSIGNATUREBASE64;
#ifdef ARBITERBUILD #ifdef ARBITERBUILD
DataModel__getJobId_t DataModel__getJobId = (DataModel__getJobId_t)ADDRESS_DATAMODEL__GETJOBID;
StandardOut__print_t StandardOut__print = (StandardOut__print_t)ADDRESS_STANDARDOUT__PRINT; StandardOut__print_t StandardOut__print = (StandardOut__print_t)ADDRESS_STANDARDOUT__PRINT;
// Network__RakNetAddressToString_t Network__RakNetAddressToString = (Network__RakNetAddressToString_t)ADDRESS_NETWORK__RAKNETADDRESSTOSTRING; // Network__RakNetAddressToString_t Network__RakNetAddressToString = (Network__RakNetAddressToString_t)ADDRESS_NETWORK__RAKNETADDRESSTOSTRING;
#endif #endif
@ -31,34 +34,6 @@ CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam = (CRobl
BOOL __fastcall Http__trustCheck_hook(const char* url) BOOL __fastcall Http__trustCheck_hook(const char* url)
{ {
const std::vector<std::string> allowedHosts
{
"polygon.pizzaboxer.xyz",
"polygondev.pizzaboxer.xyz",
"polygonapi.pizzaboxer.xyz",
"roblox.com",
"www.roblox.com",
"assetdelivery.roblox.com",
"tadah.rocks",
"www.tadah.rocks"
};
const std::vector<std::string> allowedSchemes
{
"http",
"https",
"ftp",
};
const std::vector<std::string> allowedEmbeddedSchemes
{
"javascript",
"jscript",
"res",
};
LUrlParser::ParseURL parsedUrl = LUrlParser::ParseURL::parseURL(url); LUrlParser::ParseURL parsedUrl = LUrlParser::ParseURL::parseURL(url);
if (!parsedUrl.isValid()) if (!parsedUrl.isValid())
@ -71,10 +46,10 @@ BOOL __fastcall Http__trustCheck_hook(const char* url)
if (std::string("about:blank") == url) if (std::string("about:blank") == url)
return true; return true;
if (std::find(allowedSchemes.begin(), allowedSchemes.end(), parsedUrl.scheme_) != allowedSchemes.end()) if (std::find(Util::allowedSchemes.begin(), Util::allowedSchemes.end(), parsedUrl.scheme_) != Util::allowedSchemes.end())
return std::find(allowedHosts.begin(), allowedHosts.end(), parsedUrl.host_) != allowedHosts.end(); return std::find(Util::allowedHosts.begin(), Util::allowedHosts.end(), parsedUrl.host_) != Util::allowedHosts.end();
if (std::find(allowedEmbeddedSchemes.begin(), allowedEmbeddedSchemes.end(), parsedUrl.scheme_) != allowedEmbeddedSchemes.end()) if (std::find(Util::allowedEmbeddedSchemes.begin(), Util::allowedEmbeddedSchemes.end(), parsedUrl.scheme_) != Util::allowedEmbeddedSchemes.end())
return true; return true;
return false; return false;
@ -98,6 +73,28 @@ void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, char
} }
#ifdef ARBITERBUILD #ifdef ARBITERBUILD
int __fastcall DataModel__getJobId_hook(char* _this, void*, int a2)
{
// this only sets the job id when game.jobId is called by lua
// so the gameserver script must call game.jobId at the beginning for this to take effect
// also, this only applies to the first datamodel that is created
if (!setJobId && hasJobId && !jobId.empty())
{
int jobIdPtr = (int)_this + STRUCTOFFSET_DATAMODEL__JOBID;
#ifdef NDEBUG
jobIdPtr += 4;
#endif
std::string* jobIdValue = (std::string*)jobIdPtr;
jobIdValue->assign(jobId);
setJobId = true;
}
return DataModel__getJobId(_this, a2);
}
void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message) void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message)
{ {
StandardOut__print(_this, type, message); StandardOut__print(_this, type, message);
@ -107,11 +104,10 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string*
#ifdef NDEBUG #ifdef NDEBUG
// for some reason, the location of the message pointer is offset 4 bytes when compiled as release // for some reason, the location of the message pointer is offset 4 bytes when compiled as release
// i assume doing this is safe? most of the examples ive seen use reinterpret_cast but this seems to work fine // i assume doing this is safe? most of the examples ive seen use reinterpret_cast but this seems to work fine
int messagePtr = (int)message; int messagePtr = (int)message + 4;
messagePtr += 4;
std::string* message = (std::string*)messagePtr; std::string* message = (std::string*)messagePtr;
#endif #endif
switch (type) switch (type)
{ {
case 1: // RBX::MESSAGE_OUTPUT: case 1: // RBX::MESSAGE_OUTPUT:
@ -131,7 +127,6 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string*
SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_INTENSITY); SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_INTENSITY);
break; break;
} }
printf("%s\n", message->c_str()); printf("%s\n", message->c_str());
SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} }

View File

@ -4,9 +4,10 @@
// Type Definitions // // Type Definitions //
typedef void(__thiscall* Http__trustCheck_t)(const char* url); typedef BOOL(__thiscall* Http__trustCheck_t)(const char* url);
typedef void(__thiscall* Crypt__verifySignatureBase64_t)(HCRYPTPROV* _this, char a2, int a3, int a4, int a5, int a6, int a7, int a8, char a9, int a10, int a11, int a12, int a13, int a14, int a15); typedef void(__thiscall* Crypt__verifySignatureBase64_t)(HCRYPTPROV* _this, char a2, int a3, int a4, int a5, int a6, int a7, int a8, char a9, int a10, int a11, int a12, int a13, int a14, int a15);
#ifdef ARBITERBUILD #ifdef ARBITERBUILD
typedef INT(__thiscall* DataModel__getJobId_t)(char* _this, int a2);
typedef void(__thiscall* StandardOut__print_t)(int _this, int type, std::string* message); typedef void(__thiscall* StandardOut__print_t)(int _this, int type, std::string* message);
// typedef void(__thiscall* Network__RakNetAddressToString_t)(int raknetAddress, bool writePort, char portDelineator); // typedef void(__thiscall* Network__RakNetAddressToString_t)(int raknetAddress, bool writePort, char portDelineator);
#endif #endif
@ -20,6 +21,7 @@ typedef void(__thiscall* CRobloxCommandLineInfo__ParseParam_t)(CRobloxCommandLin
extern Http__trustCheck_t Http__trustCheck; extern Http__trustCheck_t Http__trustCheck;
extern Crypt__verifySignatureBase64_t Crypt__verifySignatureBase64; extern Crypt__verifySignatureBase64_t Crypt__verifySignatureBase64;
#ifdef ARBITERBUILD #ifdef ARBITERBUILD
extern DataModel__getJobId_t DataModel__getJobId;
extern StandardOut__print_t StandardOut__print; extern StandardOut__print_t StandardOut__print;
// extern Network__RakNetAddressToString_t Network__RakNetAddressToString; // extern Network__RakNetAddressToString_t Network__RakNetAddressToString;
#endif #endif
@ -33,6 +35,7 @@ extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam;
BOOL __fastcall Http__trustCheck_hook(const char* url); BOOL __fastcall Http__trustCheck_hook(const char* url);
void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, char a2, int a3, int a4, int a5, int a6, int a7, int a8, char a9, int a10, int a11, int a12, int a13, int a14, int a15); void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, char a2, int a3, int a4, int a5, int a6, int a7, int a8, char a9, int a10, int a11, int a12, int a13, int a14, int a15);
#ifdef ARBITERBUILD #ifdef ARBITERBUILD
INT __fastcall DataModel__getJobId_hook(char* _this, void*, int a2);
void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message); void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message);
// std::string __fastcall Network__RakNetAddressToString_hook(int raknetAddress, bool writePort, char portDelineator); // std::string __fastcall Network__RakNetAddressToString_hook(int raknetAddress, bool writePort, char portDelineator);
#endif #endif

View File

@ -0,0 +1,30 @@
#include "pch.h"
#include "Util.h"
const std::vector<std::string> Util::allowedHosts
{
"polygon.pizzaboxer.xyz",
"polygondev.pizzaboxer.xyz",
"polygonapi.pizzaboxer.xyz",
"roblox.com",
"www.roblox.com",
"assetdelivery.roblox.com",
"tadah.rocks",
"www.tadah.rocks"
};
const std::vector<std::string> Util::allowedSchemes
{
"http",
"https",
"ftp"
};
const std::vector<std::string> Util::allowedEmbeddedSchemes
{
"javascript",
"jscript",
"res"
};

View File

@ -0,0 +1,11 @@
#pragma once
#include "pch.h"
class Util
{
public:
static const std::vector<std::string> allowedHosts;
static const std::vector<std::string> allowedSchemes;
static const std::vector<std::string> allowedEmbeddedSchemes;
};

View File

@ -7,6 +7,7 @@ START_PATCH_LIST()
ADD_PATCH(Http__trustCheck, Http__trustCheck_hook) ADD_PATCH(Http__trustCheck, Http__trustCheck_hook)
ADD_PATCH(Crypt__verifySignatureBase64, Crypt__verifySignatureBase64_hook) ADD_PATCH(Crypt__verifySignatureBase64, Crypt__verifySignatureBase64_hook)
#if defined(MFC2010) || defined(MFC2011) #if defined(MFC2010) || defined(MFC2011)
ADD_PATCH(DataModel__getJobId, DataModel__getJobId_hook)
ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook) ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook)
ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook) ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook)
#endif #endif