From 55ab43563ea07bd27ddd09eadade004b068e3d58 Mon Sep 17 00:00:00 2001 From: Yimura Date: Mon, 26 Jul 2021 00:38:03 +0200 Subject: [PATCH] feat(Protections): Added scripted game event protection --- BigBaseV2/src/core/enums.hpp | 22 ++++ BigBaseV2/src/core/globals.hpp | 60 +++++++++ BigBaseV2/src/hooking.cpp | 9 +- BigBaseV2/src/hooking.hpp | 4 + BigBaseV2/src/hooks/script_event_handler.cpp | 130 +++++++++++++++++++ BigBaseV2/src/pointers.cpp | 6 + BigBaseV2/src/pointers.hpp | 1 + 7 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 BigBaseV2/src/hooks/script_event_handler.cpp diff --git a/BigBaseV2/src/core/enums.hpp b/BigBaseV2/src/core/enums.hpp index c2a536c9..05d238b3 100644 --- a/BigBaseV2/src/core/enums.hpp +++ b/BigBaseV2/src/core/enums.hpp @@ -13,6 +13,28 @@ namespace big VEHICLE_GUN }; + enum class RemoteEvent : int64_t + { + Bounty = -1906146218, + CeoBan = 1355230914, + CeoKick = -316948135, + CeoMoney = 1152266822, + ClearWantedLevel = 1187364773, + FakeDeposit = 153488394, + ForceMission = -1147284669, + GtaBanner = 1659915470, + PersonalVehicleDestroyed = 299217086, + RemoteOffradar = -397188359, + RotateCam = -1320260596, + SendToCutscene = 1889984715, + SendToIsland = -1479371259, + SoundSpam = 1537221257, + Spectate = -148441291, + Teleport = 1249026189, + TransactionError = -2041535807, + VehicleKick = -1005623606 + }; + enum class SpeedoMeter { DISABLED, diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 22a2fb40..a9c9ce45 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -21,6 +21,26 @@ struct globals { bool spectating = false; }; + struct protections { + bool bounty = true; + bool ceo_ban = true; + bool ceo_kick = true; + bool ceo_money = true; + bool clear_wanted_level = true; + bool fake_deposit = true; + bool force_mission = true; + bool force_teleport = true; + bool gta_banner = true; + bool personal_vehicle_destroyed = true; + bool remote_off_radar = true; + bool send_to_cutscene = true; + bool send_to_island = true; + bool sound_spam = true; + bool spectate = true; + bool transaction_error = true; + bool vehicle_kick = true; + }; + struct self { bool godmode = false; bool off_radar = false; @@ -56,6 +76,7 @@ struct globals { tunables tunables{}; player player{}; + protections protections{}; self self{}; vehicle vehicle{}; weapons weapons{}; @@ -63,6 +84,24 @@ struct globals { void from_json(const nlohmann::json& j) { + this->protections.bounty = j["protections"]["bounty"]; + this->protections.ceo_ban = j["protections"]["ceo_ban"]; + this->protections.ceo_kick = j["protections"]["ceo_kick"]; + this->protections.ceo_money = j["protections"]["ceo_money"]; + this->protections.clear_wanted_level = j["protections"]["clear_wanted_level"]; + this->protections.fake_deposit = j["protections"]["fake_deposit"]; + this->protections.force_mission = j["protections"]["force_mission"]; + this->protections.force_teleport = j["protections"]["force_teleport"]; + this->protections.gta_banner = j["protections"]["gta_banner"]; + this->protections.personal_vehicle_destroyed = j["protections"]["personal_vehicle_destroyed"]; + this->protections.remote_off_radar = j["protections"]["remote_off_radar"]; + this->protections.send_to_cutscene = j["protections"]["send_to_cutscene"]; + this->protections.send_to_island = j["protections"]["send_to_island"]; + this->protections.sound_spam = j["protections"]["sound_spam"]; + this->protections.spectate = j["protections"]["spectate"]; + this->protections.transaction_error = j["protections"]["transaction_error"]; + this->protections.vehicle_kick = j["protections"]["vehicle_kick"]; + this->tunables.disable_phone = j["tunables"]["disable_phone"]; this->tunables.no_idle_kick = j["tunables"]["no_idle_kick"]; @@ -84,6 +123,27 @@ struct globals { nlohmann::json to_json() { return nlohmann::json{ + { + "protections", { + { "bounty", this->protections.bounty }, + { "ceo_ban", this->protections.ceo_ban }, + { "ceo_kick", this->protections.ceo_kick }, + { "ceo_money", this->protections.ceo_money }, + { "clear_wanted_level", this->protections.clear_wanted_level }, + { "fake_deposit", this->protections.fake_deposit }, + { "force_mission", this->protections.force_mission }, + { "force_teleport", this->protections.force_teleport }, + { "gta_banner", this->protections.gta_banner }, + { "personal_vehicle_destroyed", this->protections.personal_vehicle_destroyed }, + { "remote_off_radar", this->protections.remote_off_radar }, + { "send_to_cutscene", this->protections.send_to_cutscene }, + { "send_to_island", this->protections.send_to_island }, + { "sound_spam", this->protections.sound_spam }, + { "spectate", this->protections.spectate }, + { "transaction_error", this->protections.transaction_error }, + { "vehicle_kick", this->protections.vehicle_kick } + } + }, { "tunables", { { "disable_phone", this->tunables.disable_phone }, diff --git a/BigBaseV2/src/hooking.cpp b/BigBaseV2/src/hooking.cpp index f33b2e76..d77b6c87 100644 --- a/BigBaseV2/src/hooking.cpp +++ b/BigBaseV2/src/hooking.cpp @@ -59,7 +59,10 @@ namespace big // Report Cash Spawn Event m_report_cash_spawn_event_hook("RCSE", g_pointers->m_report_cash_spawn, &hooks::report_cash_spawn_handler), // Report Cheating Hook - m_report_cheating_hook("RC", g_pointers->m_report_cheating, &hooks::report_cheating_handler) + m_report_cheating_hook("RC", g_pointers->m_report_cheating, &hooks::report_cheating_handler), + + // Scripted Game Event Hook + m_scripted_game_event_hook("SGEH", g_pointers->m_scripted_game_event, &hooks::scripted_game_event) { m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present); m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers); @@ -96,6 +99,8 @@ namespace big m_report_cash_spawn_event_hook.enable(); m_report_cheating_hook.enable(); + m_scripted_game_event_hook.enable(); + m_enabled = true; } @@ -103,6 +108,8 @@ namespace big { m_enabled = false; + m_scripted_game_event_hook.disable(); + m_report_cheating_hook.disable(); m_report_cash_spawn_event_hook.disable(); diff --git a/BigBaseV2/src/hooking.hpp b/BigBaseV2/src/hooking.hpp index 51f3e312..9cd2e29b 100644 --- a/BigBaseV2/src/hooking.hpp +++ b/BigBaseV2/src/hooking.hpp @@ -43,6 +43,8 @@ namespace big static bool report_cash_spawn_handler(__int64 creport_cash_spawn_event, CNetGamePlayer* source_player); static void report_cheating_handler(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4); + + static bool scripted_game_event(CScriptedGameEvent* scripted_game_event, CNetGamePlayer* player); }; struct minhook_keepalive @@ -83,6 +85,8 @@ namespace big detour_hook m_report_cash_spawn_event_hook; detour_hook m_report_cheating_hook; + + detour_hook m_scripted_game_event_hook; }; inline hooking *g_hooking{}; diff --git a/BigBaseV2/src/hooks/script_event_handler.cpp b/BigBaseV2/src/hooks/script_event_handler.cpp new file mode 100644 index 00000000..f9dd8591 --- /dev/null +++ b/BigBaseV2/src/hooks/script_event_handler.cpp @@ -0,0 +1,130 @@ +#include "hooking.hpp" +#include "gta/enums.hpp" +#include "util/notify.hpp" + +namespace big +{ + bool hooks::scripted_game_event(CScriptedGameEvent* scripted_game_event, CNetGamePlayer* player) + { + auto args = scripted_game_event->m_args; + + RemoteEvent hash = (RemoteEvent)args[0]; + + char type[32] = ""; + + + switch (hash) + { + case RemoteEvent::Bounty: + if (g.protections.bounty) + strcpy(type, "Bounty"); + + break; + case RemoteEvent::CeoBan: + if (g.protections.ceo_ban) + strcpy(type, "Ceo Ban"); + + break; + case RemoteEvent::CeoKick: + if (g.protections.ceo_kick) + strcpy(type, "Ceo Kick"); + + break; + case RemoteEvent::CeoMoney: + if (g.protections.ceo_money) + strcpy(type, "Ceo Money"); + + break; + case RemoteEvent::ClearWantedLevel: + if (g.protections.clear_wanted_level) + strcpy(type, "Clear Wanted Level"); + + break; + case RemoteEvent::FakeDeposit: + if (g.protections.fake_deposit) + strcpy(type, "Fake Deposit"); + + break; + case RemoteEvent::ForceMission: + if (g.protections.force_mission) + strcpy(type, "Force Mission"); + + break; + case RemoteEvent::GtaBanner: + if (g.protections.gta_banner) + strcpy(type, "GTA Banner"); + + break; + case RemoteEvent::PersonalVehicleDestroyed: + if (g.protections.personal_vehicle_destroyed) + strcpy(type, "Personal Vehicle Destroyed"); + + break; + case RemoteEvent::RemoteOffradar: + if (g.protections.remote_off_radar) + strcpy(type, "Remote Off Radar"); + + break; + case RemoteEvent::SendToCutscene: + if (g.protections.send_to_cutscene) + strcpy(type, "Send To Cutscene"); + + break; + case RemoteEvent::SendToIsland: + if (g.protections.send_to_island) + strcpy(type, "Send To Island"); + + break; + case RemoteEvent::SoundSpam: + if (g.protections.sound_spam) + strcpy(type, "Sound Spam"); + + break; + case RemoteEvent::Spectate: + if (g.protections.spectate) + strcpy(type, "Specate"); + + break; + case RemoteEvent::Teleport: + if (g.protections.force_teleport) + strcpy(type, "Force Teleport"); + + break; + case RemoteEvent::TransactionError: + if (g.protections.transaction_error) + strcpy(type, "Transaction Error"); + + break; + case RemoteEvent::VehicleKick: + if (g.protections.vehicle_kick) + strcpy(type, "Vehicle Kick"); + + break; + } + + if (strlen(type) != 0) + { + char msg[128]; + strcpy(msg, "~g~BLOCKED SCRIPT EVENT~s~\nFrom: "); + strcat(msg, player->get_name()); + strcat(msg, "\nEvent Type: ~b~"); + strcat(msg, type); + + notify::above_map(msg); + + return true; + } + + if (false) + { + LOG(INFO) << "Received Script Event"; + LOG(INFO) << "Player: " << player->get_name(); + LOG(INFO) << "Hash: " << (int64_t)hash; + + for (int i = 1; i < sizeof(args); i++) + LOG(INFO) << "Arg #" << i << ": " << args[i]; + } + + return g_hooking->m_scripted_game_event_hook.get_original()(scripted_game_event, player); + } +} \ No newline at end of file diff --git a/BigBaseV2/src/pointers.cpp b/BigBaseV2/src/pointers.cpp index ff906195..5084e0c4 100644 --- a/BigBaseV2/src/pointers.cpp +++ b/BigBaseV2/src/pointers.cpp @@ -179,6 +179,12 @@ namespace big { m_report_cheating = ptr.as(); }); + + // Scripted Game Event Handler + main_batch.add("SGEH", "40 53 48 81 EC ? ? ? ? 44 8B 81 ? ? ? ? 4C 8B CA 41 8D 40 FF 3D ? ? ? ? 77 42", [this](memory::handle ptr) + { + m_scripted_game_event = ptr.as(); + }); main_batch.run(memory::module(nullptr)); diff --git a/BigBaseV2/src/pointers.hpp b/BigBaseV2/src/pointers.hpp index 4b59bb09..6091d364 100644 --- a/BigBaseV2/src/pointers.hpp +++ b/BigBaseV2/src/pointers.hpp @@ -43,6 +43,7 @@ namespace big functions::increment_stat_event* m_increment_stat_event{}; + PVOID m_scripted_game_event{}; functions::trigger_script_event* m_trigger_script_event{}; // Received Event Signatures START