From 9b2d7092116d8ee4d460388466832a99db3b1e9f Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 28 Jun 2016 11:30:49 +0200 Subject: [PATCH] Optimize antishit --- deps/mongoose | 2 +- deps/protobuf | 2 +- src/Components/Modules/AntiCheat.cpp | 12 ++++++++++-- src/Utils/Utils.cpp | 10 ++++++++++ src/Utils/Utils.hpp | 2 ++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/deps/mongoose b/deps/mongoose index 79325bd2..ced823cd 160000 --- a/deps/mongoose +++ b/deps/mongoose @@ -1 +1 @@ -Subproject commit 79325bd219ae6fea7809324c38824269c2774fd1 +Subproject commit ced823cd95b70b313fa56baad544ccec5d6ccd5b diff --git a/deps/protobuf b/deps/protobuf index 2bcd43af..dc0aeaa9 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 2bcd43afe4b649c95d932daf31b0b83948f7cf7c +Subproject commit dc0aeaa9030bdac264b44d56d07b6839a1ae94e9 diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index fb38cbdb..daae193f 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -97,8 +97,16 @@ namespace Components static uint8_t loadLibStub[] = { 0x33, 0xC0, 0xC2, 0x04, 0x00 }; // xor eax, eax; retn 04h static uint8_t loadLibExStub[] = { 0x33, 0xC0, 0xC2, 0x0C, 0x00 }; // xor eax, eax; retn 0Ch - AntiCheat::LoadLibHook[0].Initialize(LoadLibraryA, loadLibStub, HOOK_JUMP); - AntiCheat::LoadLibHook[1].Initialize(LoadLibraryW, loadLibStub, HOOK_JUMP); + static uint8_t kernel32Str[] = { 0xB4, 0x9A, 0x8D, 0xB1, 0x9A, 0x93, 0xCC, 0xCD, 0xD1, 0x9B, 0x93, 0x93 }; // KerNel32.dll + static uint8_t loadLibAStr[] = { 0xB3, 0x90, 0x9E, 0x9B, 0xB3, 0x96, 0x9D, 0x8D, 0x9E, 0x8D, 0x86, 0xBE }; // LoadLibraryA + static uint8_t loadLibWStr[] = { 0xB3, 0x90, 0x9E, 0x9B, 0xB3, 0x96, 0x9D, 0x8D, 0x9E, 0x8D, 0x86, 0xA8 }; // LoadLibraryW + + HMODULE kernel32 = GetModuleHandleA(Utils::XORString(std::string(reinterpret_cast(kernel32Str), sizeof kernel32Str), -1).data()); + FARPROC loadLibA = GetProcAddress(kernel32, Utils::XORString(std::string(reinterpret_cast(loadLibAStr), sizeof loadLibAStr), -1).data()); + FARPROC loadLibW = GetProcAddress(kernel32, Utils::XORString(std::string(reinterpret_cast(loadLibWStr), sizeof loadLibWStr), -1).data()); + + AntiCheat::LoadLibHook[0].Initialize(loadLibA, loadLibStub, HOOK_JUMP); + AntiCheat::LoadLibHook[1].Initialize(loadLibW, loadLibStub, HOOK_JUMP); //AntiCheat::LoadLibHook[2].Initialize(LoadLibraryExA, loadLibExStub, HOOK_JUMP); //AntiCheat::LoadLibHook[3].Initialize(LoadLibraryExW, loadLibExStub, HOOK_JUMP); } diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index 87368fa8..1ff08653 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -61,6 +61,16 @@ namespace Utils return result; } + std::string XORString(std::string str, char value) + { + for (unsigned int i = 0; i < str.size(); ++i) + { + str[i] ^= value; + } + + return str; + } + // Complementary function for memset, which checks if a memory is set bool MemIsSet(void* mem, char chr, size_t length) { diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index fdc58de4..dd78d04a 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -22,6 +22,8 @@ namespace Utils std::string DumpHex(std::string data, std::string separator = " "); + std::string XORString(std::string str, char value); + bool MemIsSet(void* mem, char chr, size_t length); class InfoString