SHARE
TWEET

Untitled

a guest Oct 28th, 2017 178 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Windows.h>
  2. #include <stdio.h>
  3. #include <detours.h>
  4. #include <iostream>
  5. #include <string.h>
  6. #include <mono/metadata/object.h>
  7. //#include <mono/metadata/environment.h>
  8. //#include <mono/metadata/assembly.h>
  9. //#include <mono/metadata/debug-helpers.h>
  10.  
  11.  
  12. void LogConsole(const char *szFmt, ...)
  13. {
  14.     va_list args;
  15.     va_start(args, szFmt);
  16.  
  17.     int buffSize = _vscprintf(szFmt, args) + 1;
  18.  
  19.     if (buffSize <= 1)
  20.         return;
  21.  
  22.     char *szBuff = new char[buffSize];
  23.     memset(szBuff, 0, buffSize);
  24.  
  25.     int len = vsprintf_s(szBuff, buffSize, szFmt, args);
  26.  
  27.     szBuff[buffSize - 1] = 0;
  28.  
  29.     HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
  30.  
  31.     DWORD numWritten = 0;
  32.     WriteFile(hOutput, szBuff, len, &numWritten, NULL);
  33.  
  34.     delete[] szBuff;
  35. }
  36.  
  37.  
  38.  
  39. HMODULE hMono = GetModuleHandle("mono.dll");
  40.  
  41. DWORD_PTR GetMonoFunction(char* funcname)
  42. {
  43.     return (DWORD_PTR)GetProcAddress(hMono, funcname);
  44. }
  45.  
  46. //Class
  47. typedef MonoClass* (__cdecl* mono_class_from_name_t)(MonoImage* image, const char* name_space, const char* name);
  48. typedef MonoMethod* (__cdecl* mono_class_get_method_from_name_t)(MonoClass* mclass, const char* name, int param_count);
  49. mono_class_from_name_t mono_class_from_name_ = (mono_class_from_name_t)GetMonoFunction("mono_class_from_name");
  50. mono_class_get_method_from_name_t mono_class_get_method_from_name_ = (mono_class_get_method_from_name_t)GetMonoFunction("mono_class_get_method_from_name");
  51.  
  52. //Method
  53. typedef MonoObject* (__cdecl* mono_runtime_invoke_t)(MonoMethod* method, void* obj, void** params, MonoObject** exc);
  54. mono_runtime_invoke_t mono_runtime_invoke_ = (mono_runtime_invoke_t)GetMonoFunction("mono_runtime_invoke");
  55.  
  56. //Property
  57. typedef MonoProperty* (__cdecl* mono_class_get_property_from_name_t)(MonoClass* mclass, const char* name);
  58. typedef MonoMethod* (__cdecl* mono_property_get_set_method_t)(MonoProperty* prop);
  59. typedef MonoMethod* (__cdecl* mono_property_get_get_method_t)(MonoProperty* prop);
  60. mono_class_get_property_from_name_t mono_class_get_property_from_name_ = (mono_class_get_property_from_name_t)GetMonoFunction("mono_class_get_property_from_name");
  61. mono_property_get_set_method_t mono_property_get_set_method_ = (mono_property_get_set_method_t)GetMonoFunction("mono_property_get_set_method");
  62. mono_property_get_get_method_t mono_property_get_get_method_ = (mono_property_get_get_method_t)GetMonoFunction("mono_property_get_get_method");
  63.  
  64. //Assembly
  65. typedef MonoAssembly* (__cdecl* mono_assembly_open_t)(const char *filename, MonoImageOpenStatus *status);
  66. typedef MonoImage* (__cdecl* mono_assembly_get_image_t)(MonoAssembly *assembly);
  67. mono_assembly_open_t mono_assembly_open_ = (mono_assembly_open_t)GetMonoFunction("mono_assembly_open");
  68. mono_assembly_get_image_t mono_assembly_get_image_ = (mono_assembly_get_image_t)GetMonoFunction("mono_assembly_get_image");
  69.  
  70. // Assambly VAN IK
  71. typedef MonoDomain* (__cdecl* mono_domain_get_t)();
  72. typedef MonoDomain* (*mono_get_root_domain_t)();
  73. typedef MonoAssembly* (__cdecl* mono_domain_assembly_open_t)(MonoDomain* domain, const char* fileName);
  74. typedef void*(__cdecl* mono_thread_attach_t)(MonoDomain* domain);
  75. mono_domain_get_t mono_domain_get_ = (mono_domain_get_t)GetMonoFunction("mono_domain_get");
  76. mono_get_root_domain_t mono_get_root_domain_ = (mono_get_root_domain_t)GetMonoFunction("mono_get_root_domain");
  77. mono_domain_assembly_open_t mono_domain_assembly_open_ = (mono_domain_assembly_open_t)GetMonoFunction("mono_domain_assembly_open");
  78. mono_thread_attach_t mono_thread_attach_ = (mono_thread_attach_t)GetMonoFunction("mono_thread_attach");
  79.  
  80. // Field shizz VAN IK
  81. typedef MonoClassField* (__cdecl*mono_class_get_field_from_name_t)(MonoClass *klass, const char *name);
  82. typedef void* (__cdecl* mono_field_get_value_t)(MonoObject *obj, MonoClassField *field, void *value);
  83. typedef MonoObject* (__cdecl* mono_field_get_value_object_t)(MonoDomain *domain, MonoClassField *field, MonoObject *obj);
  84. typedef MonoObject* (__cdecl* mono_object_new_t)  (MonoDomain *domain, MonoClass *klass);
  85. typedef MonoVTable* (__cdecl* mono_class_vtable_t)(MonoDomain *domain, MonoClass *klass);
  86. typedef void* (__cdecl* mono_field_static_get_value_t)(MonoVTable *vt, MonoClassField *field, void *value);
  87. mono_class_get_field_from_name_t mono_class_get_field_from_name_ = (mono_class_get_field_from_name_t)GetMonoFunction("mono_class_get_field_from_name");
  88. mono_field_get_value_t mono_field_get_value_ = (mono_field_get_value_t)GetMonoFunction("mono_field_get_value");
  89. mono_field_get_value_object_t mono_field_get_value_object_ = (mono_field_get_value_object_t)GetMonoFunction("mono_field_get_value_object");
  90. mono_object_new_t mono_object_new_ = (mono_object_new_t)GetMonoFunction("mono_object_new");
  91. mono_class_vtable_t mono_class_vtable_ = (mono_class_vtable_t)GetMonoFunction("mono_class_vtable");
  92. mono_field_static_get_value_t mono_field_static_get_value_ = (mono_field_static_get_value_t)GetMonoFunction("mono_field_static_get_value");
  93.  
  94.  
  95. VOID Deject(PCHAR reason) {
  96.     if (reason) {
  97.         MessageBox(NULL, reason, "", MB_OK | MB_ICONERROR | MB_TOPMOST);
  98.     }
  99. }
  100.  
  101. const char * boolToStr(bool b) {
  102.     if (b == true) {
  103.         return "true";
  104.     }
  105.     else {
  106.         return "false";
  107.     }
  108. }
  109.  
  110. DWORD WINAPI LoopFunction(LPVOID lpParam) {
  111.     AllocConsole();
  112.     LogConsole("Loaded CodestageBypass x64 \n");
  113.  
  114.     char path[2048];
  115.     GetModuleFileNameA(NULL, path, 2048);
  116.     LogConsole("Parent executable = %s\n", path);
  117.  
  118.     mono_thread_attach_(mono_get_root_domain_());
  119.  
  120.  
  121.     MonoDomain* domain_ = mono_domain_get_();
  122.     //C:\\Users\\Win7\\Desktop\\Unity Example games\\RogueLike\\Build_Data\\Managed\\Assembly-CSharp.dll
  123.     //E:\\Software\\Steam\\steamapps\\common\\BlockNLoad\\Win64\\BlockNLoad_Data\\Managed\\Assembly-CSharp.dll
  124.     MonoAssembly* assembly_ = mono_domain_assembly_open_(domain_, "E:\\Software\\Steam\\steamapps\\common\\BlockNLoad\\Win64\\BlockNLoad_Data\\Managed\\Assembly-CSharp.dll");
  125.     MonoImage* image_ = mono_assembly_get_image_(assembly_);
  126.  
  127.     MonoClass* class_ID = mono_class_from_name_(image_, "CodeStage.AntiCheat.Detectors", "InjectionDetector");
  128.     MonoClass* class_OCD = mono_class_from_name_(image_, "CodeStage.AntiCheat.Detectors", "ObscuredCheatingDetector");
  129.     MonoClass* class_SHD = mono_class_from_name_(image_, "CodeStage.AntiCheat.Detectors", "SpeedHackDetector");
  130.  
  131.     MonoMethod* method_ID = mono_class_get_method_from_name_(class_ID, "StopDetection", 0); // Method for disabling InjectionDetector
  132.     MonoMethod* method_OCD = mono_class_get_method_from_name_(class_OCD, "StopDetection", 0); // Method for disabling ObscuredCheatingDetector
  133.     MonoMethod* method_SHD = mono_class_get_method_from_name_(class_SHD, "StopDetection", 0); // Method for disabling SpeedHackDetector
  134.  
  135.     bool b = false;
  136.     while (true) {
  137.  
  138.         MonoVTable* table_ID = mono_class_vtable_(domain_, class_ID);
  139.         MonoVTable* table_OCD = mono_class_vtable_(domain_, class_OCD);
  140.         MonoVTable* table_SHD = mono_class_vtable_(domain_, class_SHD);
  141.  
  142.         MonoClassField* field_ID = mono_class_get_field_from_name_(class_ID, "isRunning"); // Internal static bool isRunning (InjectionDetector.isRunning)
  143.         MonoClassField* field_OCD = mono_class_get_field_from_name_(class_OCD, "isRunning"); // Internal static bool isRunning (ObscuredCheatingDetector.isRunning)
  144.         MonoClassField* field_SHD = mono_class_get_field_from_name_(class_SHD, "isRunning"); // Internal static bool isRunning (SpeedHackDetector.isRunning)
  145.  
  146.         bool res_ID;
  147.         bool res_OCD;
  148.         bool res_SHD;
  149.  
  150.         mono_field_static_get_value_(table_ID, field_ID, &res_ID);
  151.         mono_field_static_get_value_(table_OCD, field_OCD, &res_OCD);
  152.         mono_field_static_get_value_(table_SHD, field_SHD, &res_SHD);
  153.  
  154.         LogConsole("\n");
  155.         if (res_ID == true) { LogConsole("InjectionDetector.isRunning: true"); }
  156.         else { LogConsole("InjectionDetector.isRunning: false"); }
  157.         LogConsole("\n");
  158.         if (res_OCD == true) { LogConsole("ObscuredCheatingDetector.isRunning: true"); }
  159.         else { LogConsole("ObscuredCheatingDetector.isRunning: false"); }
  160.         LogConsole("\n");
  161.         if (res_SHD == true) { LogConsole("SpeedHackDetector.isRunning: true"); }
  162.         else { LogConsole("SpeedHackDetector.isRunning: false"); }
  163.         LogConsole("\n");
  164.  
  165.  
  166.  
  167.         if (b == false) {
  168.             LogConsole("Disabling InjectionDetector... \n");
  169.             mono_runtime_invoke_(method_ID, NULL, NULL, NULL);
  170.             LogConsole("Disabling ObscuredCheatingDetector... \n");
  171.             mono_runtime_invoke_(method_OCD, NULL, NULL, NULL);
  172.             LogConsole("Disabling SpeedHackDetector... \n");
  173.             mono_runtime_invoke_(method_SHD, NULL, NULL, NULL);
  174.             b = true;
  175.         }
  176.         else {
  177.             Sleep(4000);
  178.         }
  179.     }
  180.  
  181.  
  182.  
  183.  
  184.     //try
  185.     //{
  186.  
  187.  
  188.     //}
  189.     //catch (const std::exception&e)
  190.     //{
  191.     //  LogConsole("Error: ");
  192.     //  LogConsole(e.what());
  193.     //  LogConsole("\n");
  194.     //}
  195.  
  196.     return 0;
  197. }
  198.  
  199.  
  200. BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
  201. {
  202.     switch (dwReason)
  203.     {
  204.     case DLL_PROCESS_ATTACH:
  205.         DisableThreadLibraryCalls(hModule);
  206.         //CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)onAttach, NULL, 0, NULL);
  207.         CreateThread(NULL, 0, &LoopFunction, NULL, 0, NULL);
  208.         return true;
  209.         break;
  210.  
  211.     case DLL_PROCESS_DETACH:
  212.         FreeConsole();
  213.         return true;
  214.         break;
  215.     }
  216.  
  217.  
  218. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top