From 428f35b97a3befa2feac79f23d3bae08424ac532 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Wed, 21 Dec 2016 21:14:14 +0300 Subject: [PATCH] CatVars --- cathook/src/common.h | 1 + cathook/src/copypasted/Netvar.cpp | 1 - cathook/src/cvwrapper.cpp | 55 ++++++++++++++++-- cathook/src/cvwrapper.h | 46 +++++++++++++-- cathook/src/enums.h | 38 ++++++------- cathook/src/gui/controls.cpp | 21 ++++++- cathook/src/gui/gui.cpp | 70 +++++++++++++++-------- cathook/src/gui/gui.h | 4 ++ cathook/src/hack.cpp | 29 ++++++++-- cathook/src/hack.h | 2 +- cathook/src/hacks/Aimbot.cpp | 94 +++++++++++++++++-------------- cathook/src/hacks/Aimbot.h | 60 ++++++++++---------- cathook/src/hacks/AutoHeal.cpp | 2 +- cathook/src/hacks/ESP.cpp | 7 ++- cathook/src/hacks/IHack.h | 1 + cathook/src/hacks/Misc.cpp | 1 + cathook/src/hacks/Trigger.cpp | 2 +- cathook/src/helpers.cpp | 15 ++++- cathook/src/helpers.h | 2 + cathook/src/hooks.cpp | 2 + cathook/src/hooks.h | 2 + cathook/src/interfaces.cpp | 2 + cathook/src/interfaces.h | 2 + cathook/src/sdk.h | 1 + 24 files changed, 318 insertions(+), 142 deletions(-) diff --git a/cathook/src/common.h b/cathook/src/common.h index 78c4dcb4..207f6c18 100644 --- a/cathook/src/common.h +++ b/cathook/src/common.h @@ -21,6 +21,7 @@ #include "relations.h" #include "usercmd.h" #include "trace.h" +#include "cvwrapper.h" #include "prediction.h" #define CON_NAME "cat" diff --git a/cathook/src/copypasted/Netvar.cpp b/cathook/src/copypasted/Netvar.cpp index e928ff0a..56734004 100644 --- a/cathook/src/copypasted/Netvar.cpp +++ b/cathook/src/copypasted/Netvar.cpp @@ -1,6 +1,5 @@ #include "Netvar.h" -//#include "SDK.h" #include "../interfaces.h" #include "../logging.h" #include diff --git a/cathook/src/cvwrapper.cpp b/cathook/src/cvwrapper.cpp index eab1d95d..1d1cc9e9 100644 --- a/cathook/src/cvwrapper.cpp +++ b/cathook/src/cvwrapper.cpp @@ -10,33 +10,76 @@ #include "common.h" #include "sdk.h" -void CatVar::Increment() { +CatEnum::CatEnum(const char** values, int size, int min) { + m_Values = values; + m_iMin = min; + m_iMax = min + size - 1; + m_iLength = size; + logging::Info("Created enum with size %i", size); +} + +const char* CatEnum::Name(int value) { + if (value + m_iMin >= 0 && value + m_iMin < m_iMax) { + return m_Values[value + m_iMin]; + } + return (const char*)0; +} + +int CatEnum::Maximum() { + return m_iMax; +} + +int CatEnum::Minimum() { + return m_iMin; +} + +bool CatVar::GetBool() { return m_pConVar->GetBool(); } +int CatVar::GetInt() { return m_pConVar->GetInt(); } +float CatVar::GetFloat() { return m_pConVar->GetFloat(); } + +void CatVar::Increment(int factor) { if (!m_pConVar) return; switch (m_Type) { case CatVar_t::CV_SWITCH: { m_pConVar->SetValue(!m_pConVar->GetInt()); } break; case CatVar_t::CV_INT: - m_pConVar->SetValue(m_pConVar->GetInt() + 1); + m_pConVar->SetValue(m_pConVar->GetInt() + factor * m_iStep); break; case CatVar_t::CV_FLOAT: - m_pConVar->SetValue(m_pConVar->GetFloat() + 0.5f); + m_pConVar->SetValue(m_pConVar->GetFloat() + (float)factor * m_fStep); break; + case CatVar_t::CV_ENUM: { + int cur = m_pConVar->GetInt(); + int newv = cur + 1; + if (newv > m_EnumType->Maximum()) { + newv = m_EnumType->Minimum(); + } + m_pConVar->SetValue(newv); + } break; } } -void CatVar::Decrement() { +void CatVar::Decrement(int factor) { if (!m_pConVar) return; switch (m_Type) { case CatVar_t::CV_SWITCH: m_pConVar->SetValue((int)!m_pConVar->GetInt()); break; case CatVar_t::CV_INT: - m_pConVar->SetValue(m_pConVar->GetInt() - 1); + m_pConVar->SetValue(m_pConVar->GetInt() - factor * m_iStep); break; case CatVar_t::CV_FLOAT: - m_pConVar->SetValue(m_pConVar->GetFloat() - 0.5f); + m_pConVar->SetValue(m_pConVar->GetFloat() - (float)factor * m_fStep); break; + case CatVar_t::CV_ENUM: { + int cur = m_pConVar->GetInt(); + int newv = cur - 1; + if (newv < m_EnumType->Minimum()) { + newv = m_EnumType->Maximum() - 1; + } + m_pConVar->SetValue(newv); + } break; } } diff --git a/cathook/src/cvwrapper.h b/cathook/src/cvwrapper.h index 2db3835a..c354553d 100644 --- a/cathook/src/cvwrapper.h +++ b/cathook/src/cvwrapper.h @@ -10,21 +10,59 @@ class ConVar; +#define CREATE_CV(type, name, defaults, description) \ + new CatVar(CreateConVar(CON_PREFIX name, defaults, description), type); + enum CatVar_t { CV_SWITCH, CV_INT, CV_FLOAT, - CV_STRING + CV_STRING, + CV_ENUM +}; + +class ICatEnum { +public: + inline virtual ~ICatEnum() {} + virtual const char* Name(int value) = 0; + virtual int Minimum() = 0; + virtual int Maximum() = 0; +}; + +class CatEnum : public ICatEnum { +public: + CatEnum(const char** values, int size, int min = 0); + virtual const char* Name(int value); + virtual int Maximum(); + virtual int Minimum(); + const char** m_Values; + int m_iMin; + int m_iMax; + int m_iLength; }; class CatVar { public: - inline CatVar(ConVar* var, CatVar_t type) { m_pConVar = var; m_Type = type; } + inline CatVar(ConVar* var, CatVar_t type) { m_iStep = 1; m_fStep = 0.5f; m_pConVar = var; m_Type = type; } + inline CatVar(ConVar* var, ICatEnum* catenum) { m_pConVar = var; m_Type = CatVar_t::CV_ENUM; m_EnumType = catenum; } inline CatVar_t GetType() { return m_Type; } + inline ICatEnum* GetEnum() { return 0; } inline ConVar* GetConVar() { return m_pConVar; } - void Increment(); - void Decrement(); + bool GetBool(); + int GetInt(); + float GetFloat(); + + void Increment(int factor = 1); + void Decrement(int factor = 1); + + inline void SetStep(int step) { m_iStep = step; } + inline void SetStep(float step) { m_fStep = step; } + + int m_iStep; + float m_fStep; + + ICatEnum* m_EnumType; CatVar_t m_Type; ConVar* m_pConVar; }; diff --git a/cathook/src/enums.h b/cathook/src/enums.h index c0a8edeb..0b54e555 100644 --- a/cathook/src/enums.h +++ b/cathook/src/enums.h @@ -535,26 +535,24 @@ enum weaponmode { }; enum hitbox_t { - hb_head = 0, - hb_neck, - hb_necklower, - hb_pelvis, - hb_body, - hb_lowerchest, - hb_chest, - hb_upperchest, - hb_rightthigh, - hb_leftthigh, - hb_rightshin, - hb_leftshin, - hb_rightfoot, - hb_leftfoot, - hb_righthand, - hb_lefthand, - hb_rightupperarm, - hb_rightlowerarm, - hb_leftupperArm, - hb_leftlowerArm + head = 0, + pelvis = 1, + spine_0 = 2, + spine_1 = 3, + spine_2 = 4, + spine_3 = 5, + upperArm_L = 6, + lowerArm_L = 7, + hand_L = 8, + upperArm_R = 9, + lowerArm_R = 10, + hand_R = 11, + hip_L = 12, + knee_L = 13, + foot_L = 14, + hip_R = 15, + knee_R = 16, + foot_R = 17 }; enum relation { diff --git a/cathook/src/gui/controls.cpp b/cathook/src/gui/controls.cpp index 67aa1404..e6b6b06b 100644 --- a/cathook/src/gui/controls.cpp +++ b/cathook/src/gui/controls.cpp @@ -121,20 +121,35 @@ void GUIListElement_Var::Draw(int x, int y, bool selected) { draw::GetStringLength(strfmt("%i", m_pCatVar->GetConVar()->GetInt()), l, h); draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), "%i", m_pCatVar->GetConVar()->GetInt()); } break; + case CatVar_t::CV_ENUM: { + draw::DrawString(x, y, selected ? colors::pink : colors::Transparent(colors::pink), "%s", m_pCatVar->GetConVar()->GetHelpText()); + int l, h; + const char* str = m_pCatVar->m_EnumType->Name(m_pCatVar->GetInt()); + if (str) { + draw::GetStringLength((char*)str, l, h); + draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), str); + } else { + draw::GetStringLength(strfmt("%i", m_pCatVar->GetConVar()->GetInt()), l, h); + draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), "%i", m_pCatVar->GetConVar()->GetInt()); + } + } break; } } void GUIListElement_Var::KeyEvent(ButtonCode_t key) { + int factor = 1; + if (g_pGUI->m_bPressedState[ButtonCode_t::KEY_LSHIFT]) factor *= 10; + if (g_pGUI->m_bPressedState[ButtonCode_t::KEY_LCONTROL]) factor *= 100; switch (key) { case ButtonCode_t::KEY_SPACE: case ButtonCode_t::KEY_ENTER: - m_pCatVar->Increment(); + m_pCatVar->Increment(factor); break; case ButtonCode_t::KEY_RIGHT: - m_pCatVar->Increment(); + m_pCatVar->Increment(factor); break; case ButtonCode_t::KEY_LEFT: - m_pCatVar->Decrement(); + m_pCatVar->Decrement(factor); break; } } diff --git a/cathook/src/gui/gui.cpp b/cathook/src/gui/gui.cpp index 1c54c1cd..da9ad42b 100644 --- a/cathook/src/gui/gui.cpp +++ b/cathook/src/gui/gui.cpp @@ -52,18 +52,35 @@ void GUI::Draw() { } } -bool GUI::KeyEvent(ButtonCode_t key) { - if (key == KEY_INSERT) - m_bActive = !m_bActive; - if (!m_bActive) return false; - if (key == KEY_BACKSPACE) { - PopList(); - return false; +void GUI::UpdateKeys() { + for (int i = 0; i < ButtonCode_t::KEY_COUNT; i++) { + bool down = interfaces::input->IsButtonDown((ButtonCode_t)(KEY_FIRST + i)); + bool changed = m_bPressedState[i] != down; + if (changed && down) m_iPressedFrame[i] = interfaces::gvars->framecount; + m_bPressedState[i] = down; + if (m_bKeysInit) { + if (changed) { + KeyEvent((ButtonCode_t)i); + } + } } + if (!m_bKeysInit) m_bKeysInit = 1; +} - if (m_nStackSize) { - if (m_ListStack[m_nStackSize - 1]) - m_ListStack[m_nStackSize - 1]->KeyEvent(key); +bool GUI::KeyEvent(ButtonCode_t key) { + if (m_bPressedState[key]) { + if (key == KEY_INSERT) + m_bActive = !m_bActive; + if (!m_bActive) return false; + if (key == KEY_BACKSPACE) { + PopList(); + return false; + } + + if (m_nStackSize) { + if (m_ListStack[m_nStackSize - 1]) + m_ListStack[m_nStackSize - 1]->KeyEvent(key); + } } return false; } @@ -84,6 +101,9 @@ bool GUI::KeyEvent(ButtonCode_t key) { #define ADD_FLOAT(list, var) \ list_##list->AddElement(new GUIListElement_Var(new CatVar(var, CatVar_t::CV_FLOAT))); +#define ADD_VAR(list, var) \ + list_##list->AddElement(new GUIListElement_Var(var)); + void GUI::Setup() { CREATE_LIST(main, "MAIN"); @@ -106,24 +126,24 @@ void GUI::Setup() { ADD_SUBLIST(main, autoheal); ADD_SUBLIST(main, bhop); - ADD_SWITCH(aimbot, g_phAimbot->v_bEnabled); + ADD_VAR(aimbot, g_phAimbot->v_bEnabled); // TODO enums - ADD_INT(aimbot, g_phAimbot->v_iAimKeyMode); - ADD_INT(aimbot, g_phAimbot->v_iAimKey); - ADD_INT(aimbot, g_phAimbot->v_iHitbox); - ADD_SWITCH(aimbot, g_phAimbot->v_bAutoHitbox); - ADD_SWITCH(aimbot, g_phAimbot->v_bPrediction); - ADD_SWITCH(aimbot, g_phAimbot->v_bAutoShoot); - ADD_SWITCH(aimbot, g_phAimbot->v_bSilent); - ADD_SWITCH(aimbot, g_phAimbot->v_bZoomedOnly); - ADD_SWITCH(aimbot, g_phAimbot->v_bRespectCloak); - ADD_SWITCH(aimbot, g_phAimbot->v_bAimBuildings); - ADD_FLOAT(aimbot, g_phAimbot->v_fFOV); - ADD_SWITCH(aimbot, g_phAimbot->v_bMachinaPenetration); + ADD_VAR(aimbot, g_phAimbot->v_eAimKeyMode); + ADD_VAR(aimbot, g_phAimbot->v_eAimKey); + ADD_VAR(aimbot, g_phAimbot->v_eHitbox); + ADD_VAR(aimbot, g_phAimbot->v_bAutoHitbox); + ADD_VAR(aimbot, g_phAimbot->v_bPrediction); + ADD_VAR(aimbot, g_phAimbot->v_bAutoShoot); + ADD_VAR(aimbot, g_phAimbot->v_bSilent); + ADD_VAR(aimbot, g_phAimbot->v_bZoomedOnly); + ADD_VAR(aimbot, g_phAimbot->v_bRespectCloak); + ADD_VAR(aimbot, g_phAimbot->v_bAimBuildings); + ADD_VAR(aimbot, g_phAimbot->v_fFOV); + ADD_VAR(aimbot, g_phAimbot->v_bMachinaPenetration); CREATE_LIST(aimbot_smooth, "Smooth") ADD_SUBLIST(aimbot, aimbot_smooth); - ADD_SWITCH(aimbot_smooth, g_phAimbot->v_bSmooth); - ADD_INT(aimbot, g_phAimbot->v_iSeenDelay); + ADD_VAR(aimbot_smooth, g_phAimbot->v_bSmooth); + ADD_VAR(aimbot, g_phAimbot->v_iSeenDelay); ADD_SWITCH(antiaim, g_phAntiAim->v_bEnabled); ADD_FLOAT(antiaim, g_phAntiAim->v_flPitch); diff --git a/cathook/src/gui/gui.h b/cathook/src/gui/gui.h index d021012e..0a16bb30 100644 --- a/cathook/src/gui/gui.h +++ b/cathook/src/gui/gui.h @@ -23,9 +23,13 @@ public: void PushList(const char* id); void PopList(); + void UpdateKeys(); void Setup(); + bool m_bKeysInit; + bool m_bPressedState[ButtonCode_t::KEY_COUNT]; + int m_iPressedFrame[ButtonCode_t::KEY_COUNT]; GUI_List** m_Lists; GUI_List** m_ListStack; int m_nListCount; diff --git a/cathook/src/hack.cpp b/cathook/src/hack.cpp index fe53c822..a61a7d57 100644 --- a/cathook/src/hack.cpp +++ b/cathook/src/hack.cpp @@ -85,7 +85,7 @@ void hack::Hk_PaintTraverse(void* p, unsigned int vp, bool fr, bool ar) { } SEGV_BEGIN; - ((PaintTraverse_t*)hooks::hkPanel->GetMethod(hooks::offPaintTraverse))(p, vp, fr, ar); + SAFE_CALL(((PaintTraverse_t*)hooks::hkPanel->GetMethod(hooks::offPaintTraverse))(p, vp, fr, ar)); // Because of single-multi thread shit I'm gonna put this thing riiiight here. if (g_phFollowBot->v_bEnabled->GetBool()) { ipc_client_seg* seg_g = g_phFollowBot->m_pIPC->GetClientSegment(0); @@ -156,6 +156,7 @@ void hack::Hk_PaintTraverse(void* p, unsigned int vp, bool fr, bool ar) { } } } + g_pGUI->UpdateKeys(); g_pGUI->Draw(); DrawStrings(); } @@ -365,6 +366,12 @@ void hack::CC_Cat(const CCommand& args) { interfaces::cvar->ConsoleColorPrintf(colors::red, "[DEVELOPER BUILD]\n"); } +typedef bool(HandleInputEvent_t)(IMatSystemSurface* thisptr, const InputEvent_t& event); +bool hk_HandleInputEvent(IMatSystemSurface* thisptr, const InputEvent_t& event) { + //logging::Info("Handling event %u [%u]", event.m_nType, event.m_nData); + return ((HandleInputEvent_t*)hooks::hkMatSurface->GetMethod(hooks::offHandleInputEvent))(thisptr, event); +} + void hack::Initialize() { logging::Initialize(); prctl(PR_SET_DUMPABLE,0,42,42,42); @@ -382,6 +389,14 @@ void hack::Initialize() { draw::Initialize(); logging::Info("Colorizing..."); colors::Init(); + logging::Info("Boosting luck..."); + uintptr_t mmmf = (gSignatures.GetClientSignature("C7 44 24 04 09 00 00 00 BB ? ? ? ? C7 04 24 00 00 00 00 E8 ? ? ? ? BA ? ? ? ? 85 C0 B8 ? ? ? ? 0F 44 DA") + 37); + if (mmmf) { + unsigned char patch1[] = { 0x89, 0xD3, 0x90 }; + unsigned char patch2[] = { 0x89, 0xC2, 0x90 }; + Patch((void*)mmmf, (void*)patch1, 3); + Patch((void*)(mmmf + 8), (void*)patch2, 3); + } else logging::Info("You are already filled with luck."); logging::Info("Adding hacks..."); BeginConVars(); @@ -421,6 +436,11 @@ void hack::Initialize() { hooks::hkClient->HookMethod((void*)&hack::Hk_DispatchUserMessage, hooks::offFrameStageNotify + 1); hooks::hkClient->HookMethod((void*)&Hk_IN_KeyEvent, hooks::offKeyEvent); hooks::hkClient->Apply(); + /*hooks::hkMatSurface = new hooks::VMTHook(); + hooks::hkMatSurface->Init((void*)interfaces::matsurface, 0); + hooks::hkMatSurface->HookMethod((void*)hk_HandleInputEvent, hooks::offHandleInputEvent); + hooks::hkMatSurface->Apply(); + logging::Info("MatSurface Hooked? %f", interfaces::matsurface->DrawGetAlphaMultiplier());*/ logging::Info("Hooked!"); InitStrings(); logging::Info("Init done!"); @@ -436,9 +456,10 @@ void hack::Shutdown() { logging::Info("Shutting down..."); logging::Shutdown(); ConVar_Unregister(); - hooks::hkPanel->Kill(); - hooks::hkClientMode->Kill(); - hooks::hkClient->Kill(); + if (hooks::hkPanel) hooks::hkPanel->Kill(); + if (hooks::hkClientMode) hooks::hkClientMode->Kill(); + if (hooks::hkClient) hooks::hkClient->Kill(); + if (hooks::hkMatSurface) hooks::hkMatSurface->Kill(); for (IHack* i_hack : hack::hacks) { delete i_hack; } diff --git a/cathook/src/hack.h b/cathook/src/hack.h index d7ac7b16..b918190a 100644 --- a/cathook/src/hack.h +++ b/cathook/src/hack.h @@ -16,7 +16,7 @@ #define CREATE_MOVE(x) \ g_ph##x->CreateMove(thisptr, inputSample, cmd) -#define DEBUG_SEGV false +#define DEBUG_SEGV true #if DEBUG_SEGV == true diff --git a/cathook/src/hacks/Aimbot.cpp b/cathook/src/hacks/Aimbot.cpp index 0e889522..32bd5c2a 100644 --- a/cathook/src/hacks/Aimbot.cpp +++ b/cathook/src/hacks/Aimbot.cpp @@ -38,41 +38,51 @@ const char* Aimbot::GetName() { } /* null-safe */ + +const char* psza__AimKeyMode[] = { "DISABLED", "AIMKEY", "REVERSE", "TOGGLE" }; +const char* psza__Hitbox[] = { + "HEAD", "PELVIS", "SPINE 0", "SPINE 1", "SPINE 2", "SPINE 3", "UPPER ARM L", "LOWER ARM L", + "HAND L", "UPPER ARM R", "LOWER ARM R", "HAND R", "HIP L", "KNEE L", "FOOT L", "HIP R", + "KNEE R", "FOOT R" +}; +const char* psza__Priority[] = { + "SMART", "FOV", "DISTANCE", "HEALTH" +}; + Aimbot::Aimbot() { target_systems[0] = new TargetSystemSmart(); target_systems[1] = new TargetSystemFOV(); target_systems[2] = new TargetSystemDistance(); m_bAimKeySwitch = false; - this->v_iAimKeyMode = CreateConVar(CON_PREFIX "aimbot_aimkey_mode", "1", "Aimkey Mode"); - this->v_bEnabled = CreateConVar(CON_PREFIX "aimbot_enabled", "0", "Enabled"); - this->v_iHitbox = CreateConVar(CON_PREFIX "aimbot_hitbox", "0", "Hitbox"); - this->v_bAutoHitbox = CreateConVar(CON_PREFIX "aimbot_autohitbox", "1", "Autohitbox"); - this->v_bPrediction = CreateConVar(CON_PREFIX "aimbot_prediction", "1", "Latency pred"); - this->v_bAutoShoot = CreateConVar(CON_PREFIX "aimbot_autoshoot", "1", "Autoshoot"); - this->v_bSilent = CreateConVar(CON_PREFIX "aimbot_silent", "1", "Silent"); - this->v_bZoomedOnly = CreateConVar(CON_PREFIX "aimbot_zoomed", "1", "Zoomed Only"); - this->v_iAutoShootCharge = CreateConVar(CON_PREFIX "aimbot_autoshoot_charge", "0.0", "Autoshoot Charge"); - this->v_iMaxRange = CreateConVar(CON_PREFIX "aimbot_maxrange", "0", "Max distance"); - this->v_bRespectCloak = CreateConVar(CON_PREFIX "aimbot_respect_cloak", "1", "Respect cloak"); - this->v_bCharge = CreateConVar(CON_PREFIX "aimbot_charge", "0", "Wait for charge"); - this->v_bEnabledAttacking = CreateConVar(CON_PREFIX "aimbot_enable_attack_only", "0", "Active when attacking"); - this->v_bStrictAttack = CreateConVar(CON_PREFIX "aimbot_strict_attack", "0", "Strict attack"); - this->v_bProjectileAimbot = CreateConVar(CON_PREFIX "aimbot_projectile", "1", "Projectile aimbot"); - this->v_iOverrideProjSpeed = CreateConVar(CON_PREFIX "aimbot_proj_speed", "0", "Projectile speed"); - this->v_bDebug = CreateConVar(CON_PREFIX "aimbot_debug", "0", "Debug"); - this->v_fFOV = CreateConVar(CON_PREFIX "aimbot_fov", "0", "FOV"); - this->v_bMachinaPenetration = CreateConVar(CON_PREFIX "aimbot_machina", "0", "Machina Mode"); - this->v_bSmooth = CreateConVar(CON_PREFIX "aimbot_smooth", "0", "Smooth"); - this->v_flAutoShootHuntsmanCharge = CreateConVar(CON_PREFIX "aimbot_huntsman_charge", "0.5", "Huntsman charge"); - this->v_fSmoothValue = CreateConVar(CON_PREFIX "aimbot_smooth_value", "0.2", "Smooth value"); - this->v_iAimKey = CreateConVar(CON_PREFIX "aimbot_aimkey", "0", "Aimkey"); - this->v_iPriorityMode = CreateConVar(CON_PREFIX "aimbot_prioritymode", "0", "Priority mode"); - this->v_bMinigunFix = CreateConVar(CON_PREFIX "aimbot_minigun_fix", "1", "Minigun fix"); - v_bAimBuildings = CreateConVar(CON_PREFIX "aimbot_buildings", "1", "Aim @ Buildings"); - v_bActiveOnlyWhenCanShoot = CreateConVar(CON_PREFIX "aimbot_only_when_can_shoot", "1", "Active when can shoot"); - v_fSmoothAutoshootTreshold = CreateConVar(CON_PREFIX "aimbot_smooth_autoshoot_treshold", "0.01", "Smooth autoshoot"); - this->v_fSmoothRandomness = CreateConVar(CON_PREFIX "aimbot_smooth_randomness", "1.0", "Smooth randomness"); - this->v_iSeenDelay = CreateConVar(CON_PREFIX "aimbot_delay", "0", "Aimbot delay"); + this->v_eAimKeyMode = CREATE_CV(new CatEnum(psza__AimKeyMode, ARRAYSIZE(psza__AimKeyMode)), "aimbot_aimkey_mode", "1", "Aimkey Mode"); + this->v_bEnabled = CREATE_CV(CV_SWITCH, "aimbot_enabled", "0", "Enabled"); + this->v_eHitbox = CREATE_CV(new CatEnum(psza__Hitbox, ARRAYSIZE(psza__Hitbox)), "aimbot_hitbox", "0", "Hitbox"); + this->v_bAutoHitbox = CREATE_CV(CV_SWITCH, "aimbot_autohitbox", "1", "Autohitbox"); + this->v_bPrediction = CREATE_CV(CV_SWITCH, "aimbot_prediction", "1", "Latency pred"); + this->v_bAutoShoot = CREATE_CV(CV_SWITCH, "aimbot_autoshoot", "1", "Autoshoot"); + this->v_bSilent = CREATE_CV(CV_SWITCH, "aimbot_silent", "1", "Silent"); + this->v_bZoomedOnly = CREATE_CV(CV_SWITCH, "aimbot_zoomed", "1", "Zoomed Only"); + this->v_iAutoShootCharge = CREATE_CV(CV_FLOAT, "aimbot_autoshoot_charge", "0.0", "Autoshoot Charge"); + this->v_iMaxRange = CREATE_CV(CV_INT, "aimbot_maxrange", "0", "Max distance"); + this->v_bRespectCloak = CREATE_CV(CV_SWITCH, "aimbot_respect_cloak", "1", "Respect cloak"); + this->v_bCharge = CREATE_CV(CV_SWITCH, "aimbot_charge", "0", "Wait for charge"); + this->v_bEnabledAttacking = CREATE_CV(CV_SWITCH, "aimbot_enable_attack_only", "0", "Active when attacking"); + this->v_bTriggerMode = CREATE_CV(CV_SWITCH, "aimbot_triggerlock", "0", "Trigger lock"); + this->v_bProjectileAimbot = CREATE_CV(CV_SWITCH, "aimbot_projectile", "1", "Projectile aimbot"); + this->v_fOverrideProjSpeed = CREATE_CV(CV_FLOAT, "aimbot_proj_speed", "0", "Projectile speed"); + this->v_bDebug = CREATE_CV(CV_SWITCH, "aimbot_debug", "0", "Debug"); + this->v_fFOV = CREATE_CV(CV_FLOAT, "aimbot_fov", "0", "FOV"); + this->v_bMachinaPenetration = CREATE_CV(CV_SWITCH, "aimbot_machina", "0", "Machina Mode"); + this->v_bSmooth = CREATE_CV(CV_SWITCH, "aimbot_smooth", "0", "Smooth"); + this->v_fAutoShootHuntsmanCharge = CREATE_CV(CV_FLOAT, "aimbot_huntsman_charge", "0.5", "Huntsman charge"); + this->v_fSmoothValue = CREATE_CV(CV_FLOAT, "aimbot_smooth_value", "0.2", "Smooth value"); + this->v_eAimKey = CREATE_CV(CV_INT, "aimbot_aimkey", "0", "Aimkey"); + this->v_ePriorityMode = CREATE_CV(new CatEnum(psza__Priority, ARRAYSIZE(psza__Priority)), "aimbot_prioritymode", "0", "Priority mode"); + v_bAimBuildings = CREATE_CV(CV_SWITCH, "aimbot_buildings", "1", "Aim @ Buildings"); + v_bActiveOnlyWhenCanShoot = CREATE_CV(CV_SWITCH, "aimbot_only_when_can_shoot", "1", "Active when can shoot"); + v_fSmoothAutoshootTreshold = CREATE_CV(CV_FLOAT, "aimbot_smooth_autoshoot_treshold", "0.01", "Smooth autoshoot"); + this->v_fSmoothRandomness = CREATE_CV(CV_FLOAT, "aimbot_smooth_randomness", "1.0", "Smooth randomness"); + this->v_iSeenDelay = CREATE_CV(CV_INT, "aimbot_delay", "0", "Aimbot delay"); fix_silent = false; } @@ -80,9 +90,9 @@ bool Aimbot::CreateMove(void*, float, CUserCmd* cmd) { if (!this->v_bEnabled->GetBool()) return true; if (g_pLocalPlayer->entity && g_pLocalPlayer->life_state) return true; this->m_iLastTarget = -1; - if (this->v_iAimKey->GetBool() && this->v_iAimKeyMode->GetBool()) { - bool key_down = interfaces::input->IsButtonDown((ButtonCode_t)this->v_iAimKey->GetInt()); - switch (this->v_iAimKeyMode->GetInt()) { + if (this->v_eAimKey->GetBool() && this->v_eAimKeyMode->GetBool()) { + bool key_down = interfaces::input->IsButtonDown((ButtonCode_t)this->v_eAimKey->GetInt()); + switch (this->v_eAimKeyMode->GetInt()) { case AimKeyMode_t::PRESS_TO_ENABLE: if (key_down) break; else return true; @@ -136,13 +146,13 @@ bool Aimbot::CreateMove(void*, float, CUserCmd* cmd) { if(cmd->buttons & IN_USE) return true; - if (this->v_bStrictAttack->GetBool() ) { + if (this->v_bTriggerMode->GetBool() ) { cmd->buttons = cmd->buttons &~ IN_ATTACK; } IClientEntity* player = g_pLocalPlayer->entity; if (!player) return true; if (player->IsDormant()) return true; - m_iHitbox = this->v_iHitbox->GetInt(); + m_iHitbox = this->v_eHitbox->GetInt(); if (this->v_bAutoHitbox->GetBool()) m_iHitbox = 7; if (g_pLocalPlayer->weapon && this->v_bAutoHitbox->GetBool()) { switch (g_pLocalPlayer->weapon->GetClientClass()->m_ClassID) { @@ -192,7 +202,7 @@ bool Aimbot::CreateMove(void*, float, CUserCmd* cmd) { if (ent == 0) continue; if (!(IsPlayer(ent) || IsBuilding(ent))) continue; if (ShouldTarget(ent)) { - if (GetWeaponMode(player) == weaponmode::weapon_melee || this->v_iPriorityMode->GetInt() == 2) { + if (GetWeaponMode(player) == weaponmode::weapon_melee || this->v_ePriorityMode->GetInt() == 2) { Vector result; if (IsBuilding(ent)) { result = GetBuildingPosition(ent); @@ -205,7 +215,7 @@ bool Aimbot::CreateMove(void*, float, CUserCmd* cmd) { target_highest = ent; } } else { - switch (this->v_iPriorityMode->GetInt()) { + switch (this->v_ePriorityMode->GetInt()) { case 0: { int scr = GetScoreForEntity(ent); if (scr > target_highest_score) { @@ -288,7 +298,7 @@ bool Aimbot::ShouldTarget(IClientEntity* entity) { char life_state = GetEntityValue(entity, netvar.iLifeState); if (life_state) return false; if (!player) return false; - if (v_bRespectCloak->GetBool() && (GetEntityValue(entity, netvar.iCond) & cond::cloaked)) return false; + if (v_bRespectCloak->GetBool() && IsPlayerInvisible(entity)) return false; int health = GetEntityValue(entity, netvar.iHealth); /*if (this->v_bCharge->GetBool() && (GetEntityValue(player, eoffsets.iClass) == 2)) { int rifleHandle = GetEntityValue(player, eoffsets.hActiveWeapon); @@ -316,7 +326,7 @@ bool Aimbot::ShouldTarget(IClientEntity* entity) { } else { if (v_bMachinaPenetration->GetBool()) { if (GetHitboxPosition(entity, m_iHitbox, resultAim)) return false; - if (!IsEntityVisiblePenetration(entity, v_iHitbox->GetInt())) return false; + if (!IsEntityVisiblePenetration(entity, v_eHitbox->GetInt())) return false; } else { if (GetHitboxPosition(entity, m_iHitbox, resultAim)) return false; if (!IsEntityVisible(entity, m_iHitbox)) return false; @@ -371,8 +381,8 @@ bool Aimbot::Aim(IClientEntity* entity, CUserCmd* cmd) { } if (v_bProjectileAimbot->GetBool()) { if (m_bProjectileMode) { - if (v_iOverrideProjSpeed->GetBool()) - m_flProjSpeed = v_iOverrideProjSpeed->GetFloat(); + if (v_fOverrideProjSpeed->GetBool()) + m_flProjSpeed = v_fOverrideProjSpeed->GetFloat(); hit = ProjectilePrediction(entity, m_iHitbox, m_flProjSpeed, m_flProjGravity); } } @@ -414,7 +424,7 @@ bool Aimbot::Aim(IClientEntity* entity, CUserCmd* cmd) { charge = interfaces::gvars->curtime - begincharge; if (charge > 1.0f) charge = 1.0f; } - if (charge >= v_flAutoShootHuntsmanCharge->GetFloat()) { + if (charge >= v_fAutoShootHuntsmanCharge->GetFloat()) { cmd->buttons &= ~IN_ATTACK; } } else { diff --git a/cathook/src/hacks/Aimbot.h b/cathook/src/hacks/Aimbot.h index 3d94da2a..5a7e437a 100644 --- a/cathook/src/hacks/Aimbot.h +++ b/cathook/src/hacks/Aimbot.h @@ -40,36 +40,36 @@ public: int m_iHitbox; bool m_bAimKeySwitch; int m_nMinigunFixTicks; - ConVar* v_iAimKey; - ConVar* v_iAimKeyMode; - ConVar* v_bMinigunFix; - ConVar* v_bSmooth; - ConVar* v_fSmoothValue; - ConVar* v_bDebug; - ConVar* v_bEnabled; - ConVar* v_fFOV; - ConVar* v_iHitbox; - ConVar* v_bAutoHitbox; - ConVar* v_iSeenDelay; - ConVar* v_bPrediction; - ConVar* v_bAutoShoot; - ConVar* v_bSilent; - ConVar* v_bZoomedOnly; - ConVar* v_iAutoShootCharge; - ConVar* v_flAutoShootHuntsmanCharge; - ConVar* v_iMaxRange; - ConVar* v_bRespectCloak; - ConVar* v_bCharge; - ConVar* v_bEnabledAttacking; - ConVar* v_bStrictAttack; - ConVar* v_bProjectileAimbot; - ConVar* v_iOverrideProjSpeed; - ConVar* v_bMachinaPenetration; - ConVar* v_bAimBuildings; - ConVar* v_bActiveOnlyWhenCanShoot; - ConVar* v_fSmoothAutoshootTreshold; - ConVar* v_fSmoothRandomness; - ConVar* v_iPriorityMode; + + CatVar* v_eAimKey; + CatVar* v_eAimKeyMode; + CatVar* v_bSmooth; + CatVar* v_fSmoothValue; + CatVar* v_bDebug; + CatVar* v_bEnabled; + CatVar* v_fFOV; + CatVar* v_eHitbox; + CatVar* v_bAutoHitbox; + CatVar* v_iSeenDelay; + CatVar* v_bPrediction; + CatVar* v_bAutoShoot; + CatVar* v_bSilent; + CatVar* v_bZoomedOnly; + CatVar* v_iAutoShootCharge; + CatVar* v_fAutoShootHuntsmanCharge; + CatVar* v_iMaxRange; + CatVar* v_bRespectCloak; + CatVar* v_bCharge; + CatVar* v_bEnabledAttacking; + CatVar* v_bTriggerMode; + CatVar* v_bProjectileAimbot; + CatVar* v_fOverrideProjSpeed; + CatVar* v_bMachinaPenetration; + CatVar* v_bAimBuildings; + CatVar* v_bActiveOnlyWhenCanShoot; + CatVar* v_fSmoothAutoshootTreshold; + CatVar* v_fSmoothRandomness; + CatVar* v_ePriorityMode; }; DECLARE_HACK_SINGLETON(Aimbot); diff --git a/cathook/src/hacks/AutoHeal.cpp b/cathook/src/hacks/AutoHeal.cpp index 7d7e5254..936aa786 100644 --- a/cathook/src/hacks/AutoHeal.cpp +++ b/cathook/src/hacks/AutoHeal.cpp @@ -59,7 +59,7 @@ bool AutoHeal::CanHeal(int idx) { if (g_pLocalPlayer->team != GetEntityValue(ent, netvar.iTeamNum)) return false; if (g_pLocalPlayer->v_Origin.DistToSqr(ent->GetAbsOrigin()) > 420 * 420) return false; if (!IsEntityVisible(ent, 7)) return false; - if (GetEntityValue(ent, netvar.iCond) & cond::cloaked) return false; + if (IsPlayerInvisible(ent)) return false; return true; } diff --git a/cathook/src/hacks/ESP.cpp b/cathook/src/hacks/ESP.cpp index 13ce7975..94122e57 100644 --- a/cathook/src/hacks/ESP.cpp +++ b/cathook/src/hacks/ESP.cpp @@ -69,7 +69,7 @@ ESP::ESP() { void ESP::DrawBox(CachedEntity* ent, Color clr, float widthFactor, float addHeight, bool healthbar, int health, int healthmax) { if (!CheckCE(ent)) return; - bool cloak = ent->m_iClassID == ClassID::CTFPlayer && (ent->Var(netvar.iCond) & cond::cloaked); + bool cloak = ent->m_iClassID == ClassID::CTFPlayer && IsPlayerInvisible(ent->m_pEntity);//(ent->Var(netvar.iCond) & cond::cloaked); Vector min, max; ent->m_pEntity->GetRenderBounds(min, max); Vector origin = ent->m_pEntity->GetAbsOrigin(); @@ -120,7 +120,7 @@ void ESP::ProcessEntityPT(CachedEntity* ent) { Color fg = colors::EntityF(ent); switch (ent->m_iClassID) { case ClassID::CTFPlayer: { - bool cloak = ent->Var(netvar.iCond) & cond::cloaked; + bool cloak = IsPlayerInvisible(ent->m_pEntity);//ent->Var(netvar.iCond) & cond::cloaked; if (v_bLegit->GetBool() && ent->m_iTeam != g_pLocalPlayer->team && !GetRelation(ent->m_pEntity)) { if (cloak) return; if (ent->m_lLastSeen > v_iLegitSeenTicks->GetInt()) { @@ -272,7 +272,8 @@ void ESP::ProcessEntity(CachedEntity* ent) { // If target is enemy, always show powerups, if player is teammate, show powerups // only if bTeammatePowerup or bTeammates is true if (v_bLegit->GetBool() && ent->m_iTeam != g_pLocalPlayer->team && !GetRelation(ent->m_pEntity)) { - if (pcond & cond::cloaked) return; + //if (pcond & cond::cloaked) return; + if (IsPlayerInvisible(ent->m_pEntity)) return; if (ent->m_lLastSeen > (unsigned)v_iLegitSeenTicks->GetInt()) { return; } diff --git a/cathook/src/hacks/IHack.h b/cathook/src/hacks/IHack.h index 9743b146..daa676c3 100644 --- a/cathook/src/hacks/IHack.h +++ b/cathook/src/hacks/IHack.h @@ -10,6 +10,7 @@ class CUserCmd; class ConVar; +class CatVar; class ConCommand; class CCommand; diff --git a/cathook/src/hacks/Misc.cpp b/cathook/src/hacks/Misc.cpp index 288d4623..06eca684 100644 --- a/cathook/src/hacks/Misc.cpp +++ b/cathook/src/hacks/Misc.cpp @@ -323,6 +323,7 @@ void Misc::PaintTraverse(void*, unsigned int, bool, bool) { AddSideString(colors::white, colors::black, "ToGround: %f", DistanceToGround(g_pLocalPlayer->v_Origin)); AddSideString(colors::white, colors::black, "ServerTime: %f", GetEntityValue(g_pLocalPlayer->entity, netvar.nTickBase) * interfaces::gvars->interval_per_tick); AddSideString(colors::white, colors::black, "CurTime: %f", interfaces::gvars->curtime); + AddSideString(colors::white, colors::black, "FrameCount: %i", interfaces::gvars->framecount); float speed, gravity; GetProjectileData(g_pLocalPlayer->weapon, speed, gravity); AddSideString(colors::white, colors::black, "Speed: %f", speed); diff --git a/cathook/src/hacks/Trigger.cpp b/cathook/src/hacks/Trigger.cpp index e87ced47..1bbd62b7 100644 --- a/cathook/src/hacks/Trigger.cpp +++ b/cathook/src/hacks/Trigger.cpp @@ -89,7 +89,7 @@ bool Triggerbot::CreateMove(void* thisptr, float sampl, CUserCmd* cmd) { if (rel == relation::FRIEND || rel == relation::DEVELOPER) return true; if (IsPlayerInvulnerable(entity)) return true; if (!this->v_bIgnoreCloak->GetBool() && - ((GetEntityValue(entity, netvar.iCond)) & cond::cloaked)) return true; + (IsPlayerInvisible(entity))) return true; int health = GetEntityValue(entity, netvar.iHealth); bool bodyshot = false; if (g_pLocalPlayer->clazz == tf_class::tf_sniper) { diff --git a/cathook/src/helpers.cpp b/cathook/src/helpers.cpp index 6486d5ef..30adccf5 100644 --- a/cathook/src/helpers.cpp +++ b/cathook/src/helpers.cpp @@ -10,6 +10,7 @@ #include "sdk.h" #include +#include FILE* hConVarsFile = 0; void BeginConVars() { @@ -296,7 +297,12 @@ float deg2rad(float deg) { } bool IsPlayerInvisible(IClientEntity* player) { - return false; // TODO stumpy.flv + int cond = GetEntityValue(player, netvar.iCond); + int mask = cloaked; + int cond_1 = GetEntityValue(player, netvar.iCond1); + int mask_1 = cond_ex2::cloak_spell | cond_ex2::cloak_spell_fading; + int mask_v = on_fire | jarate | milk; + return !((cond & mask_v) || !((cond & mask) || (cond_1 & mask_1))); } float RandFloatRange(float min, float max) @@ -460,6 +466,13 @@ bool IsProjectile(IClientEntity* ent) { return false; } +void Patch(void* address, void* patch, size_t length) { + void* page = (void*)((uintptr_t)address &~ 0xFFF); + mprotect(page, 0xFFF, PROT_WRITE | PROT_EXEC); + memcpy(address, patch, length); + mprotect(page, 0xFFF, PROT_EXEC); +} + bool IsProjectileCrit(IClientEntity* ent) { if (!ent) return false; switch (ent->GetClientClass()->m_ClassID) { diff --git a/cathook/src/helpers.h b/cathook/src/helpers.h index 976011fa..9680eabf 100644 --- a/cathook/src/helpers.h +++ b/cathook/src/helpers.h @@ -69,6 +69,8 @@ bool IsSentryBuster(IClientEntity* ent); char* strfmt(const char* fmt, ...); bool IsAmbassador(IClientEntity* ent); +void Patch(void* address, void* patch, size_t length); + void AimAt(Vector origin, Vector target, CUserCmd* cmd); void AimAtHitbox(IClientEntity* ent, int hitbox, CUserCmd* cmd); diff --git a/cathook/src/hooks.cpp b/cathook/src/hooks.cpp index f2909acf..b4cecd0e 100644 --- a/cathook/src/hooks.cpp +++ b/cathook/src/hooks.cpp @@ -19,6 +19,7 @@ unsigned int hooks::offCanPacket = 57; unsigned int hooks::offSendNetMsg = 41; unsigned int hooks::offShutdown = 37; unsigned int hooks::offKeyEvent = 20; +unsigned int hooks::offHandleInputEvent = 78; // This thing had been copypasted from somewhere, maybe from F1Public. @@ -74,3 +75,4 @@ hooks::VMTHook* hooks::hkPanel = 0; hooks::VMTHook* hooks::hkClient = 0; hooks::VMTHook* hooks::hkNetChannel = 0; hooks::VMTHook* hooks::hkClientDLL = 0; +hooks::VMTHook* hooks::hkMatSurface = 0; diff --git a/cathook/src/hooks.h b/cathook/src/hooks.h index 230f0675..9a6f1503 100644 --- a/cathook/src/hooks.h +++ b/cathook/src/hooks.h @@ -36,7 +36,9 @@ extern VMTHook* hkClientMode; extern VMTHook* hkClient; extern VMTHook* hkNetChannel; extern VMTHook* hkClientDLL; +extern VMTHook* hkMatSurface; +extern unsigned int offHandleInputEvent; extern unsigned int offPaintTraverse; extern unsigned int offCreateMove; extern unsigned int offOverrideView; diff --git a/cathook/src/interfaces.cpp b/cathook/src/interfaces.cpp index 4d16e3be..dfc4c491 100644 --- a/cathook/src/interfaces.cpp +++ b/cathook/src/interfaces.cpp @@ -31,6 +31,7 @@ CGlobalVarsBase* interfaces::gvars = 0; IPrediction* interfaces::prediction = 0; IGameMovement* interfaces::gamemovement = 0; IInput* interfaces::iinput = 0; +IMatSystemSurface* interfaces::matsurface = 0; void interfaces::CreateInterfaces() { interfaces::centerPrint = reinterpret_cast(sharedobj::client->fptr("VCENTERPRINT002", nullptr)); @@ -56,5 +57,6 @@ void interfaces::CreateInterfaces() { interfaces::prediction = reinterpret_cast(sharedobj::client->CreateInterface("VClientPrediction001")); interfaces::gamemovement = reinterpret_cast(sharedobj::client->CreateInterface("GameMovement001")); interfaces::iinput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 B4 00 00 00 A1 ? ? ? ? 8B 10"))); + interfaces::matsurface = **reinterpret_cast((uintptr_t)19 + gSignatures.GetClientSignature("FF 92 94 02 00 00 8B 8D C4 FE FF FF 89 85 B0 FE FF FF A1 ? ? ? ? 8B 10 89 4C 24 0C")); } diff --git a/cathook/src/interfaces.h b/cathook/src/interfaces.h index b51e00e1..43c0d59e 100644 --- a/cathook/src/interfaces.h +++ b/cathook/src/interfaces.h @@ -30,6 +30,7 @@ class CGlobalVarsBase; class IPrediction; class IGameMovement; class IInput; +class IMatSystemSurface; namespace interfaces { @@ -50,6 +51,7 @@ extern CGlobalVarsBase* gvars; extern IPrediction* prediction; extern IGameMovement* gamemovement; extern IInput* iinput; +extern IMatSystemSurface* matsurface; void CreateInterfaces(); diff --git a/cathook/src/sdk.h b/cathook/src/sdk.h index d600706c..aefb80bc 100644 --- a/cathook/src/sdk.h +++ b/cathook/src/sdk.h @@ -36,6 +36,7 @@ #include #include #include +#include #include "sdk/in_buttons.h" #include "sdk/iinput.h"