From 29ef5d63793ae76d2c7c4217548375e73efa6e52 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 11 Jun 2017 21:24:32 +0200 Subject: [PATCH] [AntiCheat] Add redundant code scanners --- src/Components/Modules/AntiCheat.cpp | 40 ++++++++++++++++++++++++++++ src/Components/Modules/AntiCheat.hpp | 4 +++ src/Components/Modules/Changelog.cpp | 4 +++ src/Components/Modules/Menus.cpp | 4 +++ 4 files changed, 52 insertions(+) diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index a8228db2..4c23ae0d 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -229,6 +229,46 @@ namespace Components AntiCheat::Flags |= AntiCheat::IntergrityFlag::MEMORY_SCAN; } + void AntiCheat::QuickCodeScanner_1() + { + static Utils::Time::Interval interval; + static Utils::Value hashVal; + + if (!interval.elapsed(11s)) return; + interval.update(); + + // Hash .text segment + // Add 1 to each value, so searching in memory doesn't reveal anything + size_t textSize = 0x2D5FFF; + uint8_t* textBase = reinterpret_cast(0x400FFF); + std::string hash = Utils::Cryptography::SHA256::Compute(textBase + 1, textSize + 1, false); + + if (hashVal.isValid() && hash != hashVal.get()) + { + Utils::Hook::Set(0x42A667, 0x90); // Crash + } + + hashVal.set(hash); + } + + void AntiCheat::QuickCodeScanner_2() + { + static Utils::Time::Interval interval; + static Utils::Value hashVal; + + if (!interval.elapsed(12s)) return; + interval.update(); + + // Hash .text segment + std::string hash = Utils::Cryptography::SHA1::Compute(reinterpret_cast(0x401000), 0x2D6000, false); + if (hashVal.isValid() && hash != hashVal.get()) + { + Utils::Hook::Set(0x40797C, 0x90); // Crash + } + + hashVal.set(hash); + } + #ifdef DEBUG_LOAD_LIBRARY HANDLE AntiCheat::LoadLibary(std::wstring library, HANDLE file, DWORD flags, void* callee) { diff --git a/src/Components/Modules/AntiCheat.hpp b/src/Components/Modules/AntiCheat.hpp index ce82edc3..5c0b5279 100644 --- a/src/Components/Modules/AntiCheat.hpp +++ b/src/Components/Modules/AntiCheat.hpp @@ -31,6 +31,10 @@ namespace Components static void VerifyThreadIntegrity(); + static void QuickCodeScanner_1(); + static void QuickCodeScanner_2(); + static void QuickCodeScanner_3(); + private: enum IntergrityFlag { diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index 6dc2d719..e45e937f 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -55,6 +55,10 @@ namespace Components // Changelog UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog); + +#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) + Scheduler::OnFrame(AntiCheat::QuickCodeScanner_1); +#endif } Changelog::~Changelog() diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 68ba3277..2d8d8ad9 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -766,6 +766,10 @@ namespace Components } }); +#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) + Scheduler::OnFrame(AntiCheat::QuickCodeScanner_2); +#endif + Command::Add("mp_QuickMessage", [] (Command::Params*) { Command::Execute("openmenu quickmessage");